New test.
authorMarek Safar <marek.safar@gmail.com>
Fri, 26 Mar 2010 14:37:44 +0000 (14:37 -0000)
committerMarek Safar <marek.safar@gmail.com>
Fri, 26 Mar 2010 14:37:44 +0000 (14:37 -0000)
svn path=/trunk/mcs/; revision=154277

940 files changed:
COPYING.LIB
ChangeLog
LICENSE
autogen.sh
build-mingw32.sh
configure.in
data/Makefile.am
data/system.web.mvc2.pc.in [new file with mode: 0644]
docs/jit-imt
man/ChangeLog
man/mono.1
mcs/ChangeLog
mcs/Makefile
mcs/build/ChangeLog
mcs/build/Makefile
mcs/build/library.make
mcs/build/profiles/moonlight.make [new file with mode: 0644]
mcs/build/profiles/moonlight_bootstrap.make [new file with mode: 0644]
mcs/build/profiles/moonlight_raw.make [new file with mode: 0644]
mcs/build/profiles/net_2_1.make [deleted file]
mcs/build/profiles/net_2_1_bootstrap.make [deleted file]
mcs/build/profiles/net_2_1_raw.make [deleted file]
mcs/build/rules.make
mcs/class/ChangeLog
mcs/class/Makefile
mcs/class/Mono.Security/Mono.Security/ASN1Convert.cs
mcs/class/Mono.Security/Mono.Security/ChangeLog
mcs/class/Mono.Simd/Mono.Simd/ChangeLog
mcs/class/Mono.Simd/Mono.Simd/Vector4f.cs
mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/DirectoryCatalog.cs
mcs/class/System.Core/Assembly/AssemblyInfo.cs
mcs/class/System.Core/Assembly/ChangeLog
mcs/class/System.Core/ChangeLog
mcs/class/System.Core/Makefile
mcs/class/System.Core/System.Linq/ChangeLog
mcs/class/System.Core/System.Linq/SortSequenceContext.cs
mcs/class/System.Core/System.Security.Cryptography/Aes.cs
mcs/class/System.Core/System.Security.Cryptography/ChangeLog
mcs/class/System.Core/Test/System.Linq/ChangeLog
mcs/class/System.Core/Test/System.Linq/EnumerableTest.cs
mcs/class/System.Core/moonlight_bootstrap_System.Core.dll.sources [new file with mode: 0644]
mcs/class/System.Core/moonlight_raw_System.Core.dll.sources [new file with mode: 0644]
mcs/class/System.Core/net_2_1_bootstrap_System.Core.dll.sources [deleted file]
mcs/class/System.Core/net_2_1_raw_System.Core.dll.sources [deleted file]
mcs/class/System.Core/net_4_0_System.Core.dll.sources
mcs/class/System.Data/System.Data.Common/ChangeLog
mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
mcs/class/System.Data/System.Data.SqlClient/ChangeLog
mcs/class/System.Data/System.Data.SqlClient/SqlDataAdapter.cs
mcs/class/System.Net/ChangeLog
mcs/class/System.Net/System.Net.Sockets/ChangeLog
mcs/class/System.Net/System.Net.Sockets/SocketException_2_1.cs
mcs/class/System.Net/System.Net/ChangeLog
mcs/class/System.Net/System.Net/HttpWebRequest_2_1.cs
mcs/class/System.Net/System.Net/WebClient_2_1.cs
mcs/class/System.Net/System.Net/WebHeaderCollection_2_1.cs
mcs/class/System.Net/System.Net/WebRequest_2_1.cs
mcs/class/System.Net/moonlight_raw_System.Net.dll.sources [new file with mode: 0644]
mcs/class/System.Net/net_2_1_raw_System.Net.dll.sources [deleted file]
mcs/class/System.Runtime.Serialization/ChangeLog
mcs/class/System.Runtime.Serialization/monotouch_System.Runtime.Serialization.dll.sources
mcs/class/System.Runtime.Serialization/moonlight_raw_System.Runtime.Serialization.dll.sources [new file with mode: 0644]
mcs/class/System.Runtime.Serialization/net_2_1_raw_System.Runtime.Serialization.dll.sources [deleted file]
mcs/class/System.Security/ChangeLog
mcs/class/System.Security/Makefile
mcs/class/System.ServiceModel.Discovery/Assembly/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel.Discovery/Assembly/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel.Discovery/Makefile [new file with mode: 0644]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/DiscoveryMessageSequenceApril2005.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/EndpointDiscoveryMetadataApril2005.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/FindCriteriaApril2005.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/ResolveCriteriaApril2005.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/DiscoveryMessageSequence11.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/EndpointDiscoveryMetadata11.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/FindCriteria11.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/ResolveCriteria11.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.dll.sources [new file with mode: 0644]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementClient.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementEndpoint.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementEventArgs.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementService.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryClient.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryClientBindingElement.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryEndpoint.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryEndpointProvider.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryMessageSequence.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryMessageSequenceGenerator.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryOperationContextExtension.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryProxy.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryService.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryServiceExtension.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryVersion.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DynamicEndpoint.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/EndpointDiscoveryBehavior.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/EndpointDiscoveryMetadata.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindCompletedEventArgs.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindCriteria.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindProgressChangedEventArgs.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindRequestContext.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindResponse.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ResolveCompletedEventArgs.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ResolveCriteria.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ResolveResponse.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ServiceDiscoveryBehavior.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ServiceDiscoveryMode.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/UdpAnnouncementEndpoint.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/UdpDiscoveryEndpoint.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/UdpTransportSettings.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery_test.dll.sources [new file with mode: 0644]
mcs/class/System.ServiceModel.Discovery/Test/System.ServiceModel.Discovery/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/Test/System.ServiceModel.Discovery/DiscoveryVersionTest.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Discovery/Test/System.ServiceModel.Discovery/FindCriteriaTest.cs [new file with mode: 0755]
mcs/class/System.ServiceModel.Web/ChangeLog
mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog
mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/DataContractJsonSerializer.cs
mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JavaScriptReader.cs
mcs/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
mcs/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs
mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs
mcs/class/System.ServiceModel.Web/common_System.ServiceModel.Web.dll.sources
mcs/class/System.ServiceModel.Web/moonlight_raw_System.ServiceModel.Web.dll.sources [new file with mode: 0644]
mcs/class/System.ServiceModel.Web/net_2_0_System.ServiceModel.Web.dll.sources
mcs/class/System.ServiceModel.Web/net_2_1_raw_System.ServiceModel.Web.dll.sources [deleted file]
mcs/class/System.ServiceModel/ChangeLog
mcs/class/System.ServiceModel/Dummy_2_1.cs
mcs/class/System.ServiceModel/HTTP_listener_notes.txt
mcs/class/System.ServiceModel/Makefile
mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressingVersion.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/AspNetReplyChannel.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/AspNetRequestContext.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelListener.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpListenerManager.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpReplyChannel.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestContext.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFault.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeaders.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/PrivacyNoticeBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReliableSessionBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/RemoteEndpointMessageProperty.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionFlowBindingElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ConfigUtil.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ConnectionOrientedTransportElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpTransportElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpsTransportElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/LocalClientSecuritySettingsElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/LocalServiceSecuritySettingsElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpBindingCollectionElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpsBindingCollectionElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqBindingElementBase.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqElementBase.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqTransportElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeConnectionPoolSettingsElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeTransportElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceDebugElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceMetadataPublishingElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingCollectionElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingReliableSessionElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpConnectionPoolSettingsElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpTransportElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Description/ClientCredentials.cs
mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs
mcs/class/System.ServiceModel/System.ServiceModel.Description/HostedBindingBehavior.cs [deleted file]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IEndpointBehavior.cs
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExchangeBindings.cs
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpointCollection.cs
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataExtension.cs
mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlExporter.cs
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationInvokerHandler.cs
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageContext.cs
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageFilterTable.cs
mcs/class/System.ServiceModel/System.ServiceModel.dll.sources
mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs
mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs
mcs/class/System.ServiceModel/System.ServiceModel/Constants.cs
mcs/class/System.ServiceModel/System.ServiceModel/Dummy.cs
mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs
mcs/class/System.ServiceModel/System.ServiceModel/WSHttpBindingBase.cs
mcs/class/System.ServiceModel/System.ServiceModel_test.dll.sources
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageBufferTest.cs
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageTest.cs
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ChangeLog
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataExchangeBindingsTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ChangeLog
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/XPathMessageContextTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/TransportSecurityBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ChangeLog
mcs/class/System.ServiceModel/Test/System.ServiceModel/Constants.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceHostBaseTest.cs
mcs/class/System.ServiceModel/monotouch_System.ServiceModel.dll.sources
mcs/class/System.ServiceModel/moonlight_raw_System.ServiceModel.dll.sources [new file with mode: 0755]
mcs/class/System.ServiceModel/net_2_1_raw_System.ServiceModel.dll.sources [deleted file]
mcs/class/System.ServiceModel/net_4_0_System.ServiceModel.dll.sources
mcs/class/System.Web.Mvc/ChangeLog
mcs/class/System.Web.Mvc/Makefile
mcs/class/System.Web.Mvc2/ChangeLog [new file with mode: 0644]
mcs/class/System.Web.Mvc2/GlobalSuppressions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/Makefile [new file with mode: 0644]
mcs/class/System.Web.Mvc2/Properties/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/Properties/ChangeLog [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc.csproj [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc.dll.sources [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AcceptVerbsAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionDescriptor.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionExecutedContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionExecutingContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionFilterAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodDispatcher.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodDispatcherCache.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodSelector.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodSelectorAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionNameAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionNameSelectorAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionSelector.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Ajax/AjaxExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Ajax/AjaxOptions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Ajax/InsertionMode.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AjaxHelper.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AjaxHelper`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AjaxRequestExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AntiForgeryData.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AntiForgeryDataSerializer.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AreaHelpers.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AreaRegistration.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AreaRegistrationContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AssociatedMetadataProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AssociatedValidatorProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/ActionDescriptorCreator.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncActionDescriptor.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncActionMethodSelector.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncControllerActionInvoker.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncManager.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncResultWrapper.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncUtil.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncVoid.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/BeginInvokeDelegate.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/EndInvokeDelegate.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/EndInvokeDelegate`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/IAsyncActionInvoker.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/IAsyncController.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/IAsyncManagerContainer.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/OperationCounter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/ReflectedAsyncActionDescriptor.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/ReflectedAsyncControllerDescriptor.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SimpleAsyncResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SingleEntryGate.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SynchronizationContextUtil.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SynchronousOperationException.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/Trigger.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/TriggerListener.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AsyncController.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AsyncTimeoutAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AuthorizationContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/AuthorizeAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/BindAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/BuildManagerWrapper.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ByteArrayModelBinder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ChildActionOnlyAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ClientDataTypeModelValidatorProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ContentResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Controller.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerActionInvoker.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerBase.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerBuilder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerDescriptor.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerDescriptorCache.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerTypeCache.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/CustomModelBinderAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelMetadata.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelMetadataProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelValidator.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelValidatorProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelValidator`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DataErrorInfoModelValidatorProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DefaultControllerFactory.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DefaultModelBinder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DefaultViewLocationCache.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DescriptorUtil.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DictionaryHelpers.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DictionaryValueProvider`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/DynamicTypeGenerator.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/EmptyModelMetadataProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/EmptyModelValidatorProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/EmptyResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Error.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExceptionContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionHelper.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/BinaryExpressionFingerprint.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/CachedExpressionCompiler.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/CompiledExpressionDelegate`2.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ConditionalExpressionFingerprint.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ConstantExpressionFingerprint.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ExpressionFingerprint.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ExpressionParser.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/FastTrack`2.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/HashCodeCombiner.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/MemberExpressionFingerprint.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/MethodCallExpressionFingerprint.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ParameterExpressionFingerprint.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ParserContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/UnaryExpressionFingerprint.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FieldValidationMetadata.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FileContentResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FilePathResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FileResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FileStreamResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FilterAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FilterInfo.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FormCollection.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FormContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FormMethod.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FormValueProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/FormValueProviderFactory.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HandleErrorAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HandleErrorInfo.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HiddenInputAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/ChildActionExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DefaultDisplayTemplates.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DefaultEditorTemplates.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DisplayExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DisplayTextExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/EditorExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/FormExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/InputExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/LabelExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/LinkExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/MvcForm.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/PartialExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/RenderPartialExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/SelectExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/TemplateHelpers.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/TextAreaExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/ValidationExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HtmlHelper.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HtmlHelper`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpAntiForgeryException.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpDeleteAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpFileCollectionValueProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpFileCollectionValueProviderFactory.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpGetAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpHandlerUtil.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpPostAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpPostedFileBaseModelBinder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpPutAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpRequestExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpUnauthorizedResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpVerbs.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IActionFilter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IActionInvoker.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IAuthorizationFilter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IBuildManager.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IController.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IControllerFactory.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IExceptionFilter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IModelBinder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IResultFilter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IRouteWithArea.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ITempDataProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IValueProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IView.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IViewDataContainer.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IViewEngine.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/IViewLocationCache.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/InputType.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/JavaScriptResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/JsonRequestBehavior.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/JsonResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/LinqBinaryModelBinder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBinderAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBinderDictionary.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBinders.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBindingContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRangeRule.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRegexRule.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRequiredRule.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRule.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationStringLengthRule.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelError.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelErrorCollection.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelMetadata.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelMetadataProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelMetadataProviders.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelState.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelStateDictionary.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidationResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidator.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidatorProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidatorProviderCollection.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidatorProviders.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/MultiSelectList.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcHandler.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcHtmlString.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcHttpHandler.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcRouteHandler.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/NameValueCollectionExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/NameValueCollectionValueProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/NoAsyncTimeoutAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/NonActionAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/NullViewLocationCache.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/OutputCacheAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ParameterBindingInfo.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ParameterDescriptor.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ParameterInfoUtil.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/PartialViewResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/PathHelpers.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/QueryStringValueProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/QueryStringValueProviderFactory.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RangeAttributeAdapter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ReaderWriterCache`2.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RedirectResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RedirectToRouteResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedActionDescriptor.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedControllerDescriptor.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedParameterBindingInfo.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedParameterDescriptor.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RegularExpressionAttributeAdapter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RequireHttpsAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RequiredAttributeAdapter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Resources/MvcResources.Designer.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/Resources/MvcResources.resx [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ResultExecutedContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ResultExecutingContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteCollectionExtensions.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteDataValueProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteDataValueProviderFactory.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteValuesHelpers.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/SelectList.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/SelectListItem.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/SessionStateTempDataProvider.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/StringLengthAttributeAdapter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/TagBuilder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/TagRenderMode.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/TempDataDictionary.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/TemplateInfo.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/TryGetValueDelegate.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeCacheSerializer.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeCacheUtil.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeDescriptorHelper.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeHelpers.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/UrlHelper.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/UrlParameter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ValidateAntiForgeryTokenAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ValidateInputAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderCollection.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderDictionary.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderFactories.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderFactory.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderFactoryCollection.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderUtil.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewContext.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewDataDictionary.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewDataDictionary`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewDataInfo.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewEngineCollection.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewEngineResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewEngines.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewMasterPage.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewMasterPage`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewPage.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewPageControlBuilder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewPage`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewResult.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewResultBase.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTemplateUserControl.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTemplateUserControl`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewType.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTypeControlBuilder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTypeParserFilter.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewUserControl.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewUserControlControlBuilder.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewUserControl`1.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/VirtualPathProviderViewEngine.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/WebFormView.cs [new file with mode: 0644]
mcs/class/System.Web.Mvc2/System.Web.Mvc/WebFormViewEngine.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
mcs/class/System.Web/System.Web.Compilation/AspParser.cs
mcs/class/System.Web/System.Web.Compilation/ChangeLog
mcs/class/System.Web/System.Web.Compilation/TagType.cs
mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs
mcs/class/System.Web/System.Web.UI/CodeRenderBuilder.cs
mcs/class/System.Web/System.Web/ChangeLog
mcs/class/System.Web/System.Web/SiteMapNode.cs
mcs/class/System.Web/Test/System.Web/ChangeLog
mcs/class/System.Web/Test/System.Web/XmlSiteMapProviderTest.cs
mcs/class/System.XML/ChangeLog
mcs/class/System.XML/Makefile
mcs/class/System.XML/System.Xml.Schema/ChangeLog
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
mcs/class/System.XML/System.Xml.Serialization/ChangeLog
mcs/class/System.XML/System.Xml.Serialization/SerializationSource.cs
mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/DTDValidatingReader2.cs
mcs/class/System.XML/System.Xml/XmlInputStream.cs
mcs/class/System.XML/System.Xml/XmlNodeReader2.cs
mcs/class/System.XML/System.Xml/XmlNodeReaderImpl.cs
mcs/class/System.XML/System.Xml/XmlQualifiedName.cs
mcs/class/System.XML/System.Xml/XmlReader.cs
mcs/class/System.XML/System.Xml/XmlReaderSettings.cs
mcs/class/System.XML/System.Xml/XmlResolver.cs
mcs/class/System.XML/System.Xml/XmlTextReader.cs
mcs/class/System.XML/System.Xml/XmlTextWriter2.cs
mcs/class/System.XML/System.Xml/XmlWriter.cs
mcs/class/System.XML/System.Xml/XmlWriterSettings.cs
mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog
mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaValidatorTests.cs
mcs/class/System.XML/Test/System.Xml/ChangeLog
mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs
mcs/class/System.XML/Test/XmlFiles/xsd/584664a.xml [new file with mode: 0644]
mcs/class/System.XML/Test/XmlFiles/xsd/584664a.xsd [new file with mode: 0644]
mcs/class/System.XML/Test/XmlFiles/xsd/584664b.xml [new file with mode: 0644]
mcs/class/System.XML/Test/XmlFiles/xsd/584664b.xsd [new file with mode: 0644]
mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog
mcs/class/System.XML/moonlight_raw_System.Xml.dll.sources [new file with mode: 0644]
mcs/class/System.XML/net_2_1_raw_System.Xml.dll.sources [deleted file]
mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog
mcs/class/System.Xml.Linq/System.Xml.Linq/SaveOptions.cs
mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs
mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeNavigator.cs
mcs/class/System.Xml.Linq/System.Xml.XPath/ChangeLog
mcs/class/System.Xml.Linq/System.Xml.XPath/Extensions.cs
mcs/class/System.Xml.Serialization/Assembly/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/Assembly/ChangeLog [new file with mode: 0644]
mcs/class/System.Xml.Serialization/ChangeLog [new file with mode: 0644]
mcs/class/System.Xml.Serialization/Makefile [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization.dll.sources [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/ChangeLog [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlAttributeOverrides.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlAttributes.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlMapping.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializationGeneratedCode.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializationReader.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializationWriter.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializer.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializerNamespaces.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlTypeMapping.cs [new file with mode: 0644]
mcs/class/System.Xml.Serialization/moonlight_raw_System.Xml.Serialization.dll.sources [new file with mode: 0644]
mcs/class/System/ChangeLog
mcs/class/System/Makefile
mcs/class/System/System.CodeDom/CodeMemberMethod.cs
mcs/class/System/System.CodeDom/CodeNamespace.cs
mcs/class/System/System.CodeDom/CodeTypeDeclaration.cs
mcs/class/System/System.CodeDom/CodeTypeReference.cs
mcs/class/System/System.Collections.Generic/ChangeLog
mcs/class/System/System.Collections.Generic/RBTree.cs
mcs/class/System/System.ComponentModel/ChangeLog
mcs/class/System/System.ComponentModel/ComponentCollection.cs
mcs/class/System/System.ComponentModel/PropertyDescriptor.cs
mcs/class/System/System.ComponentModel/TypeConverter_2_1.cs
mcs/class/System/System.ComponentModel/TypeDescriptor.cs
mcs/class/System/System.Configuration/ConfigurationSettings.cs
mcs/class/System/System.Net.Mail/SmtpClient.cs
mcs/class/System/System.Net.NetworkInformation/ChangeLog
mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs
mcs/class/System/System.Net.NetworkInformation/IPInterfaceProperties.cs
mcs/class/System/System.Net.NetworkInformation/IPv4InterfaceStatistics.cs
mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs
mcs/class/System/System.Net.NetworkInformation/Ping.cs
mcs/class/System/System.Net.Security/RemoteCertificateValidationCallback.cs
mcs/class/System/System.Net.Sockets/ChangeLog
mcs/class/System/System.Net.Sockets/Socket.cs
mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs
mcs/class/System/System.Net.Sockets/Socket_2_1.cs
mcs/class/System/System.Net/AuthenticationManager.cs
mcs/class/System/System.Net/ChangeLog
mcs/class/System/System.Net/CookieContainer.cs
mcs/class/System/System.Net/Dns.cs
mcs/class/System/System.Net/FtpWebRequest.cs
mcs/class/System/System.Net/FtpWebResponse.cs
mcs/class/System/System.Net/HttpConnection.cs
mcs/class/System/System.Net/HttpContinueDelegate.cs
mcs/class/System/System.Net/HttpRequestCreator.cs
mcs/class/System/System.Net/HttpStatusCode.cs
mcs/class/System/System.Net/HttpWebRequest.cs
mcs/class/System/System.Net/HttpWebResponse.cs
mcs/class/System/System.Net/IAuthenticationModule.cs
mcs/class/System/System.Net/ICertificatePolicy.cs
mcs/class/System/System.Net/ICredentialPolicy.cs
mcs/class/System/System.Net/IWebRequestCreate.cs
mcs/class/System/System.Net/NtlmClient.cs
mcs/class/System/System.Net/ServicePoint.cs
mcs/class/System/System.Net/ServicePointManager.cs
mcs/class/System/System.Net/WebClient.cs
mcs/class/System/System.Net/WebConnection.cs
mcs/class/System/System.Net/WebConnectionGroup.cs
mcs/class/System/System.Net/WebException.cs
mcs/class/System/System.Net/WebHeaderCollection.cs
mcs/class/System/System.Net/WebRequest.cs
mcs/class/System/System.Net/WebResponse.cs
mcs/class/System/System.Security.Cryptography.X509Certificates/ChangeLog
mcs/class/System/System.Security.Cryptography.X509Certificates/X509Chain.cs
mcs/class/System/System.Text.RegularExpressions/CILCompiler.cs
mcs/class/System/System.Text.RegularExpressions/ChangeLog
mcs/class/System/System.Text.RegularExpressions/RxInterpreter.cs
mcs/class/System/System.Timers/ChangeLog
mcs/class/System/System.Timers/Timer.cs
mcs/class/System/System/ChangeLog
mcs/class/System/System/Uri.cs
mcs/class/System/System/UriTypeConverter.cs
mcs/class/System/monotouch_System.dll.sources
mcs/class/System/moonlight_bootstrap_System.dll.sources [new file with mode: 0644]
mcs/class/System/moonlight_raw_System.dll.sources [new file with mode: 0644]
mcs/class/System/net_2_1_bootstrap_System.dll.sources [deleted file]
mcs/class/System/net_2_1_raw_System.dll.sources [deleted file]
mcs/class/corlib/Assembly/AssemblyInfo.cs
mcs/class/corlib/Assembly/ChangeLog
mcs/class/corlib/ChangeLog
mcs/class/corlib/Makefile
mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs
mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs
mcs/class/corlib/Mono.Security.Authenticode/ChangeLog
mcs/class/corlib/Mono.Security.Cryptography/ChangeLog
mcs/class/corlib/Mono.Security.Cryptography/CryptoTools.cs
mcs/class/corlib/Mono.Security.Cryptography/KeyPairPersistence.cs
mcs/class/corlib/Mono.Security.Cryptography/PKCS1.cs
mcs/class/corlib/Mono.Security.Cryptography/PKCS8.cs
mcs/class/corlib/Mono.Security.Cryptography/SymmetricTransform.cs
mcs/class/corlib/Mono.Security.X509/ChangeLog
mcs/class/corlib/Mono.Security.X509/X509Certificate.cs
mcs/class/corlib/Mono.Security/ASN1Convert.cs
mcs/class/corlib/Mono.Security/ChangeLog
mcs/class/corlib/Mono.Security/StrongName.cs
mcs/class/corlib/Mono/Runtime.cs
mcs/class/corlib/System.Collections.Concurrent/ChangeLog
mcs/class/corlib/System.Collections.Concurrent/ConcurrentDictionary.cs
mcs/class/corlib/System.Collections.Concurrent/ConcurrentSkipList.cs
mcs/class/corlib/System.Collections.Generic/ChangeLog
mcs/class/corlib/System.Collections.Generic/CollectionDebuggerView.cs
mcs/class/corlib/System.Collections/ChangeLog
mcs/class/corlib/System.Collections/CollectionDebuggerView.cs
mcs/class/corlib/System.Collections/IStructuralComparable.cs
mcs/class/corlib/System.Collections/IStructuralEquatable.cs
mcs/class/corlib/System.Diagnostics/ChangeLog
mcs/class/corlib/System.Diagnostics/StackFrame.cs
mcs/class/corlib/System.Globalization/Calendar.cs
mcs/class/corlib/System.Globalization/ChangeLog
mcs/class/corlib/System.Globalization/CompareInfo.cs
mcs/class/corlib/System.Globalization/CultureInfo.cs
mcs/class/corlib/System.IO.IsolatedStorage/ChangeLog
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage.cs
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFile.cs
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFileEnumerator.cs
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFileStream.cs
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageScope.cs
mcs/class/corlib/System.IO.IsolatedStorage/MoonIsolatedStorage.cs
mcs/class/corlib/System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs
mcs/class/corlib/System.IO.IsolatedStorage/MoonIsolatedStorageFileStream.cs
mcs/class/corlib/System.IO/ChangeLog
mcs/class/corlib/System.IO/Directory.cs
mcs/class/corlib/System.IO/DirectoryInfo.cs
mcs/class/corlib/System.IO/File.cs
mcs/class/corlib/System.IO/FileStream.cs
mcs/class/corlib/System.IO/Path.cs
mcs/class/corlib/System.IO/SearchOption.cs
mcs/class/corlib/System.IO/Stream.cs
mcs/class/corlib/System.IO/StreamReader.cs
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/MethodOnTypeBuilderInst.cs
mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
mcs/class/corlib/System.Reflection/Assembly.cs
mcs/class/corlib/System.Reflection/ChangeLog
mcs/class/corlib/System.Reflection/MethodInfo.cs
mcs/class/corlib/System.Reflection/MonoAssembly.cs [new file with mode: 0644]
mcs/class/corlib/System.Resources/ChangeLog
mcs/class/corlib/System.Resources/ResourceManager.cs
mcs/class/corlib/System.Runtime.CompilerServices/ChangeLog
mcs/class/corlib/System.Runtime.CompilerServices/ConditionalWeakTable.cs
mcs/class/corlib/System.Runtime.CompilerServices/ReferenceAssemblyAttribute.cs
mcs/class/corlib/System.Runtime.CompilerServices/TypeForwardedFromAttribute.cs
mcs/class/corlib/System.Runtime.InteropServices/ChangeLog
mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
mcs/class/corlib/System.Runtime.InteropServices/MarshalAsAttribute.cs
mcs/class/corlib/System.Runtime.Remoting.Contexts/ChangeLog
mcs/class/corlib/System.Runtime.Remoting.Contexts/Context.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog
mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryCommon.cs
mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ChangeLog
mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate20.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509ContentType.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509KeyStorageFlags.cs
mcs/class/corlib/System.Security.Cryptography/ChangeLog
mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs
mcs/class/corlib/System.Security.Cryptography/CryptoConfig_2_1.cs
mcs/class/corlib/System.Security.Cryptography/DES.cs
mcs/class/corlib/System.Security.Cryptography/DESCryptoServiceProvider.cs
mcs/class/corlib/System.Security.Cryptography/DSACryptoServiceProvider.cs
mcs/class/corlib/System.Security.Cryptography/HMACMD5.cs
mcs/class/corlib/System.Security.Cryptography/HMACRIPEMD160.cs
mcs/class/corlib/System.Security.Cryptography/HMACSHA384.cs
mcs/class/corlib/System.Security.Cryptography/HMACSHA512.cs
mcs/class/corlib/System.Security.Cryptography/MACTripleDES.cs
mcs/class/corlib/System.Security.Cryptography/RC2.cs
mcs/class/corlib/System.Security.Cryptography/RC2CryptoServiceProvider.cs
mcs/class/corlib/System.Security.Cryptography/RIPEMD160.cs
mcs/class/corlib/System.Security.Cryptography/RIPEMD160Managed.cs
mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs
mcs/class/corlib/System.Security.Cryptography/Rijndael.cs
mcs/class/corlib/System.Security.Cryptography/RijndaelManaged.cs
mcs/class/corlib/System.Security.Cryptography/RijndaelManagedTransform.cs
mcs/class/corlib/System.Security.Cryptography/SHA1CryptoServiceProvider.cs
mcs/class/corlib/System.Security.Cryptography/SHA384.cs
mcs/class/corlib/System.Security.Cryptography/SHA384Managed.cs
mcs/class/corlib/System.Security.Cryptography/SHA512.cs
mcs/class/corlib/System.Security.Cryptography/SHA512Managed.cs
mcs/class/corlib/System.Security.Cryptography/SymmetricAlgorithm.cs
mcs/class/corlib/System.Security.Cryptography/TripleDES.cs
mcs/class/corlib/System.Security.Cryptography/TripleDESCryptoServiceProvider.cs
mcs/class/corlib/System.Security.Permissions/ChangeLog
mcs/class/corlib/System.Security.Permissions/PublisherIdentityPermissionAttribute.cs
mcs/class/corlib/System.Security.Policy/ChangeLog
mcs/class/corlib/System.Security.Policy/Evidence.cs
mcs/class/corlib/System.Security.Policy/Hash.cs
mcs/class/corlib/System.Security.Policy/HashMembershipCondition.cs
mcs/class/corlib/System.Security.Policy/PolicyLevel.cs
mcs/class/corlib/System.Security.Policy/PolicyLevel_2_1.cs
mcs/class/corlib/System.Security.Policy/Zone.cs
mcs/class/corlib/System.Security.Policy/ZoneMembershipCondition.cs
mcs/class/corlib/System.Security/ChangeLog
mcs/class/corlib/System.Security/IPermission.cs
mcs/class/corlib/System.Security/SecurityFrame.cs
mcs/class/corlib/System.Security/SecurityManager.cs
mcs/class/corlib/System.Security/SecurityManager_2_1.cs
mcs/class/corlib/System.Security/SecuritySafeCriticalAttribute.cs
mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs
mcs/class/corlib/System.Text/ChangeLog
mcs/class/corlib/System.Text/Encoding.cs
mcs/class/corlib/System.Text/StringBuilder.cs
mcs/class/corlib/System.Threading/ChangeLog
mcs/class/corlib/System.Threading/ExecutionContext.cs
mcs/class/corlib/System.Threading/Monitor.cs
mcs/class/corlib/System.Threading/Thread.cs
mcs/class/corlib/System.Threading/ThreadPool.cs
mcs/class/corlib/System/Activator.cs
mcs/class/corlib/System/AppDomain.cs
mcs/class/corlib/System/AppDomainSetup.cs
mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/CharEnumerator.cs
mcs/class/corlib/System/Console.cs
mcs/class/corlib/System/Delegate.cs
mcs/class/corlib/System/Enum.cs
mcs/class/corlib/System/Environment.cs
mcs/class/corlib/System/Exception.cs
mcs/class/corlib/System/MonoAsyncCall.cs
mcs/class/corlib/System/MulticastDelegate.cs
mcs/class/corlib/System/String.cs
mcs/class/corlib/System/TimeSpan.cs
mcs/class/corlib/System/Tuple.cs
mcs/class/corlib/System/Tuples.cs
mcs/class/corlib/Test/System.Collections.Concurrent/ChangeLog
mcs/class/corlib/Test/System.Collections.Concurrent/ConcurrentDictionaryTests.cs
mcs/class/corlib/Test/System.IO/ChangeLog
mcs/class/corlib/Test/System.IO/DirectoryTest.cs
mcs/class/corlib/Test/System.IO/StreamReaderTest.cs
mcs/class/corlib/Test/System.Reflection.Emit/AssemblyBuilderTest.cs
mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog
mcs/class/corlib/Test/System.Reflection.Emit/DerivedTypesTest.cs
mcs/class/corlib/Test/System.Reflection.Emit/MethodOnTypeBuilderInstTest.cs
mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs
mcs/class/corlib/Test/System.Reflection/ChangeLog
mcs/class/corlib/Test/System.Threading/ChangeLog
mcs/class/corlib/Test/System.Threading/SpinLockTests.cs
mcs/class/corlib/Test/System/ChangeLog
mcs/class/corlib/Test/System/TimeSpanTest.cs
mcs/class/corlib/corlib.dll.sources
mcs/class/corlib/moonlight_bootstrap_corlib.dll.sources [new file with mode: 0644]
mcs/class/corlib/moonlight_raw_corlib.dll.sources [new file with mode: 0644]
mcs/class/corlib/net_2_1_bootstrap_corlib.dll.sources [deleted file]
mcs/class/corlib/net_2_1_raw_corlib.dll.sources [deleted file]
mcs/errors/ChangeLog
mcs/errors/Makefile
mcs/errors/gcs0701-3.cs [deleted file]
mcs/errors/gcs0706.cs [new file with mode: 0644]
mcs/ilasm/parser/ChangeLog
mcs/ilasm/parser/ILParser.jay
mcs/mcs/ChangeLog
mcs/mcs/Makefile
mcs/tests/Makefile
mcs/tests/gtest-232.cs [deleted file]
mcs/tests/gtest-316.cs
mcs/tests/gtest-473.cs [new file with mode: 0644]
mcs/tests/gtest-anon-11.cs
mcs/tests/gtest-iter-12.cs [new file with mode: 0644]
mcs/tests/known-issues-dmcs
mcs/tests/known-issues-gmcs
mcs/tests/test-733.cs
mcs/tests/test-743-lib.cs [new file with mode: 0644]
mcs/tests/test-743.cs [new file with mode: 0644]
mcs/tests/test-744.cs [new file with mode: 0644]
mcs/tests/test-745.cs [new file with mode: 0644]
mcs/tests/ver-il-gmcs.xml
mcs/tools/ChangeLog
mcs/tools/Makefile
mcs/tools/compiler-tester/Makefile
mcs/tools/mkbundle/ChangeLog
mcs/tools/mkbundle/mkbundle.cs
mono/arch/s390x/ChangeLog
mono/arch/s390x/s390x-codegen.h
mono/io-layer/ChangeLog
mono/io-layer/shared.c
mono/io-layer/sockets.c
mono/io-layer/threads.h
mono/io-layer/wthreads.c
mono/metadata/ChangeLog
mono/metadata/Makefile.am
mono/metadata/appdomain.c
mono/metadata/boehm-gc.c
mono/metadata/class-internals.h
mono/metadata/class.c
mono/metadata/cominterop.c
mono/metadata/culture-info-tables.h
mono/metadata/debug-helpers.c
mono/metadata/domain-internals.h
mono/metadata/domain.c
mono/metadata/gc-internal.h
mono/metadata/icall-def.h
mono/metadata/icall.c
mono/metadata/loader.c
mono/metadata/locales.c
mono/metadata/marshal.c
mono/metadata/metadata-internals.h
mono/metadata/metadata.c
mono/metadata/method-builder.c
mono/metadata/mono-debug.c
mono/metadata/mono-mlist.c
mono/metadata/mono-mlist.h
mono/metadata/mono-perfcounters-def.h
mono/metadata/mono-perfcounters.c
mono/metadata/mono-wsq.c [new file with mode: 0644]
mono/metadata/mono-wsq.h [new file with mode: 0644]
mono/metadata/null-gc.c
mono/metadata/object-internals.h
mono/metadata/object.c
mono/metadata/object.h
mono/metadata/process.c
mono/metadata/reflection.c
mono/metadata/sgen-archdep.h
mono/metadata/sgen-gc.c
mono/metadata/sgen-gc.h
mono/metadata/sgen-gray.c
mono/metadata/sgen-pinning-stats.c
mono/metadata/sgen-pinning.c
mono/metadata/sgen-protocol.c
mono/metadata/sgen-protocol.h
mono/metadata/sgen-scan-object.h
mono/metadata/socket-io.c
mono/metadata/threadpool.c
mono/metadata/threadpool.h
mono/metadata/threads-types.h
mono/metadata/threads.c
mono/metadata/threads.h
mono/metadata/verify.c
mono/mini/ChangeLog
mono/mini/Makefile.am
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/basic-simd.cs
mono/mini/cpu-s390x.md
mono/mini/debugger-agent.c
mono/mini/driver.c
mono/mini/exceptions-amd64.c
mono/mini/exceptions-s390x.c
mono/mini/generics.cs
mono/mini/iltests.il.in
mono/mini/jit-icalls.c
mono/mini/method-to-ir.c
mono/mini/mini-amd64.c
mono/mini/mini-amd64.h
mono/mini/mini-arm.c
mono/mini/mini-exceptions.c
mono/mini/mini-generic-sharing.c
mono/mini/mini-ia64.c
mono/mini/mini-mips.c
mono/mini/mini-ppc.c
mono/mini/mini-s390.c
mono/mini/mini-s390x.c
mono/mini/mini-s390x.h
mono/mini/mini-sparc.c
mono/mini/mini-trampolines.c
mono/mini/mini-x86.c
mono/mini/mini-x86.h
mono/mini/mini.c
mono/mini/mini.h
mono/mini/simd-intrinsics.c
mono/mini/tramp-s390x.c
mono/profiler/ChangeLog
mono/profiler/mono-profiler-iomap.c
mono/tests/.gitignore
mono/tests/ChangeLog
mono/tests/Makefile.am
mono/tests/test-runner.cs
mono/utils/ChangeLog
mono/utils/mono-dl.c
mono/utils/mono-ehash.c
mono/utils/mono-hash.c
mono/utils/mono-proclib.c
mono/utils/mono-semaphore.c
mono/utils/mono-semaphore.h
mono/utils/mono-sigcontext.h
msvc/ChangeLog
msvc/libmono.vcproj
msvc/scripts/genproj.cs
msvc/scripts/monowrap.cs
msvc05/ChangeLog
msvc05/setup-solution.bat
runtime/Makefile.am
support/ChangeLog
support/old-map.c
tools/locale-builder/supp/ChangeLog
tools/locale-builder/supp/da.xml

index ee8f329b8e3abf105bdf9b935c61ee37b2d115af..0247f818a69806e0424645864c19c3cff0aedd68 100644 (file)
@@ -1,6 +1,16 @@
 
 The Mono runtime is licensed under the terms of the GNU 
 Library General Public License, version 2.
+
+The eglib directory is licensed under the terms of the MIT
+X11 license and is a drop-in replacement for Mono's use of
+glib 2.0 (which was LGPL).
+
+The Boehm licensing information is in the libgc directory
+
+The SGen Garbage Collector is under the terms of the MIT X11
+license
+
                  
                GNU LIBRARY GENERAL PUBLIC LICENSE
                       Version 2, June 1991
index 5043ae6eaac63f378b094f28dbb2c19f6dab09fb..9cdabe810f78ba4c219070458458a25ecde0ea76 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2010-03-26  Zoltan Varga  <vargaz@gmail.com>
+
+       * configure.in: Apply some openbsd changes from openbsd ports.
+
+2010-03-23  Neale Ferguson <neale@sinenomine.net>
+
+       * configure.in: Change ACCESS_UNALINGED to "yes" for s390/s390x.
+
+2010-03-22  Andreia Gaita  <avidigal@gmail.com>
+
+       * configure.in: fix build when doing with-mcs-docs=no on a clean tree
+
+2010-03-19  Zoltan Varga  <vargaz@gmail.com>
+
+       * autogen.sh: Pass -Wno-portability to automake to quiet some warnings.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * runtime/Makefile.am, build-mingw32.sh: rename
+       the net_2_1 profile to moonlight.
+
 2010-03-10  Andrew Jorgensen  <ajorgensen@novell.com>
 
        * configure.in: configure eglib even when we are not building
diff --git a/LICENSE b/LICENSE
index 6177891cdc035bb2b2117d298155ff7394fe2937..e9655394176bfd6b807e12637877b17526b573f5 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -54,6 +54,13 @@ For comments, corrections and updates, please contact mono@novell.com
        the terms of the MIT X11, this means that this code can be
        used for any purposes by anyone.
 
+** mono/metadata/sgen*: Mono's Copying Collector
+
+       This new garbage collector is licensed under the terms of
+       the MIT X11 license, in hopes that the GC could be reused
+       by third party projects, follows the same spirit than the
+       Boehm GC.
+
 ** mcs/mcs, mcs/gmcs
 
        The C# Compilers (1.0 and 2.0)
index eba9274a8fab2ef2c9978ff6bed561f3dabd7ebb..898b2d80beb5bda8afb2db16c0bffe3cf0cbe86d 100755 (executable)
@@ -119,7 +119,7 @@ if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
 fi
 
 echo "Running automake --gnu $am_opt ..."
-automake --add-missing --gnu $am_opt ||
+automake --add-missing --gnu -Wno-portability $am_opt ||
   { echo "**Error**: automake failed."; exit 1; }
 echo "Running autoconf ..."
 autoconf || { echo "**Error**: autoconf failed."; exit 1; }
index 200c5fa71881a68495dc6f40f7a7427701ff7c18..3b0538e6fc13909c136f168cb964b917d84912f2 100755 (executable)
@@ -8,7 +8,7 @@ CROSS_PKG_CONFIG_DIR=$CROSS_DIR/$MINGW/lib/pkgconfig
 COPY_DLLS="libgio*.dll libglib*.dll libgmodule*.dll libgthread*.dll libgobject*.dll"
 PATH=$CROSS_BIN_DIR:$PATH
 INSTALL_DESTDIR="$CURDIR/mono-win32"
-PROFILES="default net_2_0 net_2_1 net_3_5"
+PROFILES="default net_2_0 moonlight net_3_5"
 
 export PATH
 
index 723850e1c7656cf627f64cb066a161c5f2052cae..92c4cf98630fc3bef0e8c2252ba7cd99353f6b6e 100644 (file)
@@ -151,8 +151,11 @@ case "$host" in
                ;;
        *-*-*openbsd*)
                host_win32=no
-               CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS -DPLATFORM_BSD"
-               libmono_cflags="-D_THREAD_SAFE"
+               CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS -DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
+               if test "x$disable_munmap" != "xyes"; then
+               CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
+               fi
+               libmono_cflags="-D_THREAD_SAFE -D_REENTRANT"
                LDFLAGS="$LDFLAGS -pthread"
                libmono_ldflags="-pthread"
                need_link_unlink=yes
@@ -1279,6 +1282,9 @@ if test x$target_win32 = xno; then
                *-*-*freebsd*)
                        AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
                ;;
+               *-*-*openbsd*)
+                       AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
+               ;;
                *)
                        AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
                ;;
@@ -1671,6 +1677,7 @@ if test x$target_win32 = xno; then
        AC_CHECK_MEMBERS(
                [struct kinfo_proc.kp_proc],,, 
                [#include <sys/types.h>
+                #include <sys/param.h>
                 #include <sys/sysctl.h>
                 #include <sys/proc.h>
                 ])
@@ -2149,7 +2156,7 @@ case "$host" in
        s390-*-linux*)
                TARGET=S390;
                arch_target=s390;
-               ACCESS_UNALIGNED="no"
+               ACCESS_UNALIGNED="yes"
                JIT_SUPPORTED=yes
                jit_wanted=true
                # Required CFLAGS for s390[x].  USE_STRING_INLINES is automatic with gcc 4.1
@@ -2158,7 +2165,7 @@ case "$host" in
        s390x-*-linux*)
                TARGET=S390x;
                arch_target=s390x;
-               ACCESS_UNALIGNED="no"
+               ACCESS_UNALIGNED="yes"
                JIT_SUPPORTED=yes
                jit_wanted=true
                CFLAGS="$CFLAGS -mbackchain -D__USE_STRING_INLINES"
@@ -2469,6 +2476,9 @@ dnl Consistency settings
 dnl
 if test x$cross_compiling = xyes -o x$enable_mcs_build = xno; then
    DISABLE_MCS_DOCS=yes
+fi
+
+if test x$DISABLE_MCS_DOCS = xyes; then
    docs_dir=""
 else
    docs_dir=docs
@@ -2709,6 +2719,7 @@ data/cecil.pc
 data/system.web.extensions_1.0.pc
 data/system.web.extensions.design_1.0.pc
 data/system.web.mvc.pc
+data/system.web.mvc2.pc
 samples/Makefile
 support/Makefile
 data/config
index 3ae35a43747c34385a60cb5fc043fd821e20ed14..e8384baead9544bf2987199a604627f38b664d8b 100644 (file)
@@ -12,7 +12,7 @@ EXTRA_DIST =          \
        mono-2.pc.in mint.pc.in dotnet.pc.in dotnet35.pc.in wcf.pc.in monodoc.pc.in \
        mono-nunit.pc.in mono-cairo.pc.in mono-options.pc.in cecil.pc.in \
        mono-lineeditor.pc.in system.web.extensions_1.0.pc.in system.web.extensions.design_1.0.pc.in\
-       dtrace-prelink.sh mono.web.pc.in system.web.mvc.pc.in \
+       dtrace-prelink.sh mono.web.pc.in system.web.mvc.pc.in system.web.mvc2.pc.in \
        net_1_1/machine.config \
        gdb/mono-gdb.py \
        gdb/gdb-python.diff
@@ -22,17 +22,17 @@ pkgconfigdir = $(libdir)/pkgconfig
 if JIT_SUPPORTED
 if INTERP_SUPPORTED
 pkgconfig_DATA= mono-2.pc mint.pc dotnet.pc dotnet35.pc wcf.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc system.web.extensions_1.0.pc \
-               system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc
+               system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc
 else
 pkgconfig_DATA= mono-2.pc dotnet.pc dotnet35.pc wcf.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc system.web.extensions_1.0.pc \
-               system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc
+               system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc
 endif
 else
 pkgconfig_DATA= mint.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc
 endif
 
 DISTCLEANFILES= mono-2.pc mint.pc dotnet.pc dotnet35.pc wcf.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc system.web.extensions_1.0.pc \
-               system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc
+               system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc
 
 mono_DATA =  config \
             browscap.ini
diff --git a/data/system.web.mvc2.pc.in b/data/system.web.mvc2.pc.in
new file mode 100644 (file)
index 0000000..8b17369
--- /dev/null
@@ -0,0 +1,4 @@
+Name: System.Web.Mvc2
+Description: System.Web.Mvc - ASP.NET MVC v2
+Version: 2.0.0.0
+Libs: -r:@prefix@/lib/mono/gac/System.Web.Mvc/2.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll
index 1a2f51733cda0835177bfb6a90b14b7820f5f920..f7751e2e3b6f804a0437e442ccf82bad944bb75d 100644 (file)
@@ -24,7 +24,7 @@ A small note on the choice of magic_reg for different JIT backends: the IMT
 method identifier doesn't necessarily need to be stored in a register, though
 doing so is fast and the JIT code has already the infrastructure to handle this
 case in an arch-independent way. A JIT porter just needs to #define
-MONO_ARCH_IMT_REG to the choosen register. Note that this register should be
+MONO_ARCH_IMT_REG to the chosen register. Note that this register should be
 part of the MONO_ARCH_CALLEE_REGS set as it will be handled by the local register
 allocator (see mini/inssel.brg) and it must not be part of the registers used for
 argument passing as you'd overwrite an argument in that case.
@@ -72,7 +72,7 @@ the IMT slot was asked to execute an interface method that the type doesn't impl
 In the future we might want to handle this case not with a breakpoint or assert, but
 by either throwing an InvalidCast exception or by going into the runtime and
 adding support for the interface automagically to the type/vtable: this could be used
-both for tranparent proxies and for the implicit interfaces that vectors in 2.0
+both for transparent proxies and for the implicit interfaces that vectors in 2.0
 provide.
 
 For a bisect check the code is even simpler:
@@ -131,7 +131,7 @@ called the magic trampoline will fill-in the IMT slot with the proper thunk or
 trampoline, so later calls will use the fast path.
 This single-instance trampoline will use MONO_FAKE_IMT_METHOD as the method
 it's asking to be compiled and executed: the trampoline code does recognize
-this special value and retrives the interface method to call from the usual
+this special value and retrieves the interface method to call from the usual
 MONO_ARCH_IMT_REG saved by the trampoline code.
 Given that only the IMT slots that are actually used will be initialized, this saves
 quite a bit of memory, as it's unlikely that all the interface methods are called on
index e0a3ab437ab7bcbcb984b1cad0e89389aa19b822..57d06fb98191107853c7d2bf1a9b25fe8562e3a1 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-26  Zoltan Varga  <vargaz@gmail.com>
+
+       * mono.1: Document the MONO_ENABLE_SHM env variable.
+
 2010-03-03  Rolf Bjarne Kvinge  <RKvinge@novell.com>
 
        * mono.1: Document exception tracing.
index ea99ab88a703c647f55b1e62bdf61efc244be39f..6c005b00d14207f66d91dff4309b36cf06e9435b 100644 (file)
@@ -1481,6 +1481,11 @@ processes.
 .Sp
 This is can also be enabled by default by passing the
 "--disable-shared-handles" option to configure.
+.Sp
+This is the default from mono 2.8 onwards.
+.TP
+\fBMONO_ENABLE_SHM\fR
+Enable support for cross-process handles.
 .TP
 \fBMONO_THEME\fR
 The name of the theme to be used by Windows.Forms.   Available themes today
index e4e31b255d435219d05397a30479a7dad97561a4..401517b94e5a4df06f3a262fa0ea536ee589d556 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: rename the net_2_1 profile to moonlight.
+
 2010-03-03  Rolf Bjarne Kvinge  <RKvinge@novell.com>
 
        * Makefile: Make basic the bootstrapping profile for net_2_1_bootstrap.
index b30f44ec5df9b14914ef0d62b7ecb746c7c37c0e..311d477cedff1727145a0b7819479f525df3457f 100644 (file)
@@ -5,9 +5,9 @@ SUBDIRS := build jay mcs class nunit24 ilasm tools tests errors docs
 basic_SUBDIRS := build jay mcs class tools
 net_2_0_bootstrap_SUBDIRS := build tools
 net_2_0_SUBDIRS := build mcs class nunit24 ilasm tools tests errors 
-net_2_1_bootstrap_SUBDIRS := build mcs class
-net_2_1_raw_SUBDIRS := build mcs class tools
-net_2_1_SUBDIRS := tools tests errors
+moonlight_bootstrap_SUBDIRS := build mcs class
+moonlight_raw_SUBDIRS := build mcs class tools
+moonlight_SUBDIRS := tools tests errors
 monotouch_SUBDIRS := build mcs class
 monotouch_bootstrap_SUBDIRS := build mcs class
 net_3_5_SUBDIRS := build class
@@ -106,11 +106,11 @@ _boot_ = all clean install
 $(_boot_:%=profile-do--net_4_0--%):           profile-do--net_4_0--%:           profile-do--net_4_0_bootstrap--%
 $(_boot_:%=profile-do--net_4_0_bootstrap--%): profile-do--net_4_0_bootstrap--%: profile-do--net_2_0--%
 $(_boot_:%=profile-do--net_3_5--%):           profile-do--net_3_5--%:           profile-do--net_2_0--%
-$(_boot_:%=profile-do--net_2_1--%):           profile-do--net_2_1--%:           profile-do--net_2_1_raw--%
+$(_boot_:%=profile-do--moonlight--%):           profile-do--moonlight--%:           profile-do--moonlight_raw--%
 $(_boot_:%=profile-do--monotouch--%):         profile-do--monotouch--%:         profile-do--monotouch_bootstrap--%
 $(_boot_:%=profile-do--monotouch_bootstrap--%): profile-do--monotouch_bootstrap--%: profile-do--net_2_0--%
-$(_boot_:%=profile-do--net_2_1_raw--%):       profile-do--net_2_1_raw--%:       profile-do--net_2_1_bootstrap--%
-$(_boot_:%=profile-do--net_2_1_bootstrap--%): profile-do--net_2_1_bootstrap--%: profile-do--basic--%
+$(_boot_:%=profile-do--moonlight_raw--%):       profile-do--moonlight_raw--%:       profile-do--moonlight_bootstrap--%
+$(_boot_:%=profile-do--moonlight_bootstrap--%): profile-do--moonlight_bootstrap--%: profile-do--basic--%
 $(_boot_:%=profile-do--net_2_0--%):           profile-do--net_2_0--%:           profile-do--net_2_0_bootstrap--%
 $(_boot_:%=profile-do--net_2_0_bootstrap--%): profile-do--net_2_0_bootstrap--%: profile-do--basic--%
 
index 2b6610dd9757a85de2a4fa951255d17b98c3a7a1..af80c5cb42632a6cf0c45710e3237f1323f30e66 100644 (file)
@@ -1,3 +1,14 @@
+2010-03-16  Jonathan Pryor  <jpryor@novell.com>
+
+       * library.make (MDOC_UP): Set MONO_PATH to find monodoc.dll.
+       * rules.make (MDOC): MONO_PATH needs to include 
+         $(topdir)/class/lib/net_2_0 so that monodoc.dll can be found.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * profiles/net_2_1_*.make: rename to moonlight_*.make and
+       define the MOONLIGHT symbol.
+
 2010-03-03  Jonathan Pryor <jpryor@novell.com>
 
        * library.make: Add the generated per-profile .source file to
index 08640a9f4acbd8fc1937a514e1ff6a3c496ff539..af6ce7356b47435ee5625891362c1c7692cba399 100644 (file)
@@ -19,9 +19,9 @@ PROFILES = \
        basic \
        net_2_0_bootstrap \
        net_2_0 \
-       net_2_1_bootstrap \
-       net_2_1_raw \
-       net_2_1 \
+       moonlight_bootstrap \
+       moonlight_raw \
+       moonlight \
        net_3_5 \
        net_4_0_bootstrap \
        net_4_0 
index f5844153850f730857c12bbc8ac87999bac3d64c..a8eb8ae17907b5b8cbf82b8b3d71d90f63610fc6 100644 (file)
@@ -276,6 +276,7 @@ $(makefrag) $(test_response) $(test_makefrag) $(btest_response) $(btest_makefrag
 
 Q_MDOC_UP=$(if $(V),,@echo "MDOC-UP [$(PROFILE)] $(notdir $(@))";)
 MDOC_UP  =$(Q_MDOC_UP) \
+               MONO_PATH="$(topdir)/class/lib/net_4_0$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" \
                $(RUNTIME) $(topdir)/tools/mdoc/mdoc.exe update --delete            \
                        -o Documentation/en $(the_lib)
 
diff --git a/mcs/build/profiles/moonlight.make b/mcs/build/profiles/moonlight.make
new file mode 100644 (file)
index 0000000..f3aba43
--- /dev/null
@@ -0,0 +1,19 @@
+#! -*- makefile -*-
+
+my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack
+INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe
+
+BOOTSTRAP_PROFILE = moonlight_bootstrap
+
+BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe
+MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
+
+profile-check:
+       @:
+
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOONLIGHT
+FRAMEWORK_VERSION = 2.1
+NO_TEST = yes
+
+# the tuner takes care of the install
+NO_INSTALL = yes
diff --git a/mcs/build/profiles/moonlight_bootstrap.make b/mcs/build/profiles/moonlight_bootstrap.make
new file mode 100644 (file)
index 0000000..b6bb555
--- /dev/null
@@ -0,0 +1,17 @@
+#! -*- makefile -*-
+
+INTERNAL_SMCS = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack $(topdir)/class/lib/$(PROFILE)/smcs.exe
+
+BOOTSTRAP_PROFILE = basic
+BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
+MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
+
+profile-check:
+       @:
+
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOONLIGHT
+FRAMEWORK_VERSION = 2.1
+NO_TEST = yes
+
+# the tuner takes care of the install
+NO_INSTALL = yes
diff --git a/mcs/build/profiles/moonlight_raw.make b/mcs/build/profiles/moonlight_raw.make
new file mode 100644 (file)
index 0000000..f3aba43
--- /dev/null
@@ -0,0 +1,19 @@
+#! -*- makefile -*-
+
+my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack
+INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe
+
+BOOTSTRAP_PROFILE = moonlight_bootstrap
+
+BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe
+MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
+
+profile-check:
+       @:
+
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOONLIGHT
+FRAMEWORK_VERSION = 2.1
+NO_TEST = yes
+
+# the tuner takes care of the install
+NO_INSTALL = yes
diff --git a/mcs/build/profiles/net_2_1.make b/mcs/build/profiles/net_2_1.make
deleted file mode 100644 (file)
index f6a58a5..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#! -*- makefile -*-
-
-my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack
-INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe
-
-BOOTSTRAP_PROFILE = net_2_1_bootstrap
-
-BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe
-MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
-
-profile-check:
-       @:
-
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1
-FRAMEWORK_VERSION = 2.1
-NO_TEST = yes
-
-# the tuner takes care of the install
-NO_INSTALL = yes
diff --git a/mcs/build/profiles/net_2_1_bootstrap.make b/mcs/build/profiles/net_2_1_bootstrap.make
deleted file mode 100644 (file)
index 230c391..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#! -*- makefile -*-
-
-INTERNAL_SMCS = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack $(topdir)/class/lib/$(PROFILE)/smcs.exe
-
-BOOTSTRAP_PROFILE = basic
-BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
-MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
-
-profile-check:
-       @:
-
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1
-FRAMEWORK_VERSION = 2.1
-NO_TEST = yes
-
-# the tuner takes care of the install
-NO_INSTALL = yes
diff --git a/mcs/build/profiles/net_2_1_raw.make b/mcs/build/profiles/net_2_1_raw.make
deleted file mode 100644 (file)
index f6a58a5..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#! -*- makefile -*-
-
-my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack
-INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe
-
-BOOTSTRAP_PROFILE = net_2_1_bootstrap
-
-BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe
-MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
-
-profile-check:
-       @:
-
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1
-FRAMEWORK_VERSION = 2.1
-NO_TEST = yes
-
-# the tuner takes care of the install
-NO_INSTALL = yes
index 5f34ce865d55eab56848a58982c5eacadee95fd5..08bdc227483efca89eb25b519de2b92253c0a5fe 100644 (file)
@@ -205,5 +205,6 @@ withmcs:
 ## Documentation stuff
 
 Q_MDOC =$(if $(V),,@echo "MDOC    [$(PROFILE)] $(notdir $(@))";)
-MDOC   =$(Q_MDOC) MONO_PATH="$(topdir)/class/lib/net_4_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(topdir)/tools/mdoc/mdoc.exe
+MDOC   =$(Q_MDOC) MONO_PATH="$(topdir)/class/lib/net_4_0$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" \
+       $(RUNTIME) $(topdir)/tools/mdoc/mdoc.exe
 
index 44fb1d7a4a41078b7d7ba0abb72af8754a444f30..0b4b7277f259aa9fbdb5b200bd2067c57dcd3e00 100644 (file)
@@ -1,3 +1,15 @@
+2010-03-16  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * Makefile: Add System.Xml.Serialization to the Moonlight build.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: rename the net_2_1 profile to moonlight.
+
+2010-03-15  Marek Habersack  <mhabersack@novell.com>
+
+       * Makefile (net_2_0_dirs): added System.Web.Mvc2
+
 2010-03-11  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Makefile : build Sys.Json after Sys.SM.Web.
index c61e7fee1321e501a47da195ebc9402d1ea79476..62d21f04c40a5cb9ebcd31bae6db8684bc99e330 100644 (file)
@@ -106,6 +106,7 @@ net_2_0_dirs := \
        System.Web.DynamicData          \
        System.ServiceModel.Web         \
        System.Web.Mvc                  \
+       System.Web.Mvc2                 \
        Mono.C5                         \
        Mono.Management                 \
        Mono.Options                    \
@@ -119,7 +120,7 @@ net_2_0_only_dirs := \
        System.Web.Extensions_1.0       \
        System.Web.Extensions.Design_1.0
 
-net_2_1_dirs := \
+moonlight_dirs := \
        corlib                  \
        Mono.CompilerServices.SymbolWriter \
        System.Core             \
@@ -127,6 +128,7 @@ net_2_1_dirs := \
        System.XML              \
        System.Net              \
        System.Xml.Linq \
+       System.Xml.Serialization        \
        System.Runtime.Serialization    \
        System.ServiceModel     \
        System.ServiceModel.Web
@@ -169,8 +171,8 @@ net_4_0_dirs := \
 
 net_2_0_bootstrap_SUBDIRS := $(bootstrap_dirs)
 net_2_0_SUBDIRS := $(common_dirs) $(net_2_0_dirs) $(net_2_0_only_dirs)
-net_2_1_bootstrap_SUBDIRS := corlib System Mono.CompilerServices.SymbolWriter System.Core
-net_2_1_raw_SUBDIRS := $(net_2_1_dirs)
+moonlight_bootstrap_SUBDIRS := corlib System Mono.CompilerServices.SymbolWriter System.Core
+moonlight_raw_SUBDIRS := $(moonlight_dirs)
 monotouch_bootstrap_SUBDIRS := corlib System Mono.CompilerServices.SymbolWriter System.Core
 monotouch_SUBDIRS := $(monotouch_dirs)
 net_3_5_SUBDIRS := $(net_3_5_dirs)
@@ -179,7 +181,7 @@ net_4_0_SUBDIRS := $(common_dirs) $(net_2_0_dirs) $(net_4_0_dirs)
 
 include ../build/rules.make
 
-SUBDIRS = $(common_dirs) $(net_2_0_dirs) $(net_2_0_only_dirs) $(net_2_1_dirs) $(net_3_5_dirs) $(net_4_0_dirs)
+SUBDIRS = $(common_dirs) $(net_2_0_dirs) $(net_2_0_only_dirs) $(moonlight_dirs) $(monotouch_dirs) $(net_3_5_dirs) $(net_4_0_dirs)
 
 DIST_ONLY_SUBDIRS = dlr
 
index c878a999eacc0b5e21d4d57f24694283e50fa37c..3a1cf930183b92155e5fd1b872a803f6496de0e5 100644 (file)
@@ -206,7 +206,7 @@ namespace Mono.Security {
                                        mask = "yyyyMMddHHmmsszzz";
                                        break;
                        }
-                       return DateTime.ParseExact (t, mask, null, DateTimeStyles.AdjustToUniversal);
+                       return DateTime.ParseExact (t, mask, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
                }
        }
 }
index 56a0e5a2d5fe096b5dd0a5d0096fcc650fadd841..fba575945bf34ae5a0e673f6b3a7ff9f88116832 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-24  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ASN1Convert.cs: Specify CultureInfo.InvariantCulture (instead of 
+       null) to avoid crash on Windows. Patch by Yoni Shalom.
+
 2008-09-12  Sebastien Pouliot  <sebastien@ximian.com>
 
        * ASN1.cs: Use File.Create instead of OpenWrite to make sure nothing
index 8ab1729a9e21c41ad8f24cb6fec9d0c358aabfde..e508f043319f7b68b7e625cfcf5bf1aeeb5098db 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-24 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * Vector4f.cs: Add vector x scalar multiply.
+
 2009-09-18 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * SimdRuntime.cs: Raise an exception if the method been queried
index 77ba2cd6def328504fde43dabe8d54f3660ce61d..db7143b9b4952b293cdef1282405e012f7df392a 100644 (file)
@@ -80,9 +80,7 @@ namespace Mono.Simd
         Abs (implemented as pand [7fffffff,...] )
         Comparison functions
         Mask extraction function
-        Setters
         vector x float ops
-        Single float constructor (expand it to the 4 positions)
                Replace Shuffle with less bug prone methods
 */
 
@@ -223,6 +221,18 @@ namespace Mono.Simd
                        return new Vector4f (v1.x * v2.x, v1.y * v2.y, v1.z * v2.z, v1.w * v2.w);
                }
 
+               [Acceleration (AccelMode.SSE1)]
+               public static Vector4f operator * (float scalar, Vector4f v)
+               {
+                       return new Vector4f (scalar * v.x, scalar * v.y, scalar * v.z, scalar * v.w);
+               }
+
+               [Acceleration (AccelMode.SSE1)]
+               public static Vector4f operator * (Vector4f v, float scalar)
+               {
+                       return new Vector4f (scalar * v.x, scalar * v.y, scalar * v.z, scalar * v.w);
+               }
+
                [Acceleration (AccelMode.SSE1)]
                public static Vector4f operator / (Vector4f v1, Vector4f v2)
                {
index ae15ef4b2908cf316fa679160a52855f91a39cb2..616ef4577a4995bb34217c3fc205b385f26c3233 100644 (file)
@@ -468,7 +468,7 @@ namespace System.ComponentModel.Composition.Hosting
         private string[] GetFiles()\r
         {\r
             string[] files = Directory.GetFiles(this._fullPath, this._searchPattern);\r
-            return Array.ConvertAll<string, string>(files, (file) => file.ToUpperInvariant());\r
+            return Array.ConvertAll<string, string>(files, (file) => file);\r
         }\r
 \r
         private static string GetFullPath(string path)\r
@@ -478,7 +478,7 @@ namespace System.ComponentModel.Composition.Hosting
                 path = IOPath.Combine(AppDomain.CurrentDomain.BaseDirectory, path);\r
             }\r
 \r
-            return IOPath.GetFullPath(path).ToUpperInvariant();\r
+            return IOPath.GetFullPath(path);\r
         }\r
 \r
         private void Initialize(string path, string searchPattern)\r
index 0ccc1d0801e6a78e2ecd7fd2be7801fd28b77d70..d2adf2ccf02b6fbd021d119d383411f4c782414b 100644 (file)
@@ -73,3 +73,8 @@ using System.Runtime.InteropServices;
 // Extension attribute should be added by compiler
 
 [assembly: SecurityPermission (SecurityAction.RequestMinimum, SkipVerification = true)]
+
+#if NET_4_0
+[assembly: TypeForwardedTo (typeof (System.Security.Cryptography.Aes))]
+#endif
+
index 02c2a5d0dfaf619783d73346cc37732edac93de3..640ce64edd96696067b8037f7e25e1ee67378c14 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-18  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * AssemblyInfo.cs: Add TypeForwardTo for Aes on NET_4_0
+
 2008-08-08  Sebastien Pouliot  <sebastien@ximian.com>
 
        * AssemblyInfo.cs: Remove a few attributes for SL2
index 5bddef0064e34eaaf86951f865d6d5a9ee7ad07a..d093c0ce64630f261abc8c89aa6725bb2213419a 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * net_2_1_*.dll.sources: rename to moonlight_*.dll.sources.
+
 2009-12-17  Marek Safar  <marek.safar@gmail.com>
 
        * Makefile: Compile itself using bootstrap System.Core.
index dde17448c70e8821d27c7d88eed1ee4f31093681..893de76b60b7e0524c5f581e78d02f060bd6f736 100644 (file)
@@ -14,7 +14,7 @@ ifeq (4.0, $(FRAMEWORK_VERSION))
 LIB_MCS_FLAGS += -d:CODEPLEX_40
 endif
 
-FULL_PROFILE := $(filter net_2_0 net_4_0 net_2_1_raw monotouch, $(PROFILE))
+FULL_PROFILE := $(filter net_2_0 net_4_0 moonlight_raw monotouch, $(PROFILE))
 ifdef FULL_PROFILE
 LIBRARY_COMPILE = $(BOOT_COMPILE)
 endif
index a7c2221dc4c4ff1628402522e411c66580f2a397..0438c8dd5732119845b4e430893a91c61d65a421 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-24  Jb Evain  <jbevain@novell.com>
+
+       * SortSequenceContext.cs: Fix OrderByDescending stability.
+       Based on a patch by Richard Kiene  <richard.kiene@logos.com>.
+
 2010-02-23  Marek Safar  <marek.safar@gmail.com>
 
        * Enumerable.cs: Implement Zip.
index 2ec42114a4105d8c26865a31216a0db16b214869..a25427e60cbce19b2f6b5c60f8d89b09d3a4042f 100644 (file)
@@ -62,8 +62,10 @@ namespace System.Linq {
                        if (comparison == 0) {
                                if (child_context != null)
                                        return child_context.Compare (first_index, second_index);
-                               else
-                                       comparison = first_index - second_index;
+
+                               comparison = direction == SortDirection.Descending
+                                       ? second_index - first_index
+                                       : first_index - second_index;
                        }
 
                        return direction == SortDirection.Descending ? -comparison : comparison;
index 3c7da47c1d2c08bc168aacd379127a1dfd60b1ac..eaee476a5005b273ce30f724f51c3036ed336663 100644 (file)
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+// Since 4.0 (both FX and SL) this type is defined in mscorlib - before 4.0 it was in System.Core.dll
+#if (INSIDE_CORLIB && (NET_4_0 || BOOTSTRAP_NET_4_0 || MOONLIGHT)) || (!INSIDE_CORLIB && !NET_4_0 && !BOOTSTRAP_NET_4_0 && !MOONLIGHT)
 \r
+using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 \r
 namespace System.Security.Cryptography {\r
@@ -37,12 +41,22 @@ namespace System.Security.Cryptography {
        // References:
        // a.   FIPS PUB 197: Advanced Encryption Standard
        //      http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
-\r
+
+#if INSIDE_CORLIB
+       // since 4.0 (both FX and SL) this type now resides inside mscorlib.dll and link back to System.Core.dll\r
+       #if MOONLIGHT
+       // version has not changed between SL3 (System.Core) and SL4
+       [TypeForwardedFrom (Consts.AssemblySystem_Core)]
+       #elif NET_4_0 || BOOTSTRAP_NET_4_0
+       // use 3.5 version
+       [TypeForwardedFrom ("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
+       #endif
+#endif
        public abstract class Aes : SymmetricAlgorithm {\r
-\r
+
                public static new Aes Create () \r
                {\r
-               return Create ("System.Security.Cryptography.AesManaged, " + Consts.AssemblySystem_Core);\r
+                       return Create ("System.Security.Cryptography.AesManaged, " + Consts.AssemblySystem_Core);\r
                }\r
 \r
                public static new Aes Create (string algName) \r
@@ -66,3 +80,5 @@ namespace System.Security.Cryptography {
                }\r
        }\r
 }\r
+#endif
+
index b25f7385f60b68ee331d8e44cedf6bcd79d0e2d9..aef59b427ec3fac81203f7346687a45ed2b34016 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-18  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Aes.cs: Build here before NET_4_0 (or MOONLIGHT) otherwise 
+       build only if compiled from mscorlib.dll
+
 2009-11-12  Jb Evain  <jbevain@novell.com>
 
        * Aes.cs: avoid using an hardcoded assembly version for System.Core.
index 2a8b2b7f85824665d367d69a132d865be82c70da..071f09de73436707cb7a95952b352a7599ab727c 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-24  Jb Evain  <jbevain@novell.com>
+
+       * EnumerableTest.cs: add test for #582502.
+
 2009-11-12  Eric Maupin  <me@ermau.com>
 
        * EnumerableMoreTest.cs: Added ToLookup test for null keys, updated old test to check count.
index addc5438c7f43ec9f289fd46c2df2f9225848693..19687eb3d509969c1dfe4454d40d66b35754b98f 100644 (file)
@@ -490,6 +490,38 @@ namespace MonoTests.System.Linq {
                        Assert.AreEqual ("Zyx", list [3].Name);
                }
 
+               [Test]
+               public void TestOrderByDescendingStability ()
+               {
+                       var data = new [] {
+                               new { Key = true, Value = 1 },
+                               new { Key = false, Value = 2},
+                               new { Key = true, Value = 3},
+                               new { Key = false, Value = 4},
+                               new { Key = true, Value = 5},
+                               new { Key = false, Value = 6},
+                               new { Key = true, Value = 7},
+                               new { Key = false, Value = 8},
+                               new { Key = true, Value = 9},
+                               new { Key = false, Value = 10},
+                       };
+
+                       var expected = new [] {
+                               new { Key = true, Value = 1 },
+                               new { Key = true, Value = 3},
+                               new { Key = true, Value = 5},
+                               new { Key = true, Value = 7},
+                               new { Key = true, Value = 9},
+                               new { Key = false, Value = 2},
+                               new { Key = false, Value = 4},
+                               new { Key = false, Value = 6},
+                               new { Key = false, Value = 8},
+                               new { Key = false, Value = 10},
+                       };
+
+                       AssertAreSame (expected, data.OrderByDescending (x => x.Key));
+               }
+
                static void AssertIsOrdered (IEnumerable<int> e)
                {
                                int f = int.MinValue;
diff --git a/mcs/class/System.Core/moonlight_bootstrap_System.Core.dll.sources b/mcs/class/System.Core/moonlight_bootstrap_System.Core.dll.sources
new file mode 100644 (file)
index 0000000..82f86b0
--- /dev/null
@@ -0,0 +1 @@
+#include moonlight_raw_System.Core.dll.sources
diff --git a/mcs/class/System.Core/moonlight_raw_System.Core.dll.sources b/mcs/class/System.Core/moonlight_raw_System.Core.dll.sources
new file mode 100644 (file)
index 0000000..844e40b
--- /dev/null
@@ -0,0 +1,71 @@
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+../../build/common/MonoTODOAttribute.cs
+../corlib/Mono.Security.Cryptography/CryptoTools.cs
+../corlib/Mono.Security.Cryptography/SymmetricTransform.cs
+Assembly/AssemblyInfo.cs
+System/Actions.cs
+System/Funcs.cs
+System/InvalidTimeZoneException.cs
+System/TimeZoneInfo.AdjustmentRule.cs
+System/TimeZoneInfo.cs
+System/TimeZoneInfo.TransitionTime.cs
+System/TimeZoneNotFoundException.cs
+System.Runtime.CompilerServices/ExecutionScope.cs
+System.Runtime.CompilerServices/ExtensionAttribute.cs
+System.Runtime.CompilerServices/IStrongBox.cs
+System.Runtime.CompilerServices/StrongBox_T.cs
+System.Linq/Check.cs
+System.Linq/Enumerable.cs
+System.Linq/QueryableEnumerable.cs
+System.Linq/QueryableTransformer.cs
+System.Linq/Grouping.cs
+System.Linq/IGrouping.cs
+System.Linq/IOrderedQueryable.cs
+System.Linq/IOrderedQueryable_T.cs
+System.Linq/IOrderedEnumerable_T.cs
+System.Linq/IQueryable.cs
+System.Linq/IQueryable_T.cs
+System.Linq/Lookup.cs
+System.Linq/ILookup_T.cs
+System.Linq/OrderedEnumerable.cs
+System.Linq/OrderedSequence.cs
+System.Linq/Queryable.cs
+System.Linq/QuickSort.cs
+System.Linq/SortContext.cs
+System.Linq/SortDirection.cs
+System.Linq/SortSequenceContext.cs
+System.Linq/IQueryProvider.cs
+System.Linq.Expressions/BinaryExpression.cs
+System.Linq.Expressions/ConditionalExpression.cs
+System.Linq.Expressions/ConstantExpression.cs
+System.Linq.Expressions/ElementInit.cs
+System.Linq.Expressions/EmitContext.cs
+System.Linq.Expressions/Expression.cs
+System.Linq.Expressions/Expression_T.cs
+System.Linq.Expressions/ExpressionPrinter.cs
+System.Linq.Expressions/ExpressionType.cs
+System.Linq.Expressions/ExpressionVisitor.cs
+System.Linq.Expressions/ExpressionTransformer.cs
+System.Linq.Expressions/Extensions.cs
+System.Linq.Expressions/InvocationExpression.cs
+System.Linq.Expressions/LambdaExpression.cs
+System.Linq.Expressions/ListInitExpression.cs
+System.Linq.Expressions/MemberAssignment.cs
+System.Linq.Expressions/MemberBinding.cs
+System.Linq.Expressions/MemberBindingType.cs
+System.Linq.Expressions/MemberExpression.cs
+System.Linq.Expressions/MemberInitExpression.cs
+System.Linq.Expressions/MemberListBinding.cs
+System.Linq.Expressions/MemberMemberBinding.cs
+System.Linq.Expressions/MethodCallExpression.cs
+System.Linq.Expressions/NewArrayExpression.cs
+System.Linq.Expressions/NewExpression.cs
+System.Linq.Expressions/ParameterExpression.cs
+System.Linq.Expressions/TypeBinaryExpression.cs
+System.Linq.Expressions/UnaryExpression.cs
+System.Collections.Generic/HashSet.cs
+../corlib/System.Collections.Generic/CollectionDebuggerView.cs
+System.Security.Cryptography/Aes.cs
+System.Security.Cryptography/AesManaged.cs
+System.Security.Cryptography/AesTransform.cs
diff --git a/mcs/class/System.Core/net_2_1_bootstrap_System.Core.dll.sources b/mcs/class/System.Core/net_2_1_bootstrap_System.Core.dll.sources
deleted file mode 100644 (file)
index 5e32150..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include net_2_1_raw_System.Core.dll.sources
diff --git a/mcs/class/System.Core/net_2_1_raw_System.Core.dll.sources b/mcs/class/System.Core/net_2_1_raw_System.Core.dll.sources
deleted file mode 100644 (file)
index 844e40b..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-../../build/common/Consts.cs
-../../build/common/Locale.cs
-../../build/common/MonoTODOAttribute.cs
-../corlib/Mono.Security.Cryptography/CryptoTools.cs
-../corlib/Mono.Security.Cryptography/SymmetricTransform.cs
-Assembly/AssemblyInfo.cs
-System/Actions.cs
-System/Funcs.cs
-System/InvalidTimeZoneException.cs
-System/TimeZoneInfo.AdjustmentRule.cs
-System/TimeZoneInfo.cs
-System/TimeZoneInfo.TransitionTime.cs
-System/TimeZoneNotFoundException.cs
-System.Runtime.CompilerServices/ExecutionScope.cs
-System.Runtime.CompilerServices/ExtensionAttribute.cs
-System.Runtime.CompilerServices/IStrongBox.cs
-System.Runtime.CompilerServices/StrongBox_T.cs
-System.Linq/Check.cs
-System.Linq/Enumerable.cs
-System.Linq/QueryableEnumerable.cs
-System.Linq/QueryableTransformer.cs
-System.Linq/Grouping.cs
-System.Linq/IGrouping.cs
-System.Linq/IOrderedQueryable.cs
-System.Linq/IOrderedQueryable_T.cs
-System.Linq/IOrderedEnumerable_T.cs
-System.Linq/IQueryable.cs
-System.Linq/IQueryable_T.cs
-System.Linq/Lookup.cs
-System.Linq/ILookup_T.cs
-System.Linq/OrderedEnumerable.cs
-System.Linq/OrderedSequence.cs
-System.Linq/Queryable.cs
-System.Linq/QuickSort.cs
-System.Linq/SortContext.cs
-System.Linq/SortDirection.cs
-System.Linq/SortSequenceContext.cs
-System.Linq/IQueryProvider.cs
-System.Linq.Expressions/BinaryExpression.cs
-System.Linq.Expressions/ConditionalExpression.cs
-System.Linq.Expressions/ConstantExpression.cs
-System.Linq.Expressions/ElementInit.cs
-System.Linq.Expressions/EmitContext.cs
-System.Linq.Expressions/Expression.cs
-System.Linq.Expressions/Expression_T.cs
-System.Linq.Expressions/ExpressionPrinter.cs
-System.Linq.Expressions/ExpressionType.cs
-System.Linq.Expressions/ExpressionVisitor.cs
-System.Linq.Expressions/ExpressionTransformer.cs
-System.Linq.Expressions/Extensions.cs
-System.Linq.Expressions/InvocationExpression.cs
-System.Linq.Expressions/LambdaExpression.cs
-System.Linq.Expressions/ListInitExpression.cs
-System.Linq.Expressions/MemberAssignment.cs
-System.Linq.Expressions/MemberBinding.cs
-System.Linq.Expressions/MemberBindingType.cs
-System.Linq.Expressions/MemberExpression.cs
-System.Linq.Expressions/MemberInitExpression.cs
-System.Linq.Expressions/MemberListBinding.cs
-System.Linq.Expressions/MemberMemberBinding.cs
-System.Linq.Expressions/MethodCallExpression.cs
-System.Linq.Expressions/NewArrayExpression.cs
-System.Linq.Expressions/NewExpression.cs
-System.Linq.Expressions/ParameterExpression.cs
-System.Linq.Expressions/TypeBinaryExpression.cs
-System.Linq.Expressions/UnaryExpression.cs
-System.Collections.Generic/HashSet.cs
-../corlib/System.Collections.Generic/CollectionDebuggerView.cs
-System.Security.Cryptography/Aes.cs
-System.Security.Cryptography/AesManaged.cs
-System.Security.Cryptography/AesTransform.cs
index 138709e664ceecc102bd58a8dc5edcbce602b783..e8cc52919c8d26837eda2439d6df65e389061563 100644 (file)
@@ -49,7 +49,6 @@ System.Linq/SortSequenceContext.cs
 System.Linq/IQueryProvider.cs
 System.Collections.Generic/HashSet.cs
 ../corlib/System.Collections.Generic/CollectionDebuggerView.cs
-System.Security.Cryptography/Aes.cs
 System.Security.Cryptography/AesManaged.cs
 System.Security.Cryptography/AesCryptoServiceProvider.cs
 System.Security.Cryptography/AesTransform.cs
index 5f732499b2afc96d7c8c4a11a9e3d29caa7b87fc..dbab2e7dbd171544804e2bd3ca4b89db68e647a8 100644 (file)
@@ -1,3 +1,10 @@
+2010-03-26  Veerapuram Varadhan  <vvaradhan@novell.com>
+
+    ** Fixes #564833/580736
+    * DbDataAdapter.cs (*Command): Fix for .NET compatibility which
+    supports both type of adapters with/without discrete command
+    instances.
+               
 2009-10-28  Veerapuram Varadhan  <vvaradhan@novell.com>
 
        ** Fixes #385028/#385029
index f6699ea93b3c0d5e1579aa6951fae00ffb0136e3..3fdc3ca11052a0f53df4ee8ba5d95bd44fef5082 100644 (file)
@@ -85,51 +85,83 @@ namespace System.Data.Common
                }
 
                IDbCommand IDbDataAdapter.SelectCommand {
-                       get { return _selectCommand; }
-                       set { _selectCommand = value; }
+                   get { return ((DbDataAdapter)this).SelectCommand; }
+                   set { ((DbDataAdapter)this).SelectCommand = (DbCommand)value; }
                }
 
                IDbCommand IDbDataAdapter.UpdateCommand{
-                       get { return _updateCommand; }
-                       set { _updateCommand = value; }
+                   get { return ((DbDataAdapter)this).UpdateCommand; }
+                   set { ((DbDataAdapter)this).UpdateCommand = (DbCommand)value; }
                }
-
+               
                IDbCommand IDbDataAdapter.DeleteCommand{
-                       get { return _deleteCommand; }
-                       set { _deleteCommand = value; }
+                   get { return ((DbDataAdapter)this).DeleteCommand; }
+                   set { ((DbDataAdapter)this).DeleteCommand = (DbCommand)value; }
                }
 
                IDbCommand IDbDataAdapter.InsertCommand{
-                       get { return _insertCommand; }
-                       set { _insertCommand = value; }
+                   get { return ((DbDataAdapter)this).InsertCommand; }
+                   set { ((DbDataAdapter)this).InsertCommand = (DbCommand)value; }
                }
                
                [Browsable (false)]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public DbCommand SelectCommand {
-                       get { return (DbCommand) _selectCommand; }
-                       set { _selectCommand = value; }
+                   get {
+                                       return (DbCommand) _selectCommand;
+                                       //return (DbCommand) ((IDbDataAdapter)this).SelectCommand; 
+                       }
+                   set {
+                                       if (_selectCommand != value) {
+                                               _selectCommand = value;
+                                               ((IDbDataAdapter)this).SelectCommand = value; 
+                                       }
+                       }
                }
 
                [Browsable (false)]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public DbCommand DeleteCommand {
-                       get { return (DbCommand) _deleteCommand; }
-                       set { _deleteCommand = value; }
+                   get {
+                                       return (DbCommand) _deleteCommand;
+                                       //return (DbCommand) ((IDbDataAdapter)this).DeleteCommand; 
+                       }
+                   set {
+                                       if (_deleteCommand != value) {
+                                               _deleteCommand = value;
+                                               ((IDbDataAdapter)this).DeleteCommand = value; 
+                                       }
+                       }
                }
 
                [Browsable (false)]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public DbCommand InsertCommand {
-                       get { return (DbCommand)_insertCommand; }
-                       set { _insertCommand = value; }
+                   get {
+                                       return (DbCommand) _insertCommand;
+                                       //return (DbCommand) ((IDbDataAdapter)this).InsertCommand; 
+                       }
+                   set {
+                                       if (_insertCommand != value) {
+                                               _insertCommand = value;
+                                               ((IDbDataAdapter)this).InsertCommand = value; 
+                                       }
+                       }
                }
 
                [Browsable (false)]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public DbCommand UpdateCommand {
-                       get { return (DbCommand)_updateCommand; }
-                       set { _updateCommand = value; }
+                   get {
+                                       return (DbCommand) _updateCommand;
+                                       //return (DbCommand) ((IDbDataAdapter)this).DeleteCommand; 
+                       }
+                   set {
+                                       if (_updateCommand != value) {
+                                               _updateCommand = value;
+                                               ((IDbDataAdapter)this).UpdateCommand = value; 
+                                       }
+                       }
                }
 
                [DefaultValue (1)]
index 09279a138a9f14c0606469afa0a45a9432558b82..658095b3926a892a75d26a8dd494fa43ff988408 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-26  Veerapuram Varadhan  <vvaradhan@novell.com>
+
+       * SqlDataAdapter.cs: 2.0 profile changes
+       
 2009-12-03  Jonathan Pobst  <monkey@jpobst.com>
 
        * SortOrder.cs: Add enum.
index d14df461f0a64ad92fe2fa03433ddf3042468ac5..a8bc4aef436ec07f0100ddd642a6843e8abee108 100644 (file)
@@ -97,11 +97,7 @@ namespace System.Data.SqlClient {
 #endif
                [DefaultValue (null)]
                [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
-               public
-#if ONLY_1_1
-               new 
-#endif 
-               SqlCommand DeleteCommand {
+               public new SqlCommand DeleteCommand {
                        get { 
 #if NET_2_0
                                return (SqlCommand)base.DeleteCommand; 
@@ -123,11 +119,7 @@ namespace System.Data.SqlClient {
 #endif
                [DefaultValue (null)]
                [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
-               public
-#if ONLY_1_1
-               new 
-#endif 
-               SqlCommand InsertCommand {
+               public new SqlCommand InsertCommand {
                        get { 
 #if NET_2_0                            
                                return (SqlCommand)base.InsertCommand; 
@@ -149,11 +141,7 @@ namespace System.Data.SqlClient {
 #endif
                [DefaultValue (null)]
                [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
-               public
-#if ONLY_1_1
-               new 
-#endif 
-               SqlCommand SelectCommand {
+               public new SqlCommand SelectCommand {
                        get { 
 #if NET_2_0
                                return (SqlCommand)base.SelectCommand; 
@@ -175,11 +163,7 @@ namespace System.Data.SqlClient {
 #endif
                [DefaultValue (null)]
                [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
-               public
-#if ONLY_1_1
-               new 
-#endif 
-               SqlCommand UpdateCommand {
+               public new  SqlCommand UpdateCommand {
                        get { 
 #if NET_2_0
                                return (SqlCommand)base.UpdateCommand; 
index db2a5875fd9c924d0763c0bff1adf6d6d431e0be..7da7dd94bd6e2fd27e7d86f9cf6eb9e918a7e0cc 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * net_2_1_*.dll.sources: rename to moonlight_*.dll.sources.
+
 2010-03-10  Sebastien Pouliot  <sebastien@ximian.com>
 
        * net_2_1_raw_System.Net.dll.sources: Add types from (new internal)
index 382f28b43fc8a4cdf3774edd66e11f08d643b385..6b96b8f6656cdb0e44f35573aa035c56e74a7f7c 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SocketException_2_1.cs: Add extra ctor (soon to be used)
+
 2009-04-28  Sebastien Pouliot  <sebastien@ximian.com>
 
        * SocketException_2_1.cs: Remove extra ctor and property unused in 2.1
index 9d040c2c5651654216b4c86d341c752d4d0147da..133ec798dc255020fe68faf44d1dc5c5707d089f 100644 (file)
@@ -48,6 +48,12 @@ namespace System.Net.Sockets {
                        error_code = error;
                }
 
+               internal SocketException (int error, string message)
+                       : base (message)
+               {
+                       error_code = error;
+               }
+
                public int ErrorCode {
                        get { return error_code; }
                }
index 8dab13acca7e5b40bd6c97836644a846c1b26c85..fc157453b8bcc99aeb63af497758029c661245ba 100644 (file)
@@ -1,3 +1,31 @@
+2010-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * HttpWebRequest_2_1.cs: AllowWriteStreamBuffering getter/setter
+       throws NIE by default (must be overridden). Revert Accept and
+       ContentType behavior to SL2 (identical to SL4 but different from
+       SL3). 
+       * WebClient_2_1.cs: Initialize UseDefaultCredentials to true. Set
+       the properties when creating a new WebRequest
+
+2010-03-18  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * HttpWebRequest_2_1.cs: Add SL4 RC AllowWriteStreamBuffering and
+       SupportsCookieContainer properties.
+       * WebClient_2_1.cs: Add SL4 RC AllowWriteStreamBuffering and 
+       UseDefaultCredentials properties.
+       * WebHeaderCollection_2_1.cs: Authorization and Proxy-Authorization
+       are valid (i.e. usable) headers in SL4 (in both stacks)
+
+2010-03-16  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * WebRequest_2_1.cs: Added UseDefaultCredentials property.
+
+2010-03-12  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * WebClient_2_1.cs: Directly set 'progress' delegate field
+       * WebRequest_2_1.cs: Avoid using reflection (since it was not 
+       really needed anyway)
+
 2010-03-03  Andreia Gaita  <avidigal@novell.com>
 
        * InternalWebRequestStreamWrapper.cs: don't add a newline to the
index 4f980982895959cd5a1cd8aab24450fad0ba16c9..e2fccc637c47b6d8beebe2548834221c022baadf 100644 (file)
@@ -53,13 +53,7 @@ namespace System.Net {
                public string Accept {
                        get { return Headers [HttpRequestHeader.Accept]; }
                        // this header cannot be set directly inside the collection (hence the helper)
-                       set {
-                               if (value == null)
-                                       throw new ArgumentNullException ("Accept");
-                               if (value.Length == 0)
-                                       throw new ArgumentException ("Accept");
-                               Headers.SetHeader ("accept", value);
-                       }
+                       set { Headers.SetHeader ("accept", value); }
                }
 
                public virtual bool AllowReadStreamBuffering {
@@ -67,16 +61,16 @@ namespace System.Net {
                        set { throw NotImplemented (); }
                }
 
+               // new in SL4 RC
+               public virtual bool AllowWriteStreamBuffering {
+                       get { throw NotImplemented (); }
+                       set { throw NotImplemented (); }
+               }
+
                public override string ContentType {
                        get { return Headers [HttpRequestHeader.ContentType]; }
                        // this header cannot be set directly inside the collection (hence the helper)
-                       set {
-                               if (value == null)
-                                       throw new ArgumentNullException ("ContentType");
-                               if (value.Length == 0)
-                                       throw new ArgumentException ("ContentType");
-                               Headers.SetHeader ("content-type", value);
-                       }
+                       set { Headers.SetHeader ("content-type", value); }
                }
 
                public virtual bool HaveResponse {
@@ -119,6 +113,10 @@ namespace System.Net {
                        get { throw NotImplemented (); }
                }
 
+               // new in SL4 RC
+               public virtual bool SupportsCookieContainer {
+                       get { return false; }
+               }
 
                public override void Abort ()
                {
index 0fc7bf404e6f2d368f57500597211b2899abdee4..1487adc40b62382f791f2bfd94b73d82e2829099 100644 (file)
@@ -47,6 +47,7 @@ namespace System.Net {
                bool is_busy;
                Encoding encoding = Encoding.UTF8;
                bool allow_read_buffering = true;
+               bool allow_write_buffering = true;
                WebRequest request;
                object locker;
                CallbackData callback_data;
@@ -59,6 +60,7 @@ namespace System.Net {
                        // but it happens that MS SL2 also has this default .ctor as SSC :-)
                        baseAddress = (AppDomain.CurrentDomain.GetData ("xap_uri") as string);
                        locker = new object ();
+                       UseDefaultCredentials = true;
                }
                
                // Properties
@@ -115,6 +117,17 @@ namespace System.Net {
                        set { allow_read_buffering = value; }
                }
 
+               // new in SL4 RC
+               [MonoTODO ("value is unused, current implementation always works like it's true (default)")]
+               public bool AllowWriteStreamBuffering {
+                       get { return allow_write_buffering; }
+                       set { allow_write_buffering = value; }
+               }
+
+               public bool UseDefaultCredentials {
+                       get; set;
+               }
+
                // Methods
 
                void CheckBusy ()
@@ -536,14 +549,17 @@ namespace System.Net {
                        // if the URI is relative then we use our base address URI to make an absolute one
                        Uri uri = address.IsAbsoluteUri ? address : new Uri (new Uri (baseAddress), address);
 
-                       WebRequest request = WebRequest.Create (uri);
+                       HttpWebRequest request = (HttpWebRequest) WebRequest.Create (uri);
+                       request.AllowReadStreamBuffering = AllowReadStreamBuffering;
+                       request.AllowWriteStreamBuffering = AllowWriteStreamBuffering;
+                       request.UseDefaultCredentials = UseDefaultCredentials;
 
-                       request.SetupProgressDelegate (delegate (long read, long length) {
+                       request.progress = delegate (long read, long length) {
                                callback_data.sync_context.Post (delegate (object sender) {
                                        OnDownloadProgressChanged (new DownloadProgressChangedEventArgs (read, length, callback_data.user_token));
                                }, null);
 
-                       });
+                       };
                        return request;
                }
 
index 61274562a4d91770a19a1139a9adcd7712d2b914..c12528ccddeb2a8461803005a3e3d176a34c4272 100644 (file)
@@ -220,13 +220,11 @@ namespace System.Net {
                        case "accept-charset":
                        case "accept-encoding":
                        case "accept-language":
-                       case "authorization":
                        case "cookie":
                        case "expect":
                        case "host":
                        case "if-modified-since":
                        case "max-forwards":
-                       case "proxy-authorization":
                        case "referer":
                        case "te":
                        case "user-agent":
index 68b18aa63b29346a40a346161412b9cc3a51b3cf..f531674a1a6d30789d10a8bd509dd28c28bb986e 100644 (file)
@@ -43,6 +43,8 @@ namespace System.Net {
                static IWebRequestCreate default_creator;
                static Dictionary<string, IWebRequestCreate> registred_prefixes;
 
+               internal Action<long,long> progress;
+
                public abstract string ContentType { get; set; }
                public abstract WebHeaderCollection Headers { get; set; }
                public abstract string Method { get; set; }
@@ -58,6 +60,11 @@ namespace System.Net {
                        set { throw NotImplemented (); }
                }
 
+               public virtual bool UseDefaultCredentials {
+                       get { throw NotImplemented (); }
+                       set { throw NotImplemented (); }
+               }
+
                static WebRequest ()
                {
                        registred_prefixes = new Dictionary<string, IWebRequestCreate> (StringComparer.OrdinalIgnoreCase);
@@ -150,13 +157,6 @@ namespace System.Net {
                        return true;
                }
 
-               internal void SetupProgressDelegate (Action<long,long> progress)
-               {
-                       FieldInfo fi = GetType ().GetField ("progress", BindingFlags.Instance | BindingFlags.NonPublic);
-                       if (fi != null)
-                               fi.SetValue (this, progress);
-               }
-
                static Exception NotImplemented ()
                {
                        // hide the "normal" NotImplementedException from corcompare-like tools
diff --git a/mcs/class/System.Net/moonlight_raw_System.Net.dll.sources b/mcs/class/System.Net/moonlight_raw_System.Net.dll.sources
new file mode 100644 (file)
index 0000000..85566a0
--- /dev/null
@@ -0,0 +1,75 @@
+Assembly/AssemblyInfo.cs
+System.Net/Dns_2_1.cs
+System.Net/HttpWebRequest_2_1.cs
+System.Net/HttpWebResponse_2_1.cs
+System.Net/InternalWebRequestStreamWrapper.cs
+System.Net/InternalWebResponseStreamWrapper.cs
+System.Net/WebExceptionStatus_2_1.cs
+System.Net/WebHeaderCollection_2_1.cs
+System.Net/WebClient_2_1.cs
+System.Net/WebRequest_2_1.cs
+System.Net/WebResponse_2_1.cs
+System.Net/WriteStreamClosedEventArgs_2_1.cs
+System.Net/WriteStreamClosedEventHandler_2_1.cs
+System.Net.Sockets/AddressFamily_2_1.cs
+System.Net.Sockets/SocketException_2_1.cs
+System.Net.Sockets/ProtocolType_2_1.cs
+System.Net.Sockets/SocketAsyncOperation_2_1.cs
+System.Net.Sockets/SocketType_2_1.cs
+System.Net.Sockets/UdpAnySourceMulticastClient.cs
+System.Net.Sockets/UdpSingleSourceMulticastClient.cs
+System.Net.NetworkInformation/NetworkChange_2_1.cs
+System.Net.NetworkInformation/NetworkInterface_2_1.cs
+System.Net.Policy/BaseDomainPolicy.cs
+System.Net.Policy/ClientAccessPolicy.cs
+System.Net.Policy/ClientAccessPolicyParser.cs
+System.Net.Policy/CrossDomainPolicyManager.cs
+System.Net.Policy/FlashCrossDomainPolicy.cs
+System.Net.Policy/FlashCrossDomainPolicyParser.cs
+System.Net.Policy/ICrossDomainPolicy.cs
+System.Net.Policy/NoAccessPolicy.cs
+System.Net.Policy/PolicyDownloadPolicy.cs
+System.Net.Policy/SiteOfOriginPolicy.cs
+../System/System.Net/Cookie.cs
+../System/System.Net/CookieCollection.cs
+../System/System.Net/CookieContainer.cs
+../System/System.Net/CookieException.cs
+../System/System.Net/DnsEndPoint.cs
+../System/System.Net/EndPoint.cs
+../System/System.Net/HttpRequestHeader.cs
+../System/System.Net/HttpResponseHeader.cs
+../System/System.Net/HttpStatusCode.cs
+../System/System.Net/ICredentialLookup.cs
+../System/System.Net/IPAddress.cs
+../System/System.Net/IPEndPoint.cs
+../System/System.Net/IPHostEntry.cs
+../System/System.Net/IPv6Address.cs
+../System/System.Net/IWebRequestCreate.cs
+../System/System.Net/NetworkCredential.cs
+../System/System.Net/ProtocolViolationException.cs
+../System/System.Net/SocketAddress.cs
+../System/System.Net.Sockets/LingerOption.cs
+../System/System.Net.Sockets/MulticastOption.cs
+../System/System.Net.Sockets/ProtocolFamily.cs
+../System/System.Net.Sockets/SelectMode.cs
+../System/System.Net.Sockets/Socket_2_1.cs
+../System/System.Net.Sockets/SocketError.cs
+../System/System.Net.Sockets/SocketFlags.cs
+../System/System.Net.Sockets/SocketOptionLevel.cs
+../System/System.Net.Sockets/SocketOptionName.cs
+../System/System.Net.Sockets/SocketShutdown.cs
+../System/System.Net.Sockets/SocketAsyncEventArgs.cs
+../System/System.Net/WebException.cs
+../System/System.Net/DownloadProgressChangedEventArgs.cs
+../System/System.Net/DownloadProgressChangedEventHandler.cs
+../System/System.Net/DownloadStringCompletedEventArgs.cs
+../System/System.Net/DownloadStringCompletedEventHandler.cs
+../System/System.Net/OpenReadCompletedEventArgs.cs
+../System/System.Net/OpenReadCompletedEventHandler.cs
+../System/System.Net/OpenWriteCompletedEventArgs.cs
+../System/System.Net/OpenWriteCompletedEventHandler.cs
+../System/System.Net/UploadProgressChangedEventArgs.cs
+../System/System.Net/UploadProgressChangedEventHandler.cs
+../System/System.Net/UploadStringCompletedEventArgs.cs
+../System/System.Net/UploadStringCompletedEventHandler.cs
+../System/System.Net.NetworkInformation/NetworkAddressChangedEventHandler.cs
diff --git a/mcs/class/System.Net/net_2_1_raw_System.Net.dll.sources b/mcs/class/System.Net/net_2_1_raw_System.Net.dll.sources
deleted file mode 100644 (file)
index 85566a0..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-Assembly/AssemblyInfo.cs
-System.Net/Dns_2_1.cs
-System.Net/HttpWebRequest_2_1.cs
-System.Net/HttpWebResponse_2_1.cs
-System.Net/InternalWebRequestStreamWrapper.cs
-System.Net/InternalWebResponseStreamWrapper.cs
-System.Net/WebExceptionStatus_2_1.cs
-System.Net/WebHeaderCollection_2_1.cs
-System.Net/WebClient_2_1.cs
-System.Net/WebRequest_2_1.cs
-System.Net/WebResponse_2_1.cs
-System.Net/WriteStreamClosedEventArgs_2_1.cs
-System.Net/WriteStreamClosedEventHandler_2_1.cs
-System.Net.Sockets/AddressFamily_2_1.cs
-System.Net.Sockets/SocketException_2_1.cs
-System.Net.Sockets/ProtocolType_2_1.cs
-System.Net.Sockets/SocketAsyncOperation_2_1.cs
-System.Net.Sockets/SocketType_2_1.cs
-System.Net.Sockets/UdpAnySourceMulticastClient.cs
-System.Net.Sockets/UdpSingleSourceMulticastClient.cs
-System.Net.NetworkInformation/NetworkChange_2_1.cs
-System.Net.NetworkInformation/NetworkInterface_2_1.cs
-System.Net.Policy/BaseDomainPolicy.cs
-System.Net.Policy/ClientAccessPolicy.cs
-System.Net.Policy/ClientAccessPolicyParser.cs
-System.Net.Policy/CrossDomainPolicyManager.cs
-System.Net.Policy/FlashCrossDomainPolicy.cs
-System.Net.Policy/FlashCrossDomainPolicyParser.cs
-System.Net.Policy/ICrossDomainPolicy.cs
-System.Net.Policy/NoAccessPolicy.cs
-System.Net.Policy/PolicyDownloadPolicy.cs
-System.Net.Policy/SiteOfOriginPolicy.cs
-../System/System.Net/Cookie.cs
-../System/System.Net/CookieCollection.cs
-../System/System.Net/CookieContainer.cs
-../System/System.Net/CookieException.cs
-../System/System.Net/DnsEndPoint.cs
-../System/System.Net/EndPoint.cs
-../System/System.Net/HttpRequestHeader.cs
-../System/System.Net/HttpResponseHeader.cs
-../System/System.Net/HttpStatusCode.cs
-../System/System.Net/ICredentialLookup.cs
-../System/System.Net/IPAddress.cs
-../System/System.Net/IPEndPoint.cs
-../System/System.Net/IPHostEntry.cs
-../System/System.Net/IPv6Address.cs
-../System/System.Net/IWebRequestCreate.cs
-../System/System.Net/NetworkCredential.cs
-../System/System.Net/ProtocolViolationException.cs
-../System/System.Net/SocketAddress.cs
-../System/System.Net.Sockets/LingerOption.cs
-../System/System.Net.Sockets/MulticastOption.cs
-../System/System.Net.Sockets/ProtocolFamily.cs
-../System/System.Net.Sockets/SelectMode.cs
-../System/System.Net.Sockets/Socket_2_1.cs
-../System/System.Net.Sockets/SocketError.cs
-../System/System.Net.Sockets/SocketFlags.cs
-../System/System.Net.Sockets/SocketOptionLevel.cs
-../System/System.Net.Sockets/SocketOptionName.cs
-../System/System.Net.Sockets/SocketShutdown.cs
-../System/System.Net.Sockets/SocketAsyncEventArgs.cs
-../System/System.Net/WebException.cs
-../System/System.Net/DownloadProgressChangedEventArgs.cs
-../System/System.Net/DownloadProgressChangedEventHandler.cs
-../System/System.Net/DownloadStringCompletedEventArgs.cs
-../System/System.Net/DownloadStringCompletedEventHandler.cs
-../System/System.Net/OpenReadCompletedEventArgs.cs
-../System/System.Net/OpenReadCompletedEventHandler.cs
-../System/System.Net/OpenWriteCompletedEventArgs.cs
-../System/System.Net/OpenWriteCompletedEventHandler.cs
-../System/System.Net/UploadProgressChangedEventArgs.cs
-../System/System.Net/UploadProgressChangedEventHandler.cs
-../System/System.Net/UploadStringCompletedEventArgs.cs
-../System/System.Net/UploadStringCompletedEventHandler.cs
-../System/System.Net.NetworkInformation/NetworkAddressChangedEventHandler.cs
index 701f3bbfe19306382fb668d515d694bd157ac183..06bfd0b1de35d46755d21806e1bd8a69cf1e9441 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * net_2_1_*.dll.sources: rename to moonlight_*.dll.sources.
+
 2010-03-03  Atsushi Enomoto  <atsushi@ximian.com>
 
        * System.Runtime.Serialization.dll.sources:
index 602d0d07a6922f581503e4f0f52ebda8cce360eb..7885b804a7c8b2cde571eaf73ef0402c89e13c8d 100644 (file)
@@ -1,2 +1,2 @@
-#include net_2_1_raw_System.Runtime.Serialization.dll.sources
+#include moonlight_raw_System.Runtime.Serialization.dll.sources
 System.Xml/OnXmlDictionaryReaderClose.cs
diff --git a/mcs/class/System.Runtime.Serialization/moonlight_raw_System.Runtime.Serialization.dll.sources b/mcs/class/System.Runtime.Serialization/moonlight_raw_System.Runtime.Serialization.dll.sources
new file mode 100644 (file)
index 0000000..59cd659
--- /dev/null
@@ -0,0 +1,46 @@
+Assembly/AssemblyInfo.cs
+System.Runtime.Serialization/CollectionDataContractAttribute.cs
+System.Runtime.Serialization/ContractNamespaceAttribute.cs
+System.Runtime.Serialization/DataContractAttribute.cs
+System.Runtime.Serialization/DataContractSerializer.cs
+System.Runtime.Serialization/DataMemberAttribute.cs
+System.Runtime.Serialization/EnumMemberAttribute.cs
+System.Runtime.Serialization/ExportOptions.cs
+System.Runtime.Serialization/ExtensionDataObject.cs
+System.Runtime.Serialization/IDataContractSurrogate.cs
+System.Runtime.Serialization/IExtensibleDataObject.cs
+System.Runtime.Serialization/IgnoreDataMemberAttribute.cs
+System.Runtime.Serialization/InvalidDataContractException.cs
+System.Runtime.Serialization/KnownTypeAttribute.cs
+System.Runtime.Serialization/KnownTypeCollection.cs
+System.Runtime.Serialization/NetDataContractSerializer.cs
+System.Runtime.Serialization/SerializationMap.cs
+System.Runtime.Serialization/XmlFormatterDeserializer.cs
+System.Runtime.Serialization/XmlFormatterSerializer.cs
+System.Runtime.Serialization/XmlObjectSerializer.cs
+System.Xml/IStreamProvider.cs
+System.Xml/IXmlBinaryReaderInitializer.cs
+System.Xml/IXmlBinaryWriterInitializer.cs
+System.Xml/IXmlDictionary.cs
+System.Xml/IXmlMtomReaderInitializer.cs
+System.Xml/IXmlMtomWriterInitializer.cs
+System.Xml/IXmlUTF8ReaderInitializer.cs
+System.Xml/IXmlUTF8WriterInitializer.cs
+System.Xml/OnXmlDictionaryReaderClose.cs
+System.Xml/UniqueId.cs
+System.Xml/XmlBinaryDictionaryReader.cs
+System.Xml/XmlBinaryDictionaryWriter.cs
+System.Xml/XmlBinaryFormat.cs
+System.Xml/XmlBinaryReaderSession.cs
+System.Xml/XmlBinaryWriterSession.cs
+System.Xml/XmlC14NWriter.cs
+System.Xml/XmlCanonicalWriter.cs
+System.Xml/XmlDictionary.cs
+System.Xml/XmlDictionaryReader.cs
+System.Xml/XmlDictionaryReaderAutoGen.cs
+System.Xml/XmlDictionaryReaderQuotas.cs
+System.Xml/XmlDictionaryString.cs
+System.Xml/XmlDictionaryWriter.cs
+System.Xml/XmlDictionaryWriterAutoGen.cs
+System.Xml/XmlSimpleDictionaryReader.cs
+System.Xml/XmlSimpleDictionaryWriter.cs
diff --git a/mcs/class/System.Runtime.Serialization/net_2_1_raw_System.Runtime.Serialization.dll.sources b/mcs/class/System.Runtime.Serialization/net_2_1_raw_System.Runtime.Serialization.dll.sources
deleted file mode 100644 (file)
index 59cd659..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-Assembly/AssemblyInfo.cs
-System.Runtime.Serialization/CollectionDataContractAttribute.cs
-System.Runtime.Serialization/ContractNamespaceAttribute.cs
-System.Runtime.Serialization/DataContractAttribute.cs
-System.Runtime.Serialization/DataContractSerializer.cs
-System.Runtime.Serialization/DataMemberAttribute.cs
-System.Runtime.Serialization/EnumMemberAttribute.cs
-System.Runtime.Serialization/ExportOptions.cs
-System.Runtime.Serialization/ExtensionDataObject.cs
-System.Runtime.Serialization/IDataContractSurrogate.cs
-System.Runtime.Serialization/IExtensibleDataObject.cs
-System.Runtime.Serialization/IgnoreDataMemberAttribute.cs
-System.Runtime.Serialization/InvalidDataContractException.cs
-System.Runtime.Serialization/KnownTypeAttribute.cs
-System.Runtime.Serialization/KnownTypeCollection.cs
-System.Runtime.Serialization/NetDataContractSerializer.cs
-System.Runtime.Serialization/SerializationMap.cs
-System.Runtime.Serialization/XmlFormatterDeserializer.cs
-System.Runtime.Serialization/XmlFormatterSerializer.cs
-System.Runtime.Serialization/XmlObjectSerializer.cs
-System.Xml/IStreamProvider.cs
-System.Xml/IXmlBinaryReaderInitializer.cs
-System.Xml/IXmlBinaryWriterInitializer.cs
-System.Xml/IXmlDictionary.cs
-System.Xml/IXmlMtomReaderInitializer.cs
-System.Xml/IXmlMtomWriterInitializer.cs
-System.Xml/IXmlUTF8ReaderInitializer.cs
-System.Xml/IXmlUTF8WriterInitializer.cs
-System.Xml/OnXmlDictionaryReaderClose.cs
-System.Xml/UniqueId.cs
-System.Xml/XmlBinaryDictionaryReader.cs
-System.Xml/XmlBinaryDictionaryWriter.cs
-System.Xml/XmlBinaryFormat.cs
-System.Xml/XmlBinaryReaderSession.cs
-System.Xml/XmlBinaryWriterSession.cs
-System.Xml/XmlC14NWriter.cs
-System.Xml/XmlCanonicalWriter.cs
-System.Xml/XmlDictionary.cs
-System.Xml/XmlDictionaryReader.cs
-System.Xml/XmlDictionaryReaderAutoGen.cs
-System.Xml/XmlDictionaryReaderQuotas.cs
-System.Xml/XmlDictionaryString.cs
-System.Xml/XmlDictionaryWriter.cs
-System.Xml/XmlDictionaryWriterAutoGen.cs
-System.Xml/XmlSimpleDictionaryReader.cs
-System.Xml/XmlSimpleDictionaryWriter.cs
index 770ffc3a8a1f877ffd145decef40338a6a9816e2..82455b4257cf5d11fab81b3c9010b0b846613578 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: rename the net_2_1 profile to moonlight.
+
 2009-06-05  Marek Safar  <marek.safar@gmail.com>
 
        * Makefile: Fixed NET_2_0 conditional to actually handle Mono.Security
index 3d55d17cf2b8a52a7677f98d6f9225eacf71e0b6..bf261067d24d0e10f2456efba60c4678a93a89e6 100644 (file)
@@ -13,7 +13,7 @@ LIB_MCS_FLAGS += -r:Mono.Security.dll -nowarn:414
 TEST_MCS_FLAGS += -nowarn:168,183,414
 endif
 
-VALID_PROFILE := $(filter net_1_1 net_2_0 net_2_1_raw net_4_0, $(PROFILE))
+VALID_PROFILE := $(filter net_1_1 net_2_0 moonlight_raw net_4_0, $(PROFILE))
 ifndef VALID_PROFILE
 # @echo "** Warning: System.Security.dll built without parts that depend on: Mono.Security.dll "
 else
diff --git a/mcs/class/System.ServiceModel.Discovery/Assembly/AssemblyInfo.cs b/mcs/class/System.ServiceModel.Discovery/Assembly/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..fb52359
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+//   Joel W. Reed (joelwreed@gmail.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the System.ServiceModel assembly
+
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+
+[assembly: AssemblyTitle ("System.ServiceModel.Discovery.dll")]
+[assembly: AssemblyDescription ("System.ServiceModel.Discovery.dll")]
+[assembly: AssemblyConfiguration ("Development version")]
+[assembly: AssemblyCompany ("MONO development team")]
+[assembly: AssemblyProduct ("MONO CLI")]
+[assembly: AssemblyCopyright ("(c) 2003 Various Authors")]
+[assembly: AssemblyTrademark ("")]
+
+[assembly: CLSCompliant (true)]
+[assembly: AssemblyDefaultAlias ("System.ServiceModel.Discovery.dll")]
+[assembly: AssemblyInformationalVersion ("3.5.594.0")]
+[assembly: NeutralResourcesLanguage ("en-US")]
+
+[assembly: ComVisible (false)]
+
+[assembly: AssemblyDelaySign (true)]
+#if NET_2_1
+[assembly: AssemblyKeyFile ("../silverlight.pub")]
+#else
+[assembly: AssemblyKeyFile("../winfx.pub")]
+#endif
diff --git a/mcs/class/System.ServiceModel.Discovery/Assembly/ChangeLog b/mcs/class/System.ServiceModel.Discovery/Assembly/ChangeLog
new file mode 100755 (executable)
index 0000000..ce289a8
--- /dev/null
@@ -0,0 +1,4 @@
+2010-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * : initial checkin (mostly stubs).
+
diff --git a/mcs/class/System.ServiceModel.Discovery/ChangeLog b/mcs/class/System.ServiceModel.Discovery/ChangeLog
new file mode 100644 (file)
index 0000000..ce289a8
--- /dev/null
@@ -0,0 +1,4 @@
+2010-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * : initial checkin (mostly stubs).
+
diff --git a/mcs/class/System.ServiceModel.Discovery/Makefile b/mcs/class/System.ServiceModel.Discovery/Makefile
new file mode 100644 (file)
index 0000000..de570d0
--- /dev/null
@@ -0,0 +1,24 @@
+thisdir = class/System.ServiceModel.Discovery
+SUBDIRS = 
+include ../../build/rules.make
+
+LIBRARY = System.ServiceModel.Discovery.dll
+LIB_MCS_FLAGS = -r:System.dll -r:System.Xml.dll -r:System.Runtime.Serialization.dll -r:System.ServiceModel.dll -r:System.Core.dll -r:System.Xml.Linq.dll
+
+ifneq (2.1, $(FRAMEWORK_VERSION))
+LIB_MCS_FLAGS += -d:NET_3_5 -d:NET_3_0         \
+                       -r:System.Configuration.dll
+endif
+
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
+
+EXTRA_DISTFILES = $(RESOURCE_FILES)
+
+VALID_PROFILE := $(filter 2.0 2.1 4.0, $(FRAMEWORK_VERSION))
+ifndef VALID_PROFILE
+LIBRARY_NAME = dummy-System.ServiceModel.Discovery.dll
+NO_INSTALL = yes
+NO_SIGN_ASSEMBLY = yes
+endif
+
+include ../../build/library.make
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/ChangeLog b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/ChangeLog
new file mode 100755 (executable)
index 0000000..ce289a8
--- /dev/null
@@ -0,0 +1,4 @@
+2010-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * : initial checkin (mostly stubs).
+
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/DiscoveryMessageSequenceApril2005.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/DiscoveryMessageSequenceApril2005.cs
new file mode 100755 (executable)
index 0000000..ea4791f
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Discovery.VersionApril2005
+{
+       public class DiscoveryMessageSequenceApril2005 : IXmlSerializable
+       {
+               public static DiscoveryMessageSequenceApril2005 FromDiscoveryMessageSequence (DiscoveryMessageSequence discoveryMessageSequence)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               internal DiscoveryMessageSequenceApril2005 ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public XmlSchema GetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public DiscoveryMessageSequence ToDiscoveryMessageSequence ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/EndpointDiscoveryMetadataApril2005.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/EndpointDiscoveryMetadataApril2005.cs
new file mode 100755 (executable)
index 0000000..526de2e
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Discovery.VersionApril2005
+{
+       public class EndpointDiscoveryMetadataApril2005 : IXmlSerializable
+       {
+               public static EndpointDiscoveryMetadataApril2005 FromEndpointDiscoveryMetadata (EndpointDiscoveryMetadata endpointDiscoveryMetadata)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public XmlSchema GetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public EndpointDiscoveryMetadata ToEndpointDiscoveryMetadata ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/FindCriteriaApril2005.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/FindCriteriaApril2005.cs
new file mode 100755 (executable)
index 0000000..a7603ae
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Discovery.VersionApril2005
+{
+       public class FindCriteriaApril2005 : IXmlSerializable
+       {
+               public static FindCriteriaApril2005 FromFindCriteria (FindCriteria findCriteria)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public XmlSchema GetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public FindCriteria ToFindCriteria ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/ResolveCriteriaApril2005.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionApril2005/ResolveCriteriaApril2005.cs
new file mode 100755 (executable)
index 0000000..0a65673
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Discovery.VersionApril2005
+{
+       public class ResolveCriteriaApril2005 : IXmlSerializable
+       {
+               public static ResolveCriteriaApril2005 FromResolveCriteria (ResolveCriteria resolveCriteria)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public XmlSchema GetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public ResolveCriteria ToResolveCriteria ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/ChangeLog b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/ChangeLog
new file mode 100755 (executable)
index 0000000..ce289a8
--- /dev/null
@@ -0,0 +1,4 @@
+2010-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * : initial checkin (mostly stubs).
+
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/DiscoveryMessageSequence11.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/DiscoveryMessageSequence11.cs
new file mode 100755 (executable)
index 0000000..1b88d4d
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Discovery.VersionCD1
+{
+       public class DiscoveryMessageSequence11 : IXmlSerializable
+       {
+               public static DiscoveryMessageSequence11 FromDiscoveryMessageSequence (DiscoveryMessageSequence discoveryMessageSequence)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               internal DiscoveryMessageSequence11 ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public XmlSchema GetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public DiscoveryMessageSequence ToDiscoveryMessageSequence ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/EndpointDiscoveryMetadata11.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/EndpointDiscoveryMetadata11.cs
new file mode 100755 (executable)
index 0000000..4d2260b
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Discovery.VersionCD1
+{
+       public class EndpointDiscoveryMetadata11 : IXmlSerializable
+       {
+               public static EndpointDiscoveryMetadata11 FromEndpointDiscoveryMetadata (EndpointDiscoveryMetadata endpointDiscoveryMetadata)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public XmlSchema GetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public EndpointDiscoveryMetadata ToEndpointDiscoveryMetadata ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/FindCriteria11.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/FindCriteria11.cs
new file mode 100755 (executable)
index 0000000..a82174b
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Discovery.VersionCD1
+{
+       public class FindCriteria11 : IXmlSerializable
+       {
+               public static FindCriteria11 FromFindCriteria (FindCriteria findCriteria)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public XmlSchema GetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public FindCriteria ToFindCriteria ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/ResolveCriteria11.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.VersionCD1/ResolveCriteria11.cs
new file mode 100755 (executable)
index 0000000..3367061
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Discovery.VersionCD1
+{
+       public class ResolveCriteria11 : IXmlSerializable
+       {
+               public static ResolveCriteria11 FromResolveCriteria (ResolveCriteria resolveCriteria)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet schemaSet)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public XmlSchema GetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public ResolveCriteria ToResolveCriteria ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.dll.sources b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery.dll.sources
new file mode 100644 (file)
index 0000000..4805004
--- /dev/null
@@ -0,0 +1,43 @@
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+../../build/common/MonoTODOAttribute.cs
+Assembly/AssemblyInfo.cs
+System.ServiceModel.Discovery.VersionApril2005/DiscoveryMessageSequenceApril2005.cs
+System.ServiceModel.Discovery.VersionApril2005/EndpointDiscoveryMetadataApril2005.cs
+System.ServiceModel.Discovery.VersionApril2005/FindCriteriaApril2005.cs
+System.ServiceModel.Discovery.VersionApril2005/ResolveCriteriaApril2005.cs
+System.ServiceModel.Discovery.VersionCD1/DiscoveryMessageSequence11.cs
+System.ServiceModel.Discovery.VersionCD1/EndpointDiscoveryMetadata11.cs
+System.ServiceModel.Discovery.VersionCD1/FindCriteria11.cs
+System.ServiceModel.Discovery.VersionCD1/ResolveCriteria11.cs
+System.ServiceModel.Discovery/AnnouncementClient.cs
+System.ServiceModel.Discovery/AnnouncementEndpoint.cs
+System.ServiceModel.Discovery/AnnouncementEventArgs.cs
+System.ServiceModel.Discovery/AnnouncementService.cs
+System.ServiceModel.Discovery/DiscoveryClient.cs
+System.ServiceModel.Discovery/DiscoveryClientBindingElement.cs
+System.ServiceModel.Discovery/DiscoveryEndpoint.cs
+System.ServiceModel.Discovery/DiscoveryEndpointProvider.cs
+System.ServiceModel.Discovery/DiscoveryMessageSequence.cs
+System.ServiceModel.Discovery/DiscoveryMessageSequenceGenerator.cs
+System.ServiceModel.Discovery/DiscoveryOperationContextExtension.cs
+System.ServiceModel.Discovery/DiscoveryProxy.cs
+System.ServiceModel.Discovery/DiscoveryService.cs
+System.ServiceModel.Discovery/DiscoveryServiceExtension.cs
+System.ServiceModel.Discovery/DiscoveryVersion.cs
+System.ServiceModel.Discovery/DynamicEndpoint.cs
+System.ServiceModel.Discovery/EndpointDiscoveryBehavior.cs
+System.ServiceModel.Discovery/EndpointDiscoveryMetadata.cs
+System.ServiceModel.Discovery/FindCompletedEventArgs.cs
+System.ServiceModel.Discovery/FindCriteria.cs
+System.ServiceModel.Discovery/FindProgressChangedEventArgs.cs
+System.ServiceModel.Discovery/FindRequestContext.cs
+System.ServiceModel.Discovery/FindResponse.cs
+System.ServiceModel.Discovery/ResolveCompletedEventArgs.cs
+System.ServiceModel.Discovery/ResolveCriteria.cs
+System.ServiceModel.Discovery/ResolveResponse.cs
+System.ServiceModel.Discovery/ServiceDiscoveryBehavior.cs
+System.ServiceModel.Discovery/ServiceDiscoveryMode.cs
+System.ServiceModel.Discovery/UdpAnnouncementEndpoint.cs
+System.ServiceModel.Discovery/UdpDiscoveryEndpoint.cs
+System.ServiceModel.Discovery/UdpTransportSettings.cs
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementClient.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementClient.cs
new file mode 100755 (executable)
index 0000000..380e5ed
--- /dev/null
@@ -0,0 +1,183 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public sealed class AnnouncementClient : ICommunicationObject, IDisposable
+       {
+               public AnnouncementClient ()
+               {
+               }
+
+               public AnnouncementClient (AnnouncementEndpoint announcementEndpoint)
+               {
+               }
+
+               public AnnouncementClient (string endpointConfigurationName)
+               {
+               }
+
+               public ChannelFactory ChannelFactory { get; private set; }
+               public ClientCredentials ClientCredentials { get; private set; }
+               public ServiceEndpoint Endpoint { get; private set; }
+               public IClientChannel InnerChannel { get; private set; }
+               public DiscoveryMessageSequenceGenerator MessageSequenceGenerator { get; set; }
+
+               CommunicationState ICommunicationObject.State {
+                       get { return InnerChannel.State; }
+               }
+
+               public event EventHandler<AsyncCompletedEventArgs> AnnounceOfflineCompleted;
+               public event EventHandler<AsyncCompletedEventArgs> AnnounceOnlineCompleted;
+
+               event EventHandler ICommunicationObject.Closed {
+                       add { InnerChannel.Closed += value; }
+                       remove { InnerChannel.Closed -= value; }
+               }
+               event EventHandler ICommunicationObject.Closing {
+                       add { InnerChannel.Closing += value; }
+                       remove { InnerChannel.Closing -= value; }
+               }
+               event EventHandler ICommunicationObject.Faulted {
+                       add { InnerChannel.Faulted += value; }
+                       remove { InnerChannel.Faulted -= value; }
+               }
+               event EventHandler ICommunicationObject.Opened {
+                       add { InnerChannel.Opened += value; }
+                       remove { InnerChannel.Opened -= value; }
+               }
+               event EventHandler ICommunicationObject.Opening {
+                       add { InnerChannel.Opening += value; }
+                       remove { InnerChannel.Opening -= value; }
+               }
+
+               public void AnnounceOffline (EndpointDiscoveryMetadata discoveryMetadata)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void AnnounceOfflineAsync (EndpointDiscoveryMetadata discoveryMetadata)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void AnnounceOfflineAsync (EndpointDiscoveryMetadata discoveryMetadata, object userState)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void AnnounceOnline (EndpointDiscoveryMetadata discoveryMetadata)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void AnnounceOnlineAsync (EndpointDiscoveryMetadata discoveryMetadata)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void AnnounceOnlineAsync (EndpointDiscoveryMetadata discoveryMetadata, object userState)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public IAsyncResult BeginAnnounceOffline (EndpointDiscoveryMetadata discoveryMetadata, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public IAsyncResult BeginAnnounceOnline (EndpointDiscoveryMetadata discoveryMetadata, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void EndAnnounceOffline (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void EndAnnounceOnline (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void Close ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void Open ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // explicit interface impl.
+
+               void ICommunicationObject.Open ()
+               {
+                       InnerChannel.Open ();
+               }
+
+               void ICommunicationObject.Open (TimeSpan timeout)
+               {
+                       InnerChannel.Open (timeout);
+               }
+
+               void ICommunicationObject.Close ()
+               {
+                       InnerChannel.Close ();
+               }
+
+               void ICommunicationObject.Close (TimeSpan timeout)
+               {
+                       InnerChannel.Close (timeout);
+               }
+
+               IAsyncResult ICommunicationObject.BeginOpen (AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginOpen (callback, state);
+               }
+
+               IAsyncResult ICommunicationObject.BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginOpen (timeout, callback, state);
+               }
+
+               IAsyncResult ICommunicationObject.BeginClose (AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginClose (callback, state);
+               }
+
+               IAsyncResult ICommunicationObject.BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginClose (timeout, callback, state);
+               }
+
+               void ICommunicationObject.EndOpen (IAsyncResult result)
+               {
+                       InnerChannel.EndOpen (result);
+               }
+
+               void ICommunicationObject.EndClose (IAsyncResult result)
+               {
+                       InnerChannel.EndClose (result);
+               }
+
+               void ICommunicationObject.Abort ()
+               {
+                       InnerChannel.Abort ();
+               }
+
+               void IDisposable.Dispose ()
+               {
+                       InnerChannel.Dispose ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementEndpoint.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementEndpoint.cs
new file mode 100755 (executable)
index 0000000..0de0547
--- /dev/null
@@ -0,0 +1,69 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class AnnouncementEndpoint : ServiceEndpoint
+       {
+               public AnnouncementEndpoint ()
+                       : this (DiscoveryVersion.WSDiscovery11)
+               {
+               }
+
+               public AnnouncementEndpoint (DiscoveryVersion discoveryVersion)
+                       : this (discoveryVersion, null, null)
+               {
+                       if (discoveryVersion == null)
+                               throw new ArgumentNullException ("discoveryVersion");
+                       DiscoveryVersion = discoveryVersion;
+               }
+
+               public AnnouncementEndpoint (Binding binding, EndpointAddress address)
+                       : this (DiscoveryVersion.WSDiscoveryApril2005, binding, address)
+               {
+               }
+
+               [MonoTODO]
+               public AnnouncementEndpoint (DiscoveryVersion discoveryVersion, Binding binding, EndpointAddress address)
+                       : base (null, binding, address)
+               {
+                       if (discoveryVersion == null)
+                               throw new ArgumentNullException ("discoveryVersion");
+                       DiscoveryVersion = discoveryVersion;
+               }
+
+               public DiscoveryVersion DiscoveryVersion { get; private set; }
+
+               [MonoTODO]
+               public TimeSpan MaxAnnouncementDelay { get; set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementEventArgs.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementEventArgs.cs
new file mode 100755 (executable)
index 0000000..e929544
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class AnnouncementEventArgs : EventArgs
+       {
+               internal AnnouncementEventArgs (EndpointDiscoveryMetadata metadata, DiscoveryMessageSequence queue)
+               {
+                       EndpointDiscoveryMetadata = metadata;
+                       MessageSequence = queue;
+               }
+
+               public EndpointDiscoveryMetadata EndpointDiscoveryMetadata { get; private set; }
+               public DiscoveryMessageSequence MessageSequence { get; private set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementService.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/AnnouncementService.cs
new file mode 100755 (executable)
index 0000000..69f42d9
--- /dev/null
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       [ServiceBehavior (InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
+       public class AnnouncementService
+       {
+               public AnnouncementService ()
+               {
+               }
+
+               public AnnouncementService (int duplicateMessageHistoryLength)
+               {
+               }
+
+               public event EventHandler<AnnouncementEventArgs> OfflineAnnouncementReceived;
+               public event EventHandler<AnnouncementEventArgs> OnlineAnnouncementReceived;
+
+               protected virtual IAsyncResult OnBeginOfflineAnnouncement (DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual IAsyncResult OnBeginOnlineAnnouncement (DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual void OnEndOfflineAnnouncement (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual void OnEndOnlineAnnouncement (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ChangeLog b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ChangeLog
new file mode 100755 (executable)
index 0000000..ce289a8
--- /dev/null
@@ -0,0 +1,4 @@
+2010-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * : initial checkin (mostly stubs).
+
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryClient.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryClient.cs
new file mode 100755 (executable)
index 0000000..b454c53
--- /dev/null
@@ -0,0 +1,169 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public sealed class DiscoveryClient : ICommunicationObject, IDisposable
+       {
+               public DiscoveryClient ()
+               {
+               }
+
+               public DiscoveryClient (DiscoveryEndpoint discoveryEndpoint)
+               {
+               }
+
+               public DiscoveryClient (string endpointConfigurationName)
+               {
+               }
+
+               public ChannelFactory ChannelFactory { get; private set; }
+               public ClientCredentials ClientCredentials { get; private set; }
+               public ServiceEndpoint Endpoint { get; private set; }
+               public IClientChannel InnerChannel { get; private set; }
+
+               CommunicationState ICommunicationObject.State {
+                       get { return InnerChannel.State; }
+               }
+
+               public event EventHandler<FindCompletedEventArgs> FindCompleted;
+               public event EventHandler<FindProgressChangedEventArgs> FindProgressChanged;
+               public event EventHandler<AnnouncementEventArgs> ProxyAvailable;
+               public event EventHandler<ResolveCompletedEventArgs> ResolveCompleted;
+
+               event EventHandler ICommunicationObject.Closed {
+                       add { InnerChannel.Closed += value; }
+                       remove { InnerChannel.Closed -= value; }
+               }
+               event EventHandler ICommunicationObject.Closing {
+                       add { InnerChannel.Closing += value; }
+                       remove { InnerChannel.Closing -= value; }
+               }
+               event EventHandler ICommunicationObject.Faulted {
+                       add { InnerChannel.Faulted += value; }
+                       remove { InnerChannel.Faulted -= value; }
+               }
+               event EventHandler ICommunicationObject.Opened {
+                       add { InnerChannel.Opened += value; }
+                       remove { InnerChannel.Opened -= value; }
+               }
+               event EventHandler ICommunicationObject.Opening {
+                       add { InnerChannel.Opening += value; }
+                       remove { InnerChannel.Opening -= value; }
+               }
+
+               public void CancelAsync (object userState)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void Close ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public FindResponse Find (FindCriteria criteria)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void FindAsync (FindCriteria criteria)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void FindAsync (FindCriteria criteria, object userState)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void Open ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public ResolveResponse Resolve (ResolveCriteria criteria)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ResolveAsync (ResolveCriteria criteria)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ResolveAsync (ResolveCriteria criteria, object userState)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // explicit interface impl.
+
+               void ICommunicationObject.Open ()
+               {
+                       InnerChannel.Open ();
+               }
+
+               void ICommunicationObject.Open (TimeSpan timeout)
+               {
+                       InnerChannel.Open (timeout);
+               }
+
+               void ICommunicationObject.Close ()
+               {
+                       InnerChannel.Close ();
+               }
+
+               void ICommunicationObject.Close (TimeSpan timeout)
+               {
+                       InnerChannel.Close (timeout);
+               }
+
+               IAsyncResult ICommunicationObject.BeginOpen (AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginOpen (callback, state);
+               }
+
+               IAsyncResult ICommunicationObject.BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginOpen (timeout, callback, state);
+               }
+
+               IAsyncResult ICommunicationObject.BeginClose (AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginClose (callback, state);
+               }
+
+               IAsyncResult ICommunicationObject.BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginClose (timeout, callback, state);
+               }
+
+               void ICommunicationObject.EndOpen (IAsyncResult result)
+               {
+                       InnerChannel.EndOpen (result);
+               }
+
+               void ICommunicationObject.EndClose (IAsyncResult result)
+               {
+                       InnerChannel.EndClose (result);
+               }
+
+               void ICommunicationObject.Abort ()
+               {
+                       InnerChannel.Abort ();
+               }
+
+               void IDisposable.Dispose ()
+               {
+                       InnerChannel.Dispose ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryClientBindingElement.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryClientBindingElement.cs
new file mode 100755 (executable)
index 0000000..c3b2d2a
--- /dev/null
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public sealed class DiscoveryClientBindingElement : BindingElement
+       {
+               [MonoTODO]
+               public static readonly EndpointAddress DiscoveryEndpointAddress = null;
+
+               public DiscoveryClientBindingElement ()
+               {
+               }
+
+               public DiscoveryClientBindingElement (DiscoveryEndpointProvider discoveryEndpointProvider, FindCriteria findCriteria)
+               {
+                       DiscoveryEndpointProvider = discoveryEndpointProvider;
+                       FindCriteria = findCriteria;
+               }
+
+               public DiscoveryEndpointProvider DiscoveryEndpointProvider { get; set; }
+               public FindCriteria FindCriteria { get; set; }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool CanBuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool CanBuildChannelListener<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryEndpoint.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryEndpoint.cs
new file mode 100755 (executable)
index 0000000..5b3d8b8
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class DiscoveryEndpoint : ServiceEndpoint
+       {
+               public DiscoveryEndpoint ()
+                       : this (null, null)
+               {
+               }
+
+               public DiscoveryEndpoint (Binding binding, EndpointAddress endpointAddress)
+                       : this (DiscoveryVersion.WSDiscoveryApril2005, ServiceDiscoveryMode.Managed, binding, endpointAddress)
+               {
+               }
+
+               public DiscoveryEndpoint (DiscoveryVersion discoveryVersion, ServiceDiscoveryMode discoveryMode)
+                       : this (discoveryVersion, discoveryMode, null, null)
+               {
+               }
+
+               public DiscoveryEndpoint (DiscoveryVersion discoveryVersion, ServiceDiscoveryMode discoveryMode, Binding binding, EndpointAddress endpointAddress)
+                       : base (null, binding, endpointAddress)
+               {
+                       if (discoveryVersion == null)
+                               throw new ArgumentNullException ("discoveryVersion");
+                       DiscoveryVersion = discoveryVersion;
+                       DiscoveryMode = discoveryMode;
+               }
+
+               public ServiceDiscoveryMode DiscoveryMode { get; private set; }
+               public DiscoveryVersion DiscoveryVersion { get; private set; }
+               [MonoTODO]
+               public TimeSpan MaxResponseDelay { get; set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryEndpointProvider.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryEndpointProvider.cs
new file mode 100755 (executable)
index 0000000..46cff0d
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public abstract class DiscoveryEndpointProvider
+       {
+               public abstract DiscoveryEndpoint GetDiscoveryEndpoint ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryMessageSequence.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryMessageSequence.cs
new file mode 100755 (executable)
index 0000000..7590eb1
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class DiscoveryMessageSequence : IComparable<DiscoveryMessageSequence>, IEquatable<DiscoveryMessageSequence>
+       {
+               internal DiscoveryMessageSequence (long instanceId, Uri sequenceId, long messageNumber)
+               {
+                       InstanceId = instanceId;
+                       SequenceId = sequenceId;
+                       MessageNumber = messageNumber;
+               }
+
+               public long InstanceId { get; private set; }
+               public long MessageNumber { get; private set; }
+               public Uri SequenceId { get; private set; }
+
+               [MonoTODO]
+               public bool CanCompareTo (DiscoveryMessageSequence other)
+               {
+                       if (other == null)
+                               return false;
+                       return InstanceId == other.InstanceId && SequenceId.Equals (other.SequenceId);
+               }
+
+               [MonoTODO]
+               public int CompareTo (DiscoveryMessageSequence other)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool Equals (DiscoveryMessageSequence other)
+               {
+                       if (other == null)
+                               return false;
+                       return  InstanceId == other.InstanceId &&
+                               SequenceId.Equals (other.SequenceId) &&
+                               MessageNumber == other.MessageNumber;
+               }
+
+               public override bool Equals (object obj)
+               {
+                       var s = obj as DiscoveryMessageSequence;
+                       return s != null && Equals (s);
+               }
+
+               [MonoTODO]
+               public override int GetHashCode ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static bool operator == (DiscoveryMessageSequence messageSequence1, DiscoveryMessageSequence messageSequence2)
+               {
+                       return messageSequence1 != null ? messageSequence1.Equals (messageSequence2) : messageSequence2 == null;
+               }
+
+               public static bool operator != (DiscoveryMessageSequence messageSequence1, DiscoveryMessageSequence messageSequence2)
+               {
+                       return messageSequence1 == null ? messageSequence2 != null : !messageSequence1.Equals (messageSequence2);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryMessageSequenceGenerator.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryMessageSequenceGenerator.cs
new file mode 100755 (executable)
index 0000000..f960a4a
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class DiscoveryMessageSequenceGenerator
+       {
+               [MonoTODO ("default values?")]
+               public DiscoveryMessageSequenceGenerator ()
+               {
+               }
+
+               public DiscoveryMessageSequenceGenerator (long instanceId, Uri sequenceId)
+               {
+                       instance_id = instanceId;
+                       sequence_id = sequenceId;
+               }
+
+               long instance_id, message_count;
+               Uri sequence_id;
+
+               [MonoTODO ("default number?")]
+               public DiscoveryMessageSequence Next ()
+               {
+                       return new DiscoveryMessageSequence (instance_id, sequence_id, message_count++);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryOperationContextExtension.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryOperationContextExtension.cs
new file mode 100755 (executable)
index 0000000..ccc6489
--- /dev/null
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public class DiscoveryOperationContextExtension : IExtension<OperationContext>
+       {
+               internal DiscoveryOperationContextExtension ()
+               {
+               }
+
+               void IExtension<OperationContext>.Attach (OperationContext owner)
+               {
+               }
+
+               void IExtension<OperationContext>.Detach (OperationContext owner)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryProxy.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryProxy.cs
new file mode 100755 (executable)
index 0000000..33a3ffb
--- /dev/null
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public abstract class DiscoveryProxy
+       {
+               protected DiscoveryProxy ()
+               {
+               }
+
+               protected DiscoveryProxy (DiscoveryMessageSequenceGenerator messageSequenceGenerator)
+               {
+               }
+
+               protected DiscoveryProxy (DiscoveryMessageSequenceGenerator messageSequenceGenerator, int duplicateMessageHistoryLength)
+               {
+               }
+
+               protected virtual IAsyncResult BeginShouldRedirectFind (FindCriteria resolveCriteria, AsyncCallback callback, Object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual IAsyncResult BeginShouldRedirectResolve (ResolveCriteria findCriteria, AsyncCallback callback, Object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual bool EndShouldRedirectFind (IAsyncResult result, out Collection<EndpointDiscoveryMetadata> redirectionEndpoints)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual bool EndShouldRedirectResolve (IAsyncResult result, out Collection<EndpointDiscoveryMetadata> redirectionEndpoints)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected abstract IAsyncResult OnBeginFind (FindRequestContext findRequestContext, AsyncCallback callback, Object state);
+               protected abstract IAsyncResult OnBeginOfflineAnnouncement (DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, Object state);
+               protected abstract IAsyncResult OnBeginOnlineAnnouncement (DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, Object state);
+               protected abstract IAsyncResult OnBeginResolve (ResolveCriteria resolveCriteria, AsyncCallback callback, Object state);
+               protected abstract void OnEndFind (IAsyncResult result);
+               protected abstract void OnEndOfflineAnnouncement (IAsyncResult result);
+               protected abstract void OnEndOnlineAnnouncement (IAsyncResult result);
+               protected abstract EndpointDiscoveryMetadata OnEndResolve (IAsyncResult result);
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryService.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryService.cs
new file mode 100755 (executable)
index 0000000..1bd1c9a
--- /dev/null
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public abstract class DiscoveryService
+       {
+               protected DiscoveryService ()
+               {
+               }
+
+               protected DiscoveryService (DiscoveryMessageSequenceGenerator discoveryMessageSequenceGenerator)
+               {
+               }
+
+               protected DiscoveryService (DiscoveryMessageSequenceGenerator discoveryMessageSequenceGenerator, int duplicateMessageHistoryLength)
+               {
+               }
+
+               protected abstract IAsyncResult OnBeginFind (FindRequestContext findRequestContext, AsyncCallback callback, Object state);
+
+               protected abstract IAsyncResult OnBeginResolve (ResolveCriteria resolveCriteria, AsyncCallback callback, Object state);
+
+               protected abstract void OnEndFind (IAsyncResult result);
+
+               protected abstract EndpointDiscoveryMetadata OnEndResolve (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryServiceExtension.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryServiceExtension.cs
new file mode 100755 (executable)
index 0000000..a55f145
--- /dev/null
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public abstract class DiscoveryServiceExtension : IExtension<ServiceHostBase>
+       {
+               protected abstract DiscoveryService GetDiscoveryService ();
+
+               void IExtension<ServiceHostBase>.Attach (ServiceHostBase owner)
+               {
+               }
+
+               void IExtension<ServiceHostBase>.Detach (ServiceHostBase owner)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryVersion.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DiscoveryVersion.cs
new file mode 100755 (executable)
index 0000000..ac106cc
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public sealed class DiscoveryVersion
+       {
+               static DiscoveryVersion ()
+               {
+                       v11 = new DiscoveryVersion ("WSDiscovery11");
+                       april2005 = new DiscoveryVersion ("WSDiscoveryApril2005");
+                       cd1 = new DiscoveryVersion ("WSDiscoveryCD1");
+               }
+
+               static readonly DiscoveryVersion v11, april2005, cd1;
+
+               public static DiscoveryVersion WSDiscovery11 {
+                       get { return v11; }
+               }
+
+               public static DiscoveryVersion WSDiscoveryApril2005 {
+                       get { return april2005; }
+               }
+
+               public static DiscoveryVersion WSDiscoveryCD1 {
+                       get { return cd1; }
+               }
+
+               public static DiscoveryVersion FromName (string name)
+               {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       switch (name) {
+                       case "WSDiscovery11":
+                               return v11;
+                       case "WSDiscoveryApril2005":
+                               return april2005;
+                       case "WSDiscoveryCD1":
+                               return cd1;
+                       default:
+                               throw new ArgumentNullException (String.Format ("Invalid version name: {0}", name));
+                       }
+               }
+
+               internal DiscoveryVersion (string name)
+               {
+                       this.Name = name;
+               }
+
+               public Uri AdhocAddress { get; private set; }
+               public MessageVersion MessageVersion { get; private set; }
+               public string Name { get; private set; }
+               public string Namespace { get; private set; }
+
+               public override string ToString ()
+               {
+                       return Name;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DynamicEndpoint.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/DynamicEndpoint.cs
new file mode 100755 (executable)
index 0000000..80f1d81
--- /dev/null
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public class DynamicEndpoint : ServiceEndpoint
+       {
+               public DynamicEndpoint (ContractDescription contract, Binding binding)
+                       : base (contract, binding, null)
+               {
+               }
+
+               public DiscoveryEndpointProvider DiscoveryEndpointProvider { get; set; }
+               public FindCriteria FindCriteria { get; set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/EndpointDiscoveryBehavior.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/EndpointDiscoveryBehavior.cs
new file mode 100755 (executable)
index 0000000..334c944
--- /dev/null
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public class EndpointDiscoveryBehavior : IEndpointBehavior
+       {
+               void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
+               {
+               }
+
+               void IEndpointBehavior.ApplyClientBehavior (ServiceEndpoint endpoint, ClientRuntime clientRuntime)
+               {
+               }
+
+               void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
+               {
+               }
+
+               void IEndpointBehavior.Validate (ServiceEndpoint endpoint)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/EndpointDiscoveryMetadata.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/EndpointDiscoveryMetadata.cs
new file mode 100755 (executable)
index 0000000..a905159
--- /dev/null
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Linq;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public class EndpointDiscoveryMetadata
+       {
+               public static EndpointDiscoveryMetadata FromServiceEndpoint (ServiceEndpoint endpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static EndpointDiscoveryMetadata FromServiceEndpoint (ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public EndpointAddress Address { get; set; }
+               public Collection<XmlQualifiedName> ContractTypeNames { get; private set; }
+               public Collection<XElement> Extensions { get; private set; }
+               public Collection<Uri> ListenUris { get; private set; }
+               public Collection<Uri> Scopes { get; private set; }
+               public int Version { get; set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindCompletedEventArgs.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindCompletedEventArgs.cs
new file mode 100755 (executable)
index 0000000..7abcfb4
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class FindCompletedEventArgs : AsyncCompletedEventArgs
+       {
+               internal FindCompletedEventArgs (FindResponse result, Exception error, bool cancelled, object userState)
+                       : base (error, cancelled, userState)
+               {
+                       this.Result = result;
+               }
+
+               public FindResponse Result { get; private set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindCriteria.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindCriteria.cs
new file mode 100755 (executable)
index 0000000..12c79fd
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using System.Xml.Linq;
+
+namespace System.ServiceModel.Discovery
+{
+       public class FindCriteria
+       {
+               public static readonly Uri ScopeMatchByExact = new Uri ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/strcmp0");
+               public static readonly Uri ScopeMatchByLdap = new Uri ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ldap");
+               public static readonly Uri ScopeMatchByNone = new Uri ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/none");
+               public static readonly Uri ScopeMatchByPrefix = new Uri ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/rfc3986");
+               public static readonly Uri ScopeMatchByUuid = new Uri ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/uuid");
+
+               public static FindCriteria CreateMetadataExchangeEndpointCriteria ()
+               {
+                       return CreateMetadataExchangeEndpointCriteria (typeof (IMetadataExchange));
+               }
+
+               public static FindCriteria CreateMetadataExchangeEndpointCriteria (IEnumerable<XmlQualifiedName> contractTypeNames)
+               {
+                       var fc = new FindCriteria ();
+                       foreach (var type in contractTypeNames)
+                               fc.ContractTypeNames.Add (type);
+                       return fc;
+               }
+
+               public static FindCriteria CreateMetadataExchangeEndpointCriteria (Type contractType)
+               {
+                       return new FindCriteria (contractType);
+               }
+
+               public FindCriteria ()
+               {
+                       ContractTypeNames = new Collection<XmlQualifiedName> ();
+                       Extensions = new Collection<XElement> ();
+                       Scopes = new Collection<Uri> ();
+               }
+
+               [MonoTODO]
+               public FindCriteria (Type contractType)
+                       : this ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public Collection<XmlQualifiedName> ContractTypeNames { get; private set; }
+               public TimeSpan Duration { get; set; }
+               public Collection<XElement> Extensions { get; private set; }
+               [MonoTODO]
+               public int MaxResults { get; set; }
+               public Uri ScopeMatchBy { get; set; }
+               public Collection<Uri> Scopes { get; private set; }
+
+               [MonoTODO]
+               public bool IsMatch (EndpointDiscoveryMetadata endpointDiscoveryMetadata)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindProgressChangedEventArgs.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindProgressChangedEventArgs.cs
new file mode 100755 (executable)
index 0000000..d01affd
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class FindProgressChangedEventArgs : ProgressChangedEventArgs
+       {
+               internal FindProgressChangedEventArgs (EndpointDiscoveryMetadata metadata, DiscoveryMessageSequence sequence, int progressPercentage, object userState)
+                       : base (progressPercentage, userState)
+               {
+                       EndpointDiscoveryMetadata = metadata;
+                       MessageSequence = sequence;
+               }
+
+               public EndpointDiscoveryMetadata EndpointDiscoveryMetadata { get;private set; }
+               public DiscoveryMessageSequence MessageSequence { get; private set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindRequestContext.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindRequestContext.cs
new file mode 100755 (executable)
index 0000000..06ab140
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class FindRequestContext
+       {
+               protected FindRequestContext (FindCriteria criteria)
+               {
+                       if (criteria == null)
+                               throw new ArgumentNullException ("criteria");
+                       Criteria = criteria;
+               }
+
+               public FindCriteria Criteria { get; private set; }
+
+               [MonoTODO]
+               public void AddMatchingEndpoint (EndpointDiscoveryMetadata matchingEndpoint)
+               {
+                       OnAddMatchingEndpoint (matchingEndpoint);
+               }
+
+               [MonoTODO]
+               protected virtual void OnAddMatchingEndpoint (EndpointDiscoveryMetadata matchingEndpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindResponse.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/FindResponse.cs
new file mode 100755 (executable)
index 0000000..451d3d2
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class FindResponse
+       {
+               internal FindResponse ()
+               {
+                       Endpoints = new Collection<EndpointDiscoveryMetadata> ();
+               }
+
+               public Collection<EndpointDiscoveryMetadata> Endpoints { get; private set; }
+
+               [MonoTODO]
+               public DiscoveryMessageSequence GetMessageSequence (EndpointDiscoveryMetadata endpointDiscoveryMetadata)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ResolveCompletedEventArgs.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ResolveCompletedEventArgs.cs
new file mode 100755 (executable)
index 0000000..220fb96
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class ResolveCompletedEventArgs : AsyncCompletedEventArgs
+       {
+               internal ResolveCompletedEventArgs (ResolveResponse result, Exception error, bool cancelled, object userState)
+                       : base (error, cancelled, userState)
+               {
+                       this.Result = result;
+               }
+
+               public ResolveResponse Result { get; private set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ResolveCriteria.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ResolveCriteria.cs
new file mode 100755 (executable)
index 0000000..11731ef
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml.Linq;
+
+namespace System.ServiceModel.Discovery
+{
+       public class ResolveCriteria
+       {
+               public ResolveCriteria ()
+               {
+                       Extensions = new Collection<XElement> ();
+               }
+
+               public ResolveCriteria (EndpointAddress address)
+                       : this ()
+               {
+                       Address = address;
+               }
+
+               public EndpointAddress Address { get; set; }
+               [MonoTODO]
+               public TimeSpan Duration { get; set; }
+               public Collection<XElement> Extensions { get; private set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ResolveResponse.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ResolveResponse.cs
new file mode 100755 (executable)
index 0000000..6a1b4f1
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class ResolveResponse
+       {
+               internal ResolveResponse (EndpointDiscoveryMetadata metadata, DiscoveryMessageSequence sequence)
+               {
+                       EndpointDiscoveryMetadata = metadata;
+                       MessageSequence = sequence;
+               }
+
+               public EndpointDiscoveryMetadata EndpointDiscoveryMetadata { get; private set; }
+               public DiscoveryMessageSequence MessageSequence { get; private set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ServiceDiscoveryBehavior.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ServiceDiscoveryBehavior.cs
new file mode 100755 (executable)
index 0000000..22599e3
--- /dev/null
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       [MonoTODO]
+       public class ServiceDiscoveryBehavior : IServiceBehavior
+       {
+               void IServiceBehavior.AddBindingParameters (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
+               {
+               }
+
+               void IServiceBehavior.ApplyDispatchBehavior (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
+               {
+               }
+
+               void IServiceBehavior.Validate (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ServiceDiscoveryMode.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/ServiceDiscoveryMode.cs
new file mode 100755 (executable)
index 0000000..3b65b64
--- /dev/null
@@ -0,0 +1,32 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+namespace System.ServiceModel.Discovery
+{
+       public enum ServiceDiscoveryMode
+       {
+               Adhoc,
+               Managed
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/UdpAnnouncementEndpoint.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/UdpAnnouncementEndpoint.cs
new file mode 100755 (executable)
index 0000000..95823a6
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class UdpAnnouncementEndpoint : AnnouncementEndpoint
+       {
+               [MonoTODO]
+               public static readonly Uri DefaultIPv4MulticastAddress;
+               [MonoTODO]
+               public static readonly Uri DefaultIPv6MulticastAddress;
+
+               // (1)->(2)
+               public UdpAnnouncementEndpoint ()
+                       : this (DiscoveryVersion.WSDiscovery11)
+               {
+               }
+
+               // (2), everything falls to here.
+               public UdpAnnouncementEndpoint (DiscoveryVersion discoveryVersion)
+                       : base (discoveryVersion)
+               {
+                       TransportSettings = new UdpTransportSettings ();
+               }
+
+               // (3)->(4)
+               public UdpAnnouncementEndpoint (string multicastAddress)
+                       : this (new Uri (multicastAddress))
+               {
+               }
+
+               // (4)->(5)
+               public UdpAnnouncementEndpoint (Uri multicastAddress)
+                       : this (DiscoveryVersion.WSDiscovery11, multicastAddress)
+               {
+               }
+
+               // (5)->(6)
+               public UdpAnnouncementEndpoint (DiscoveryVersion discoveryVersion, string multicastAddress)
+                       : this (discoveryVersion, new Uri (multicastAddress))
+               {
+               }
+
+               // (6)->(2)
+               public UdpAnnouncementEndpoint (DiscoveryVersion discoveryVersion, Uri multicastAddress)
+                       : this (discoveryVersion)
+               {
+                       MulticastAddress = multicastAddress;
+               }
+
+               public Uri MulticastAddress { get; set; }
+               public UdpTransportSettings TransportSettings { get; private set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/UdpDiscoveryEndpoint.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/UdpDiscoveryEndpoint.cs
new file mode 100755 (executable)
index 0000000..72c57b7
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class UdpDiscoveryEndpoint : DiscoveryEndpoint
+       {
+               [MonoTODO]
+               public static readonly Uri DefaultIPv4MulticastAddress;
+               [MonoTODO]
+               public static readonly Uri DefaultIPv6MulticastAddress;
+
+               // (1)->(2)
+               public UdpDiscoveryEndpoint ()
+                       : this (DiscoveryVersion.WSDiscovery11)
+               {
+               }
+
+               // (2), everything falls to here.
+               public UdpDiscoveryEndpoint (DiscoveryVersion discoveryVersion)
+                       : base (discoveryVersion, ServiceDiscoveryMode.Adhoc)
+               {
+                       TransportSettings = new UdpTransportSettings ();
+               }
+
+               // (3)->(4)
+               public UdpDiscoveryEndpoint (string multicastAddress)
+                       : this (new Uri (multicastAddress))
+               {
+               }
+
+               // (4)->(5)
+               public UdpDiscoveryEndpoint (Uri multicastAddress)
+                       : this (DiscoveryVersion.WSDiscovery11, multicastAddress)
+               {
+               }
+
+               // (5)->(6)
+               public UdpDiscoveryEndpoint (DiscoveryVersion discoveryVersion, string multicastAddress)
+                       : this (discoveryVersion, new Uri (multicastAddress))
+               {
+               }
+
+               // (6)->(2)
+               public UdpDiscoveryEndpoint (DiscoveryVersion discoveryVersion, Uri multicastAddress)
+                       : this (discoveryVersion)
+               {
+                       MulticastAddress = multicastAddress;
+               }
+
+               public Uri MulticastAddress { get; set; }
+               public UdpTransportSettings TransportSettings { get; private set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/UdpTransportSettings.cs b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery/UdpTransportSettings.cs
new file mode 100755 (executable)
index 0000000..e0f2171
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Discovery
+{
+       public class UdpTransportSettings
+       {
+               internal UdpTransportSettings ()
+               {
+               }
+
+               public int DuplicateMessageHistoryLength { get; set; }
+               public long MaxBufferPoolSize { get; set; }
+               public int MaxMulticastRetransmitCount { get; set; }
+               public int MaxPendingMessageCount { get; set; }
+               public long MaxReceivedMessageSize { get; set; }
+               public int MaxUnicastRetransmitCount { get; set; }
+               public string MulticastInterfaceId { get; set; }
+               public int SocketReceiveBufferSize { get; set; }
+               public int TimeToLive { get; set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery_test.dll.sources b/mcs/class/System.ServiceModel.Discovery/System.ServiceModel.Discovery_test.dll.sources
new file mode 100644 (file)
index 0000000..ffd63d3
--- /dev/null
@@ -0,0 +1,2 @@
+System.ServiceModel.Discovery/DiscoveryVersionTest.cs
+System.ServiceModel.Discovery/FindCriteriaTest.cs
diff --git a/mcs/class/System.ServiceModel.Discovery/Test/System.ServiceModel.Discovery/ChangeLog b/mcs/class/System.ServiceModel.Discovery/Test/System.ServiceModel.Discovery/ChangeLog
new file mode 100755 (executable)
index 0000000..ce289a8
--- /dev/null
@@ -0,0 +1,4 @@
+2010-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * : initial checkin (mostly stubs).
+
diff --git a/mcs/class/System.ServiceModel.Discovery/Test/System.ServiceModel.Discovery/DiscoveryVersionTest.cs b/mcs/class/System.ServiceModel.Discovery/Test/System.ServiceModel.Discovery/DiscoveryVersionTest.cs
new file mode 100755 (executable)
index 0000000..3e73e0b
--- /dev/null
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Discovery;
+using System.ServiceModel.Dispatcher;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Discovery
+{
+       [TestFixture]
+       public class DiscoveryVersionTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void NullName ()
+               {
+                       DiscoveryVersion.FromName (null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void EmptyName ()
+               {
+                       DiscoveryVersion.FromName (String.Empty);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void InvalidName ()
+               {
+                       DiscoveryVersion.FromName ("foobar");
+               }
+
+               [Test]
+               public void ValidName ()
+               {
+                       DiscoveryVersion.FromName ("WSDiscovery11");
+                       DiscoveryVersion.FromName ("WSDiscoveryApril2005");
+                       DiscoveryVersion.FromName ("WSDiscoveryCD1");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel.Discovery/Test/System.ServiceModel.Discovery/FindCriteriaTest.cs b/mcs/class/System.ServiceModel.Discovery/Test/System.ServiceModel.Discovery/FindCriteriaTest.cs
new file mode 100755 (executable)
index 0000000..53bf01b
--- /dev/null
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Discovery;
+using System.ServiceModel.Dispatcher;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Discovery
+{
+       [TestFixture]
+       public class FindCriteriaTest
+       {
+               [Test]
+               [Ignore ("huh? should they really return Uri like 'http://schemas.microsoft.com/ws/2008/06/discovery/strcmp0' ?")]
+               public void StaticUris ()
+               {
+                       Assert.AreEqual ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/strcmp0", FindCriteria.ScopeMatchByExact.ToString (), "#1");
+                       Assert.AreEqual ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/none", FindCriteria.ScopeMatchByLdap.ToString (), "#2");
+                       Assert.AreEqual ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/none", FindCriteria.ScopeMatchByNone.ToString (), "#3");
+                       Assert.AreEqual ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/rfc3986", FindCriteria.ScopeMatchByPrefix.ToString (), "#4");
+                       Assert.AreEqual ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/uuid", FindCriteria.ScopeMatchByUuid.ToString (), "#5");
+               }
+       }
+}
index bfa93fd472e766960ec68abbf4c156790c1a2449..d0c60882654ecd60063a8aca2578a7149af817bd 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * net_2_0_System.ServiceModel.Web.dll.sources,
+         common_System.ServiceModel.Web.dll.sources : UriTemplates are
+         moved to Sys.SM.dll in 4.0 profile.
+
 2010-03-12  Atsushi Enomoto  <atsushi@ximian.com>
 
        * monotouch_System.ServiceModel.Web.dll.sources :
index ef28ea94c9fabfb6fa4b7ea407ffe3ba6fc4dd07..c9fc51f90576aba340fb9e8bc134b3c89599d160 100644 (file)
@@ -1,3 +1,13 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * DataContractJsonSerializer.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
+2010-03-13  Kornél Pál  <kornelpal@gmail.com>
+
+       * JavaScriptReader.cs: Deserialize "false" correctly.
+         Fixed bug #586712.
+
 2010-03-10  Atsushi Enomoto  <atsushi@ximian.com>
 
        * JavaScriptReader.cs : moved from Sys.Json/JsonReader.cs.
index d5ea4db36a6fa9773e6e00abe96a36ccaeb0c7b4..355ea31dadb87c57ef8a008949b9fc245fbf2cfe 100644 (file)
@@ -91,7 +91,7 @@ namespace System.Runtime.Serialization.Json
                        always_emit_type = alwaysEmitTypeInformation;
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public DataContractJsonSerializer (Type type, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation)
             : this (type, default_root_name, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, alwaysEmitTypeInformation)
                {
@@ -117,7 +117,7 @@ namespace System.Runtime.Serialization.Json
                int max_items;
                bool ignore_extension;
                bool always_emit_type;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                IDataContractSurrogate surrogate;
 
                [MonoTODO]
index b3be29ae8d9c21a1f54d33bfc96dc6bc9a1ca9c0..746030825a73557a29b684190e8d19ecfe7de2af 100644 (file)
@@ -86,7 +86,7 @@ namespace System.Runtime.Serialization.Json
                                return true;
                        case 'f':
                                Expect ("false");
-                               return true;
+                               return false;
                        case 'n':
                                Expect ("null");
                                // FIXME: what should we return?
index 2cf709207df2e0ba08e520ca649f4511ec0d8e08..cea57d025061afc6a6e2bb97c6c17991e97f7b75 100644 (file)
@@ -1,3 +1,13 @@
+2010-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WebHttpBehavior.cs : set FilterPriority to make it in higher
+         priority than conflicting endpoints (such as mex endpoint).
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * WebHttpBehavior.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2009-10-23  Atsushi Enomoto  <atsushi@ximian.com>
 
        * WebHttpBehavior.cs : add experimental monotouch build.
index cc4609ac62076929138c84756bb8d3c06d7903f2..c17c78899c908a01b62c9cc5bfee0dc5302ce79d 100644 (file)
@@ -102,7 +102,7 @@ namespace System.ServiceModel.Description
                public virtual void ApplyClientBehavior (ServiceEndpoint endpoint, ClientRuntime clientRuntime)
                {
                        AddClientErrorInspector (endpoint, clientRuntime);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        throw new NotSupportedException ("Due to the lack of ClientRuntime.Operations, Silverlight cannot support this binding.");
 #else
                        foreach (ClientOperation oper in clientRuntime.Operations) {
@@ -118,6 +118,7 @@ namespace System.ServiceModel.Description
                {
                        endpointDispatcher.DispatchRuntime.OperationSelector = GetOperationSelector (endpoint);
                        // FIXME: get HostNameComparisonMode from WebHttpBinding by some means.
+                       endpointDispatcher.FilterPriority = 1; // It is to take higher priority than that of ServiceMetadataExtension (whose URL likely conflicts with this one).
                        endpointDispatcher.AddressFilter = new PrefixEndpointAddressMessageFilter (endpoint.Address);
                        endpointDispatcher.ContractFilter = new MatchAllMessageFilter ();
                        AddServerErrorHandlers (endpoint, endpointDispatcher);
index 8c770f141e19a925a6a0faaffcee856fce2552ee..e99209a6f13be4c03cc00fb8b4faf26d10e73762 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * WebMessageFormatter.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2009-10-23  Atsushi Enomoto  <atsushi@ximian.com>
 
        * JsonQueryStringConverter.cs
index 0eefabf073d755ef8116edb70ab15cc0a7f4199e..ba802e34c03f25d2d796988115b5910655f8fc9a 100644 (file)
@@ -158,7 +158,7 @@ namespace System.ServiceModel.Description
                                break;
                        case WebContentFormat.Json:
                                // FIXME: after name argument they are hack
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                                if (IsResponseBodyWrapped)
                                        return GetSerializer (ref json_serializer, p => new DataContractJsonSerializer (p.Type, BodyName ?? p.Name, null, 0x100000, false, null, true));
                                else
index ae726bc6b951d234d1aafc80d185f2f51724a5c1..04dbe4f9bd70b8f571c93fa6bede68d9d4f9cc90 100644 (file)
@@ -37,8 +37,3 @@ System.ServiceModel.Web/WebServiceHost.cs
 System.ServiceModel/WebHttpBinding.cs
 System.ServiceModel/WebHttpSecurity.cs
 System.ServiceModel/WebHttpSecurityMode.cs
-System/UriTemplate.cs
-System/UriTemplateEquivalenceComparer.cs
-System/UriTemplateMatch.cs
-System/UriTemplateMatchException.cs
-System/UriTemplateTable.cs
diff --git a/mcs/class/System.ServiceModel.Web/moonlight_raw_System.ServiceModel.Web.dll.sources b/mcs/class/System.ServiceModel.Web/moonlight_raw_System.ServiceModel.Web.dll.sources
new file mode 100644 (file)
index 0000000..07c6038
--- /dev/null
@@ -0,0 +1,12 @@
+Assembly/AssemblyInfo.cs
+System.Runtime.Serialization.Json/DataContractJsonSerializer_2_1.cs
+System.Runtime.Serialization.Json/IXmlJsonReaderInitializer.cs
+System.Runtime.Serialization.Json/IXmlJsonWriterInitializer.cs
+System.Runtime.Serialization.Json/JavaScriptObjectDeserializer.cs
+System.Runtime.Serialization.Json/JavaScriptReader.cs
+System.Runtime.Serialization.Json/JsonReader.cs
+System.Runtime.Serialization.Json/JsonReaderWriterFactory.cs
+System.Runtime.Serialization.Json/JsonSerializationReader.cs
+System.Runtime.Serialization.Json/JsonSerializationWriter.cs
+System.Runtime.Serialization.Json/JsonWriter.cs
+System.Runtime.Serialization.Json/TypeMap.cs
index 27493ec82015c07487c19a064eaf5d3f222fc23d..effcff77237905f5b0f1423c6010f7c07f6391c9 100644 (file)
@@ -46,3 +46,8 @@ System.ServiceModel.Syndication/TextSyndicationContentKind.cs
 System.ServiceModel.Syndication/UrlSyndicationContent.cs
 System.ServiceModel.Syndication/Workspace.cs
 System.ServiceModel.Syndication/XmlSyndicationContent.cs
+System/UriTemplate.cs
+System/UriTemplateEquivalenceComparer.cs
+System/UriTemplateMatch.cs
+System/UriTemplateMatchException.cs
+System/UriTemplateTable.cs
diff --git a/mcs/class/System.ServiceModel.Web/net_2_1_raw_System.ServiceModel.Web.dll.sources b/mcs/class/System.ServiceModel.Web/net_2_1_raw_System.ServiceModel.Web.dll.sources
deleted file mode 100644 (file)
index 07c6038..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Assembly/AssemblyInfo.cs
-System.Runtime.Serialization.Json/DataContractJsonSerializer_2_1.cs
-System.Runtime.Serialization.Json/IXmlJsonReaderInitializer.cs
-System.Runtime.Serialization.Json/IXmlJsonWriterInitializer.cs
-System.Runtime.Serialization.Json/JavaScriptObjectDeserializer.cs
-System.Runtime.Serialization.Json/JavaScriptReader.cs
-System.Runtime.Serialization.Json/JsonReader.cs
-System.Runtime.Serialization.Json/JsonReaderWriterFactory.cs
-System.Runtime.Serialization.Json/JsonSerializationReader.cs
-System.Runtime.Serialization.Json/JsonSerializationWriter.cs
-System.Runtime.Serialization.Json/JsonWriter.cs
-System.Runtime.Serialization.Json/TypeMap.cs
index d2293ebdb7c2ff24e16559d4e2524d4d77289466..b4904d0afb8ad5575f6c2e08a0f207512441a957 100755 (executable)
@@ -1,3 +1,40 @@
+2010-03-24  Astushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : move back all the Features tests
+         that were once disabled (now we can handle mannerless tests).
+
+2010-03-19  Astushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : remove unused class.
+       * HTTP_listener_notes.txt : add some more comments.
+
+2010-03-18  Astushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel_test.dll.sources :
+         Add Constants.cs and XPathMessageContextTest.cs.
+
+2010-03-18  Astushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : added some missing types.
+
+2010-03-17  Astushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel_test.dll.sources :
+         add MetadataExchangeBindingsTest.cs.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * net_2_1_*.dll.sources: rename to moonlight_*.dll.sources.
+
+2010-03-15  Astushi Enomoto  <atsushi@ximian.com>
+
+       * net_4_0_System.ServiceModel.dll.sources:
+         more types from Sys.SM.Web.dll in 4.0 profile here.
+
+2010-03-15  Astushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy_2_1.cs : added cosmetic silverlight sdk compatibility stuff.
+
 2010-03-11  Astushi Enomoto  <atsushi@ximian.com>
 
        * System.ServiceModel.dll.sources,
index a3aa98d78e4c578a4fbd71b2e6155dcb9000f612..4c90120ed87cf2259e6012161a40487f3bf5b491 100644 (file)
@@ -1,3 +1,4 @@
+using System.Reflection;
 using System.Runtime.Serialization;
 
 namespace System.ServiceModel
@@ -7,6 +8,19 @@ namespace System.ServiceModel
        {
                public InstanceContext (object dummy) {}
        }
+       // introduced for silverlight sdk compatibility
+       internal class OperationFormatStyleHelper
+       {
+               public static bool IsDefined (OperationFormatStyle style)
+               {
+                       switch (style) {
+                       case OperationFormatStyle.Document:
+                       case OperationFormatStyle.Rpc:
+                               return true;
+                       }
+                       return false;
+               }
+       }
 }
 namespace System.ServiceModel.Channels
 {
@@ -23,6 +37,41 @@ namespace System.ServiceModel.Description
        public interface IWsdlExportExtension {}
        public interface IWsdlImportExtension {}
        public interface IContractBehavior {}
+
+       // introduced for silverlight sdk compatibility
+       internal class ServiceReflector
+       {
+               public static T GetSingleAttribute<T> (ICustomAttributeProvider p, Type [] types)
+               {
+                       T ret = default (T);
+                       foreach (Type t in types) {
+                               foreach (object att in p.GetCustomAttributes (t, false)) {
+                                       if (att is T) {
+                                               if (ret != null)
+                                                       throw new InvalidOperationException (String.Format ("More than one {0} attributes are found in the argument types", typeof (T)));
+                                               ret = (T) att;
+                                       }
+                               }
+                       }
+                       return ret;
+               }
+       }
+}
+namespace System.ServiceModel.DiagnosticUtility
+{
+       // introduced for silverlight sdk compatibility
+       internal class ExceptionUtility
+       {
+               public static Exception ThrowHelperError (Exception error)
+               {
+                       return error;
+               }
+
+               public static Exception ThrowHelperArgumentNull (string arg)
+               {
+                       return new ArgumentNullException (arg);
+               }
+       }
 }
 namespace System.ServiceModel.Dispatcher
 {
index 0a04e518873466d447db72115fd48852a3ee0d70..ca668d6d22c630377a18ae4a59809e152e389218 100644 (file)
@@ -47,10 +47,16 @@ This mostly explains what our WCF does, and does not explain what I think it rea
 locking: TBD
 
 
+** Some notes
+
+- WebHttpBinding creates HTTP channel listeners that share an identical endpoint URI, which could also be mapped by ServiceMetadataExtension. It brings problem on dispatching HTTP request to correct listener. FilterPriority is used to resolve the issue (possibly to some extent) that requests to wsdl/mex are treated in lower priority.
+- While multiple channel dispatchers' endpoints could indicate an identical HTTP URI, it is not allowed to use the same HTTP URI across more than one ServiceHostBase and attempt to create such endpoints will result in InvalidOperationException for conflict with existing listeners.
+
+
 ** Bugs
 
 There is not a few bugs on service implementations and there often are reasons:
 
 -- TCP duplex channels used to fail to serve requests when the throttle is 1. It was due to failure in managing closed channels (while it is duplex and hence it has to maintain channels until it is explicitly closed, clients often, or mostly, disconnects without any notice. So it had to be changed to explicitly check if the connection is available at any beginning of the request processing).
--- When there is more than one endpoint definition in web.config, it somehow fails to build appropriate HttpHandler chain (bug #573795).
+-- If there are more than one endpoint with the identical listen URI, it will fail to dispatch requests to correct listener even if the endpoints have appropriately configured FilterPriority. part of bug #573795.
 - ASP.NET listener ends up to dump ThreadAbort during its shutdown. It's mostly harmless though.
index a090d8cc0da3713355d046d789599ab81a3cbe90..6bb0e3c915b5a1ca3dd02b389b795004d134e006 100755 (executable)
@@ -31,7 +31,7 @@ LIB_MCS_FLAGS += /d:NET_3_0   \
                        /r:Mono.Security.dll
 endif
 
-ifeq (net_2_1_raw, $(PROFILE))
+ifeq (moonlight_raw, $(PROFILE))
 LIB_MCS_FLAGS += /r:System.Net
 endif
 
index 6b45f5d4ced45b9bc51467273151fc53b25d6ffa..1983e3a91e2e606bac5d76817da3dd2cd7ba4436 100644 (file)
@@ -34,24 +34,29 @@ namespace System.ServiceModel.Channels
        {
                string name;
                string address;
+               string fault_ns;
 
-               AddressingVersion (string name, string address)
+               AddressingVersion (string name, string address, string faultNS)
                {
                        this.name = name;
                        this.address = address;
+                       this.fault_ns = faultNS;
                }
 
                static AddressingVersion addressing200408 = new AddressingVersion (
                        "Addressing200408",
-                       "http://schemas.xmlsoap.org/ws/2004/08/addressing");
+                       "http://schemas.xmlsoap.org/ws/2004/08/addressing",
+                       "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault");
 
                static AddressingVersion addressing1_0 = new AddressingVersion (
                        "Addressing10",
-                       "http://www.w3.org/2005/08/addressing");
+                       "http://www.w3.org/2005/08/addressing",
+                       "http://www.w3.org/2005/08/addressing/fault");
 
                static AddressingVersion none = new AddressingVersion (
                        "AddressingNone",
-                       "http://schemas.microsoft.com/ws/2005/05/addressing/none");
+                       "http://schemas.microsoft.com/ws/2005/05/addressing/none",
+                       null);
 
                public static AddressingVersion WSAddressing10 {
                        get { return addressing1_0; }
@@ -69,6 +74,10 @@ namespace System.ServiceModel.Channels
                        get { return address; }
                }
 
+               internal string FaultNamespace {
+                       get { return fault_ns; }
+               }
+
                internal string ActionNotSupported {
                        get { return "ActionNotSupported"; }
                }
index 75cf52ce010905483037ed1489643c0317ea7fc4..8b083f5e9847f3d5eb19f145ae39ee9a6ade9558 100644 (file)
@@ -54,7 +54,7 @@ namespace System.ServiceModel.Channels
                        if (http_context == null)
                                return;
                        try {
-                               listener.HttpHandler.EndRequest (listener, http_context);
+                               ((AspNetListenerManager) listener.ListenerManager).HttpHandler.EndRequest (listener, http_context);
                        } finally {
                                http_context = null;
                        }
@@ -65,7 +65,7 @@ namespace System.ServiceModel.Channels
                        lock (waiting)
                                foreach (HttpContext ctx in waiting)
                                        try {
-                                               listener.HttpHandler.EndRequest (listener, ctx);
+                                               ((AspNetListenerManager) listener.ListenerManager).HttpHandler.EndRequest (listener, ctx);
                                        } catch {
                                        }
                }
index 9cbb4bf3c5812f05c5adee308633377e650b190f..59bf2bbcbca05e200cfbf9c1d0496c275717bd63 100644 (file)
@@ -74,6 +74,8 @@ namespace System.ServiceModel.Channels {
                                if (hp.SuppressEntityBody)
                                        suppressEntityBody = true;
                        }
+                       if (msg.IsFault)
+                               ctx.Response.StatusCode = 500;
                        if (!suppressEntityBody) {
                                ctx.Response.AddHeader ("Content-Length", ms.Length.ToString (CultureInfo.InvariantCulture));
                                ctx.Response.OutputStream.Write (ms.GetBuffer (), 0, (int) ms.Length);
index 863e71e8d3852c0ad9c274c1079b7331da285cb1..5119dfa6c1ce54e1881c23b780a919da9f550c93 100755 (executable)
@@ -1,3 +1,97 @@
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : ok, no need for conditional code path.
+
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AddressingVersion.cs : add fault action namespace.
+
+2010-03-26  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * HttpRequestChannel.cs: There is no WebHeaderCollection.Add 
+       method in SL API
+
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : pass IsFault argument in OnCreateBufferedCopy().
+
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestContext.cs, AspNetRequestContext.cs : return HTTP 500
+         for fault message.
+
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : create HttpResponseMessageProperty.
+
+2010-03-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestContext.cs : removed HTTP status rewriting for
+         commented reason.
+
+2010-03-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : handle only 4xx errors as to not process
+         content stream.
+
+2010-03-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageFault.cs : do not use SOAP11 namespace for fault contents.
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ReplyChannelBase.cs, HttpReplyChannel.cs : add some locking.
+         Patch by Matt Dargavel.
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpListenerManager.cs : use lock object which is subject to
+         change. Fix by Matt Dargavel.
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpListenerManager.cs : remove consumed HttpListenerContext from
+         the pending queue. Compare "wsdl" request in case insensitive
+         manner. Patch by Matt Dargavel.
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestContext.cs : apply the patch by Matt Dargavel, which is
+         supposed to provide detailed 400 error message.
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransactionFlowBindingElement.cs: revamp the previous change to
+         not regress regarding service metadata.
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelListenerBase.cs, TransactionFlowBindingElement.cs: fix 
+         GetProperty<T>() bug that fails to retrieve properties. (This may
+         be rewritten later if an ongoing change proposal is to take place.)
+
+2010-03-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ReliableSessionBindingElement.cs,
+         PrivacyNoticeBindingElement.cs,
+         RemoteEndpointMessageProperty.cs : added some missing types.
+
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeaders.cs :
+         why does it filter out most of the headers? kill it.
+
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SvcHttpHandler.cs, AspNetReplyChannel.cs, HttpChannelListener.cs,
+         HttpListenerManager.cs : refactoring on acquiring SvcHttpHandler
+         to not raise "not found" error (see bug #573795).
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * HttpRequestChannel.cs, HttpTransportBindingElement.cs: use
+       MOONLIGHT symbol to disambiguate MonoTouch and Moonlight code.
+
 2010-03-09  Atsushi Enomoto  <atsushi@ximian.com>
 
        * HttpListenerManager.cs : For ASP.NET, use correct GenericIdentity
index 1d3042b49ed2a0230438e0fba1103dbbfcb4c878..a932f68bf348da222ef7e9e11a30458276b3175a 100644 (file)
@@ -84,7 +84,7 @@ namespace System.ServiceModel.Channels
                        get { return timeouts.SendTimeout; }
                }
 
-               internal KeyedByTypeCollection<object> Properties {
+               internal virtual KeyedByTypeCollection<object> Properties {
                        get {
                                if (properties == null)
                                        properties = new KeyedByTypeCollection<object> ();
index bb268417eacc146fe9316dd4206a59324d0972d1..f88df1e7464e49a2d9f3da2965e0861df2768e2a 100644 (file)
@@ -79,10 +79,6 @@ namespace System.ServiceModel.Channels
                {
                }
 
-               internal SvcHttpHandler HttpHandler {
-                       get { return ((AspNetListenerManager) ListenerManager).Source; }
-               }
-
                protected override TChannel CreateChannel (TimeSpan timeout)
                {
                        if (typeof (TChannel) == typeof (IReplyChannel))
index 51b1272bef92368f1cd8bbadacdb2ec9549a6d78..14a2d54f831ce8abbeba46c5cf5f278547f51827 100644 (file)
@@ -212,12 +212,10 @@ namespace System.ServiceModel.Channels
                public AspNetListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager)
                        : base (channelListener, source, securityTokenManager)
                {
-                       http_handler = SvcHttpHandlerFactory.GetHandlerForListener (channelListener);
+                       http_handler = SvcHttpHandler.Current;
                }
 
-               public SvcHttpHandler Source {
-                       get { return http_handler; }
-               }
+               internal SvcHttpHandler HttpHandler { get { return http_handler; } }
 
                protected override void OnRegister (IChannelListener channelListener, TimeSpan timeout)
                {
@@ -334,6 +332,7 @@ namespace System.ServiceModel.Channels
                        lock (pending) {
                                foreach (var pctx in pending) {
                                        if (FilterHttpContext (pctx)) {
+                                               pending.Remove (pctx);
                                                callback (pctx);
                                                return;
                                        }
@@ -382,7 +381,7 @@ namespace System.ServiceModel.Channels
                                }
                        }
 
-                       lock (registered_channels) {
+                       lock (pending) {
                                pending.Add (ctx);
                                // FIXME: this should not be required, but it somehow saves some failures wrt concurrent calls.
                                Thread.Sleep (100);
@@ -406,7 +405,7 @@ namespace System.ServiceModel.Channels
                        if (wsdl_instance.WsdlUrl != null && Uri.Compare (ctx.RequestUrl, wsdl_instance.WsdlUrl, cmpflag, fmtflag, StringComparison.Ordinal) == 0) {
                                if (mex_info == null)
                                        return false; // Do not handle this at normal dispatcher.
-                               if (ctx.QueryString [null] == "wsdl")
+                               if (String.Compare (ctx.QueryString [null], "wsdl", StringComparison.OrdinalIgnoreCase) == 0)
                                        return mex_info.SupportsMex; // wsdl dispatcher should handle this.
                                if (!wsdl_instance.HelpUrl.Equals (wsdl_instance.WsdlUrl))
                                        return true; // in case help URL is not equivalent to WSDL URL, it anyways returns WSDL regardless of ?wsdl existence.
index 28a6fc7329296c3a8b450696fd7e56ea64920c01..41968d02a1fd7b07e9b7c21c26e8f1920f72af41 100644 (file)
@@ -197,7 +197,8 @@ w.Close ();
                                throw new InvalidOperationException ("WaitForRequest operation has not started");
                        var sctx = (HttpListenerContextInfo) ctx;
                        if (State == CommunicationState.Opened && ctx != null)
-                               waiting.Add (sctx.Source);
+                               lock (waiting)
+                                       waiting.Add (sctx.Source);
                        SignalAsyncWait ();
                }
        }
index 8e700f3c0c3c8092a708a112407d485565ab9fe5..e6d51181a11f3e360a618c014fe5106451b48e13 100644 (file)
@@ -93,7 +93,7 @@ namespace System.ServiceModel.Channels
                                ((HttpWebRequest) web_request).CookieContainer = cmgr.CookieContainer;
 #endif
 
-#if !NET_2_1 || MONOTOUCH // until we support NetworkCredential like SL4 will do.
+#if !MOONLIGHT // until we support NetworkCredential like SL4 will do.
                        // client authentication (while SL3 has NetworkCredential class, it is not implemented yet. So, it is non-SL only.)
                        var httpbe = (HttpTransportBindingElement) source.Transport;
                        string authType = null;
@@ -205,7 +205,7 @@ namespace System.ServiceModel.Channels
                        }
 
                        var hrr = (HttpWebResponse) res;
-                       if ((int) hrr.StatusCode >= 400) {
+                       if ((int) hrr.StatusCode >= 400 && (int) hrr.StatusCode < 500) {
                                channelResult.Complete (new WebException (String.Format ("There was an error on processing web request: Status code {0}({1}): {2}", (int) hrr.StatusCode, hrr.StatusCode, hrr.StatusDescription)));
                        }
 
@@ -223,9 +223,13 @@ namespace System.ServiceModel.Channels
                                        }
                                        ms.Seek (0, SeekOrigin.Begin);
 
-                                       channelResult.Response = Encoder.ReadMessage (
+                                       Message ret = Encoder.ReadMessage (
                                                //responseStream, MaxSizeOfHeaders);
                                                ms, MaxSizeOfHeaders, res.ContentType);
+                                       var rp = new HttpResponseMessageProperty () { StatusCode = hrr.StatusCode, StatusDescription = hrr.StatusDescription };
+                                       foreach (var key in hrr.Headers.AllKeys)
+                                               rp.Headers [key] = hrr.Headers [key];
+                                       ret.Properties.Add (HttpResponseMessageProperty.Name, rp);
 /*
 MessageBuffer buf = ret.CreateBufferedCopy (0x10000);
 ret = buf.CreateMessage ();
@@ -234,6 +238,7 @@ w.Formatting = System.Xml.Formatting.Indented;
 buf.CreateMessage ().WriteMessage (w);
 w.Close ();
 */
+                                       channelResult.Response = ret;
                                        channelResult.Complete ();
                                }
                        } catch (Exception ex) {
@@ -377,7 +382,7 @@ w.Close ();
                                        // FIXME: Do we need to use the timeout? If so, what happens when the timeout is reached.
                                        // Is the current request cancelled and an exception thrown? If so we need to pass the
                                        // exception to the Complete () method and allow the result to complete 'normally'.
-#if NET_2_1 || MONOTOUCH
+#if NET_2_1
                                        // neither Moonlight nor MonoTouch supports contexts (WaitOne default to false)
                                        bool result = wait.WaitOne (Timeout);
 #else
index 2919454e8be9b7213b74ff1f68934c8e8657eb64..4f3c424ecf3b6ef46b978f0e8b7bde3303ebc3d3 100644 (file)
@@ -56,18 +56,12 @@ namespace System.ServiceModel.Channels
                        if (msg == null)
                                throw new ArgumentNullException ("msg");
 
-                       // Handle DestinationUnreacheable as 400 (it is what .NET does).
-                       if (msg.IsFault) {
-                               // FIXME: isn't there any better way?
-                               var mb = msg.CreateBufferedCopy (0x10000);
-                               var fault = MessageFault.CreateFault (mb.CreateMessage (), 0x10000);
-                               if (fault.Code.Name == "DestinationUnreachable") {
-                                       ctx.Response.StatusCode = 400;
-                                       return;
-                               }
-                               else
-                                       msg = mb.CreateMessage ();
-                       }
+                       // FIXME: probably in WebHttpBinding land, there should 
+                       // be some additional code (probably IErrorHandler) that
+                       // treats DestinationUnreachable (and possibly any other)
+                       // errors as HTTP 400 or something appropriate. 
+                       // I originally rewrote the HTTP status here, but it 
+                       // was wrong.
 
                        // FIXME: should this be done here?
                        if (channel.MessageVersion.Addressing.Equals (AddressingVersion.None))
@@ -91,6 +85,8 @@ namespace System.ServiceModel.Channels
                                if (hp.SuppressEntityBody)
                                        suppressEntityBody = true;
                        }
+                       if (msg.IsFault)
+                               ctx.Response.StatusCode = 500;
                        if (!suppressEntityBody) {
                                ctx.Response.ContentLength64 = ms.Length;
                                ctx.Response.OutputStream.Write (ms.GetBuffer (), 0, (int) ms.Length);
index 977243d1430feb7d9842729f1feb1eb22e31ce16..3c229390d63e4a7d4d813490b9adc300bd40b69b 100644 (file)
@@ -47,7 +47,7 @@ namespace System.ServiceModel.Channels
                string realm = String.Empty;
                TransferMode transfer_mode;
                IDefaultCommunicationTimeouts timeouts;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                AuthenticationSchemes auth_scheme =
                        AuthenticationSchemes.Anonymous;
                AuthenticationSchemes proxy_auth_scheme =
@@ -75,13 +75,13 @@ namespace System.ServiceModel.Channels
                        transfer_mode = other.transfer_mode;
                        // FIXME: it does not look safe
                        timeouts = other.timeouts;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        auth_scheme = other.auth_scheme;
                        proxy_auth_scheme = other.proxy_auth_scheme;
 #endif
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public AuthenticationSchemes AuthenticationScheme {
                        get { return auth_scheme; }
                        set { auth_scheme = value; }
index 727667df90c1a0d430f75a0f5c6d1cc72b4cac13..90d84cee768aa3c5fdb70f7f0b87b18efb91a8b8 100644 (file)
@@ -362,7 +362,7 @@ namespace System.ServiceModel.Channels
                        EnvelopeVersion version, FaultCode code)
                {
                        if (version == EnvelopeVersion.Soap11) {
-                               writer.WriteStartElement ("", "faultcode", version.Namespace);
+                               writer.WriteStartElement ("", "faultcode", String.Empty);
                                if (code.Namespace.Length > 0)
                                        writer.WriteXmlnsAttribute ("a", code.Namespace);
                                writer.WriteQualifiedName (code.Name, code.Namespace);
@@ -385,7 +385,7 @@ namespace System.ServiceModel.Channels
                {
                        if (version == EnvelopeVersion.Soap11) {
                                foreach (FaultReasonText t in Reason.Translations) {
-                                       writer.WriteStartElement ("", "faultstring", version.Namespace);
+                                       writer.WriteStartElement ("", "faultstring", String.Empty);
                                        if (t.XmlLang != null)
                                                writer.WriteAttributeString ("xml", "lang", null, t.XmlLang);
                                        writer.WriteString (t.Text);
index 8b9016b622a1690ed576c7247b43809de11c9e7f..6b56c88d59f2ffdc948fbdc284bb75f2505c5c9f 100644 (file)
@@ -267,15 +267,6 @@ namespace System.ServiceModel.Channels
                {
                        if (version.Envelope == EnvelopeVersion.None)
                                return;
-
-                       // For AddressingVersion.None, don't output the item.
-                       //
-                       // FIXME: It should even ignore Action, but for now
-                       // service dispatcher won't work without it.
-                       if (version.Addressing == AddressingVersion.None &&
-                           l [index].Name != "Action")
-                               return;
-
                        WriteStartHeader (index, writer);
                        WriteHeaderContents (index, writer);
                        writer.WriteEndElement ();
index b3ca10f349156300dbdca0ccb64c10729f4cf900..6c8cd8fd11eca3c8bb5054e4b8f7440f923e91c9 100644 (file)
@@ -261,7 +261,7 @@ namespace System.ServiceModel.Channels
                {
                        var headers = new MessageHeaders (Headers);
                        var props = new MessageProperties (Properties);
-                       return new DefaultMessageBuffer (maxBufferSize, headers, props, body.CreateBufferedCopy (maxBufferSize), false);
+                       return new DefaultMessageBuffer (maxBufferSize, headers, props, body.CreateBufferedCopy (maxBufferSize), IsFault);
                }
        }
 }
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/PrivacyNoticeBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/PrivacyNoticeBindingElement.cs
new file mode 100644 (file)
index 0000000..d1e1e5b
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// PrivacyNoticeBindingElement.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class PrivacyNoticeBindingElement : BindingElement, IPolicyExportExtension
+       {
+               public PrivacyNoticeBindingElement ()
+               {
+                       // FIXME: apply configuration
+               }
+
+               public PrivacyNoticeBindingElement (PrivacyNoticeBindingElement elementToBeCloned)
+               {
+                       var e = elementToBeCloned;
+                       Url = e.Url;
+                       Version = e.Version;
+               }
+
+               [MonoTODO]
+               public Uri Url { get; set; }
+               [MonoTODO]
+               public int Version { get; set; }
+
+               public override BindingElement Clone ()
+               {
+                       return new PrivacyNoticeBindingElement (this);
+               }
+
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       return context.GetInnerProperty<T> ();
+               }
+
+               void IPolicyExportExtension.ExportPolicy (MetadataExporter exporter, PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReliableSessionBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReliableSessionBindingElement.cs
new file mode 100644 (file)
index 0000000..2a45cbd
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// ReliableSessionBindingElement.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class ReliableSessionBindingElement : BindingElement, IPolicyExportExtension
+       {
+               public ReliableSessionBindingElement ()
+               {
+                       // FIXME: apply configuration
+               }
+
+               public ReliableSessionBindingElement (bool ordered)
+                       : this ()
+               {
+                       Ordered = ordered;
+               }
+
+               [MonoTODO]
+               public TimeSpan AcknowledgementInterval { get; set; }
+               [MonoTODO]
+               public bool FlowControlEnabled { get; set; }
+               [MonoTODO]
+               public TimeSpan InactivityTimeout { get; set; }
+               [MonoTODO]
+               public int MaxPendingChannels { get; set; }
+               [MonoTODO]
+               public int MaxRetryCount { get; set; }
+               [MonoTODO]
+               public int MaxTransferWindowSize { get; set; }
+               [MonoTODO]
+               public bool Ordered { get; set; }
+               [MonoTODO]
+               public ReliableMessagingVersion ReliableMessagingVersion { get; set; }
+
+               [MonoTODO]
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelListener<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return (ReliableSessionBindingElement) MemberwiseClone ();
+               }
+
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IPolicyExportExtension.ExportPolicy (MetadataExporter exporter, PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/RemoteEndpointMessageProperty.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/RemoteEndpointMessageProperty.cs
new file mode 100644 (file)
index 0000000..df95178
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// RemoteEndpointMessageProperty.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class RemoteEndpointMessageProperty
+       {
+               public static string Name {
+                       get { return "System.ServiceModel.Channels.RemoteEndpointMessageProperty"; }
+               }
+
+               public RemoteEndpointMessageProperty (string address, int port)
+               {
+                       Address = address;
+                       Port = port;
+               }
+
+               public string Address { get; private set; }
+               public int Port { get; private set; }
+       }
+}
index 580545f703f6385eb4a2b74cce4366bf11f01707..9bef1913b1aca6f9abe60f57db5666a13f36f5ad 100644 (file)
@@ -106,6 +106,7 @@ namespace System.ServiceModel.Channels
                delegate bool TryReceiveDelegate (TimeSpan timeout, out RequestContext context);
                TryReceiveDelegate try_recv_delegate;
 
+               object async_result_lock = new object ();
                protected Thread CurrentAsyncThread { get; private set; }
                protected IAsyncResult CurrentAsyncResult { get; private set; }
 
@@ -115,18 +116,26 @@ namespace System.ServiceModel.Channels
                                throw new InvalidOperationException ("Another async TryReceiveRequest operation is in progress");
                        if (try_recv_delegate == null)
                                try_recv_delegate = new TryReceiveDelegate (delegate (TimeSpan tout, out RequestContext ctx) {
-                                       if (CurrentAsyncResult != null)
-                                               CurrentAsyncThread = Thread.CurrentThread;
+                                       lock (async_result_lock) {
+                                               if (CurrentAsyncResult != null)
+                                                       CurrentAsyncThread = Thread.CurrentThread;
+                                       }
                                        try {
                                                return TryReceiveRequest (tout, out ctx);
                                        } finally {
-                                               CurrentAsyncResult = null;
-                                               CurrentAsyncThread = null;
+                                               lock (async_result_lock) {
+                                                       CurrentAsyncResult = null;
+                                                       CurrentAsyncThread = null;
+                                               }
                                        }
                                        });
                        RequestContext dummy;
-                       CurrentAsyncResult = try_recv_delegate.BeginInvoke (timeout, out dummy, callback, state);
-                       return CurrentAsyncResult;
+                       IAsyncResult result;
+                       lock (async_result_lock) {
+                               result = CurrentAsyncResult = try_recv_delegate.BeginInvoke (timeout, out dummy, callback, state);
+                       }
+                       // Note that at this point CurrentAsyncResult can be null here if delegate has run to completion
+                       return result;
                }
 
                public virtual bool EndTryReceiveRequest (IAsyncResult result)
index 413650ba3eba8c874975e1c9549d1b2174f6842f..161b3f476b45c37473abf35b1d2fa69844a6ac3a 100644 (file)
@@ -63,6 +63,8 @@ namespace System.ServiceModel.Channels {
 
        internal class SvcHttpHandler : IHttpHandler
        {
+               internal static SvcHttpHandler Current;
+
                static object type_lock = new object ();
 
                Type type;
@@ -135,7 +137,9 @@ namespace System.ServiceModel.Channels {
                                if (best == null)
                                        best = l;
                        }
-                       return best;
+                       if (best != null)
+                               return best;
+                       throw new InvalidOperationException (String.Format ("The argument HTTP context did not match any of the registered listener manager (could be mismatch in URL, method etc.) {0}", ctx.Request.Url));
 /*
                        var actx = new AspNetHttpContextInfo (ctx);
                        foreach (var i in listeners)
@@ -194,7 +198,17 @@ namespace System.ServiceModel.Channels {
                void EnsureServiceHost ()
                {
                        lock (type_lock) {
+                               Current = this;
+                               try {
+                                       EnsureServiceHostCore ();
+                               } finally {
+                                       Current = null;
+                               }
+                       }
+               }
 
+               void EnsureServiceHostCore ()
+               {
                        if (host != null)
                                return;
 
@@ -211,8 +225,6 @@ namespace System.ServiceModel.Channels {
 
                        // Not precise, but it needs some wait time to have all channels start requesting. And it is somehow required.
                        Thread.Sleep (500);
-
-                       }
                }
        }
 }
index 9324471fa949b58416ce9be91615240148355365..d753c885f3e19c21d6db2f85ce329807ae097e6f 100644 (file)
@@ -161,6 +161,11 @@ namespace System.ServiceModel.Channels
                        this.protocol = protocol;
                }
 
+               public override T GetProperty<T> ()
+               {
+                       return inner_listener.GetProperty<T> () ?? base.GetProperty<T> ();
+               }
+
                public override Uri Uri {
                        get { return inner_listener.Uri; }
                }
index 756dae16d18528f31d2f0170ae744668b52da1f2..6e691a574073c863666c176b2d85ac6c17b60542 100755 (executable)
@@ -1,3 +1,45 @@
+2010-03-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ConnectionOrientedTransportElement.cs, StandardBindingElement.cs, 
+         LocalClientSecuritySettingsElement.cs, CustomBindingElement.cs:
+         add couple of missing methods and TypeConverterAttributes.
+
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceMetadataPublishingElement.cs : use IsNullOrEmpty(), names
+         could be "" which is equivalent to null here.
+
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ConfigUtil.cs, StandardBindingCollectionElement.cs,
+         MexHttpsBindingCollectionElement.cs,
+         MexHttpBindingCollectionElement.cs : use GetDefault() in
+         BindingCollectionElement to create a Binding, instead of activator
+         immediately. And for mex bindings, use MetadataExchangeBindings.
+
+2010-03-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TcpTransportElement.cs
+         MsmqIntegrationElement.cs
+         MsmqElementBase.cs
+         NamedPipeTransportElement.cs
+         HttpsTransportElement.cs
+         TransportElement.cs
+         MsmqTransportElement.cs
+         HttpTransportElement.cs : implement missing methods.
+
+2010-03-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedTokenClientElement.cs, MsmqBindingElementBase.cs,
+         NamedPipeConnectionPoolSettingsElement.cs,
+         TcpConnectionPoolSettingsElement.cs,
+         StandardBindingReliableSessionElement.cs,
+         LocalServiceSecuritySettingsElement.cs : use TimeSpanConverter.
+
+2010-03-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceDebugElement.cs : binding names could rather be empty.
+
 2010-03-09  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlDictionaryReaderQuotasElement.cs : add ApplyConfiguration().
index 360fe8cf05f7933eaedc15f3d243cfae24b859c0..ba23d85f08e97240b473a31321dfb6f982297d74 100644 (file)
@@ -74,7 +74,7 @@ namespace System.ServiceModel.Configuration
                        if (section == null)
                                throw new ArgumentException (String.Format ("binding section for {0} was not found.", binding));
 
-                       Binding b = (Binding) Activator.CreateInstance (section.BindingType, new object [0]);
+                       Binding b = section.GetDefault ();
 
                        foreach (IBindingConfigurationElement el in section.ConfiguredBindings)
                                if (el.Name == bindingConfiguration)
index 59c9bb259f00559a7197237dfe5e99da2e52ff73..5ec8e8dde055f1da4a64f6ea50d7de1b4053bee7 100644 (file)
@@ -59,7 +59,8 @@ namespace System.ServiceModel.Configuration
        {
                ConfigurationPropertyCollection _properties;
 
-               protected ConnectionOrientedTransportElement () {
+               internal ConnectionOrientedTransportElement ()
+               {
                }
 
                // Properties
@@ -67,6 +68,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("channelInitializationTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:00:05")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan ChannelInitializationTimeout {
                        get { return (TimeSpan) base ["channelInitializationTimeout"]; }
                        set { base ["channelInitializationTimeout"] = value; }
@@ -105,6 +107,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("maxOutputDelay",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:00:00.2")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan MaxOutputDelay {
                        get { return (TimeSpan) base ["maxOutputDelay"]; }
                        set { base ["maxOutputDelay"] = value; }
@@ -157,7 +160,44 @@ namespace System.ServiceModel.Configuration
                        set { base ["transferMode"] = value; }
                }
 
+               public override void ApplyConfiguration (BindingElement bindingElement)
+               {
+                       var e = (ConnectionOrientedTransportBindingElement) bindingElement;
+                       e.ChannelInitializationTimeout = ChannelInitializationTimeout;
+                       e.ConnectionBufferSize = ConnectionBufferSize;
+                       e.HostNameComparisonMode = HostNameComparisonMode;
+                       e.MaxBufferSize = MaxBufferSize;
+                       e.MaxOutputDelay = MaxOutputDelay;
+                       e.MaxPendingAccepts = MaxPendingAccepts;
+                       e.MaxPendingConnections = MaxPendingConnections;
+                       e.TransferMode = TransferMode;
+               }
+
+               public override void CopyFrom (ServiceModelExtensionElement from)
+               {
+                       var e = (ConnectionOrientedTransportElement) from;
+                       ChannelInitializationTimeout = e.ChannelInitializationTimeout;
+                       ConnectionBufferSize = e.ConnectionBufferSize;
+                       HostNameComparisonMode = e.HostNameComparisonMode;
+                       MaxBufferSize = e.MaxBufferSize;
+                       MaxOutputDelay = e.MaxOutputDelay;
+                       MaxPendingAccepts = e.MaxPendingAccepts;
+                       MaxPendingConnections = e.MaxPendingConnections;
+                       TransferMode = e.TransferMode;
+               }
 
+               protected internal override void InitializeFrom (BindingElement bindingElement)
+               {
+                       var e = (ConnectionOrientedTransportBindingElement) bindingElement;
+                       ChannelInitializationTimeout = e.ChannelInitializationTimeout;
+                       ConnectionBufferSize = e.ConnectionBufferSize;
+                       HostNameComparisonMode = e.HostNameComparisonMode;
+                       MaxBufferSize = e.MaxBufferSize;
+                       MaxOutputDelay = e.MaxOutputDelay;
+                       MaxPendingAccepts = e.MaxPendingAccepts;
+                       MaxPendingConnections = e.MaxPendingConnections;
+                       TransferMode = e.TransferMode;
+               }
        }
 
 }
index afa1dd0c09e6486b2dc6a8793a45057bb8e0ef05..ccf763505ed8b86aa2fccc30b957795aea6ed298 100644 (file)
@@ -72,6 +72,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("closeTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:01:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan CloseTimeout {
                        get { return (TimeSpan) base ["closeTimeout"]; }
                        set { base ["closeTimeout"] = value; }
@@ -80,6 +81,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("openTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:01:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan OpenTimeout {
                        get { return (TimeSpan) base ["openTimeout"]; }
                        set { base ["openTimeout"] = value; }
@@ -101,6 +103,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("receiveTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:10:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan ReceiveTimeout {
                        get { return (TimeSpan) base ["receiveTimeout"]; }
                        set { base ["receiveTimeout"] = value; }
@@ -109,14 +112,27 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("sendTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:01:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan SendTimeout {
                        get { return (TimeSpan) base ["sendTimeout"]; }
                        set { base ["sendTimeout"] = value; }
                }
 
-               [MonoTODO]
-               public void ApplyConfiguration (Binding binding) {
-                       throw new NotImplementedException ();
+               [MonoTODO ("what to reject?")]
+               public override void Add (BindingElementExtensionElement element)
+               {
+                       base.Add (element);
+               }
+
+               [MonoTODO ("what to reject?")]
+               public override bool CanAdd (BindingElementExtensionElement element)
+               {
+                       return true;
+               }
+
+               public void ApplyConfiguration (Binding binding)
+               {
+                       OnApplyConfiguration (binding);
                }
 
                [MonoTODO ("implement using EvaluationContext")]
@@ -133,6 +149,19 @@ namespace System.ServiceModel.Configuration
                        return element;
                }
 
+               protected void OnApplyConfiguration (Binding binding)
+               {
+                       if (binding == null)
+                               throw new ArgumentNullException ("binding");
+                       var b = (CustomBinding) binding;
+                       b.CloseTimeout = CloseTimeout;
+                       b.OpenTimeout = OpenTimeout;
+                       b.ReceiveTimeout = ReceiveTimeout;
+                       b.SendTimeout = SendTimeout;
+
+                       foreach (var be in this)
+                               b.Elements.Add (be.CreateBindingElement ());
+               }
        }
 
 }
index 2412b52d9bc3646cd54422e15e9eea4d1af69767..1933d25a0e805b07a76f1a253c699be5edba244c 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2006,2010 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -192,12 +192,64 @@ namespace System.ServiceModel.Configuration
                        set { base ["useDefaultWebProxy"] = value; }
                }
 
-
-               [MonoTODO]
-               protected internal override BindingElement CreateBindingElement () {
-                       throw new NotImplementedException ();
+               public override void ApplyConfiguration (BindingElement bindingElement)
+               {
+                       var b = (HttpTransportBindingElement) bindingElement;
+                       base.ApplyConfiguration (b);
+                       b.AllowCookies = AllowCookies;
+                       b.AuthenticationScheme = AuthenticationScheme;
+                       b.BypassProxyOnLocal = BypassProxyOnLocal;
+                       b.HostNameComparisonMode = HostNameComparisonMode;
+                       b.KeepAliveEnabled = KeepAliveEnabled;
+                       b.MaxBufferSize = MaxBufferSize;
+                       b.ProxyAddress = ProxyAddress;
+                       b.ProxyAuthenticationScheme = ProxyAuthenticationScheme;
+                       b.Realm = Realm;
+                       b.TransferMode = TransferMode;
+                       b.UnsafeConnectionNtlmAuthentication = UnsafeConnectionNtlmAuthentication;
+                       b.UseDefaultWebProxy = UseDefaultWebProxy;
+               }
+
+               public override void CopyFrom (ServiceModelExtensionElement from)
+               {
+                       var e = (HttpTransportElement) from;
+                       base.CopyFrom (from);
+                       AllowCookies = e.AllowCookies;
+                       AuthenticationScheme = e.AuthenticationScheme;
+                       BypassProxyOnLocal = e.BypassProxyOnLocal;
+                       HostNameComparisonMode = e.HostNameComparisonMode;
+                       KeepAliveEnabled = e.KeepAliveEnabled;
+                       MaxBufferSize = e.MaxBufferSize;
+                       ProxyAddress = e.ProxyAddress;
+                       ProxyAuthenticationScheme = e.ProxyAuthenticationScheme;
+                       Realm = e.Realm;
+                       TransferMode = e.TransferMode;
+                       UnsafeConnectionNtlmAuthentication = e.UnsafeConnectionNtlmAuthentication;
+                       UseDefaultWebProxy = e.UseDefaultWebProxy;
+               }
+
+               protected override TransportBindingElement CreateDefaultBindingElement ()
+               {
+                       return new HttpTransportBindingElement ();
+               }
+
+               protected internal override void InitializeFrom (BindingElement bindingElement)
+               {
+                       var b = (HttpTransportBindingElement) bindingElement;
+                       base.InitializeFrom (b);
+                       AllowCookies = b.AllowCookies;
+                       AuthenticationScheme = b.AuthenticationScheme;
+                       BypassProxyOnLocal = b.BypassProxyOnLocal;
+                       HostNameComparisonMode = b.HostNameComparisonMode;
+                       KeepAliveEnabled = b.KeepAliveEnabled;
+                       MaxBufferSize = b.MaxBufferSize;
+                       ProxyAddress = b.ProxyAddress;
+                       ProxyAuthenticationScheme = b.ProxyAuthenticationScheme;
+                       Realm = b.Realm;
+                       TransferMode = b.TransferMode;
+                       UnsafeConnectionNtlmAuthentication = b.UnsafeConnectionNtlmAuthentication;
+                       UseDefaultWebProxy = b.UseDefaultWebProxy;
                }
-
        }
 
 }
index c844e56dc940dbd4a5dd0f3d0a1f8267046e37b4..a2de9b7555085f7333de6aa23d16a56ce93d99a2 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2006,2010 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -87,7 +87,31 @@ namespace System.ServiceModel.Configuration
                        set { base ["requireClientCertificate"] = value; }
                }
 
+               public override void ApplyConfiguration (BindingElement bindingElement)
+               {
+                       var b = (HttpsTransportBindingElement) bindingElement;
+                       base.ApplyConfiguration (b);
+                       b.RequireClientCertificate = RequireClientCertificate;
+               }
+
+               public override void CopyFrom (ServiceModelExtensionElement from)
+               {
+                       var e = (HttpsTransportElement) from;
+                       base.CopyFrom (from);
+                       RequireClientCertificate = e.RequireClientCertificate;
+               }
 
+               protected override TransportBindingElement CreateDefaultBindingElement ()
+               {
+                       return new HttpsTransportBindingElement ();
+               }
+
+               protected internal override void InitializeFrom (BindingElement bindingElement)
+               {
+                       var b = (HttpsTransportBindingElement) bindingElement;
+                       base.InitializeFrom (b);
+                       RequireClientCertificate = b.RequireClientCertificate;
+               }
        }
 
 }
index 064d26ceb164fa276080e79f5282af68d0a0beb9..a6d8f55d8c35e7374c5d7323468b1bb6ce00d939 100644 (file)
@@ -96,7 +96,7 @@ namespace System.ServiceModel.Configuration
                                ConfigurationPropertyOptions.None);
 
                        max_issued_token_caching_time = new ConfigurationProperty ("maxIssuedTokenCachingTime",
-                               typeof (TimeSpan), "10675199.02:48:05.4775807", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "10675199.02:48:05.4775807", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        properties.Add (cache_issued_tokens);
@@ -168,6 +168,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("maxIssuedTokenCachingTime",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "10675199.02:48:05.4775807")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan MaxIssuedTokenCachingTime {
                        get { return (TimeSpan) base [max_issued_token_caching_time]; }
                        set { base [max_issued_token_caching_time] = value; }
index c0dce430f196af6564b33716d950adaa3fb5306c..9055f054906b5d8caef822a8ae25628f926a36b1 100644 (file)
@@ -94,6 +94,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("maxClockSkew",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:05:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan MaxClockSkew {
                        get { return (TimeSpan) base ["maxClockSkew"]; }
                        set { base ["maxClockSkew"] = value; }
@@ -102,6 +103,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("maxCookieCachingTime",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "10675199.02:48:05.4775807")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan MaxCookieCachingTime {
                        get { return (TimeSpan) base ["maxCookieCachingTime"]; }
                        set { base ["maxCookieCachingTime"] = value; }
@@ -133,6 +135,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("replayWindow",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:05:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan ReplayWindow {
                        get { return (TimeSpan) base ["replayWindow"]; }
                        set { base ["replayWindow"] = value; }
@@ -141,6 +144,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("sessionKeyRenewalInterval",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "10:00:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan SessionKeyRenewalInterval {
                        get { return (TimeSpan) base ["sessionKeyRenewalInterval"]; }
                        set { base ["sessionKeyRenewalInterval"] = value; }
@@ -157,6 +161,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("timestampValidityDuration",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:05:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan TimestampValidityDuration {
                        get { return (TimeSpan) base ["timestampValidityDuration"]; }
                        set { base ["timestampValidityDuration"] = value; }
index 99d7649518eb8d9e8e6f84eb3aa55a93c18c4e3f..cf4bc33dc381c79cae7e5b02d50ef1bdd018cd9b 100644 (file)
@@ -83,11 +83,11 @@ namespace System.ServiceModel.Configuration
                                ConfigurationPropertyOptions.None);
 
                        inactivity_timeout = new ConfigurationProperty ("inactivityTimeout",
-                               typeof (TimeSpan), "00:02:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:02:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        issued_cookie_lifetime = new ConfigurationProperty ("issuedCookieLifetime",
-                               typeof (TimeSpan), "10:00:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "10:00:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        max_cached_cookies = new ConfigurationProperty ("maxCachedCookies",
@@ -95,7 +95,7 @@ namespace System.ServiceModel.Configuration
                                ConfigurationPropertyOptions.None);
 
                        max_clock_skew = new ConfigurationProperty ("maxClockSkew",
-                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:05:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        max_pending_sessions = new ConfigurationProperty ("maxPendingSessions",
@@ -107,7 +107,7 @@ namespace System.ServiceModel.Configuration
                                ConfigurationPropertyOptions.None);
 
                        negotiation_timeout = new ConfigurationProperty ("negotiationTimeout",
-                               typeof (TimeSpan), "00:01:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:01:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        reconnect_transport_on_failure = new ConfigurationProperty ("reconnectTransportOnFailure",
@@ -119,19 +119,19 @@ namespace System.ServiceModel.Configuration
                                ConfigurationPropertyOptions.None);
 
                        replay_window = new ConfigurationProperty ("replayWindow",
-                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:05:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        session_key_renewal_interval = new ConfigurationProperty ("sessionKeyRenewalInterval",
-                               typeof (TimeSpan), "15:00:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "15:00:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        session_key_rollover_interval = new ConfigurationProperty ("sessionKeyRolloverInterval",
-                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:05:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        timestamp_validity_duration = new ConfigurationProperty ("timestampValidityDuration",
-                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:05:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        properties.Add (detect_replays);
@@ -168,6 +168,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("inactivityTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:02:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan InactivityTimeout {
                        get { return (TimeSpan) base [inactivity_timeout]; }
                        set { base [inactivity_timeout] = value; }
@@ -176,6 +177,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("issuedCookieLifetime",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "10:00:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan IssuedCookieLifetime {
                        get { return (TimeSpan) base [issued_cookie_lifetime]; }
                        set { base [issued_cookie_lifetime] = value; }
@@ -195,6 +197,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("maxClockSkew",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:05:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan MaxClockSkew {
                        get { return (TimeSpan) base [max_clock_skew]; }
                        set { base [max_clock_skew] = value; }
@@ -225,6 +228,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("negotiationTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:01:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan NegotiationTimeout {
                        get { return (TimeSpan) base [negotiation_timeout]; }
                        set { base [negotiation_timeout] = value; }
@@ -256,6 +260,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("replayWindow",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:05:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan ReplayWindow {
                        get { return (TimeSpan) base [replay_window]; }
                        set { base [replay_window] = value; }
@@ -264,6 +269,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("sessionKeyRenewalInterval",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "15:00:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan SessionKeyRenewalInterval {
                        get { return (TimeSpan) base [session_key_renewal_interval]; }
                        set { base [session_key_renewal_interval] = value; }
@@ -272,6 +278,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("sessionKeyRolloverInterval",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:05:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan SessionKeyRolloverInterval {
                        get { return (TimeSpan) base [session_key_rollover_interval]; }
                        set { base [session_key_rollover_interval] = value; }
@@ -280,6 +287,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("timestampValidityDuration",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:05:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan TimestampValidityDuration {
                        get { return (TimeSpan) base [timestamp_validity_duration]; }
                        set { base [timestamp_validity_duration] = value; }
index d9d252e28291590fa291c0e60a51538f86b8ae58..c97a174c2b8347a3f19621f29029bb605c9910b2 100644 (file)
@@ -54,7 +54,6 @@ using System.Xml;
 
 namespace System.ServiceModel.Configuration
 {
-       [MonoTODO]
        public partial class MexHttpBindingCollectionElement
                 : MexBindingBindingCollectionElement<WSHttpBinding, MexHttpBindingElement>
        {
@@ -70,10 +69,10 @@ namespace System.ServiceModel.Configuration
                {
                }
 
-
-               // Properties
-
-
+               protected internal override Binding GetDefault ()
+               {
+                       return MetadataExchangeBindings.CreateMexHttpBinding ();
+               }
        }
 
 }
index 09eaf398e30b2934e5636c77c4e579852c3594b2..d7288f40f11937f788600e0bd771c80c7c73443c 100644 (file)
@@ -54,7 +54,6 @@ using System.Xml;
 
 namespace System.ServiceModel.Configuration
 {
-       [MonoTODO]
        public partial class MexHttpsBindingCollectionElement
                 : MexBindingBindingCollectionElement<WSHttpBinding, MexHttpsBindingElement>
        {
@@ -70,10 +69,10 @@ namespace System.ServiceModel.Configuration
                {
                }
 
-
-               // Properties
-
-
+               protected internal override Binding GetDefault ()
+               {
+                       return MetadataExchangeBindings.CreateMexHttpsBinding ();
+               }
        }
 
 }
index d4f5d86d72be26e76b1bac9e270de4d2a450af3d..a88ce844e65c2fcbd0e5de3e69f5e68ba5863a85 100644 (file)
@@ -109,11 +109,11 @@ namespace System.ServiceModel.Configuration
                                ConfigurationPropertyOptions.None);
 
                        retry_cycle_delay = new ConfigurationProperty ("retryCycleDelay",
-                               typeof (TimeSpan), "00:30:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:30:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        time_to_live = new ConfigurationProperty ("timeToLive",
-                               typeof (TimeSpan), "1.00:00:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "1.00:00:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        use_msmq_tracing = new ConfigurationProperty ("useMsmqTracing",
@@ -225,6 +225,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("retryCycleDelay",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:30:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan RetryCycleDelay {
                        get { return (TimeSpan) base [retry_cycle_delay]; }
                        set { base [retry_cycle_delay] = value; }
@@ -233,6 +234,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("timeToLive",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "1.00:00:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan TimeToLive {
                        get { return (TimeSpan) base [time_to_live]; }
                        set { base [time_to_live] = value; }
index 81d05957c9ff69827a3be519c150f44ec663f193..1ad2b2a1f3fec7ab8eef2106f3b6f10e2f273fdb 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2006,2010 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -186,7 +186,77 @@ namespace System.ServiceModel.Configuration
                        set { base ["useSourceJournal"] = value; }
                }
 
+               public override void ApplyConfiguration (BindingElement bindingElement)
+               {
+                       var b = (System.ServiceModel.Channels.MsmqBindingElementBase) bindingElement;
+                       base.ApplyConfiguration (b);
+                       b.CustomDeadLetterQueue = CustomDeadLetterQueue;
+                       b.DeadLetterQueue = DeadLetterQueue;
+                       b.Durable = Durable;
+                       b.ExactlyOnce = ExactlyOnce;
+                       b.MaxRetryCycles = MaxRetryCycles;
+                       b.ReceiveErrorHandling = ReceiveErrorHandling;
+                       b.ReceiveRetryCount = ReceiveRetryCount;
+                       b.RetryCycleDelay = RetryCycleDelay;
+                       b.TimeToLive = TimeToLive;
+                       b.UseMsmqTracing = UseMsmqTracing;
+                       b.UseSourceJournal = UseSourceJournal;
 
+                       var bs = b.MsmqTransportSecurity;
+                       var cs = MsmqTransportSecurity;
+                       bs.MsmqAuthenticationMode = cs.MsmqAuthenticationMode;
+                       bs.MsmqEncryptionAlgorithm = cs.MsmqEncryptionAlgorithm;
+                       bs.MsmqProtectionLevel = cs.MsmqProtectionLevel;
+                       bs.MsmqSecureHashAlgorithm = cs.MsmqSecureHashAlgorithm;
+               }
+
+               public override void CopyFrom (ServiceModelExtensionElement from)
+               {
+                       var e = (MsmqElementBase) from;
+                       base.CopyFrom (from);
+                       CustomDeadLetterQueue = e.CustomDeadLetterQueue;
+                       DeadLetterQueue = e.DeadLetterQueue;
+                       Durable = e.Durable;
+                       ExactlyOnce = e.ExactlyOnce;
+                       MaxRetryCycles = e.MaxRetryCycles;
+                       ReceiveErrorHandling = e.ReceiveErrorHandling;
+                       ReceiveRetryCount = e.ReceiveRetryCount;
+                       RetryCycleDelay = e.RetryCycleDelay;
+                       TimeToLive = e.TimeToLive;
+                       UseMsmqTracing = e.UseMsmqTracing;
+                       UseSourceJournal = e.UseSourceJournal;
+
+                       var es = e.MsmqTransportSecurity;
+                       var cs = MsmqTransportSecurity;
+                       cs.MsmqAuthenticationMode = es.MsmqAuthenticationMode;
+                       cs.MsmqEncryptionAlgorithm = es.MsmqEncryptionAlgorithm;
+                       cs.MsmqProtectionLevel = es.MsmqProtectionLevel;
+                       cs.MsmqSecureHashAlgorithm = es.MsmqSecureHashAlgorithm;
+               }
+
+               protected internal override void InitializeFrom (BindingElement bindingElement)
+               {
+                       var b = (System.ServiceModel.Channels.MsmqBindingElementBase) bindingElement;
+                       base.InitializeFrom (b);
+                       CustomDeadLetterQueue = b.CustomDeadLetterQueue;
+                       DeadLetterQueue = b.DeadLetterQueue;
+                       Durable = b.Durable;
+                       ExactlyOnce = b.ExactlyOnce;
+                       MaxRetryCycles = b.MaxRetryCycles;
+                       ReceiveErrorHandling = b.ReceiveErrorHandling;
+                       ReceiveRetryCount = b.ReceiveRetryCount;
+                       RetryCycleDelay = b.RetryCycleDelay;
+                       TimeToLive = b.TimeToLive;
+                       UseMsmqTracing = b.UseMsmqTracing;
+                       UseSourceJournal = b.UseSourceJournal;
+
+                       var bs = b.MsmqTransportSecurity;
+                       var cs = MsmqTransportSecurity;
+                       cs.MsmqAuthenticationMode = bs.MsmqAuthenticationMode;
+                       cs.MsmqEncryptionAlgorithm = bs.MsmqEncryptionAlgorithm;
+                       cs.MsmqProtectionLevel = bs.MsmqProtectionLevel;
+                       cs.MsmqSecureHashAlgorithm = bs.MsmqSecureHashAlgorithm;
+               }
        }
 
 }
index 06876fdac3de3793dce577fa6d86d83d2658aabf..f1acfbd36df07f603adee7998ded6c8fea25f9d8 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2006,2010 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -86,12 +86,31 @@ namespace System.ServiceModel.Configuration
                        set { base ["serializationFormat"] = value; }
                }
 
+               public override void ApplyConfiguration (BindingElement bindingElement)
+               {
+                       var b = (System.ServiceModel.MsmqIntegration.MsmqIntegrationBindingElement) bindingElement;
+                       base.ApplyConfiguration (b);
+                       b.SerializationFormat = SerializationFormat;
+               }
+
+               public override void CopyFrom (ServiceModelExtensionElement from)
+               {
+                       var e = (MsmqIntegrationElement) from;
+                       base.CopyFrom (from);
+                       SerializationFormat = e.SerializationFormat;
+               }
 
-               [MonoTODO]
-               protected internal override BindingElement CreateBindingElement () {
-                       throw new NotImplementedException ();
+               protected override TransportBindingElement CreateDefaultBindingElement ()
+               {
+                       return new System.ServiceModel.MsmqIntegration.MsmqIntegrationBindingElement ();
                }
 
+               protected internal override void InitializeFrom (BindingElement bindingElement)
+               {
+                       var b = (System.ServiceModel.MsmqIntegration.MsmqIntegrationBindingElement) bindingElement;
+                       base.InitializeFrom (b);
+                       SerializationFormat = b.SerializationFormat;
+               }
        }
 
 }
index 59bb88b813937c43ae8df2c5f8e53ee5a13fb6cd..f4235e85cf58ff4e271b1dd67b95bc73a7bcf49c 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2006,2010 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -108,11 +108,37 @@ namespace System.ServiceModel.Configuration
                        set { base ["useActiveDirectory"] = value; }
                }
 
-               [MonoTODO]
-               protected internal override BindingElement CreateBindingElement () {
-                       throw new NotImplementedException ();
+               public override void ApplyConfiguration (BindingElement bindingElement)
+               {
+                       var b = (MsmqTransportBindingElement) bindingElement;
+                       base.ApplyConfiguration (b);
+                       b.MaxPoolSize = MaxPoolSize;
+                       b.QueueTransferProtocol = QueueTransferProtocol;
+                       b.UseActiveDirectory = UseActiveDirectory;
                }
 
+               public override void CopyFrom (ServiceModelExtensionElement from)
+               {
+                       var e = (MsmqTransportElement) from;
+                       base.CopyFrom (from);
+                       MaxPoolSize = e.MaxPoolSize;
+                       QueueTransferProtocol = e.QueueTransferProtocol;
+                       UseActiveDirectory = e.UseActiveDirectory;
+               }
+
+               protected override TransportBindingElement CreateDefaultBindingElement ()
+               {
+                       return new MsmqTransportBindingElement ();
+               }
+
+               protected internal override void InitializeFrom (BindingElement bindingElement)
+               {
+                       var b = (MsmqTransportBindingElement) bindingElement;
+                       base.InitializeFrom (b);
+                       MaxPoolSize = b.MaxPoolSize;
+                       QueueTransferProtocol = b.QueueTransferProtocol;
+                       UseActiveDirectory = b.UseActiveDirectory;
+               }
        }
 
 }
index e66eee7836abd56a77291bfdb902187ba9a072c3..7d29fdf1fabf158c54f117670d4575538eae2069 100644 (file)
@@ -72,7 +72,7 @@ namespace System.ServiceModel.Configuration
                                ConfigurationPropertyOptions.None);
 
                        idle_timeout = new ConfigurationProperty ("idleTimeout",
-                               typeof (TimeSpan), "00:02:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:02:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        max_outbound_connections_per_endpoint = new ConfigurationProperty ("maxOutboundConnectionsPerEndpoint",
@@ -105,6 +105,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("idleTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:02:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan IdleTimeout {
                        get { return (TimeSpan) base [idle_timeout]; }
                        set { base [idle_timeout] = value; }
index d8ba18ec6b52e1d625242b4579c956aec07f5619..82f25055d4125e080ceac755dd602f4cca3c3ef5 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2006,2010 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -54,7 +54,6 @@ using System.Xml;
 
 namespace System.ServiceModel.Configuration
 {
-       [MonoTODO]
        public sealed partial class NamedPipeTransportElement
                 : ConnectionOrientedTransportElement
        {
@@ -87,11 +86,46 @@ namespace System.ServiceModel.Configuration
                        }
                }
 
-               [MonoTODO]
-               protected internal override BindingElement CreateBindingElement () {
-                       throw new NotImplementedException ();
+               public override void ApplyConfiguration (BindingElement bindingElement)
+               {
+                       var b = (NamedPipeTransportBindingElement) bindingElement;
+                       base.ApplyConfiguration (b);
+
+                       var bs = b.ConnectionPoolSettings;
+                       var cs = ConnectionPoolSettings;
+                       bs.GroupName = cs.GroupName;
+                       bs.IdleTimeout = cs.IdleTimeout;
+                       bs.MaxOutboundConnectionsPerEndpoint = cs.MaxOutboundConnectionsPerEndpoint;
+               }
+
+               public override void CopyFrom (ServiceModelExtensionElement from)
+               {
+                       var e = (NamedPipeTransportElement) from;
+                       base.CopyFrom (from);
+
+                       var es = e.ConnectionPoolSettings;
+                       var cs = ConnectionPoolSettings;
+                       cs.GroupName = es.GroupName;
+                       cs.IdleTimeout = es.IdleTimeout;
+                       cs.MaxOutboundConnectionsPerEndpoint = es.MaxOutboundConnectionsPerEndpoint;
                }
 
+               protected override TransportBindingElement CreateDefaultBindingElement ()
+               {
+                       return new NamedPipeTransportBindingElement ();
+               }
+
+               protected internal override void InitializeFrom (BindingElement bindingElement)
+               {
+                       var b = (NamedPipeTransportBindingElement) bindingElement;
+                       base.InitializeFrom (b);
+
+                       var bs = b.ConnectionPoolSettings;
+                       var cs = ConnectionPoolSettings;
+                       cs.GroupName = bs.GroupName;
+                       cs.IdleTimeout = bs.IdleTimeout;
+                       cs.MaxOutboundConnectionsPerEndpoint = bs.MaxOutboundConnectionsPerEndpoint;
+               }
        }
 
 }
index b211ad9b580acc70dcb8bb4d08e3678cabbe4f73..41c8682689e3d1ae3a3c8681c36f930661e4454b 100644 (file)
@@ -146,9 +146,9 @@ namespace System.ServiceModel.Configuration
                                HttpsHelpPageUrl = HttpsHelpPageUrl,
                                IncludeExceptionDetailInFaults = IncludeExceptionDetailInFaults,
                        };
-                       if (HttpHelpPageBinding != null)
+                       if (!String.IsNullOrEmpty (HttpHelpPageBinding))
                                ret.HttpHelpPageBinding = ConfigUtil.CreateBinding (HttpHelpPageBinding, HttpHelpPageBindingConfiguration);
-                       if (HttpsHelpPageBinding != null)
+                       if (!String.IsNullOrEmpty (HttpsHelpPageBinding))
                                ret.HttpsHelpPageBinding = ConfigUtil.CreateBinding (HttpsHelpPageBinding, HttpsHelpPageBindingConfiguration);
                        return ret;
                }
index fcd314e24d85686afe58b1a433eaf5ae2b05293d..351deef520d600d4386d3b1992e417262cd7859f 100644 (file)
@@ -137,9 +137,9 @@ namespace System.ServiceModel.Configuration
                        b.HttpsGetEnabled = HttpsGetEnabled;
                        b.HttpGetUrl = HttpGetUrl;
                        b.HttpsGetUrl = HttpsGetUrl;
-                       if (HttpGetBinding != null)
+                       if (!String.IsNullOrEmpty (HttpGetBinding))
                                b.HttpGetBinding = ConfigUtil.CreateBinding (HttpGetBinding, HttpGetBindingConfiguration);
-                       if (HttpsGetBinding != null)
+                       if (!String.IsNullOrEmpty (HttpsGetBinding))
                                b.HttpsGetBinding = ConfigUtil.CreateBinding (HttpsGetBinding, HttpsGetBindingConfiguration);
                        return b;
                }
index fd75d55dc7d679842b41541dce781c6294bb4d48..5e432e1616b5f530a8852339b72a7c49934f6734 100644 (file)
@@ -99,8 +99,9 @@ namespace System.ServiceModel.Configuration
                        throw new NotImplementedException ();
                }
 
-               protected internal override Binding GetDefault () {
-                       throw new NotImplementedException ();
+               protected internal override Binding GetDefault ()
+               {
+                       return (Binding) Activator.CreateInstance (BindingType, new object [0]);
                }
 
                protected internal override bool TryAdd (string name, Binding binding, System.Configuration.Configuration config) {
index d3bf240bbe0e5e0fabac39bce3f1380dff86747b..519c09729e0cbd75885d5a7547da61e07df17356 100644 (file)
@@ -74,6 +74,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("closeTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:01:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan CloseTimeout {
                        get { return (TimeSpan) this ["closeTimeout"]; }
                        set { this ["closeTimeout"] = value; }
@@ -94,6 +95,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("openTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:01:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan OpenTimeout {
                        get { return (TimeSpan) this ["openTimeout"]; }
                        set { this ["openTimeout"] = value; }
@@ -116,6 +118,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("receiveTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:10:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan ReceiveTimeout {
                        get { return (TimeSpan) this ["receiveTimeout"]; }
                        set { this ["receiveTimeout"] = value; }
@@ -124,6 +127,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("sendTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:01:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan SendTimeout {
                        get { return (TimeSpan) this ["sendTimeout"]; }
                        set { this ["sendTimeout"] = value; }
index ce9d811ae68fed557e7e682abf941433dab13c99..f6e42409f2947f1af3ab8512bb0437b21352a066 100644 (file)
@@ -74,7 +74,7 @@ namespace System.ServiceModel.Configuration
                {
                        properties = new ConfigurationPropertyCollection ();
                        inactivity_timeout = new ConfigurationProperty ("inactivityTimeout",
-                               typeof (TimeSpan), "00:10:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:10:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        ordered = new ConfigurationProperty ("ordered",
@@ -95,6 +95,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("inactivityTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:10:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan InactivityTimeout {
                        get { return (TimeSpan) base [inactivity_timeout]; }
                        set { base [inactivity_timeout] = value; }
index c5509bbb1c2559e781de99a9838a70e13af34263..ac48e04ca54047c6293f5fd7b3816c26582297c2 100644 (file)
@@ -73,11 +73,11 @@ namespace System.ServiceModel.Configuration
                                ConfigurationPropertyOptions.None);
 
                        idle_timeout = new ConfigurationProperty ("idleTimeout",
-                               typeof (TimeSpan), "00:02:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:02:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        lease_timeout = new ConfigurationProperty ("leaseTimeout",
-                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               typeof (TimeSpan), "00:05:00", new TimeSpanConverter (), null,
                                ConfigurationPropertyOptions.None);
 
                        max_outbound_connections_per_endpoint = new ConfigurationProperty ("maxOutboundConnectionsPerEndpoint",
@@ -111,6 +111,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("idleTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:02:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan IdleTimeout {
                        get { return (TimeSpan) base [idle_timeout]; }
                        set { base [idle_timeout] = value; }
@@ -119,6 +120,7 @@ namespace System.ServiceModel.Configuration
                [ConfigurationProperty ("leaseTimeout",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = "00:05:00")]
+               [TypeConverter (typeof (TimeSpanConverter))]
                public TimeSpan LeaseTimeout {
                        get { return (TimeSpan) base [lease_timeout]; }
                        set { base [lease_timeout] = value; }
index c75adfb8e1a6f49d396e4b55e535bc6e783486d4..e11ebbebf8b83b1c062edf4aafe0113d202ca3cf 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2006,2010 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -116,12 +116,37 @@ namespace System.ServiceModel.Configuration
                        set { base ["teredoEnabled"] = value; }
                }
 
+               public override void ApplyConfiguration (BindingElement bindingElement)
+               {
+                       var b = (TcpTransportBindingElement) bindingElement;
+                       base.ApplyConfiguration (b);
+                       b.ListenBacklog = ListenBacklog;
+                       b.PortSharingEnabled = PortSharingEnabled;
+                       b.TeredoEnabled = TeredoEnabled;
+               }
+
+               public override void CopyFrom (ServiceModelExtensionElement from)
+               {
+                       var e = (TcpTransportElement) from;
+                       base.CopyFrom (from);
+                       ListenBacklog = e.ListenBacklog;
+                       PortSharingEnabled = e.PortSharingEnabled;
+                       TeredoEnabled = e.TeredoEnabled;
+               }
 
-               [MonoTODO]
-               protected internal override BindingElement CreateBindingElement () {
-                       throw new NotImplementedException ();
+               protected override TransportBindingElement CreateDefaultBindingElement ()
+               {
+                       return new TcpTransportBindingElement ();
                }
 
+               protected internal override void InitializeFrom (BindingElement bindingElement)
+               {
+                       var b = (TcpTransportBindingElement) bindingElement;
+                       base.InitializeFrom (b);
+                       ListenBacklog = b.ListenBacklog;
+                       PortSharingEnabled = b.PortSharingEnabled;
+                       TeredoEnabled = b.TeredoEnabled;
+               }
        }
 
 }
index 081e2b137e37806d27a873f734e528c40c2e34c1..0ac73504b8390b35598af429dc258d77123c1220 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2006,2010 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -108,7 +108,41 @@ namespace System.ServiceModel.Configuration
                        }
                }
 
+               public override void ApplyConfiguration (BindingElement bindingElement)
+               {
+                       var b = (TransportBindingElement) bindingElement;
+                       base.ApplyConfiguration (b);
+                       b.ManualAddressing = ManualAddressing;
+                       b.MaxBufferPoolSize = MaxBufferPoolSize;
+                       b.MaxReceivedMessageSize = MaxReceivedMessageSize;
+               }
+
+               public override void CopyFrom (ServiceModelExtensionElement from)
+               {
+                       var e = (TransportElement) from;
+                       base.CopyFrom (from);
+                       ManualAddressing = e.ManualAddressing;
+                       MaxBufferPoolSize = e.MaxBufferPoolSize;
+                       MaxReceivedMessageSize = e.MaxReceivedMessageSize;
+               }
 
+               protected internal override BindingElement CreateBindingElement ()
+               {
+                       var b = CreateDefaultBindingElement ();
+                       ApplyConfiguration (b);
+                       return b;
+               }
+
+               protected abstract TransportBindingElement CreateDefaultBindingElement ();
+
+               protected internal override void InitializeFrom (BindingElement bindingElement)
+               {
+                       var b = (TransportBindingElement) bindingElement;
+                       base.InitializeFrom (b);
+                       ManualAddressing = b.ManualAddressing;
+                       MaxBufferPoolSize = b.MaxBufferPoolSize;
+                       MaxReceivedMessageSize = b.MaxReceivedMessageSize;
+               }
        }
 
 }
index 13309137d54ddf0fdcbd33952e4b1bbc18272a8a..c79a230492f7db52fb31e19dc54f621b4a523427 100644 (file)
@@ -1,3 +1,39 @@
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceMetadataExtension.cs : compare "wsdl" parameter in case-
+         insensitive manner.
+
+2010-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HostedBindingBehavior.cs : remove unused class.
+
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WsdlExporter.cs : allow identical contract while exporting a set
+         of endpoints, while reject identical ones when calling
+         ExportEndpoint() individually.
+
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MetadataExchangeBindings.cs : use WSHttpBinding (it works if other
+         parts gets fixed).
+
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceMetadataExtension.cs, WsdlExporter.cs :
+         implement ExportEndpoints() and use it.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * ClientCredentials.cs, ContractDescription.cs,
+       IEndpointBehavior.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
+2010-03-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceEndpointCollection.cs : those overrides are rather to check
+         null arguments, not to skip contract duplicates.
+
 2010-03-12  Atsushi Enomoto  <atsushi@ximian.com>
 
        * MessageDescription.cs : implement MessageName.
index fad6fbdd2600d092bcebf9e98f9c839136e23785..7e2c785cdfad07c19fc8c9744aff41acc90d568c 100644 (file)
@@ -140,7 +140,7 @@ namespace System.ServiceModel.Description
                }
 #endif
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint,
                        BindingParameterCollection parameters)
                {
index b7fd634fe5464d86da7063822cf8c4ec1090a2a8..6af33369c8a94c8eeb523857158052e8bdb69c94 100644 (file)
@@ -153,7 +153,7 @@ namespace System.ServiceModel.Description
                        foreach (OperationDescription od in Operations) {
                                if (!proxy.Operations.Contains (od.Name))
                                        PopulateClientOperation (proxy, od);
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                                foreach (IOperationBehavior ob in od.Behaviors)
                                        ob.ApplyClientBehavior (od, proxy.Operations [od.Name]);
 #endif
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/HostedBindingBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/HostedBindingBehavior.cs
deleted file mode 100644 (file)
index 20b73cd..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// HostedBindingBehavior.cs.cs
-//
-// Author:
-//     Atsushi Enomoto <atsushi@ximian.com>
-//
-// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-using System.Collections.ObjectModel;
-using System.ServiceModel;
-using System.ServiceModel.Channels;
-using System.ServiceModel.Dispatcher;
-
-namespace System.ServiceModel.Description
-{
-       [MonoTODO]
-       internal sealed class HostedBindingBehavior : IServiceBehavior
-       {
-               string virtual_path;
-
-               internal HostedBindingBehavior (string virtualPath)
-               {
-                       virtual_path = virtualPath;
-               }
-
-               public string VirtualPath {
-                       get { return virtual_path; }
-               }
-
-               void IServiceBehavior.AddBindingParameters (
-                       ServiceDescription description,
-                       ServiceHostBase serviceHostBase,
-                       Collection<ServiceEndpoint> endpoints,
-                       BindingParameterCollection parameters)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               void IServiceBehavior.ApplyDispatchBehavior (
-                       ServiceDescription description,
-                       ServiceHostBase serviceHostBase)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               void IServiceBehavior.Validate (
-                       ServiceDescription description,
-                       ServiceHostBase serviceHostBase)
-               {
-                       throw new NotImplementedException ();
-               }
-       }
-}
index 1ba9d63f7e5c8d61102a060632a79c453981b05a..436dd438dc7b6c709e2eff6fd620305fe0812178 100644 (file)
@@ -33,7 +33,7 @@ namespace System.ServiceModel.Description
 {
        public interface IEndpointBehavior
        {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                void AddBindingParameters (ServiceEndpoint endpoint,
                        BindingParameterCollection parameters);
 #if !NET_2_1
index 469be47ce78018c60f598b88fb1b32983528d34b..89fd2b3a0bb9025f326268f9c195169268d056db 100644 (file)
@@ -34,26 +34,18 @@ namespace System.ServiceModel.Description
        {
                public static Binding CreateMexHttpBinding ()
                {
-                       //FIXME: .net uses WSHttpBinding.. 
-                       return new CustomBinding (
-                               "MetadataExchangeHttpBinding",
-                               "http://schemas.microsoft.com/ws/2005/02/mex/bindings",
-                               new TextMessageEncodingBindingElement (
-                                       MessageVersion.Soap12WSAddressing10, 
-                                       Encoding.UTF8),
-                               new HttpTransportBindingElement ());
+                       var b = new WSHttpBinding (SecurityMode.None) {
+                               Name = "MetadataExchangeHttpBinding",
+                               Namespace = "http://schemas.microsoft.com/ws/2005/02/mex/bindings"};
+                       return b;
                }
 
                public static Binding CreateMexHttpsBinding ()
                {
-                       //FIXME: .net uses WSHttpBinding.. 
-                       return new CustomBinding (
-                               "MetadataExchangeHttpsBinding",
-                               "http://schemas.microsoft.com/ws/2005/02/mex/bindings",
-                               new TextMessageEncodingBindingElement (
-                                       MessageVersion.Soap12WSAddressing10, 
-                                       Encoding.UTF8),
-                               new HttpsTransportBindingElement ());
+                       var b = (WSHttpBinding) CreateMexHttpBinding ();
+                       b.Name = "MetadataExchangeHttpsBinding";
+                       b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
+                       return b;
                }
 
                public static Binding CreateMexNamedPipeBinding ()
index 58d0024e3de8b588bd15331cbae98872dd6af249..191d411ed41c86e21abe97d4709a70aeb911dc9d 100644 (file)
@@ -107,20 +107,18 @@ namespace System.ServiceModel.Description
                        return list;
                }
 
-               [MonoTODO]
                protected override void InsertItem (int index, ServiceEndpoint item)
                {
-                       if (Find (new XmlQualifiedName (item.Contract.Name, item.Contract.Namespace)) == null)
-                               base.InsertItem (index, item);
+                       if (item == null)
+                               throw new ArgumentNullException ("item");
+                       base.InsertItem (index, item);
                }
 
-               [MonoTODO]
                protected override void SetItem (int index, ServiceEndpoint item)
                {
-                       if (Find (new XmlQualifiedName (item.Contract.Name, item.Contract.Namespace)) == null)
-                               base.SetItem (index, item);
-                       else
-                               base.RemoveItem (index);
+                       if (item == null)
+                               throw new ArgumentNullException ("item");
+                       base.SetItem (index, item);
                }
        }
 }
index 36b7fdc8f63da6dea3f72d8b1e1c0e43c0e3558f..94ae2fbf972f6fb2c779e9469d47e263b3c53941 100644 (file)
@@ -66,13 +66,8 @@ namespace System.ServiceModel.Description
                public MetadataSet Metadata {
                        get {
                                if (metadata == null) {
-                                       MetadataExporter exporter = new WsdlExporter ();
-                                       foreach (ServiceEndpoint ep in owner.Description.Endpoints) {
-                                               if (ep.Contract.Name == ServiceMetadataBehavior.MexContractName)
-                                                       continue;
-
-                                               exporter.ExportEndpoint (ep);
-                                       }
+                                       var exporter = new WsdlExporter ();
+                                       exporter.ExportEndpoints (owner.Description.Endpoints, new XmlQualifiedName (owner.Description.Name, owner.Description.Namespace));
                                        metadata = exporter.GetGeneratedMetadata ();
                                }
                                return metadata;
@@ -222,7 +217,7 @@ namespace System.ServiceModel.Description
                                        return CreateWsdlMessage (w);
                        }
 
-                       if (query_string [null] == "wsdl") {
+                       if (String.Compare (query_string [null], "wsdl", StringComparison.OrdinalIgnoreCase) == 0) {
                                WSServiceDescription wsdl = GetWsdl ("wsdl");
                                if (wsdl != null)
                                        return CreateWsdlMessage (wsdl);
index 10a4fe2c3f84cde4f7e08c627517075f99f75ea7..0a5e892fe75c95593b89d7d8b2af2f86ea0eff2d 100644 (file)
@@ -29,6 +29,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Linq;
 using System.ServiceModel;
 using System.ServiceModel.Channels;
 using System.Web.Services.Description;
@@ -50,10 +51,24 @@ namespace System.ServiceModel.Description
        [MonoTODO]
        public class WsdlExporter : MetadataExporter
        {
+               class ContractExportMap
+               {
+                       public ContractExportMap (QName qname, ContractDescription contract, List<IWsdlExportExtension> results)
+                       {
+                               QName = qname;
+                               Contract = contract;
+                               Results = results;
+                       }
+
+                       public QName QName { get; private set; }
+                       public ContractDescription Contract { get; private set; }
+                       public List<IWsdlExportExtension> Results { get; private set; }
+               }
+
                private MetadataSet metadata;
                private ServiceDescriptionCollection wsdl_colln;
                private XsdDataContractExporter xsd_exporter;
-               private Hashtable exported_contracts;
+               private List<ContractExportMap> exported_contracts;
 
                public override MetadataSet GetGeneratedMetadata ()
                {
@@ -74,16 +89,20 @@ namespace System.ServiceModel.Description
 
                public override void ExportContract (ContractDescription contract)
                {
-                       ExportContractInternal (contract);      
+                       ExportContractInternal (contract, true);
                }
 
-               List<IWsdlExportExtension> ExportContractInternal (ContractDescription contract)
+               List<IWsdlExportExtension> ExportContractInternal (ContractDescription contract, bool rejectDuplicate)
                {
                        QName qname = new QName (contract.Name, contract.Namespace);
-                       if (ExportedContracts.ContainsKey (qname))
+                       var map = ExportedContracts.FirstOrDefault (m => m.QName == qname);
+                       if (map != null) {
+                               if (map.Results != null && !rejectDuplicate)
+                                       return null; // already exported.
                                throw new ArgumentException (String.Format (
                                        "A ContractDescription with Namespace : {0} and Name : {1} has already been exported.", 
                                        contract.Namespace, contract.Name));
+                       }
 
                        WSServiceDescription sd = GetServiceDescription (contract.Namespace);
 
@@ -150,7 +169,7 @@ namespace System.ServiceModel.Description
                        sd.Types.Schemas.Add (xs_import);
 
                        sd.PortTypes.Add (ws_port);
-                       ExportedContracts [qname] = contract;
+                       ExportedContracts.Add (new ContractExportMap (qname, contract, extensions));
 
                        WsdlContractConversionContext context = new WsdlContractConversionContext (contract, ws_port);
                        foreach (IWsdlExportExtension extn in extensions)
@@ -161,7 +180,12 @@ namespace System.ServiceModel.Description
 
                public override void ExportEndpoint (ServiceEndpoint endpoint)
                {
-                       List<IWsdlExportExtension> extensions = ExportContractInternal (endpoint.Contract);
+                       ExportEndpoint (endpoint, true);
+               }
+
+               void ExportEndpoint (ServiceEndpoint endpoint, bool rejectDuplicate)
+               {
+                       List<IWsdlExportExtension> extensions = ExportContractInternal (endpoint.Contract, rejectDuplicate);
                        
                        //FIXME: Namespace
                        WSServiceDescription sd = GetServiceDescription ("http://tempuri.org/");
@@ -251,8 +275,9 @@ namespace System.ServiceModel.Description
                        WsdlEndpointConversionContext endpoint_context = new WsdlEndpointConversionContext (
                                contract_context, endpoint, ws_port, ws_binding);
 
-                       foreach (IWsdlExportExtension extn in extensions)
-                               extn.ExportEndpoint (this, endpoint_context);
+                       if (extensions != null)
+                               foreach (IWsdlExportExtension extn in extensions)
+                                       extn.ExportEndpoint (this, endpoint_context);
 
                                
                }
@@ -327,7 +352,17 @@ namespace System.ServiceModel.Description
                        IEnumerable<ServiceEndpoint> endpoints,
                        XmlQualifiedName name)
                {
-                       throw new NotImplementedException ();
+                       if (endpoints == null)
+                               throw new ArgumentNullException ("endpoints");
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+
+                       foreach (ServiceEndpoint ep in endpoints) {
+                               if (ep.Contract.Name == ServiceMetadataBehavior.MexContractName)
+                                       continue;
+
+                               ExportEndpoint (ep, false);
+                       }
                }
 
                XsdDataContractExporter XsdExporter {
@@ -339,10 +374,10 @@ namespace System.ServiceModel.Description
                        }
                }
 
-               Hashtable ExportedContracts {
+               List<ContractExportMap> ExportedContracts {
                        get {
                                if (exported_contracts == null)
-                                       exported_contracts = new Hashtable ();
+                                       exported_contracts = new List<ContractExportMap> ();
                                return exported_contracts;
                        }
                }
index 1424af7a9ef2d27fbbbda13a7338d19d87e14b76..2fd02d25e0d9b6213c4fe0a49542c6e36fafc223 100644 (file)
@@ -1,3 +1,27 @@
+2010-03-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationInvokerHandler.cs : removed unused code.
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : return EndpointDispatcher at initializing
+         for internal use. Add some locks. Patch by Matt Dargavel.
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : fix wrong method call in open_delegate.
+         Patch by Matt Dargavel.
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : give the actual exception message instead
+         of "error occured".
+
+2010-03-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XPathMessageContext.cs : implement.
+       * XPathMessageFilterTable.cs : add some missing overloads.
+
 2010-02-26  Atsushi Enomoto  <atsushi@ximian.com>
 
        * InputOrReplyRequestProcessor.cs : now ServiceRuntimeChannel is
index 713a62c2e765e1763bda63ca0c90a15a416856aa..9066a29d4e2665604531d97ee98a725b6449cc12 100644 (file)
@@ -130,7 +130,7 @@ namespace System.ServiceModel.Dispatcher
                        endpoints = new EndpointDispatcherCollection (this);
                }
 
-               internal void InitializeServiceEndpoint (Type serviceType, ServiceEndpoint se)
+               internal EndpointDispatcher InitializeServiceEndpoint (Type serviceType, ServiceEndpoint se)
                {
                        this.MessageVersion = se.Binding.MessageVersion;
                        if (this.MessageVersion == null)
@@ -140,6 +140,7 @@ namespace System.ServiceModel.Dispatcher
                        EndpointDispatcher ed = new EndpointDispatcher (se.Address, se.Contract.Name, se.Contract.Namespace);
                        this.Endpoints.Add (ed);
                        ed.InitializeServiceEndpoint (false, serviceType, se);
+                       return ed;
                }
 
                public string BindingName {
@@ -264,7 +265,7 @@ namespace System.ServiceModel.Dispatcher
                        AsyncCallback callback, object state)
                {
                        if (open_delegate == null)
-                               open_delegate = new Action<TimeSpan> (OnClose);
+                               open_delegate = new Action<TimeSpan> (OnOpen);
                        return open_delegate.BeginInvoke (timeout, callback, state);
                }
 
@@ -450,7 +451,7 @@ namespace System.ServiceModel.Dispatcher
                                        LoopCore ();
                                } catch (Exception ex) {
                                        // FIXME: log it
-                                       Console.WriteLine ("ChannelDispatcher caught an exception inside dispatcher loop, which is likely thrown by the channel listener {0}", owner.Listener);
+                                       Console.WriteLine ("ListenerLoopManager caught an exception inside dispatcher loop, which is likely thrown by the channel listener {0}", owner.Listener);
                                        Console.WriteLine (ex);
                                } finally {
                                        if (stop_handle != null)
@@ -496,16 +497,19 @@ namespace System.ServiceModel.Dispatcher
                                        return;
                                }
 
-                               channels.Add (ch);
+                               lock (channels)
+                                       channels.Add (ch);
                                ch.Opened += delegate {
                                        ch.Faulted += delegate {
-                                               if (channels.Contains (ch))
-                                                       channels.Remove (ch);
+                                               lock (channels)
+                                                       if (channels.Contains (ch))
+                                                               channels.Remove (ch);
                                                throttle_wait_handle.Set (); // release loop wait lock.
                                                };
                                        ch.Closed += delegate {
-                                               if (channels.Contains (ch))
-                                                       channels.Remove (ch);
+                                               lock (channels)
+                                                       if (channels.Contains (ch))
+                                                               channels.Remove (ch);
                                                throttle_wait_handle.Set (); // release loop wait lock.
                                                };
                                        };
@@ -567,7 +571,7 @@ namespace System.ServiceModel.Dispatcher
 
                                        MessageVersion version = rc.RequestMessage.Version;
                                        FaultCode fc = new FaultCode ("DestinationUnreachable", version.Addressing.Namespace);
-                                       Message res = Message.CreateMessage (version, fc, "error occured", rc.RequestMessage.Headers.Action);
+                                       Message res = Message.CreateMessage (version, fc, ex.Message, rc.RequestMessage.Headers.Action);
                                        rc.Reply (res);
                                } catch (Exception e) {
                                        // FIXME: log it
index f5504c8c1810c09e7972deb5ee42baa4646f22a5..081a7aab8bc1c9c790af240b5ece94b73db802c6 100644 (file)
@@ -98,16 +98,6 @@ namespace System.ServiceModel.Dispatcher
                        mrc.ReplyMessage = res;
                }
 
-               Message CreateActionNotSupported (Message req)
-               {
-                       FaultCode fc = new FaultCode (
-                               req.Version.Addressing.ActionNotSupported,
-                               req.Version.Addressing.Namespace);
-                       // FIXME: set correct namespace URI
-                       return Message.CreateMessage (req.Version, fc,
-                               String.Format ("action '{0}' is not supported in this service contract.", req.Headers.Action), String.Empty);
-               }
-
                void BuildInvokeParams (MessageProcessingContext mrc, out object [] parameters)
                {
                        DispatchOperation operation = mrc.Operation;
index 434f459ca0ea7d99176a9d23a0ac9659cc30c9a7..3bef60dc7cf8b33c4a41ce81b6d17ce60baebdab 100644 (file)
@@ -34,22 +34,22 @@ using System.ServiceModel;
 
 namespace System.ServiceModel.Dispatcher
 {
-       [MonoTODO]
        public class XPathMessageContext : XsltContext
        {
                public XPathMessageContext ()
-                       : base ()
+                       : this (new NameTable ())
                {
                }
 
                public XPathMessageContext (NameTable nameTable)
                        : base (nameTable)
                {
+                       AddNamespace ("s11", Constants.Soap11);
+                       AddNamespace ("s12", Constants.Soap12);
                }
 
-               [MonoTODO]
                public override bool Whitespace {
-                       get { throw new NotImplementedException (); }
+                       get { return false; } // as documented.
                }
 
                public override int CompareDocument (string uri1, string uri2)
@@ -57,24 +57,21 @@ namespace System.ServiceModel.Dispatcher
                        return String.CompareOrdinal (uri1, uri2);
                }
 
-               [MonoTODO]
                public override bool PreserveWhitespace (XPathNavigator node)
                {
-                       throw new NotImplementedException ();
+                       return false; // as documented.
                }
 
-               [MonoTODO]
                public override IXsltContextFunction ResolveFunction (
                        string prefix, string name, XPathResultType [] argTypes)
                {
-                       throw new NotImplementedException ();
+                       return null;
                }
 
-               [MonoTODO]
                public override IXsltContextVariable ResolveVariable (
                        string prefix, string name)
                {
-                       throw new NotImplementedException ();
+                       return null;
                }
        }
 }
\ No newline at end of file
index b65b4e94e8b3650d9331dfe2aaaf6e92e5253241..71d7536fd34d95852b8f0af0763bfe1611f25552 100644 (file)
@@ -147,6 +147,16 @@ namespace System.ServiceModel.Dispatcher
                        throw new NotImplementedException ();
                }
 
+               public bool GetMatchingFilter (SeekableXPathNavigator navigator, out MessageFilter filter)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilter (XPathNavigator navigator, out MessageFilter filter)
+               {
+                       throw new NotImplementedException ();
+               }
+
                public bool GetMatchingFilters (Message message, ICollection<MessageFilter> results)
                {
                        throw new NotImplementedException ();
@@ -157,6 +167,16 @@ namespace System.ServiceModel.Dispatcher
                        throw new NotImplementedException ();
                }
 
+               public bool GetMatchingFilters (SeekableXPathNavigator navigator, ICollection<MessageFilter> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilters (XPathNavigator navigator, ICollection<MessageFilter> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
                public bool GetMatchingValue (Message message, out TFilterData data)
                {
                        throw new NotImplementedException ();
@@ -167,6 +187,16 @@ namespace System.ServiceModel.Dispatcher
                        throw new NotImplementedException ();
                }
 
+               public bool GetMatchingValue (SeekableXPathNavigator navigator, out TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValue (XPathNavigator navigator, out TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
                public bool GetMatchingValues (Message message, ICollection<TFilterData> results)
                {
                        throw new NotImplementedException ();
@@ -177,6 +207,16 @@ namespace System.ServiceModel.Dispatcher
                        throw new NotImplementedException ();
                }
 
+               public bool GetMatchingValues (SeekableXPathNavigator navigator, ICollection<TFilterData> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValues (XPathNavigator navigator, ICollection<TFilterData> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
                public bool Remove (KeyValuePair<MessageFilter,TFilterData> item)
                {
                        if (dict.ContainsKey (item.Key) && dict [item.Key].Equals (item.Value)) {
@@ -188,29 +228,27 @@ namespace System.ServiceModel.Dispatcher
 
                public bool Remove (XPathMessageFilter filter)
                {
-                       throw new NotImplementedException ();
+                       return dict.Remove (filter);
                }
 
                public bool Remove (MessageFilter filter)
                {
-                       return dict.Remove (filter);
+                       return Remove ((XPathMessageFilter) filter);
                }
 
-               public bool TryGetValue (MessageFilter filter, out TFilterData filterData)
+               static Exception trim_to_size_error;
+
+               public void TrimToSize ()
                {
-                       if (dict.ContainsKey (filter)) {
-                               filterData = dict [filter];
-                               return true;
-                       } else {
-                               filterData = default (TFilterData);
-                               return false;
-                       }
+                       // This is the documented behavior: throws NIE.
+                       if (trim_to_size_error == null)
+                               trim_to_size_error = new NotImplementedException ();
+                       throw trim_to_size_error;
                }
 
-               [MonoTODO]
-               public void TrimToSize ()
+               public bool TryGetValue (MessageFilter filter, out TFilterData data)
                {
-                       throw new NotImplementedException ();
+                       return dict.TryGetValue (filter, out data);
                }
        }
 }
index 7e74bcf267e1257631cdaa724ac95f64b72f10aa..62296931fba85332785f022e6427127a4d4d8943 100755 (executable)
@@ -257,7 +257,10 @@ System.ServiceModel.Channels/PeerInputChannel.cs
 System.ServiceModel.Channels/PeerOutputChannel.cs
 System.ServiceModel.Channels/PeerTransportBindingElement.cs
 System.ServiceModel.Channels/PnrpPeerResolverBindingElement.cs
+System.ServiceModel.Channels/PrivacyNoticeBindingElement.cs
+System.ServiceModel.Channels/ReliableSessionBindingElement.cs
 System.ServiceModel.Channels/ReliableSessionBindingElementImporter.cs
+System.ServiceModel.Channels/RemoteEndpointMessageProperty.cs
 System.ServiceModel.Channels/ReplyChannelBase.cs
 System.ServiceModel.Channels/RequestChannelBase.cs
 System.ServiceModel.Channels/RequestContext.cs
@@ -540,7 +543,6 @@ System.ServiceModel.Description/DataContractSerializerMessageContractImporter.cs
 System.ServiceModel.Description/DataContractSerializerOperationBehavior.cs
 System.ServiceModel.Description/FaultDescription.cs
 System.ServiceModel.Description/FaultDescriptionCollection.cs
-System.ServiceModel.Description/HostedBindingBehavior.cs
 System.ServiceModel.Description/IContractBehavior.cs
 System.ServiceModel.Description/IContractBehaviorAttribute.cs
 System.ServiceModel.Description/IEndpointBehavior.cs
index d2d6c9344435729ee195f61ecdf36e9d94f14c30..b15246240f84860a471a348ffa73d073ed17f3bd 100755 (executable)
@@ -1,3 +1,39 @@
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : use FaultConverter as documented at:
+         http://msdn.microsoft.com/en-us/library/ms789039%28VS.100%29.aspx
+         (Though I found _no_ use of this FC class in the world...)
+
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : if there is an existing ChannelDispatcher
+         for the same endpoint URI, reuse it. Patch by Matt Dargavel.
+
+2010-03-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : add more.
+
+2010-03-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : removed some dummy types (not dummy anymore).
+
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : use namespace for mex binding comparison, to
+         cover other bindings than http (such as https).
+       * WSHttpBindingBase.cs : add some comment.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * ClientBase.cs, ClientRuntimeChannel.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
+2010-03-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : do not reject endpoints with an identical
+         contract to existing ones but with different binding, address or
+         listen URI.
+
 2010-03-09  Atsushi Enomoto  <atsushi@ximian.com>
 
        * HttpTransportSecurity.cs : remove MonoTODOs.
index 6281ba53bc8055100db54360d4a5b68ee5ed6170..d9e98a1856700aeeaee3c63f3cc801deaa1a8686 100644 (file)
@@ -39,13 +39,13 @@ namespace System.ServiceModel
 {
        [MonoTODO ("It somehow rejects classes, but dunno how we can do that besides our code wise.")]
        public abstract class ClientBase<TChannel> :
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                IDisposable,
 #endif
                ICommunicationObject where TChannel : class
        {
                static InstanceContext initialContxt = new InstanceContext (null);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                static readonly PropertyInfo dispatcher_main_property;
                static readonly MethodInfo dispatcher_begin_invoke_method;
 
@@ -222,7 +222,7 @@ namespace System.ServiceModel
 
                void RunCompletedCallback (SendOrPostCallback callback, InvokeAsyncCompletedEventArgs args)
                {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        callback (args);
 #else
                        object dispatcher = dispatcher_main_property.GetValue (null, null);
@@ -276,7 +276,7 @@ namespace System.ServiceModel
                }
                IAsyncResult begin_async_result;
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                void IDisposable.Dispose ()
                {
                        Close ();
@@ -402,7 +402,7 @@ namespace System.ServiceModel
                                }
                        }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        protected object Invoke (string methodName, object [] args)
                        {
                                var cd = endpoint.Contract;
index ffd858cd25669de9beb921a6eabaaf1e58f6923b..de504f94e167229d105daf0d271b98190877e274 100644 (file)
@@ -166,7 +166,7 @@ namespace System.ServiceModel.MonoInternal
                                }
                        }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        public override bool WaitOne (int millisecondsTimeout, bool exitContext)
                        {
                                return WaitHandle.WaitAll (ResultWaitHandles, millisecondsTimeout, exitContext);
@@ -482,20 +482,24 @@ namespace System.ServiceModel.MonoInternal
 
                        Message res = Request (req, OperationTimeout);
                        if (res.IsFault) {
-                               MessageFault fault = MessageFault.CreateFault (res, runtime.MaxFaultSize);
-                               if (fault.HasDetail && fault is MessageFault.SimpleMessageFault) {
-                                       MessageFault.SimpleMessageFault simpleFault = fault as MessageFault.SimpleMessageFault;
-                                       object detail = simpleFault.Detail;
-                                       Type t = detail.GetType ();
-                                       Type faultType = typeof (FaultException<>).MakeGenericType (t);
-                                       object [] constructorParams = new object [] { detail, fault.Reason, fault.Code, fault.Actor };
-                                       FaultException fe = (FaultException) Activator.CreateInstance (faultType, constructorParams);
-                                       throw fe;
-                               }
-                               else {
-                                       // given a MessageFault, it is hard to figure out the type of the embedded detail
-                                       throw new FaultException(fault);
+                               var resb = res.CreateBufferedCopy (0x10000); // FIXME: use correct MaxBufferSize
+                               MessageFault fault = MessageFault.CreateFault (resb.CreateMessage (), runtime.MaxFaultSize);
+                               var conv = OperationChannel.GetProperty<FaultConverter> () ?? FaultConverter.GetDefaultFaultConverter (res.Version);
+                               Exception ex;
+                               if (!conv.TryCreateException (resb.CreateMessage (), fault, out ex)) {
+                                       if (fault.HasDetail && fault is MessageFault.SimpleMessageFault) {
+                                               MessageFault.SimpleMessageFault simpleFault = fault as MessageFault.SimpleMessageFault;
+                                               object detail = simpleFault.Detail;
+                                               Type t = detail.GetType ();
+                                               Type faultType = typeof (FaultException<>).MakeGenericType (t);
+                                               object [] constructorParams = new object [] { detail, fault.Reason, fault.Code, fault.Actor };
+                                               ex = (FaultException) Activator.CreateInstance (faultType, constructorParams);
+                                       } else {
+                                               // given a MessageFault, it is hard to figure out the type of the embedded detail
+                                               ex = new FaultException(fault);
+                                       }
                                }
+                               throw ex;
                        }
 
                        for (int i = 0; i < inspections.Length; i++)
index 0c69185b2b77e22252aa0ce2ef788d51e9094c1d..8363da178a5e067c6d6ca08d3471010ee9c40c7a 100644 (file)
@@ -31,6 +31,9 @@ namespace System.ServiceModel
 {
        internal class Constants
        {
+               public const string Soap11 = "http://schemas.xmlsoap.org/soap/envelope/";
+               public const string Soap12 = "http://www.w3.org/2003/05/soap-envelope";
+
                public const string WSBasicSecurityProfileCore1 = "http://ws-i.org/profiles/basic-security/core/1.0";
 
                public const string WsaAnonymousUri = "http://www.w3.org/2005/08/addressing/anonymous";
index faf46e474d3faab421e84fc41b229202dbdfdc70..5a1241df70aa3e9b77c8957d1bfef1daa0c688e6 100644 (file)
@@ -17,9 +17,7 @@ namespace System.ServiceModel.Activation.Configuration
 
 namespace System.ServiceModel.Channels
 {
-       public class PrivacyNoticeBindingElement { }
        public class PrivacyNoticeBindingElementImporter { }
-       public class ReliableSessionBindingElement { }
        public class UseManagedPresentationBindingElementImporter { }
        public class XmlSerializerImportOptions { }
 }
index f799f9a3cd776e46842d86204a30c1e4eb7c64b1..df9e8cf49a8cc0a7ea54ef5b8b8400ae317a8d0c 100644 (file)
@@ -197,7 +197,7 @@ namespace System.ServiceModel
                        Uri address, Uri listenUri)
                {
                        EndpointAddress ea = BuildEndpointAddress (address, binding);
-                       ContractDescription cd = GetContract (implementedContract, binding.Name == "MetadataExchangeHttpBinding");
+                       ContractDescription cd = GetContract (implementedContract, binding.Namespace == "http://schemas.microsoft.com/ws/2005/02/mex/bindings");
                        if (cd == null)
                                throw new InvalidOperationException (String.Format ("Contract '{0}' was not found in the implemented contracts in this service host.", implementedContract));
                        return AddServiceEndpointCore (cd, binding, ea, listenUri);
@@ -279,7 +279,7 @@ namespace System.ServiceModel
                        ContractDescription cd, Binding binding, EndpointAddress address, Uri listenUri)
                {
                        foreach (ServiceEndpoint e in Description.Endpoints)
-                               if (e.Contract == cd)
+                               if (e.Contract == cd && e.Binding == binding && e.Address == address && e.ListenUri.Equals (listenUri))
                                        return e;
                        ServiceEndpoint se = new ServiceEndpoint (cd, binding, address);
                        se.ListenUri = listenUri.IsAbsoluteUri ? listenUri : new Uri (address.Uri, listenUri);
@@ -287,7 +287,6 @@ namespace System.ServiceModel
                        return se;
                }
 
-               [MonoTODO]
                protected virtual void ApplyConfiguration ()
                {
                        if (Description == null)
@@ -316,7 +315,6 @@ namespace System.ServiceModel
 
                                // services
                                foreach (ServiceEndpointElement endpoint in service.Endpoints) {
-                                       // FIXME: consider BindingName as well
                                        ServiceEndpoint se = AddServiceEndpoint (
                                                endpoint.Contract,
                                                ConfigUtil.CreateBinding (endpoint.Binding, endpoint.BindingConfiguration),
@@ -377,18 +375,18 @@ namespace System.ServiceModel
                        //Build all ChannelDispatchers, one dispatcher per user configured EndPoint.
                        //We must keep thet ServiceEndpoints as a seperate collection, since the user
                        //can change the collection in the description during the behaviors events.
-                       Dictionary<ServiceEndpoint, ChannelDispatcher> endPointToDispatcher = new Dictionary<ServiceEndpoint,ChannelDispatcher>();
                        ServiceEndpoint[] endPoints = new ServiceEndpoint[Description.Endpoints.Count];
                        Description.Endpoints.CopyTo (endPoints, 0);
+                       var builder = new DispatcherBuilder ();
                        foreach (ServiceEndpoint se in endPoints) {
 
                                var commonParams = new BindingParameterCollection ();
                                foreach (IServiceBehavior b in Description.Behaviors)
                                        b.AddBindingParameters (Description, this, Description.Endpoints, commonParams);
 
-                               var channel = new DispatcherBuilder ().BuildChannelDispatcher (Description.ServiceType, se, commonParams);
-                               ChannelDispatchers.Add (channel);
-                               endPointToDispatcher[se] = channel;
+                               var channel = builder.BuildChannelDispatcher (Description.ServiceType, se, commonParams);
+                               if (!ChannelDispatchers.Contains (channel))
+                                       ChannelDispatchers.Add (channel);
                        }
 
                        //After the ChannelDispatchers are created, and attached to the service host
@@ -396,9 +394,7 @@ namespace System.ServiceModel
                        foreach (IServiceBehavior b in Description.Behaviors)
                                b.ApplyDispatchBehavior (Description, this);
 
-                       foreach(KeyValuePair<ServiceEndpoint, ChannelDispatcher> val in endPointToDispatcher)
-                               foreach (var ed in val.Value.Endpoints)
-                                       ApplyDispatchBehavior (ed, val.Key);                    
+                       builder.ApplyDispatchBehaviors ();
                }
 
                private void ValidateDescription ()
@@ -412,19 +408,6 @@ namespace System.ServiceModel
                                throw new InvalidOperationException ("The ServiceHost must have at least one application endpoint (that does not include metadata exchange contract) defined by either configuration, behaviors or call to AddServiceEndpoint methods.");
                }
 
-               private void ApplyDispatchBehavior (EndpointDispatcher ed, ServiceEndpoint endPoint)
-               {
-                       foreach (IContractBehavior b in endPoint.Contract.Behaviors)
-                               b.ApplyDispatchBehavior (endPoint.Contract, endPoint, ed.DispatchRuntime);
-                       foreach (IEndpointBehavior b in endPoint.Behaviors)
-                               b.ApplyDispatchBehavior (endPoint, ed);
-                       foreach (OperationDescription operation in endPoint.Contract.Operations) {
-                               foreach (IOperationBehavior b in operation.Behaviors)
-                                       b.ApplyDispatchBehavior (operation, ed.DispatchRuntime.Operations [operation.Name]);
-                       }
-
-               }
-
                [MonoTODO]
                protected void LoadConfigurationSection (ServiceElement element)
                {
@@ -598,19 +581,60 @@ namespace System.ServiceModel
                */
        }
 
+       /// <summary>
+       ///  Builds ChannelDispatchers as appropriate to service the service endpoints. 
+       /// </summary>
+       /// <remarks>Will re-use ChannelDispatchers when two endpoint uris are the same</remarks>
        partial class DispatcherBuilder
        {
+               List<ChannelDispatcher> built_dispatchers = new List<ChannelDispatcher> ();
+               Dictionary<ServiceEndpoint, EndpointDispatcher> ep_to_dispatcher_ep = new Dictionary<ServiceEndpoint, EndpointDispatcher> ();
+               
                internal ChannelDispatcher BuildChannelDispatcher (Type serviceType, ServiceEndpoint se, BindingParameterCollection commonParams)
                {
                        //Let all behaviors add their binding parameters
                        AddBindingParameters (commonParams, se);
-                       //User the binding parameters to build the channel listener and Dispatcher
-                       IChannelListener lf = BuildListener (se, commonParams);
-                       ChannelDispatcher cd = new ChannelDispatcher (
-                               lf, se.Binding.Name);
-                       cd.InitializeServiceEndpoint (serviceType, se);
+                       
+                       // See if there's an existing channel that matches this endpoint
+                       ChannelDispatcher cd = FindExistingDispatcher (se);
+                       EndpointDispatcher ep;
+                       if (cd != null) {
+                               ep = cd.InitializeServiceEndpoint (serviceType, se);
+                       } else {
+                               // Use the binding parameters to build the channel listener and Dispatcher.
+                               IChannelListener lf = BuildListener (se, commonParams);
+                               cd = new ChannelDispatcher (
+                                       lf, se.Binding.Name);
+                               ep = cd.InitializeServiceEndpoint (serviceType, se);
+                               built_dispatchers.Add (cd);
+                       }
+                       ep_to_dispatcher_ep[se] = ep;
                        return cd;
                }
+               
+               ChannelDispatcher FindExistingDispatcher (ServiceEndpoint se)
+               {
+                       return built_dispatchers.FirstOrDefault ((ChannelDispatcher cd) => (cd.Listener.Uri.Equals (se.ListenUri)) && cd.MessageVersion.Equals (se.Binding.MessageVersion));
+               }
+
+               internal void ApplyDispatchBehaviors ()
+               {
+                       foreach (KeyValuePair<ServiceEndpoint, EndpointDispatcher> val in ep_to_dispatcher_ep)
+                               ApplyDispatchBehavior (val.Value, val.Key);
+               }
+               
+               private void ApplyDispatchBehavior (EndpointDispatcher ed, ServiceEndpoint endPoint)
+               {
+                       foreach (IContractBehavior b in endPoint.Contract.Behaviors)
+                               b.ApplyDispatchBehavior (endPoint.Contract, endPoint, ed.DispatchRuntime);
+                       foreach (IEndpointBehavior b in endPoint.Behaviors)
+                               b.ApplyDispatchBehavior (endPoint, ed);
+                       foreach (OperationDescription operation in endPoint.Contract.Operations) {
+                               foreach (IOperationBehavior b in operation.Behaviors)
+                                       b.ApplyDispatchBehavior (operation, ed.DispatchRuntime.Operations [operation.Name]);
+                       }
+
+               }
 
                private void AddBindingParameters (BindingParameterCollection commonParams, ServiceEndpoint endPoint) {
 
index 9f5fcac8879f53b5d287a39d41f8fc84383c9125..ea294883a65a756c6f5b5f9916f08e7952f3ebc0 100644 (file)
@@ -172,12 +172,13 @@ namespace System.ServiceModel
                        }
                        BindingElement tr = GetTransport ();
                        List<BindingElement> list = new List<BindingElement> ();
-                       list.Add (tx);
+                       list.Add (tx); // it is always added.
                        if (sec != null)
                                list.Add (sec);
                        list.Add (msg);
                        if (tr != null)
                                list.Add (tr);
+                       // FIXME: add ReliableSessionBindingElement
                        return new BindingElementCollection (list.ToArray ());
                }
 
index aaeadc7b8ff67b5524e5085890beb6da0ad24d90..b2def7116fe0f0daa75ef2761e50a7cd465cee83 100644 (file)
@@ -1,3 +1,37 @@
+FeatureBased/Features.Client/AsyncCallTesterProxy.cs
+FeatureBased/Features.Client/AsyncPatternServer.cs
+FeatureBased/Features.Client/DataContractTesterProxy.cs
+FeatureBased/Features.Client/ExitProcessHelperServer.cs
+FeatureBased/Features.Client/FaultsTesterProxy.cs
+FeatureBased/Features.Client/KnownTypeTesterProxy.cs
+FeatureBased/Features.Client/MessageContractTesterProxy.cs
+FeatureBased/Features.Client/OperationContractServer.cs
+FeatureBased/Features.Client/PrimitiveTester.cs
+FeatureBased/Features.Client/UntypedMessageTesterProxy.cs
+FeatureBased/Features.Contracts/AsyncCallTester.cs
+FeatureBased/Features.Contracts/AsyncPatternContract.cs
+FeatureBased/Features.Contracts/DataContractTester.cs
+FeatureBased/Features.Contracts/DualContract.cs
+FeatureBased/Features.Contracts/ExitpProcessHelper.cs
+FeatureBased/Features.Contracts/FaultsTester.cs
+FeatureBased/Features.Contracts/KnownTypeTester.cs
+FeatureBased/Features.Contracts/MessageContractTester.cs
+FeatureBased/Features.Contracts/OperationContract.cs
+FeatureBased/Features.Contracts/PrimitiveTester.cs
+FeatureBased/Features.Contracts/UntypedMessageTester.cs
+FeatureBased/Features.Serialization/AsyncCallTest.cs
+FeatureBased/Features.Serialization/AsyncPatternTester.cs
+FeatureBased/Features.Serialization/DataContractSerializerTest.cs
+FeatureBased/Features.Serialization/DualContractTester.cs
+FeatureBased/Features.Serialization/ExitProcessHelper.cs
+FeatureBased/Features.Serialization/FaultsTest.cs
+FeatureBased/Features.Serialization/KnownTypeTest.cs
+FeatureBased/Features.Serialization/MessageContractTest.cs
+FeatureBased/Features.Serialization/OperationContractTester.cs
+FeatureBased/Features.Serialization/PrimitiveTesterTest.cs
+FeatureBased/Features.Serialization/UntypedMessageTest.cs
+FeatureBased/Features.Serialization/XmlComparer.cs
+FeatureBased/TestFixtureBase.cs
 System.ServiceModel.Channels/AddressHeaderTest.cs
 System.ServiceModel.Channels/AddressingVersionTest.cs
 System.ServiceModel.Channels/AsymmetricSecurityBindingElementTest.cs
@@ -67,11 +101,12 @@ System.ServiceModel.Configuration/StandardBindingElementTest.cs
 System.ServiceModel.Configuration/UserBinding.cs
 System.ServiceModel.Description/ClientCredentialsTest.cs
 System.ServiceModel.Description/ContractDescriptionTest.cs
+System.ServiceModel.Description/MetadataExchangeBindingsTest.cs
 System.ServiceModel.Description/MetadataResolverTest.cs
 System.ServiceModel.Description/OperationDescriptionTest.cs
 System.ServiceModel.Description/ServiceAuthorizationBehaviorTest.cs
-System.ServiceModel.Description/ServiceCredentialsTest.cs
 System.ServiceModel.Description/ServiceContractGeneratorTest.cs
+System.ServiceModel.Description/ServiceCredentialsTest.cs
 System.ServiceModel.Description/ServiceDebugBehaviorTest.cs
 System.ServiceModel.Description/ServiceEndpointTest.cs
 System.ServiceModel.Description/ServiceMetadataBehaviorTest.cs
@@ -80,6 +115,7 @@ System.ServiceModel.Description/TypedMessageConverterTest.cs
 System.ServiceModel.Description/WsdlExporterTest.cs
 System.ServiceModel.Description/WsdlImporterTest.cs
 System.ServiceModel.Dispatcher/ActionFilterTest.cs
+System.ServiceModel.Dispatcher/ChannelDispatcherTest.cs
 System.ServiceModel.Dispatcher/DispatchOperationTest.cs
 System.ServiceModel.Dispatcher/DispatchRuntimeTest.cs
 System.ServiceModel.Dispatcher/EndpointAddressMessageFilterTest.cs
@@ -88,7 +124,7 @@ System.ServiceModel.Dispatcher/ExceptionHandlerTest.cs
 System.ServiceModel.Dispatcher/FilterTableTest.cs
 System.ServiceModel.Dispatcher/InvalidBodyAccessExceptionTest.cs
 System.ServiceModel.Dispatcher/PrefixEndpointAddressMessageFilterTest.cs
-System.ServiceModel.Dispatcher/ChannelDispatcherTest.cs
+System.ServiceModel.Dispatcher/XPathMessageContextTest.cs
 System.ServiceModel.PeerResolvers/CustomPeerResolverServiceTest.cs
 System.ServiceModel.PeerResolvers/PeerResolverSerializationTest.cs
 System.ServiceModel.Security.Tokens/IssuedSecurityTokenParametersTest.cs
@@ -113,6 +149,7 @@ System.ServiceModel.Security/SecurityTokenSpeficicationTest.cs
 System.ServiceModel.Security/ServiceCredentialsSecurityTokenManagerTest.cs
 System.ServiceModel.Security/ServiceSecurityContextTest.cs
 System.ServiceModel.Security/SupportingTokenParametersTest.cs
+System.ServiceModel.Security/TransportSecurityBindingElementTest.cs
 System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
 System.ServiceModel/BasicHttpBindingTest.cs
 System.ServiceModel/CallbackBehaviorAttributeTest.cs
@@ -122,6 +159,7 @@ System.ServiceModel/ClientBaseTest.cs
 System.ServiceModel/ClientBase_InteractiveChannelInitializerTest.cs
 System.ServiceModel/ClientCredentialsSecurityTokenManagerTest.cs
 System.ServiceModel/CommonUseCases.cs
+System.ServiceModel/Constants.cs
 System.ServiceModel/EndpointAddress10Test.cs
 System.ServiceModel/EndpointAddressBuilderTest.cs
 System.ServiceModel/EndpointAddressTest.cs
@@ -133,8 +171,8 @@ System.ServiceModel/FaultReasonTest.cs
 System.ServiceModel/IntegratedConnectionTest.cs
 System.ServiceModel/MessageSecurityVersionTest.cs
 System.ServiceModel/NetMsmqBindingTest.cs
-System.ServiceModel/NetTcpBindingTest.cs
 System.ServiceModel/NetPeerTcpBindingTest.cs
+System.ServiceModel/NetTcpBindingTest.cs
 System.ServiceModel/OperationContextTest.cs
 System.ServiceModel/PeerNodeAddressTest.cs
 System.ServiceModel/ServiceAssert.cs
@@ -147,23 +185,3 @@ System.ServiceModel/TransactionProtocolTest.cs
 System.ServiceModel/UriSchemeKeyedCollectionTest.cs
 System.ServiceModel/WSFederationHttpBindingTest.cs
 System.ServiceModel/WSHttpBindingTest.cs
-FeatureBased/TestFixtureBase.cs
-FeatureBased/Features.Client/DataContractTesterProxy.cs
-FeatureBased/Features.Client/PrimitiveTester.cs
-FeatureBased/Features.Contracts/DataContractTester.cs
-FeatureBased/Features.Contracts/DualContract.cs
-FeatureBased/Features.Contracts/MessageContractTester.cs
-FeatureBased/Features.Contracts/PrimitiveTester.cs
-FeatureBased/Features.Serialization/DataContractSerializerTest.cs
-FeatureBased/Features.Serialization/DualContractTester.cs
-FeatureBased/Features.Serialization/PrimitiveTesterTest.cs
-FeatureBased/Features.Client/FaultsTesterProxy.cs
-FeatureBased/Features.Client/KnownTypeTesterProxy.cs
-FeatureBased/Features.Client/MessageContractTesterProxy.cs
-FeatureBased/Features.Client/UntypedMessageTesterProxy.cs
-FeatureBased/Features.Serialization/FaultsTest.cs
-FeatureBased/Features.Contracts/FaultsTester.cs
-FeatureBased/Features.Contracts/KnownTypeTester.cs
-FeatureBased/Features.Serialization/MessageContractTest.cs
-FeatureBased/Features.Contracts/UntypedMessageTester.cs
-FeatureBased/Features.Serialization/XmlComparer.cs
index 75c583db55a9b82be9aefcc35e1a54a4236836df..15b366a1b1950a52724d771c3e22282bce549c5d 100644 (file)
@@ -1,3 +1,12 @@
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageBufferTest.cs : add test for copy of IsFault value.
+
+2010-03-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs : add another IsFault tests, which exposed some
+         issues at client side.
+
 2010-01-21  Atsushi Enomoto  <atsushi@ximian.com>
 
        * SslStreamSecurityBindingElementTest.cs : reduce extra base dep.
index 7bf87c60cfcd0a53e6bee2f71be4dd1d16834ef5..7a65ee94cc5b633bb93681f830ffa639d4d4190d 100644 (file)
@@ -175,6 +175,18 @@ namespace MonoTests.System.ServiceModel.Channels
                                msg.WriteMessage (w);
                        }
                }
+
+               [Test]
+               public void IsFaultCopied ()
+               {
+                       var ret = Message.CreateMessage (MessageVersion.Soap12,
+                               MessageFault.CreateFault (new FaultCode ("mycode"), "private affair"),
+                               "http://tempuri.org/IFoo/Test");
+                       Assert.IsTrue (ret.IsFault, "#1");
+                       var mb = ret.CreateBufferedCopy (0x1000);
+                       ret = mb.CreateMessage ();
+                       Assert.IsTrue (ret.IsFault, "#2");
+               }
        }
 
        internal class MyBodyWriter : BodyWriter
index a54294c2674881acd397c1a4a715e8bff6987f60..992c7209fe9f4d98277999f80e23b5353f62e520 100644 (file)
@@ -320,6 +320,39 @@ namespace MonoTests.System.ServiceModel.Channels
                        Assert.IsTrue (m.IsFault, "#2");
                }
 
+               [Test]
+               public void IsFault2 ()
+               {
+                       string xml = @"
+<s:Envelope xmlns:a='http://www.w3.org/2005/08/addressing' xmlns:s='http://www.w3.org/2003/05/soap-envelope'>
+  <s:Header>
+    <a:Action s:mustUnderstand='1'>http://www.w3.org/2005/08/addressing/fault</a:Action>
+  </s:Header>
+  <s:Body>
+    <s:Fault xmlns:s='http://www.w3.org/2003/05/soap-envelope'>
+      <s:Code>
+        <s:Value>s:Sender</s:Value>
+        <s:Subcode>
+          <s:Value>a:ActionNotSupported</s:Value>
+        </s:Subcode>
+      </s:Code>
+      <s:Reason>
+        <s:Text xml:lang='ja-JP'>message</s:Text>
+      </s:Reason>
+    </s:Fault>
+  </s:Body>
+</s:Envelope>";
+                       var msg = Message.CreateMessage (MessageVersion.Soap11, "urn:foo", XmlReader.Create (new StringReader (xml)));
+                       Assert.AreEqual ("urn:foo", msg.Headers.Action, "#1");
+                       msg.ToString ();
+                       Assert.IsFalse (msg.IsFault, "#2"); // version mismatch
+
+                       msg = Message.CreateMessage (MessageVersion.Soap12, "urn:foo", XmlReader.Create (new StringReader (xml)));
+                       Assert.AreEqual ("urn:foo", msg.Headers.Action, "#3");
+                       msg.ToString ();
+                       Assert.IsFalse (msg.IsFault, "#4"); // version match, but it doesn't set as true. It is set true only when it is constructed with fault objects.
+               }
+
                [Test]
                public void State ()
                {
index a3cd0a70029c31b830e2c7b4bff44e51b945f8dc..aeaf659a7c2cddbea2a92d00ae7503d78ef8c49c 100755 (executable)
@@ -1,3 +1,7 @@
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MetadataExchangeBindingsTest.cs : new test.
+
 2010-02-10  Atsushi Enomoto  <atsushi@ximian.com>
 
        * WsdlImporterTest.cs : ignore whatever make dist broke.
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataExchangeBindingsTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataExchangeBindingsTest.cs
new file mode 100644 (file)
index 0000000..3b533c6
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// MetadataResolverTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2010 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class MetadataExchangeBindingsTest
+       {
+               [Test]
+               public void CreateMexHttpBinding ()
+               {
+                       var b = MetadataExchangeBindings.CreateMexHttpBinding () as WSHttpBinding;
+                       Assert.IsNotNull (b, "#1");
+                       Assert.AreEqual (SecurityMode.None, b.Security.Mode, "#2");
+                       Assert.IsFalse (b.TransactionFlow, "#3");
+                       Assert.IsFalse (b.ReliableSession.Enabled, "#4");
+                       Assert.IsFalse (b.CreateBindingElements ().Any (be => be is SecurityBindingElement), "#b1");
+                       Assert.IsTrue (b.CreateBindingElements ().Any (be => be is TransactionFlowBindingElement), "#b2");
+                       Assert.IsFalse (b.CreateBindingElements ().Any (be => be is ReliableSessionBindingElement), "#b3");
+                       Assert.IsTrue (new TransactionFlowBindingElement ().TransactionProtocol == TransactionProtocol.Default, "#x1");
+               }
+       }
+}
index 31051bdbee868a15df6e311e5ab47a03b42d1695..cc0c804cafc5b3bc1aa91b4b6dec2549734dd538 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XPathMessageContextTest.cs : new.
+
 2010-01-06  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ChannelDispatcherTest.cs : format message correctly.
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/XPathMessageContextTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/XPathMessageContextTest.cs
new file mode 100644 (file)
index 0000000..6abe0e6
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// XPathMessageContextTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class XPathMessageContextTest
+       {
+               XPathMessageContext ctx = new XPathMessageContext ();
+
+               [Test]
+               public void PredefinedNamespaces ()
+               {
+                       Assert.AreEqual (Constants.Soap11, ctx.LookupNamespace ("s11"), "#1");
+                       Assert.AreEqual (Constants.Soap12, ctx.LookupNamespace ("s12"), "#2");
+                       // ... only them?
+
+                       foreach (char c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
+                               Assert.IsNull (ctx.LookupNamespace (c + ""), "char:" + c);
+
+                       Assert.IsNull (ctx.LookupNamespace ("wsa"), "#3");
+                       Assert.IsNull (ctx.LookupNamespace ("wsu"), "#4");
+               }
+       }
+}
index cb0ba913dc784e3460bbb2d6eb189bf7d858785e..fabab751925e652999a7c328175f6a02e4a2e234 100755 (executable)
@@ -1,3 +1,7 @@
+2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransportSecurityBindingElementTest.cs : new test.
+
 2009-12-14  Atsushi Enomoto  <atsushi@ximian.com>
 
        * WSSecurityTokenSerializerTest.cs : disable non-working test that
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/TransportSecurityBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/TransportSecurityBindingElementTest.cs
new file mode 100644 (file)
index 0000000..c9d7e2a
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// TransportSecurityBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Security.Cryptography.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Security
+{
+       [TestFixture]
+       public class TransportSecurityBindingElementTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       var be = new TransportSecurityBindingElement ();
+               }
+
+       }
+}
index 83dc19735136a8ce4aa372499c5112ef141e4129..8017b8750c2e3b19b0217123d431900e0baba3f9 100755 (executable)
@@ -1,3 +1,12 @@
+2010-03-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBaseTest.cs : add not-working ActionNotFound test by
+         Matt Dargavel.
+
+2010-03-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : copied from the lib itself.
+
 2010-02-05  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ServiceHostBaseTest.cs : on unixy filesystems "/foobar"
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/Constants.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/Constants.cs
new file mode 100644 (file)
index 0000000..8363da1
--- /dev/null
@@ -0,0 +1,263 @@
+//
+// Constants.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Xml;
+
+namespace System.ServiceModel
+{
+       internal class Constants
+       {
+               public const string Soap11 = "http://schemas.xmlsoap.org/soap/envelope/";
+               public const string Soap12 = "http://www.w3.org/2003/05/soap-envelope";
+
+               public const string WSBasicSecurityProfileCore1 = "http://ws-i.org/profiles/basic-security/core/1.0";
+
+               public const string WsaAnonymousUri = "http://www.w3.org/2005/08/addressing/anonymous";
+               public const string WsaIdentityUri = "http://schemas.xmlsoap.org/ws/2006/02/addressingidentity";
+
+               public const string MSSerialization = "http://schemas.microsoft.com/2003/10/Serialization/";
+
+               public const string WssKeyIdentifierX509Thumbptint = "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1";
+
+               public const string WssBase64BinaryEncodingType = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary";
+
+               public const string WssKeyIdentifierEncryptedKey = "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKeySHA1";
+
+               public const string XmlDsig = "http://www.w3.org/2000/09/xmldsig#";
+
+               public const string WSSSamlToken = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1";
+               public const string WSSX509Token = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3";
+               public const string WssKeyIdentifierSamlAssertion = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID";
+               public const string WSSUserNameToken = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken";
+               public const string WsscContextToken = "http://schemas.xmlsoap.org/ws/2005/02/sc/sct";
+               public const string WSSKerberosToken = "http://docs.oasis-open.org/wss/oasis-wss-kerberos-token-profile-1.1#GSS_Kerberosv5_AP_REQ";
+               public const string WSSEncryptedKeyToken = "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey";
+
+               public const string WstNamespace = "http://schemas.xmlsoap.org/ws/2005/02/trust";
+               public const string WssNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
+               public const string Wss11Namespace = "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd";
+               public const string WspNamespace = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+               public const string WsaNamespace = "http://www.w3.org/2005/08/addressing";
+               public const string WsuNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
+               public const string WsscNamespace = "http://schemas.xmlsoap.org/ws/2005/02/sc";
+               public const string WsidNamespace = "http://schemas.xmlsoap.org/ws/2005/05/identity";
+
+               public const string WstIssueAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue";
+               public const string WstRenewAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Renew";
+               public const string WstCancelAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Cancel";
+               public const string WstValidateAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Validate";
+               public const string WstIssueReplyAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue";
+               public const string WstRenewReplyAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Renew";
+               public const string WstCancelReplyAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Cancel";
+               public const string WstValidateReplyAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Validate";
+
+               public const string WsscDefaultLabel = "WS-SecureConversationWS-SecureConversation";
+
+               // .NET BUG: it requires extra white space !
+               public const string WstBinaryExchangeValueTls = " http://schemas.xmlsoap.org/ws/2005/02/trust/tlsnego";
+               public const string WstBinaryExchangeValueGss = "http://schemas.xmlsoap.org/ws/2005/02/trust/spnego";
+
+               public const string MSTlsnegoTokenContent = "http://schemas.microsoft.com/ws/2006/05/security";
+
+               public const string WstTlsnegoProofTokenType = "http://schemas.xmlsoap.org/2005/02/trust/tlsnego#TLS_Wrap";
+               public const string WstSpnegoProofTokenType = "http://schemas.xmlsoap.org/2005/02/trust/spnego#TLS_Wrap";
+
+               public const string WstIssueRequest = "http://schemas.xmlsoap.org/ws/2005/02/trust/Issue";
+               public const string WstRenewRequest = "http://schemas.xmlsoap.org/ws/2005/02/trust/Renew";
+               public const string WstCancelRequest = "http://schemas.xmlsoap.org/ws/2005/02/trust/Cancel";
+               public const string WstValidateRequest = "http://schemas.xmlsoap.org/ws/2005/02/trust/Validate";
+
+               public const string WstSymmetricKeyTypeUri = "http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey";
+               public const string WstAsymmetricKeyTypeUri = "http://schemas.xmlsoap.org/ws/2005/02/trust/AsymmetricKey";
+
+               public const string LifetimeFormat = "yyyy-MM-dd'T'HH:mm:ss.fffZ";
+
+               // Those OIDs except for Kerberos5 are described here:
+               // http://www.alvestrand.no/objectid/
+               // (searching web for those OIDs would give you pointers.)
+               public const string OidSpnego = "1.3.6.1.5.5.2";
+               public const string OidNtlmSsp = "1.3.6.1.4.1.311.2.2.10";
+               public const string OidKerberos5 = "1.2.840.48018.1.2.2";
+               public const string OidMIT = "1.2.840.113554.1.2.2";
+
+               // Peer resolvers
+               public const string NetPeer = "http://schemas.microsoft.com/net/2006/05/peer";
+
+               // See [MC-NBFS] in Microsoft OSP. The strings are copied from the PDF, so the actual values might be wrong.
+               static readonly string [] dict_strings = {
+                       "mustUnderstand", "Envelope",
+                       "http://www.w3.org/2003/05/soap-envelope",
+                       "http://www.w3.org/2005/08/addressing", "Header", "Action", "To", "Body", "Algorithm", "RelatesTo",
+                       "http://www.w3.org/2005/08/addressing/anonymous", "URI", "Reference", "MessageID", "Id", "Identifier",
+                       "http://schemas.xmlsoap.org/ws/2005/02/rm", "Transforms", "Transform", "DigestMethod", "DigestValue", "Address", "ReplyTo", "SequenceAcknowledgement", "AcknowledgementRange", "Upper", "Lower", "BufferRemaining",
+                       "http://schemas.microsoft.com/ws/2006/05/rm",
+                       "http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement", "SecurityTokenReference", "Sequence", "MessageNumber",
+                       "http://www.w3.org/2000/09/xmldsig#",
+                       "http://www.w3.org/2000/09/xmldsig#enveloped-signature", "KeyInfo",
+                       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
+                       "http://www.w3.org/2001/04/xmlenc#",
+                       "http://schemas.xmlsoap.org/ws/2005/02/sc", "DerivedKeyToken", "Nonce", "Signature", "SignedInfo", "CanonicalizationMethod", "SignatureMethod", "SignatureValue", "DataReference", "EncryptedData", "EncryptionMethod", "CipherData", "CipherValue",
+                       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "Security", "Timestamp", "Created", "Expires", "Length", "ReferenceList", "ValueType", "Type", "EncryptedHeader",
+                       "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd", "RequestSecurityTokenResponseCollection",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust#BinarySecret",
+                       "http://schemas.microsoft.com/ws/2006/02/transactions", "s", "Fault", "MustUnderstand", "role", "relay", "Code", "Reason", "Text", "Node", "Role", "Detail", "Value", "Subcode", "NotUnderstood", "qname", "", "From", "FaultTo", "EndpointReference", "PortType", "ServiceName", "PortName", "ReferenceProperties", "RelationshipType", "Reply", "a",
+                       "http://schemas.xmlsoap.org/ws/2006/02/addressingidentity", "Identity", "Spn", "Upn", "Rsa", "Dns", "X509v3Certificate",
+                       "http://www.w3.org/2005/08/addressing/fault", "ReferenceParameters", "IsReferenceParameter",
+                       "http://www.w3.org/2005/08/addressing/reply",
+                       "http://www.w3.org/2005/08/addressing/none", "Metadata",
+                       "http://schemas.xmlsoap.org/ws/2004/08/addressing",
+                       "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+                       "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault",
+                       "http://schemas.xmlsoap.org/ws/2004/06/addressingex", "RedirectTo", "Via",
+                       "http://www.w3.org/2001/10/xml-exc-c14n#", "PrefixList", "InclusiveNamespaces", "ec", "SecurityContextToken", "Generation", "Label", "Offset", "Properties", "Cookie", "wsc",
+                       "http://schemas.xmlsoap.org/ws/2004/04/sc",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/sc/dk",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/sc/sct",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/trust/RST/SCT",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/trust/RSTR/SCT", "RenewNeeded", "BadContextToken", "c",
+                       "http://schemas.xmlsoap.org/ws/2005/02/sc/dk",
+                       "http://schemas.xmlsoap.org/ws/2005/02/sc/sct",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/SCT",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT/Renew",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/SCT/Renew",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT/Cancel",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/SCT/Cancel",
+                       "http://www.w3.org/2001/04/xmlenc#aes128-cbc",
+                       "http://www.w3.org/2001/04/xmlenc#kw-aes128",
+                       "http://www.w3.org/2001/04/xmlenc#aes192-cbc",
+                       "http://www.w3.org/2001/04/xmlenc#kw-aes192",
+                       "http://www.w3.org/2001/04/xmlenc#aes256-cbc",
+                       "http://www.w3.org/2001/04/xmlenc#kw-aes256",
+                       "http://www.w3.org/2001/04/xmlenc#des-cbc",
+                       "http://www.w3.org/2000/09/xmldsig#dsa-sha1",
+                       "http://www.w3.org/2001/10/xml-exc-c14n#WithComments",
+                       "http://www.w3.org/2000/09/xmldsig#hmac-sha1",
+                       "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256",
+                       "http://schemas.xmlsoap.org/ws/2005/02/sc/dk/p_sha1",
+                       "http://www.w3.org/2001/04/xmlenc#ripemd160",
+                       "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p",
+                       "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
+                       "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
+                       "http://www.w3.org/2001/04/xmlenc#rsa-1_5",
+                       "http://www.w3.org/2000/09/xmldsig#sha1",
+                       "http://www.w3.org/2001/04/xmlenc#sha256",
+                       "http://www.w3.org/2001/04/xmlenc#sha512",
+                       "http://www.w3.org/2001/04/xmlenc#tripledes-cbc",
+                       "http://www.w3.org/2001/04/xmlenc#kw-tripledes",
+                       "http://schemas.xmlsoap.org/2005/02/trust/tlsnego#TLS_Wrap",
+                       "http://schemas.xmlsoap.org/2005/02/trust/spnego#GSS_Wrap",
+                       "http://schemas.microsoft.com/ws/2006/05/security", "dnse", "o", "Password", "PasswordText", "Username", "UsernameToken", "BinarySecurityToken", "EncodingType", "KeyIdentifier",
+                       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary",
+                       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#HexBinary",
+                       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Text",
+                       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier",
+                       "http://docs.oasis-open.org/wss/oasis-wss-kerberos-token-profile-1.1#GSS_Kerberosv5_AP_REQ",
+                       "http://docs.oasis-open.org/wss/oasis-wss-kerberos-token-profile-1.1#GSS_Kerberosv5_AP_REQ1510",
+                       "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID", "Assertion", "urn:oasis:names:tc:SAML:1.0:assertion",
+                       "http://docs.oasis-open.org/wss/oasis-wss-rel-token-profile-1.0.pdf#license", "FailedAuthentication", "InvalidSecurityToken", "InvalidSecurity", "k", "SignatureConfirmation", "TokenType",
+                       "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1",
+                       "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey",
+                       "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKeySHA1",
+                       "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1",
+                       "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0",
+                       "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID", "AUTH-HASH", "RequestSecurityTokenResponse", "KeySize", "RequestedTokenReference", "AppliesTo", "Authenticator", "CombinedHash", "BinaryExchange", "Lifetime", "RequestedSecurityToken", "Entropy", "RequestedProofToken", "ComputedKey", "RequestSecurityToken", "RequestType", "Context", "BinarySecret",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/spnego",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/tlsnego", "wst",
+                       "http://schemas.xmlsoap.org/ws/2004/04/trust",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/trust/RST/Issue",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/trust/RSTR/Issue",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/trust/CK/PSHA1",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/trust/SymmetricKey",
+                       "http://schemas.xmlsoap.org/ws/2004/04/security/trust/Nonce", "KeyType",
+                       "http://schemas.xmlsoap.org/ws/2004/04/trust/SymmetricKey",
+                       "http://schemas.xmlsoap.org/ws/2004/04/trust/PublicKey", "Claims", "InvalidRequest", "RequestFailed", "SignWith", "EncryptWith", "EncryptionAlgorithm", "CanonicalizationAlgorithm", "ComputedKeyAlgorithm", "UseKey",
+                       "http://schemas.microsoft.com/net/2004/07/secext/WS-SPNego",
+                       "http://schemas.microsoft.com/net/2004/07/secext/TLSNego", "t",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/Issue",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/CK/PSHA1",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/Nonce", "RenewTarget", "CancelTarget", "RequestedTokenCancelled", "RequestedAttachedReference", "RequestedUnattachedReference", "IssuedTokens",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/Renew",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/Cancel",
+                       "http://schemas.xmlsoap.org/ws/2005/02/trust/PublicKey", "Access", "AccessDecision", "Advice", "AssertionID", "AssertionIDReference", "Attribute", "AttributeName", "AttributeNamespace", "AttributeStatement", "AttributeValue", "Audience", "AudienceRestrictionCondition", "AuthenticationInstant", "AuthenticationMethod", "AuthenticationStatement", "AuthorityBinding", "AuthorityKind", "AuthorizationDecisionStatement", "Binding", "Condition", "Conditions", "Decision", "DoNotCacheCondition", "Evidence", "IssueInstant", "Issuer", "Location", "MajorVersion", "MinorVersion", "NameIdentifier", "Format", "NameQualifier", "Namespace", "NotBefore", "NotOnOrAfter", "saml", "Statement", "Subject", "SubjectConfirmation", "SubjectConfirmationData", "ConfirmationMethod", "urn:oasis:names:tc:SAML:1.0:cm:holder-of-key", "urn:oasis:names:tc:SAML:1.0:cm:sender-vouches", "SubjectLocality", "DNSAddress", "IPAddress", "SubjectStatement", "urn:oasis:names:tc:SAML:1.0:am:unspecified", "xmlns", "Resource", "UserName", "urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName", "EmailName", "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", "u", "ChannelInstance",
+                       "http://schemas.microsoft.com/ws/2005/02/duplex", "Encoding", "MimeType", "CarriedKeyName", "Recipient", "EncryptedKey", "KeyReference", "e",
+                       "http://www.w3.org/2001/04/xmlenc#Element",
+                       "http://www.w3.org/2001/04/xmlenc#Content", "KeyName", "MgmtData", "KeyValue", "RSAKeyValue", "Modulus", "Exponent", "X509Data", "X509IssuerSerial", "X509IssuerName", "X509SerialNumber", "X509Certificate", "AckRequested",
+                       "http://schemas.xmlsoap.org/ws/2005/02/rm/AckRequested", "AcksTo", "Accept", "CreateSequence",
+                       "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence", "CreateSequenceRefused", "CreateSequenceResponse",
+                       "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse", "FaultCode", "InvalidAcknowledgement", "LastMessage",
+                       "http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage", "LastMessageNumberExceeded", "MessageNumberRollover", "Nack", "netrm", "Offer", "r", "SequenceFault", "SequenceTerminated", "TerminateSequence",
+                       "http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence", "UnknownSequence",
+                       "http://schemas.microsoft.com/ws/2006/02/tx/oletx", "oletx", "OleTxTransaction", "PropagationToken",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wscoor", "wscoor", "CreateCoordinationContext", "CreateCoordinationContextResponse", "CoordinationContext", "CurrentContext", "CoordinationType", "RegistrationService", "Register", "RegisterResponse", "ProtocolIdentifier", "CoordinatorProtocolService", "ParticipantProtocolService",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContext",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContextResponse",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wscoor/Register",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wscoor/RegisterResponse",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wscoor/fault", "ActivationCoordinatorPortType", "RegistrationCoordinatorPortType", "InvalidState", "InvalidProtocol", "InvalidParameters", "NoActivity", "ContextRefused", "AlreadyRegistered",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat", "wsat",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Completion",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Durable2PC",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Volatile2PC", "Prepare", "Prepared", "ReadOnly", "Commit", "Rollback", "Committed", "Aborted", "Replay",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Commit",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Rollback",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Committed",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Aborted",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepare",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepared",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/ReadOnly",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/Replay",
+                       "http://schemas.xmlsoap.org/ws/2004/10/wsat/fault", "CompletionCoordinatorPortType", "CompletionParticipantPortType", "CoordinatorPortType", "ParticipantPortType", "InconsistentInternalState", "mstx", "Enlistment", "protocol", "LocalTransactionId", "IsolationLevel", "IsolationFlags", "Description", "Loopback", "RegisterInfo", "ContextId", "TokenId", "AccessDenied", "InvalidPolicy", "CoordinatorRegistrationFailed", "TooManyEnlistments", "Disabled", "ActivityId",
+                       "http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics",
+                       "http://docs.oasis-open.org/wss/oasis-wss-kerberos-token-profile-1.1#Kerberosv5APREQSHA1",
+                       "http://schemas.xmlsoap.org/ws/2002/12/policy", "FloodMessage", "LinkUtility", "Hops",
+                       "http://schemas.microsoft.com/net/2006/05/peer/HopCount", "PeerVia",
+                       "http://schemas.microsoft.com/net/2006/05/peer", "PeerFlooder", "PeerTo",
+                       "http://schemas.microsoft.com/ws/2005/05/routing", "PacketRoutable",
+                       "http://schemas.microsoft.com/ws/2005/05/addressing/none",
+                       "http://schemas.microsoft.com/ws/2005/05/envelope/none",
+                       "http://www.w3.org/2001/XMLSchema-instance",
+                       "http://www.w3.org/2001/XMLSchema", "nil", "type", "char", "boolean", "byte", "unsignedByte", "short", "unsignedShort", "int", "unsignedInt", "long", "unsignedLong", "float", "double", "decimal", "dateTime", "string", "base64Binary", "anyType", "duration", "guid", "anyURI", "QName", "time", "date", "hexBinary", "gYearMonth", "gYear", "gMonthDay", "gDay", "gMonth", "integer", "positiveInteger", "negativeInteger", "nonPositiveInteger", "nonNegativeInteger", "normalizedString", "ConnectionLimitReached",
+                       "http://schemas.xmlsoap.org/soap/envelope/", "Actor", "Faultcode", "Faultstring", "Faultactor", "Detail"
+               };
+
+               static Constants ()
+               {
+                       var d = new XmlDictionary ();
+                       SoapDictionary = d;
+                       foreach (var s in dict_strings)
+                               d.Add (s);
+               }
+
+               public static XmlDictionary SoapDictionary { get; private set; }
+       }
+}
index 5a1e9ea555189220d584bbc5f2a5bc578498c4bc..e668e387b3acd2dfba474166d3a2de02acc0a9e4 100644 (file)
@@ -323,6 +323,35 @@ namespace MonoTests.System.ServiceModel
                        Assert.Fail ("should not open");
                }
 
+               [Test]
+               [Category ("NotWorking")]
+               public void RunDestinationUnreachableTest ()
+               {
+                       string address = "http://localhost:37564/";
+                       var host = OpenHost (address);
+                       
+                       var binding = new BasicHttpBinding ();
+                       var client = new DestinationUnreachableClient (binding, address);
+                       
+                       try {
+                               client.NotImplementedOperation ();
+                               Assert.Fail ("ActionNotSupportedException is expected");
+                       } catch (ActionNotSupportedException) {
+                               // catching it instead of ExpectedException to distinguish errors at service side.
+                       }
+               }
+               
+               ServiceHost OpenHost (string address)
+               {
+                       var baseAddresses = new Uri[] { new Uri(address) };
+
+                       var host = new ServiceHost (typeof (DummyService), baseAddresses);
+                       var basicBinding = new BasicHttpBinding ();
+                       host.AddServiceEndpoint (typeof (IDummyService), basicBinding, new Uri ("", UriKind.Relative));
+                       host.Open ();
+                       return host;
+               }
+
                #region helpers
 
                public enum Stage
@@ -606,7 +635,39 @@ namespace MonoTests.System.ServiceModel
 
                        #endregion
                }
-               #endregion
 
+               [ServiceContract]
+               public interface IDummyService
+               {
+                       [OperationContract]
+                       void DummyOperation ();
+               }
+               public class DummyService : IDummyService
+               {
+                       public void DummyOperation ()
+                       {
+                               // Do nothing
+                       }
+               }
+               [ServiceContract]
+               public interface INotImplementedService
+               {
+                       [OperationContract]
+                       void NotImplementedOperation ();
+               }
+               public class DestinationUnreachableClient : ClientBase<INotImplementedService>, INotImplementedService
+               {
+                       public void NotImplementedOperation ()
+                       {
+                               Channel.NotImplementedOperation ();
+                       }
+               
+                       public DestinationUnreachableClient (Binding binding, string address) 
+                               : base (binding, new EndpointAddress (address))
+                       {
+                       }
+               }
+
+               #endregion
        }
 }
index 2870b466997a71bdd51c11c1523baa3786b2fa0c..fbaa524eab33dbd671abc9f909d43965a62b8ddc 100644 (file)
@@ -1,3 +1,3 @@
 ../../build/common/Consts.cs
 ../../build/common/MonoTODOAttribute.cs
-#include net_2_1_raw_System.ServiceModel.dll.sources
+#include moonlight_raw_System.ServiceModel.dll.sources
diff --git a/mcs/class/System.ServiceModel/moonlight_raw_System.ServiceModel.dll.sources b/mcs/class/System.ServiceModel/moonlight_raw_System.ServiceModel.dll.sources
new file mode 100755 (executable)
index 0000000..0108213
--- /dev/null
@@ -0,0 +1,226 @@
+Assembly/AssemblyInfo.cs
+Mono.CodeGeneration/CodeAdd.cs
+Mono.CodeGeneration/CodeAnd.cs
+Mono.CodeGeneration/CodeArgument.cs
+Mono.CodeGeneration/CodeArgumentReference.cs
+Mono.CodeGeneration/CodeArithmeticOperation.cs
+Mono.CodeGeneration/CodeArrayItem.cs
+Mono.CodeGeneration/CodeArrayLength.cs
+Mono.CodeGeneration/CodeAssignment.cs
+Mono.CodeGeneration/CodeBinaryComparison.cs
+Mono.CodeGeneration/CodeBinaryOperation.cs
+Mono.CodeGeneration/CodeBlock.cs
+Mono.CodeGeneration/CodeBuilder.cs
+Mono.CodeGeneration/CodeCast.cs
+Mono.CodeGeneration/CodeClass.cs
+Mono.CodeGeneration/CodeCustomAttribute.cs
+Mono.CodeGeneration/CodeDecrement.cs
+Mono.CodeGeneration/CodeEquals.cs
+Mono.CodeGeneration/CodeExpression.cs
+Mono.CodeGeneration/CodeFieldReference.cs
+Mono.CodeGeneration/CodeFor.cs
+Mono.CodeGeneration/CodeForeach.cs
+Mono.CodeGeneration/CodeGenerationHelper.cs
+Mono.CodeGeneration/CodeIf.cs
+Mono.CodeGeneration/CodeIncrement.cs
+Mono.CodeGeneration/CodeIs.cs
+Mono.CodeGeneration/CodeItem.cs
+Mono.CodeGeneration/CodeLiteral.cs
+Mono.CodeGeneration/CodeMethod.cs
+Mono.CodeGeneration/CodeMethodCall.cs
+Mono.CodeGeneration/CodeModule.cs
+Mono.CodeGeneration/CodeNew.cs
+Mono.CodeGeneration/CodeNewArray.cs
+Mono.CodeGeneration/CodeNotEquals.cs
+Mono.CodeGeneration/CodeOr.cs
+Mono.CodeGeneration/CodeProperty.cs
+Mono.CodeGeneration/CodePropertyReference.cs
+Mono.CodeGeneration/CodeReturn.cs
+Mono.CodeGeneration/CodeSelect.cs
+Mono.CodeGeneration/CodeTryBlock.cs
+Mono.CodeGeneration/CodeSelfIncrement.cs
+Mono.CodeGeneration/CodeUnaryOperation.cs
+Mono.CodeGeneration/CodeValueReference.cs
+Mono.CodeGeneration/CodeVariableDeclaration.cs
+Mono.CodeGeneration/CodeVariableReference.cs
+Mono.CodeGeneration/CodeWhen.cs
+Mono.CodeGeneration/CodeWhile.cs
+Mono.CodeGeneration/CodeWriter.cs
+Mono.CodeGeneration/Exp.cs
+System.Collections.Generic/KeyedByTypeCollection.cs
+System.Collections.Generic/SynchronizedCollection.cs
+System.Collections.Generic/SynchronizedKeyedCollection.cs
+System.Collections.Generic/SynchronizedReadOnlyCollection.cs
+System.ServiceModel.Channels/AddressHeader.cs
+System.ServiceModel.Channels/AddressHeaderCollection.cs
+System.ServiceModel.Channels/AddressingVersion.cs
+System.ServiceModel.Channels/BinaryMessageEncoder.cs
+System.ServiceModel.Channels/BinaryMessageEncoderFactory.cs
+System.ServiceModel.Channels/BinaryMessageEncodingBindingElement.cs
+System.ServiceModel.Channels/Binding.cs
+System.ServiceModel.Channels/BindingContext.cs
+System.ServiceModel.Channels/BindingElement.cs
+System.ServiceModel.Channels/BindingElementCollection.cs
+System.ServiceModel.Channels/BindingParameterCollection.cs
+System.ServiceModel.Channels/BodyWriter.cs
+System.ServiceModel.Channels/BufferManager.cs
+System.ServiceModel.Channels/ChannelBase.cs
+System.ServiceModel.Channels/ChannelFactoryBase.cs
+System.ServiceModel.Channels/ChannelManagerBase.cs
+System.ServiceModel.Channels/ChannelParameterCollection.cs
+System.ServiceModel.Channels/ChannelPoolSettings.cs
+System.ServiceModel.Channels/CommunicationObject.cs
+System.ServiceModel.Channels/CustomBinding.cs
+System.ServiceModel.Channels/FaultConverter.cs
+System.ServiceModel.Channels/HtmlizedException.cs
+System.ServiceModel.Channels/HttpChannelFactory.cs
+System.ServiceModel.Channels/HttpCookieContainerBindingElement.cs
+System.ServiceModel.Channels/HttpRequestChannel.cs
+System.ServiceModel.Channels/HttpRequestMessageProperty.cs
+System.ServiceModel.Channels/HttpResponseMessageProperty.cs
+System.ServiceModel.Channels/HttpTransportBindingElement.cs
+System.ServiceModel.Channels/HttpsTransportBindingElement.cs
+System.ServiceModel.Channels/IBindingRuntimePreferences.cs
+System.ServiceModel.Channels/IChannel.cs
+System.ServiceModel.Channels/IChannelFactory.cs
+System.ServiceModel.Channels/IDuplexChannel.cs
+System.ServiceModel.Channels/IDuplexSession.cs
+System.ServiceModel.Channels/IDuplexSessionChannel.cs
+System.ServiceModel.Channels/IHttpCookieContainer.cs
+System.ServiceModel.Channels/IInputChannel.cs
+System.ServiceModel.Channels/IInputSession.cs
+System.ServiceModel.Channels/IInputSessionChannel.cs
+System.ServiceModel.Channels/IMessageProperty.cs
+System.ServiceModel.Channels/IOutputChannel.cs
+System.ServiceModel.Channels/IOutputSession.cs
+System.ServiceModel.Channels/IOutputSessionChannel.cs
+System.ServiceModel.Channels/IRequestChannel.cs
+System.ServiceModel.Channels/IRequestSessionChannel.cs
+System.ServiceModel.Channels/ISecurityCapabilities.cs
+System.ServiceModel.Channels/ISession.cs
+System.ServiceModel.Channels/ISessionChannel.cs
+System.ServiceModel.Channels/LayeredCommunicationObject.cs
+System.ServiceModel.Channels/LayeredOutputChannel.cs
+System.ServiceModel.Channels/LayeredRequestChannel.cs
+System.ServiceModel.Channels/LocalClientSecuritySettings.cs
+System.ServiceModel.Channels/Message.cs
+System.ServiceModel.Channels/MessageBuffer_2_1.cs
+System.ServiceModel.Channels/MessageBufferImpl.cs
+System.ServiceModel.Channels/MessageEncoder.cs
+System.ServiceModel.Channels/MessageEncoderFactory.cs
+System.ServiceModel.Channels/MessageEncodingBindingElement.cs
+System.ServiceModel.Channels/MessageFault.cs
+System.ServiceModel.Channels/MessageFaultBodyWriter.cs
+System.ServiceModel.Channels/MessageHeader.cs
+System.ServiceModel.Channels/MessageHeaderInfo.cs
+System.ServiceModel.Channels/MessageHeaders.cs
+System.ServiceModel.Channels/MessageImpl.cs
+System.ServiceModel.Channels/MessageProperties.cs
+System.ServiceModel.Channels/MessageVersion.cs
+System.ServiceModel.Channels/OutputChannelBase.cs
+System.ServiceModel.Channels/RequestChannelBase.cs
+System.ServiceModel.Channels/RequestContext.cs
+System.ServiceModel.Channels/SecurityBindingElement.cs
+System.ServiceModel.Channels/TextMessageEncoder.cs
+System.ServiceModel.Channels/TextMessageEncoderFactory.cs
+System.ServiceModel.Channels/TextMessageEncodingBindingElement.cs
+System.ServiceModel.Channels/TransportBindingElement.cs
+System.ServiceModel.Channels/TransportSecurityBindingElement.cs
+System.ServiceModel.Channels/UnderstoodHeaders.cs
+System.ServiceModel.Channels/XmlObjectSerializerBodyWriter.cs
+System.ServiceModel.Channels/XmlReaderBodyWriter.cs
+System.ServiceModel.Description/ClientCredentials.cs
+System.ServiceModel.Description/ContractDescription.cs
+System.ServiceModel.Description/ContractDescriptionGenerator.cs
+System.ServiceModel.Description/FaultDescription.cs
+System.ServiceModel.Description/FaultDescriptionCollection.cs
+System.ServiceModel.Description/IEndpointBehavior.cs
+System.ServiceModel.Description/IOperationBehavior.cs
+System.ServiceModel.Description/MessageBodyDescription.cs
+System.ServiceModel.Description/MessageDescription.cs
+System.ServiceModel.Description/MessageDescriptionCollection.cs
+System.ServiceModel.Description/MessageHeaderDescription.cs
+System.ServiceModel.Description/MessageHeaderDescriptionCollection.cs
+System.ServiceModel.Description/MessagePartDescription.cs
+System.ServiceModel.Description/MessagePartDescriptionCollection.cs
+System.ServiceModel.Description/MessagePropertyDescription.cs
+System.ServiceModel.Description/MessagePropertyDescriptionCollection.cs
+System.ServiceModel.Description/OperationDescription.cs
+System.ServiceModel.Description/OperationDescriptionCollection.cs
+System.ServiceModel.Description/ServiceEndpoint.cs
+System.ServiceModel.Description/XmlName.cs
+System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs
+System.ServiceModel.Dispatcher/ClientOperation.cs
+System.ServiceModel.Dispatcher/ClientRuntime.cs
+System.ServiceModel.Dispatcher/FaultContractInfo.cs
+System.ServiceModel.Dispatcher/IChannelInitializer.cs
+System.ServiceModel.Dispatcher/IClientMessageFormatter.cs
+System.ServiceModel.Dispatcher/IClientMessageInspector.cs
+System.ServiceModel.Dispatcher/IClientOperationSelector.cs
+System.ServiceModel.Dispatcher/IDispatchMessageFormatter.cs
+System.ServiceModel.Dispatcher/IInteractiveChannelInitializer.cs
+System.ServiceModel.Dispatcher/IParameterInspector.cs
+System.ServiceModel.Security/MessageSecurityException.cs
+System.ServiceModel.Security/SecurityAccessDeniedException.cs
+System.ServiceModel.Security/UserNamePasswordClientCredential.cs
+System.ServiceModel/ActionNotSupportedException.cs
+System.ServiceModel/AllEnums.cs
+System.ServiceModel/BasicHttpBinding.cs
+System.ServiceModel/BasicHttpSecurity_2_1.cs
+System.ServiceModel/ChannelFactory.cs
+System.ServiceModel/ChannelFactory_1.cs
+System.ServiceModel/ClientBase.cs
+System.ServiceModel/ClientProxyGenerator.cs
+System.ServiceModel/ClientRuntimeChannel.cs
+System.ServiceModel/CommunicationException.cs
+System.ServiceModel/CommunicationObjectAbortedException.cs
+System.ServiceModel/CommunicationObjectFaultedException.cs
+System.ServiceModel/Constants.cs
+System.ServiceModel/DataContractFormatAttribute.cs
+System.ServiceModel/DefaultCommunicationTimeouts.cs
+System.ServiceModel/Dummy.cs
+System.ServiceModel/EndpointAddress.cs
+System.ServiceModel/EndpointAddress10.cs
+System.ServiceModel/EndpointAddressBuilder.cs
+System.ServiceModel/EndpointNotFoundException.cs
+System.ServiceModel/EnvelopeVersion.cs
+System.ServiceModel/ExceptionDetail.cs
+System.ServiceModel/ExtensionCollection.cs
+System.ServiceModel/FaultCode.cs
+System.ServiceModel/FaultContractAttribute.cs
+System.ServiceModel/FaultException.cs
+System.ServiceModel/FaultException_1.cs
+System.ServiceModel/FaultReason.cs
+System.ServiceModel/FaultReasonText.cs
+System.ServiceModel/IClientChannel.cs
+System.ServiceModel/ICommunicationObject.cs
+System.ServiceModel/IContextChannel.cs
+System.ServiceModel/IDefaultCommunicationTimeouts.cs
+System.ServiceModel/IExtensibleObject.cs
+System.ServiceModel/IExtension.cs
+System.ServiceModel/IExtensionCollection.cs
+System.ServiceModel/InvalidMessageContractException.cs
+System.ServiceModel/MessageBodyAttribute.cs
+System.ServiceModel/MessageContractAttribute.cs
+System.ServiceModel/MessageContractMemberAttribute.cs
+System.ServiceModel/MessageHeaderArrayAttribute.cs
+System.ServiceModel/MessageHeaderAttribute.cs
+System.ServiceModel/MessageHeaderException.cs
+System.ServiceModel/MessageHeader_1.cs
+System.ServiceModel/MessageParameterAttribute.cs
+System.ServiceModel/MessagePropertyAttribute.cs
+System.ServiceModel/OperationContext.cs
+System.ServiceModel/OperationContextScope.cs
+System.ServiceModel/OperationContractAttribute.cs
+System.ServiceModel/ProtocolException.cs
+System.ServiceModel/QuotaExceededException.cs
+System.ServiceModel/ServerTooBusyException.cs
+System.ServiceModel/ServiceActivationException.cs
+System.ServiceModel/ServiceContractAttribute.cs
+System.ServiceModel/ServiceKnownTypeAttribute.cs
+System.ServiceModel/SilverlightClientConfigLoader.cs
+System.ServiceModel/TransferMode.cs
+System.ServiceModel/UnknownMessageReceivedEventArgs.cs
+System.ServiceModel/UriSchemeKeyedCollection.cs
+System.ServiceModel/XmlSerializerFormatAttribute.cs
+Dummy_2_1.cs
diff --git a/mcs/class/System.ServiceModel/net_2_1_raw_System.ServiceModel.dll.sources b/mcs/class/System.ServiceModel/net_2_1_raw_System.ServiceModel.dll.sources
deleted file mode 100755 (executable)
index 0108213..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-Assembly/AssemblyInfo.cs
-Mono.CodeGeneration/CodeAdd.cs
-Mono.CodeGeneration/CodeAnd.cs
-Mono.CodeGeneration/CodeArgument.cs
-Mono.CodeGeneration/CodeArgumentReference.cs
-Mono.CodeGeneration/CodeArithmeticOperation.cs
-Mono.CodeGeneration/CodeArrayItem.cs
-Mono.CodeGeneration/CodeArrayLength.cs
-Mono.CodeGeneration/CodeAssignment.cs
-Mono.CodeGeneration/CodeBinaryComparison.cs
-Mono.CodeGeneration/CodeBinaryOperation.cs
-Mono.CodeGeneration/CodeBlock.cs
-Mono.CodeGeneration/CodeBuilder.cs
-Mono.CodeGeneration/CodeCast.cs
-Mono.CodeGeneration/CodeClass.cs
-Mono.CodeGeneration/CodeCustomAttribute.cs
-Mono.CodeGeneration/CodeDecrement.cs
-Mono.CodeGeneration/CodeEquals.cs
-Mono.CodeGeneration/CodeExpression.cs
-Mono.CodeGeneration/CodeFieldReference.cs
-Mono.CodeGeneration/CodeFor.cs
-Mono.CodeGeneration/CodeForeach.cs
-Mono.CodeGeneration/CodeGenerationHelper.cs
-Mono.CodeGeneration/CodeIf.cs
-Mono.CodeGeneration/CodeIncrement.cs
-Mono.CodeGeneration/CodeIs.cs
-Mono.CodeGeneration/CodeItem.cs
-Mono.CodeGeneration/CodeLiteral.cs
-Mono.CodeGeneration/CodeMethod.cs
-Mono.CodeGeneration/CodeMethodCall.cs
-Mono.CodeGeneration/CodeModule.cs
-Mono.CodeGeneration/CodeNew.cs
-Mono.CodeGeneration/CodeNewArray.cs
-Mono.CodeGeneration/CodeNotEquals.cs
-Mono.CodeGeneration/CodeOr.cs
-Mono.CodeGeneration/CodeProperty.cs
-Mono.CodeGeneration/CodePropertyReference.cs
-Mono.CodeGeneration/CodeReturn.cs
-Mono.CodeGeneration/CodeSelect.cs
-Mono.CodeGeneration/CodeTryBlock.cs
-Mono.CodeGeneration/CodeSelfIncrement.cs
-Mono.CodeGeneration/CodeUnaryOperation.cs
-Mono.CodeGeneration/CodeValueReference.cs
-Mono.CodeGeneration/CodeVariableDeclaration.cs
-Mono.CodeGeneration/CodeVariableReference.cs
-Mono.CodeGeneration/CodeWhen.cs
-Mono.CodeGeneration/CodeWhile.cs
-Mono.CodeGeneration/CodeWriter.cs
-Mono.CodeGeneration/Exp.cs
-System.Collections.Generic/KeyedByTypeCollection.cs
-System.Collections.Generic/SynchronizedCollection.cs
-System.Collections.Generic/SynchronizedKeyedCollection.cs
-System.Collections.Generic/SynchronizedReadOnlyCollection.cs
-System.ServiceModel.Channels/AddressHeader.cs
-System.ServiceModel.Channels/AddressHeaderCollection.cs
-System.ServiceModel.Channels/AddressingVersion.cs
-System.ServiceModel.Channels/BinaryMessageEncoder.cs
-System.ServiceModel.Channels/BinaryMessageEncoderFactory.cs
-System.ServiceModel.Channels/BinaryMessageEncodingBindingElement.cs
-System.ServiceModel.Channels/Binding.cs
-System.ServiceModel.Channels/BindingContext.cs
-System.ServiceModel.Channels/BindingElement.cs
-System.ServiceModel.Channels/BindingElementCollection.cs
-System.ServiceModel.Channels/BindingParameterCollection.cs
-System.ServiceModel.Channels/BodyWriter.cs
-System.ServiceModel.Channels/BufferManager.cs
-System.ServiceModel.Channels/ChannelBase.cs
-System.ServiceModel.Channels/ChannelFactoryBase.cs
-System.ServiceModel.Channels/ChannelManagerBase.cs
-System.ServiceModel.Channels/ChannelParameterCollection.cs
-System.ServiceModel.Channels/ChannelPoolSettings.cs
-System.ServiceModel.Channels/CommunicationObject.cs
-System.ServiceModel.Channels/CustomBinding.cs
-System.ServiceModel.Channels/FaultConverter.cs
-System.ServiceModel.Channels/HtmlizedException.cs
-System.ServiceModel.Channels/HttpChannelFactory.cs
-System.ServiceModel.Channels/HttpCookieContainerBindingElement.cs
-System.ServiceModel.Channels/HttpRequestChannel.cs
-System.ServiceModel.Channels/HttpRequestMessageProperty.cs
-System.ServiceModel.Channels/HttpResponseMessageProperty.cs
-System.ServiceModel.Channels/HttpTransportBindingElement.cs
-System.ServiceModel.Channels/HttpsTransportBindingElement.cs
-System.ServiceModel.Channels/IBindingRuntimePreferences.cs
-System.ServiceModel.Channels/IChannel.cs
-System.ServiceModel.Channels/IChannelFactory.cs
-System.ServiceModel.Channels/IDuplexChannel.cs
-System.ServiceModel.Channels/IDuplexSession.cs
-System.ServiceModel.Channels/IDuplexSessionChannel.cs
-System.ServiceModel.Channels/IHttpCookieContainer.cs
-System.ServiceModel.Channels/IInputChannel.cs
-System.ServiceModel.Channels/IInputSession.cs
-System.ServiceModel.Channels/IInputSessionChannel.cs
-System.ServiceModel.Channels/IMessageProperty.cs
-System.ServiceModel.Channels/IOutputChannel.cs
-System.ServiceModel.Channels/IOutputSession.cs
-System.ServiceModel.Channels/IOutputSessionChannel.cs
-System.ServiceModel.Channels/IRequestChannel.cs
-System.ServiceModel.Channels/IRequestSessionChannel.cs
-System.ServiceModel.Channels/ISecurityCapabilities.cs
-System.ServiceModel.Channels/ISession.cs
-System.ServiceModel.Channels/ISessionChannel.cs
-System.ServiceModel.Channels/LayeredCommunicationObject.cs
-System.ServiceModel.Channels/LayeredOutputChannel.cs
-System.ServiceModel.Channels/LayeredRequestChannel.cs
-System.ServiceModel.Channels/LocalClientSecuritySettings.cs
-System.ServiceModel.Channels/Message.cs
-System.ServiceModel.Channels/MessageBuffer_2_1.cs
-System.ServiceModel.Channels/MessageBufferImpl.cs
-System.ServiceModel.Channels/MessageEncoder.cs
-System.ServiceModel.Channels/MessageEncoderFactory.cs
-System.ServiceModel.Channels/MessageEncodingBindingElement.cs
-System.ServiceModel.Channels/MessageFault.cs
-System.ServiceModel.Channels/MessageFaultBodyWriter.cs
-System.ServiceModel.Channels/MessageHeader.cs
-System.ServiceModel.Channels/MessageHeaderInfo.cs
-System.ServiceModel.Channels/MessageHeaders.cs
-System.ServiceModel.Channels/MessageImpl.cs
-System.ServiceModel.Channels/MessageProperties.cs
-System.ServiceModel.Channels/MessageVersion.cs
-System.ServiceModel.Channels/OutputChannelBase.cs
-System.ServiceModel.Channels/RequestChannelBase.cs
-System.ServiceModel.Channels/RequestContext.cs
-System.ServiceModel.Channels/SecurityBindingElement.cs
-System.ServiceModel.Channels/TextMessageEncoder.cs
-System.ServiceModel.Channels/TextMessageEncoderFactory.cs
-System.ServiceModel.Channels/TextMessageEncodingBindingElement.cs
-System.ServiceModel.Channels/TransportBindingElement.cs
-System.ServiceModel.Channels/TransportSecurityBindingElement.cs
-System.ServiceModel.Channels/UnderstoodHeaders.cs
-System.ServiceModel.Channels/XmlObjectSerializerBodyWriter.cs
-System.ServiceModel.Channels/XmlReaderBodyWriter.cs
-System.ServiceModel.Description/ClientCredentials.cs
-System.ServiceModel.Description/ContractDescription.cs
-System.ServiceModel.Description/ContractDescriptionGenerator.cs
-System.ServiceModel.Description/FaultDescription.cs
-System.ServiceModel.Description/FaultDescriptionCollection.cs
-System.ServiceModel.Description/IEndpointBehavior.cs
-System.ServiceModel.Description/IOperationBehavior.cs
-System.ServiceModel.Description/MessageBodyDescription.cs
-System.ServiceModel.Description/MessageDescription.cs
-System.ServiceModel.Description/MessageDescriptionCollection.cs
-System.ServiceModel.Description/MessageHeaderDescription.cs
-System.ServiceModel.Description/MessageHeaderDescriptionCollection.cs
-System.ServiceModel.Description/MessagePartDescription.cs
-System.ServiceModel.Description/MessagePartDescriptionCollection.cs
-System.ServiceModel.Description/MessagePropertyDescription.cs
-System.ServiceModel.Description/MessagePropertyDescriptionCollection.cs
-System.ServiceModel.Description/OperationDescription.cs
-System.ServiceModel.Description/OperationDescriptionCollection.cs
-System.ServiceModel.Description/ServiceEndpoint.cs
-System.ServiceModel.Description/XmlName.cs
-System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs
-System.ServiceModel.Dispatcher/ClientOperation.cs
-System.ServiceModel.Dispatcher/ClientRuntime.cs
-System.ServiceModel.Dispatcher/FaultContractInfo.cs
-System.ServiceModel.Dispatcher/IChannelInitializer.cs
-System.ServiceModel.Dispatcher/IClientMessageFormatter.cs
-System.ServiceModel.Dispatcher/IClientMessageInspector.cs
-System.ServiceModel.Dispatcher/IClientOperationSelector.cs
-System.ServiceModel.Dispatcher/IDispatchMessageFormatter.cs
-System.ServiceModel.Dispatcher/IInteractiveChannelInitializer.cs
-System.ServiceModel.Dispatcher/IParameterInspector.cs
-System.ServiceModel.Security/MessageSecurityException.cs
-System.ServiceModel.Security/SecurityAccessDeniedException.cs
-System.ServiceModel.Security/UserNamePasswordClientCredential.cs
-System.ServiceModel/ActionNotSupportedException.cs
-System.ServiceModel/AllEnums.cs
-System.ServiceModel/BasicHttpBinding.cs
-System.ServiceModel/BasicHttpSecurity_2_1.cs
-System.ServiceModel/ChannelFactory.cs
-System.ServiceModel/ChannelFactory_1.cs
-System.ServiceModel/ClientBase.cs
-System.ServiceModel/ClientProxyGenerator.cs
-System.ServiceModel/ClientRuntimeChannel.cs
-System.ServiceModel/CommunicationException.cs
-System.ServiceModel/CommunicationObjectAbortedException.cs
-System.ServiceModel/CommunicationObjectFaultedException.cs
-System.ServiceModel/Constants.cs
-System.ServiceModel/DataContractFormatAttribute.cs
-System.ServiceModel/DefaultCommunicationTimeouts.cs
-System.ServiceModel/Dummy.cs
-System.ServiceModel/EndpointAddress.cs
-System.ServiceModel/EndpointAddress10.cs
-System.ServiceModel/EndpointAddressBuilder.cs
-System.ServiceModel/EndpointNotFoundException.cs
-System.ServiceModel/EnvelopeVersion.cs
-System.ServiceModel/ExceptionDetail.cs
-System.ServiceModel/ExtensionCollection.cs
-System.ServiceModel/FaultCode.cs
-System.ServiceModel/FaultContractAttribute.cs
-System.ServiceModel/FaultException.cs
-System.ServiceModel/FaultException_1.cs
-System.ServiceModel/FaultReason.cs
-System.ServiceModel/FaultReasonText.cs
-System.ServiceModel/IClientChannel.cs
-System.ServiceModel/ICommunicationObject.cs
-System.ServiceModel/IContextChannel.cs
-System.ServiceModel/IDefaultCommunicationTimeouts.cs
-System.ServiceModel/IExtensibleObject.cs
-System.ServiceModel/IExtension.cs
-System.ServiceModel/IExtensionCollection.cs
-System.ServiceModel/InvalidMessageContractException.cs
-System.ServiceModel/MessageBodyAttribute.cs
-System.ServiceModel/MessageContractAttribute.cs
-System.ServiceModel/MessageContractMemberAttribute.cs
-System.ServiceModel/MessageHeaderArrayAttribute.cs
-System.ServiceModel/MessageHeaderAttribute.cs
-System.ServiceModel/MessageHeaderException.cs
-System.ServiceModel/MessageHeader_1.cs
-System.ServiceModel/MessageParameterAttribute.cs
-System.ServiceModel/MessagePropertyAttribute.cs
-System.ServiceModel/OperationContext.cs
-System.ServiceModel/OperationContextScope.cs
-System.ServiceModel/OperationContractAttribute.cs
-System.ServiceModel/ProtocolException.cs
-System.ServiceModel/QuotaExceededException.cs
-System.ServiceModel/ServerTooBusyException.cs
-System.ServiceModel/ServiceActivationException.cs
-System.ServiceModel/ServiceContractAttribute.cs
-System.ServiceModel/ServiceKnownTypeAttribute.cs
-System.ServiceModel/SilverlightClientConfigLoader.cs
-System.ServiceModel/TransferMode.cs
-System.ServiceModel/UnknownMessageReceivedEventArgs.cs
-System.ServiceModel/UriSchemeKeyedCollection.cs
-System.ServiceModel/XmlSerializerFormatAttribute.cs
-Dummy_2_1.cs
index 550ccf05bd45f2dbe38eaf0ea887a00398f28c6c..f8b48c78c8388b1483b8cce3f1effdfc43bc849e 100644 (file)
@@ -38,3 +38,8 @@
 ../System.ServiceModel.Web/System.ServiceModel.Syndication/UrlSyndicationContent.cs
 ../System.ServiceModel.Web/System.ServiceModel.Syndication/Workspace.cs
 ../System.ServiceModel.Web/System.ServiceModel.Syndication/XmlSyndicationContent.cs
+../System.ServiceModel.Web/System/UriTemplate.cs
+../System.ServiceModel.Web/System/UriTemplateEquivalenceComparer.cs
+../System.ServiceModel.Web/System/UriTemplateMatch.cs
+../System.ServiceModel.Web/System/UriTemplateMatchException.cs
+../System.ServiceModel.Web/System/UriTemplateTable.cs
index 171a479d7fa16e1723b0df7b1faf614f3d2a37da..3815b79811d714e64872558e3ae646ba11f6b857 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-15  Marek Habersack  <mhabersack@novell.com>
+
+       * Makefile (LIBRARY_COMPAT): added - this lib is installed in the
+       compat dir.
+
 2010-02-17  Marek Habersack  <mhabersack@novell.com>
 
        * Makefile: RESX_RES is no more, it was replaced with
index bc6793722575d904a668465ebba0909d700e152f..8f8ce46a161b4b5b4fa7c79cd6f296e9f6b11674 100644 (file)
@@ -4,6 +4,7 @@ include ../../build/rules.make
 
 LIBRARY = System.Web.Mvc.dll
 LIBRARY_USE_INTERMEDIATE_FILE = yes
+LIBRARY_COMPAT = yes
 
 RESX_DIST =  System.Web.Mvc/Resources/MvcResources.resx
 
diff --git a/mcs/class/System.Web.Mvc2/ChangeLog b/mcs/class/System.Web.Mvc2/ChangeLog
new file mode 100644 (file)
index 0000000..07970aa
--- /dev/null
@@ -0,0 +1,9 @@
+2010-03-18  Marek Habersack  <mhabersack@novell.com>
+
+       * Makefile: include resources in compilation
+
+2010-02-09  Marek Habersack  <mhabersack@novell.com>
+
+       * Makefile: added references to
+       System.ComponentModel.DataAnnotations and System.Data.Linq
+
diff --git a/mcs/class/System.Web.Mvc2/GlobalSuppressions.cs b/mcs/class/System.Web.Mvc2/GlobalSuppressions.cs
new file mode 100644 (file)
index 0000000..71130ae
--- /dev/null
@@ -0,0 +1,26 @@
+// This file is used by Code Analysis to maintain SuppressMessage \r
+// attributes that are applied to this project. \r
+// Project-level suppressions either have no target or are given \r
+// a specific target and scoped to a namespace, type, member, etc. \r
+//\r
+// To add a suppression to this file, right-click the message in the \r
+// Error List, point to "Suppress Message(s)", and click \r
+// "In Project Suppression File". \r
+// You do not need to add suppressions to this file manually. \r
+\r
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "System.Web.Mvc.TempDataDictionary.#System.Collections.Generic.ICollection`1<System.Collections.Generic.KeyValuePair`2<System.String,System.Object>>.Contains(System.Collections.Generic.KeyValuePair`2<System.String,System.Object>)",\r
+    Justification = "There are no defined scenarios for wanting to derive from this class, but we don't want to prevent it either.")]\r
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "System.Web.Mvc.TempDataDictionary.#System.Collections.Generic.ICollection`1<System.Collections.Generic.KeyValuePair`2<System.String,System.Object>>.CopyTo(System.Collections.Generic.KeyValuePair`2<System.String,System.Object>[],System.Int32)",\r
+    Justification = "There are no defined scenarios for wanting to derive from this class, but we don't want to prevent it either.")]\r
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "System.Web.Mvc.TempDataDictionary.#System.Collections.Generic.ICollection`1<System.Collections.Generic.KeyValuePair`2<System.String,System.Object>>.IsReadOnly",\r
+    Justification = "There are no defined scenarios for wanting to derive from this class, but we don't want to prevent it either.")]\r
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Web.Mvc.Ajax",\r
+    Justification = "Helpers reside within a separate namespace to support alternate helper classes.")]\r
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1903:UseOnlyApiFromTargetedFramework", MessageId = "System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",\r
+    Justification = "MVC has a .NET Framework 3.5 SP1 dependency.")]\r
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1903:UseOnlyApiFromTargetedFramework", MessageId = "System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",\r
+    Justification = "MVC has a .NET Framework 3.5 SP1 dependency.")]\r
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1903:UseOnlyApiFromTargetedFramework", MessageId = "System.ComponentModel.DataAnnotations, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",\r
+    Justification = "MVC has a .NET Framework 3.5 SP1 dependency.")]\r
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1903:UseOnlyApiFromTargetedFramework", MessageId = "System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",\r
+    Justification = "MVC has a .NET Framework 3.5 SP1 dependency.")]\r
diff --git a/mcs/class/System.Web.Mvc2/Makefile b/mcs/class/System.Web.Mvc2/Makefile
new file mode 100644 (file)
index 0000000..5aba709
--- /dev/null
@@ -0,0 +1,50 @@
+thisdir = class/System.Web.Mvc2
+SUBDIRS = 
+include ../../build/rules.make
+
+LIBRARY = System.Web.Mvc.dll
+LIBRARY_USE_INTERMEDIATE_FILE = yes
+
+RESX_DIST =  System.Web.Mvc/Resources/MvcResources.resx
+
+LIB_MCS_FLAGS = \
+               /warnaserror- \
+               /noconfig \
+               /keyfile:../winfx.pub \
+               /r:System.dll \
+               /r:System.Core.dll \
+               /r:System.Configuration.dll \
+               /r:System.Data.dll \
+               /r:System.Xml.dll \
+               /r:System.Web.dll \
+               /r:System.Web.Abstractions.dll \
+               /r:System.Web.Routing.dll \
+               /r:System.Web.Extensions.dll \
+               /r:System.ComponentModel.DataAnnotations.dll \
+               /r:System.Data.Linq.dll \
+               $(foreach r, $(RESOURCES), /resource:$(r),System.Web.Mvc.Resources.$(notdir $(r)))
+
+ifeq (2.0, $(FRAMEWORK_VERSION))
+# This is a .NET 3.5 only assembly, but built during the 2.0 build
+LIB_MCS_FLAGS += -d:NET_3_5 -d:MONO
+endif
+
+EXTRA_DISTFILES = $(RESX_DIST)
+
+# This is a .NET 3.5+ assembly - it must be built ONLY in the 2.0 profile
+VALID_PROFILE := $(filter net_2_0, $(PROFILE))
+ifndef VALID_PROFILE
+LIBRARY_NAME = dummy-System.Web.Mvc.dll
+NO_INSTALL = yes
+NO_SIGN_ASSEMBLY = yes
+NO_TEST = yes
+else
+RESOURCES = $(RESX_DIST:.resx=.resources)
+endif
+
+include ../../build/library.make
+
+$(build_lib): $(RESOURCES)
+
+$(RESOURCES): %.resources: %.resx
+       $(RESGEN) `echo $< | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
diff --git a/mcs/class/System.Web.Mvc2/Properties/AssemblyInfo.cs b/mcs/class/System.Web.Mvc2/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..4a06eb8
--- /dev/null
@@ -0,0 +1,63 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+using System;\r
+using System.Diagnostics.CodeAnalysis;\r
+using System.Reflection;\r
+using System.Resources;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+using System.Security;\r
+\r
+// General Information about an assembly is controlled through the following \r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+[assembly: AssemblyTitle("System.Web.Mvc.dll")]\r
+[assembly: AssemblyDescription("System.Web.Mvc.dll")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("Microsoft Corporation")]\r
+[assembly: AssemblyProduct("Microsoft® .NET Framework")]\r
+[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]\r
+\r
+// Setting ComVisible to false makes the types in this assembly not visible \r
+// to COM components.  If you need to access a type in this assembly from \r
+// COM, set the ComVisible attribute to true on that type.\r
+[assembly: ComVisible(false)]\r
+\r
+// The following GUID is for the ID of the typelib if this project is exposed to COM\r
+[assembly: Guid("4b5f4208-c6b0-4c37-9a41-63325ffa52ad")]\r
+\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+//      Major Version\r
+//      Minor Version \r
+//      Build Number\r
+//      Revision\r
+//\r
+// You can specify all the values or you can default the Build and Revision Numbers \r
+// by using the '*' as shown below:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion("2.0.0.0")]\r
+[assembly: AssemblyFileVersion("2.0.50217.0")]\r
+\r
+[assembly: AllowPartiallyTrustedCallers]\r
+[assembly: SecurityTransparent]\r
+[assembly: CLSCompliant(true)]\r
+[assembly: NeutralResourcesLanguage("en-US")]\r
+\r
+[assembly: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames",\r
+    Justification = "Assembly is delay-signed.")]\r
+
+[assembly: AssemblyDelaySign (true)]\r
+[assembly: AssemblyKeyFile("../winfx.pub")]\r
diff --git a/mcs/class/System.Web.Mvc2/Properties/ChangeLog b/mcs/class/System.Web.Mvc2/Properties/ChangeLog
new file mode 100644 (file)
index 0000000..6e4c8c6
--- /dev/null
@@ -0,0 +1,5 @@
+2010-02-09  Marek Habersack  <mhabersack@novell.com>
+
+       * AssemblyInfo.cs: added Mono-specific attributes to delay-sign
+       the assembly and use the winfs.pub key
+
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc.csproj b/mcs/class/System.Web.Mvc2/System.Web.Mvc.csproj
new file mode 100644 (file)
index 0000000..a47c382
--- /dev/null
@@ -0,0 +1,381 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProductVersion>9.0.30729</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{3D3FFD8A-624D-4E9B-954B-E1C105507975}</ProjectGuid>\r
+    <OutputType>Library</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>System.Web</RootNamespace>\r
+    <AssemblyName>System.Web.Mvc</AssemblyName>\r
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>\r
+    <BaseAddress>1609891840</BaseAddress>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>..\..\bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>..\..\bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.ComponentModel.DataAnnotations">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.configuration" />\r
+    <Reference Include="System.Core">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Data.Entity">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Data.Linq">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Web" />\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Web.Abstractions">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Web.Extensions">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Web.Routing">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="Mvc\AssociatedMetadataProvider.cs" />\r
+    <Compile Include="Mvc\ActionExecutedContext.cs" />\r
+    <Compile Include="Mvc\ActionExecutingContext.cs" />\r
+    <Compile Include="Mvc\AntiForgeryData.cs" />\r
+    <Compile Include="Mvc\AntiForgeryDataSerializer.cs" />\r
+    <Compile Include="Mvc\ClientDataTypeModelValidatorProvider.cs" />\r
+    <Compile Include="Mvc\AssociatedValidatorProvider.cs" />\r
+    <Compile Include="Mvc\Async\ActionDescriptorCreator.cs" />\r
+    <Compile Include="Mvc\Async\AsyncActionDescriptor.cs" />\r
+    <Compile Include="Mvc\Async\AsyncActionMethodSelector.cs" />\r
+    <Compile Include="Mvc\Async\AsyncControllerActionInvoker.cs" />\r
+    <Compile Include="Mvc\Async\SynchronousOperationException.cs" />\r
+    <Compile Include="Mvc\Async\AsyncManager.cs" />\r
+    <Compile Include="Mvc\AsyncTimeoutAttribute.cs" />\r
+    <Compile Include="Mvc\Async\BeginInvokeDelegate.cs" />\r
+    <Compile Include="Mvc\Async\AsyncResultWrapper.cs" />\r
+    <Compile Include="Mvc\Async\AsyncVoid.cs" />\r
+    <Compile Include="Mvc\AsyncController.cs" />\r
+    <Compile Include="Mvc\Async\AsyncUtil.cs" />\r
+    <Compile Include="Mvc\Async\IAsyncController.cs" />\r
+    <Compile Include="Mvc\Async\IAsyncActionInvoker.cs" />\r
+    <Compile Include="Mvc\Async\IAsyncManagerContainer.cs" />\r
+    <Compile Include="Mvc\UrlParameter.cs" />\r
+    <Compile Include="Mvc\FormValueProvider.cs" />\r
+    <Compile Include="Mvc\FormValueProviderFactory.cs" />\r
+    <Compile Include="Mvc\HttpFileCollectionValueProvider.cs" />\r
+    <Compile Include="Mvc\HttpFileCollectionValueProviderFactory.cs" />\r
+    <Compile Include="Mvc\QueryStringValueProvider.cs" />\r
+    <Compile Include="Mvc\QueryStringValueProviderFactory.cs" />\r
+    <Compile Include="Mvc\RangeAttributeAdapter.cs" />\r
+    <Compile Include="Mvc\RegularExpressionAttributeAdapter.cs" />\r
+    <Compile Include="Mvc\RequiredAttributeAdapter.cs" />\r
+    <Compile Include="Mvc\RouteDataValueProvider.cs" />\r
+    <Compile Include="Mvc\RouteDataValueProviderFactory.cs" />\r
+    <Compile Include="Mvc\StringLengthAttributeAdapter.cs" />\r
+    <Compile Include="Mvc\TypeCacheUtil.cs" />\r
+    <Compile Include="Mvc\TypeCacheSerializer.cs" />\r
+    <Compile Include="Mvc\Html\DisplayTextExtensions.cs" />\r
+    <Compile Include="Mvc\NoAsyncTimeoutAttribute.cs" />\r
+    <Compile Include="Mvc\Async\OperationCounter.cs" />\r
+    <Compile Include="Mvc\Async\ReflectedAsyncActionDescriptor.cs" />\r
+    <Compile Include="Mvc\Async\ReflectedAsyncControllerDescriptor.cs" />\r
+    <Compile Include="Mvc\Async\Trigger.cs" />\r
+    <Compile Include="Mvc\Async\TriggerListener.cs" />\r
+    <Compile Include="Mvc\Async\SimpleAsyncResult.cs" />\r
+    <Compile Include="Mvc\Async\EndInvokeDelegate.cs" />\r
+    <Compile Include="Mvc\Async\EndInvokeDelegate`1.cs" />\r
+    <Compile Include="Mvc\Async\SynchronizationContextUtil.cs" />\r
+    <Compile Include="Mvc\AuthorizationContext.cs" />\r
+    <Compile Include="Mvc\ByteArrayModelBinder.cs" />\r
+    <Compile Include="Mvc\ControllerContext.cs" />\r
+    <Compile Include="Mvc\Html\ChildActionExtensions.cs" />\r
+    <Compile Include="Mvc\ParameterInfoUtil.cs" />\r
+    <Compile Include="Mvc\HttpHandlerUtil.cs" />\r
+    <Compile Include="Mvc\ChildActionOnlyAttribute.cs" />\r
+    <Compile Include="Mvc\TypeDescriptorHelper.cs" />\r
+    <Compile Include="Mvc\ValueProviderFactories.cs" />\r
+    <Compile Include="Mvc\ValueProviderFactory.cs" />\r
+    <Compile Include="Mvc\ValueProviderFactoryCollection.cs" />\r
+    <Compile Include="Mvc\ValueProviderCollection.cs" />\r
+    <Compile Include="Mvc\DictionaryValueProvider`1.cs" />\r
+    <Compile Include="Mvc\NameValueCollectionValueProvider.cs" />\r
+    <Compile Include="Mvc\ValueProviderUtil.cs" />\r
+    <Compile Include="Mvc\IValueProvider.cs" />\r
+    <Compile Include="Mvc\DataErrorInfoModelValidatorProvider.cs" />\r
+    <Compile Include="Mvc\ModelValidatorProviderCollection.cs" />\r
+    <Compile Include="Mvc\DataAnnotationsModelMetadata.cs" />\r
+    <Compile Include="Mvc\HiddenInputAttribute.cs" />\r
+    <Compile Include="Mvc\HttpGetAttribute.cs" />\r
+    <Compile Include="Mvc\HttpPutAttribute.cs" />\r
+    <Compile Include="Mvc\HttpDeleteAttribute.cs" />\r
+    <Compile Include="Mvc\DynamicTypeGenerator.cs" />\r
+    <Compile Include="Mvc\ModelClientValidationRequiredRule.cs" />\r
+    <Compile Include="Mvc\ModelClientValidationRangeRule.cs" />\r
+    <Compile Include="Mvc\ModelClientValidationStringLengthRule.cs" />\r
+    <Compile Include="Mvc\MvcHtmlString.cs" />\r
+    <Compile Include="Mvc\DataAnnotationsModelValidator.cs" />\r
+    <Compile Include="Mvc\DataAnnotationsModelValidatorProvider.cs" />\r
+    <Compile Include="Mvc\DataAnnotationsModelValidator`1.cs" />\r
+    <Compile Include="Mvc\EmptyModelValidatorProvider.cs" />\r
+    <Compile Include="Mvc\ExpressionHelper.cs" />\r
+    <Compile Include="Mvc\FieldValidationMetadata.cs" />\r
+    <Compile Include="Mvc\FormContext.cs" />\r
+    <Compile Include="Mvc\JsonRequestBehavior.cs" />\r
+    <Compile Include="Mvc\ModelClientValidationRegexRule.cs" />\r
+    <Compile Include="Mvc\ModelClientValidationRule.cs" />\r
+    <Compile Include="Mvc\ModelValidationResult.cs" />\r
+    <Compile Include="Mvc\ModelValidator.cs" />\r
+    <Compile Include="Mvc\ModelValidatorProvider.cs" />\r
+    <Compile Include="Mvc\ModelValidatorProviders.cs" />\r
+    <Compile Include="Mvc\RequireHttpsAttribute.cs" />\r
+    <Compile Include="Mvc\HttpRequestExtensions.cs" />\r
+    <Compile Include="Mvc\DataAnnotationsModelMetadataProvider.cs" />\r
+    <Compile Include="Mvc\EmptyModelMetadataProvider.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\BinaryExpressionFingerprint.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\CachedExpressionCompiler.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\ExpressionParser.cs" />\r
+    <Compile Include="Mvc\ModelMetadata.cs" />\r
+    <Compile Include="Mvc\ModelMetadataProvider.cs" />\r
+    <Compile Include="Mvc\ModelMetadataProviders.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\CompiledExpressionDelegate`2.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\ConstantExpressionFingerprint.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\ConditionalExpressionFingerprint.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\MethodCallExpressionFingerprint.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\MemberExpressionFingerprint.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\UnaryExpressionFingerprint.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\ParserContext.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\ParameterExpressionFingerprint.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\HashCodeCombiner.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\ExpressionFingerprint.cs" />\r
+    <Compile Include="Mvc\ExpressionUtil\FastTrack`2.cs" />\r
+    <Compile Include="Mvc\AreaHelpers.cs" />\r
+    <Compile Include="Mvc\AreaRegistration.cs" />\r
+    <Compile Include="Mvc\AreaRegistrationContext.cs" />\r
+    <Compile Include="Mvc\Error.cs" />\r
+    <Compile Include="Mvc\IRouteWithArea.cs" />\r
+    <Compile Include="Mvc\Async\SingleEntryGate.cs" />\r
+    <Compile Include="Mvc\Html\PartialExtensions.cs" />\r
+    <Compile Include="Mvc\LinqBinaryModelBinder.cs" />\r
+    <Compile Include="Mvc\TryGetValueDelegate.cs" />\r
+    <Compile Include="Mvc\ViewDataInfo.cs" />\r
+    <Compile Include="Mvc\Html\DefaultDisplayTemplates.cs" />\r
+    <Compile Include="Mvc\Html\DefaultEditorTemplates.cs" />\r
+    <Compile Include="Mvc\Html\DisplayExtensions.cs" />\r
+    <Compile Include="Mvc\Html\EditorExtensions.cs" />\r
+    <Compile Include="Mvc\Html\LabelExtensions.cs" />\r
+    <Compile Include="Mvc\Html\TemplateHelpers.cs" />\r
+    <Compile Include="Mvc\HttpPostAttribute.cs" />\r
+    <Compile Include="Mvc\PathHelpers.cs" />\r
+    <Compile Include="Mvc\ExceptionContext.cs" />\r
+    <Compile Include="Mvc\ResultExecutedContext.cs" />\r
+    <Compile Include="Mvc\ResultExecutingContext.cs" />\r
+    <Compile Include="Mvc\TemplateInfo.cs" />\r
+    <Compile Include="Mvc\ValidateAntiForgeryTokenAttribute.cs" />\r
+    <Compile Include="Mvc\HttpAntiForgeryException.cs" />\r
+    <Compile Include="Mvc\JavaScriptResult.cs" />\r
+    <Compile Include="Mvc\ActionDescriptor.cs" />\r
+    <Compile Include="Mvc\ActionMethodDispatcher.cs" />\r
+    <Compile Include="Mvc\ActionMethodSelector.cs" />\r
+    <Compile Include="Mvc\ActionMethodSelectorAttribute.cs" />\r
+    <Compile Include="Mvc\ActionNameSelectorAttribute.cs" />\r
+    <Compile Include="Mvc\AuthorizeAttribute.cs" />\r
+    <Compile Include="Mvc\Ajax\AjaxOptions.cs" />\r
+    <Compile Include="Mvc\Ajax\AjaxExtensions.cs" />\r
+    <Compile Include="Mvc\ActionMethodDispatcherCache.cs" />\r
+    <Compile Include="Mvc\BindAttribute.cs" />\r
+    <Compile Include="Mvc\ControllerBase.cs" />\r
+    <Compile Include="Mvc\ActionNameAttribute.cs" />\r
+    <Compile Include="Mvc\AcceptVerbsAttribute.cs" />\r
+    <Compile Include="Mvc\AjaxHelper`1.cs" />\r
+    <Compile Include="Mvc\HtmlHelper`1.cs" />\r
+    <Compile Include="Mvc\DictionaryHelpers.cs" />\r
+    <Compile Include="Mvc\AjaxRequestExtensions.cs" />\r
+    <Compile Include="Mvc\ModelBinderDictionary.cs" />\r
+    <Compile Include="Mvc\ValueProviderDictionary.cs" />\r
+    <Compile Include="Mvc\ViewContext.cs" />\r
+    <Compile Include="Mvc\ViewTemplateUserControl.cs">\r
+      <SubType>ASPXCodeBehind</SubType>\r
+    </Compile>\r
+    <Compile Include="Mvc\ViewTemplateUserControl`1.cs">\r
+      <SubType>ASPXCodeBehind</SubType>\r
+    </Compile>\r
+    <Compile Include="Mvc\ViewType.cs" />\r
+    <Compile Include="Mvc\ViewTypeControlBuilder.cs" />\r
+    <Compile Include="Mvc\ViewUserControlControlBuilder.cs">\r
+    </Compile>\r
+    <Compile Include="Mvc\ViewPageControlBuilder.cs">\r
+    </Compile>\r
+    <Compile Include="Mvc\ViewTypeParserFilter.cs" />\r
+    <Compile Include="Mvc\DefaultViewLocationCache.cs" />\r
+    <Compile Include="Mvc\FormCollection.cs" />\r
+    <Compile Include="Mvc\HttpPostedFileBaseModelBinder.cs" />\r
+    <Compile Include="Mvc\NullViewLocationCache.cs" />\r
+    <Compile Include="Mvc\ValidateInputAttribute.cs" />\r
+    <Compile Include="Mvc\FileContentResult.cs" />\r
+    <Compile Include="Mvc\FilePathResult.cs" />\r
+    <Compile Include="Mvc\FileResult.cs" />\r
+    <Compile Include="Mvc\FileStreamResult.cs" />\r
+    <Compile Include="Mvc\InputType.cs" />\r
+    <Compile Include="Mvc\ControllerDescriptorCache.cs" />\r
+    <Compile Include="Mvc\ReflectedParameterBindingInfo.cs" />\r
+    <Compile Include="Mvc\ParameterBindingInfo.cs" />\r
+    <Compile Include="Mvc\ReaderWriterCache`2.cs" />\r
+    <Compile Include="Mvc\DescriptorUtil.cs" />\r
+    <Compile Include="Mvc\ReflectedControllerDescriptor.cs" />\r
+    <Compile Include="Mvc\ControllerDescriptor.cs" />\r
+    <Compile Include="Mvc\ActionSelector.cs" />\r
+    <Compile Include="Mvc\ReflectedActionDescriptor.cs" />\r
+    <Compile Include="Mvc\Html\MvcForm.cs" />\r
+    <Compile Include="Mvc\HttpVerbs.cs" />\r
+    <Compile Include="Mvc\DefaultModelBinder.cs" />\r
+    <Compile Include="Mvc\ModelBindingContext.cs" />\r
+    <Compile Include="Mvc\ParameterDescriptor.cs" />\r
+    <Compile Include="Mvc\RouteValuesHelpers.cs" />\r
+    <Compile Include="Mvc\SelectListItem.cs" />\r
+    <Compile Include="Mvc\TagRenderMode.cs" />\r
+    <Compile Include="Mvc\ReflectedParameterDescriptor.cs" />\r
+    <Compile Include="Mvc\ValueProviderResult.cs" />\r
+    <Compile Include="Mvc\CustomModelBinderAttribute.cs" />\r
+    <Compile Include="Mvc\FormMethod.cs" />\r
+    <Compile Include="Mvc\Html\FormExtensions.cs" />\r
+    <Compile Include="Mvc\Html\InputExtensions.cs">\r
+      <SubType>Code</SubType>\r
+    </Compile>\r
+    <Compile Include="Mvc\Html\RenderPartialExtensions.cs" />\r
+    <Compile Include="Mvc\Html\SelectExtensions.cs" />\r
+    <Compile Include="Mvc\Html\TextAreaExtensions.cs" />\r
+    <Compile Include="Mvc\Html\ValidationExtensions.cs" />\r
+    <Compile Include="Mvc\IModelBinder.cs" />\r
+    <Compile Include="Mvc\Html\LinkExtensions.cs" />\r
+    <Compile Include="Mvc\ModelBinderAttribute.cs" />\r
+    <Compile Include="Mvc\ModelBinders.cs" />\r
+    <Compile Include="Mvc\ModelStateDictionary.cs" />\r
+    <Compile Include="Mvc\ModelState.cs" />\r
+    <Compile Include="Mvc\ModelErrorCollection.cs" />\r
+    <Compile Include="Mvc\ModelError.cs" />\r
+    <Compile Include="Mvc\Ajax\InsertionMode.cs" />\r
+    <Compile Include="Mvc\HandleErrorAttribute.cs" />\r
+    <Compile Include="Mvc\HandleErrorInfo.cs" />\r
+    <Compile Include="Mvc\HttpUnauthorizedResult.cs" />\r
+    <Compile Include="Mvc\IActionInvoker.cs" />\r
+    <Compile Include="Mvc\IView.cs" />\r
+    <Compile Include="Mvc\IViewLocationCache.cs" />\r
+    <Compile Include="Mvc\MvcHttpHandler.cs" />\r
+    <Compile Include="Mvc\PartialViewResult.cs" />\r
+    <Compile Include="Mvc\SessionStateTempDataProvider.cs" />\r
+    <Compile Include="Mvc\ITempDataProvider.cs" />\r
+    <Compile Include="Mvc\OutputCacheAttribute.cs" />\r
+    <Compile Include="Mvc\FilterInfo.cs" />\r
+    <Compile Include="GlobalSuppressions.cs" />\r
+    <Compile Include="Mvc\ActionFilterAttribute.cs" />\r
+    <Compile Include="Mvc\ActionResult.cs" />\r
+    <Compile Include="Mvc\AjaxHelper.cs" />\r
+    <Compile Include="Mvc\BuildManagerWrapper.cs" />\r
+    <Compile Include="Mvc\Controller.cs" />\r
+    <Compile Include="Mvc\ControllerActionInvoker.cs" />\r
+    <Compile Include="Mvc\ControllerBuilder.cs" />\r
+    <Compile Include="Mvc\ControllerTypeCache.cs" />\r
+    <Compile Include="Mvc\ContentResult.cs" />\r
+    <Compile Include="Mvc\FilterAttribute.cs" />\r
+    <Compile Include="Mvc\IResultFilter.cs" />\r
+    <Compile Include="Mvc\IExceptionFilter.cs" />\r
+    <Compile Include="Mvc\IAuthorizationFilter.cs" />\r
+    <Compile Include="Mvc\JsonResult.cs" />\r
+    <Compile Include="Mvc\NameValueCollectionExtensions.cs" />\r
+    <Compile Include="Mvc\ViewDataDictionary`1.cs" />\r
+    <Compile Include="Mvc\EmptyResult.cs" />\r
+    <Compile Include="Mvc\MultiSelectList.cs" />\r
+    <Compile Include="Mvc\RedirectResult.cs" />\r
+    <Compile Include="Mvc\RedirectToRouteResult.cs" />\r
+    <Compile Include="Mvc\DefaultControllerFactory.cs" />\r
+    <Compile Include="Mvc\HtmlHelper.cs" />\r
+    <Compile Include="Mvc\IActionFilter.cs" />\r
+    <Compile Include="Mvc\IBuildManager.cs" />\r
+    <Compile Include="Mvc\IController.cs" />\r
+    <Compile Include="Mvc\IControllerFactory.cs" />\r
+    <Compile Include="Mvc\IViewDataContainer.cs" />\r
+    <Compile Include="Mvc\IViewEngine.cs" />\r
+    <Compile Include="Mvc\MvcHandler.cs" />\r
+    <Compile Include="Mvc\MvcRouteHandler.cs" />\r
+    <Compile Include="Mvc\NonActionAttribute.cs" />\r
+    <Compile Include="Mvc\RouteCollectionExtensions.cs" />\r
+    <Compile Include="Mvc\SelectList.cs" />\r
+    <Compile Include="Mvc\TagBuilder.cs" />\r
+    <Compile Include="Mvc\TempDataDictionary.cs" />\r
+    <Compile Include="Mvc\TypeHelpers.cs" />\r
+    <Compile Include="Mvc\UrlHelper.cs" />\r
+    <Compile Include="Mvc\ViewDataDictionary.cs" />\r
+    <Compile Include="Mvc\ViewEngineCollection.cs" />\r
+    <Compile Include="Mvc\ViewEngineResult.cs" />\r
+    <Compile Include="Mvc\ViewEngines.cs" />\r
+    <Compile Include="Mvc\ViewMasterPage.cs">\r
+      <SubType>ASPXCodeBehind</SubType>\r
+    </Compile>\r
+    <Compile Include="Mvc\ViewMasterPage`1.cs">\r
+      <SubType>ASPXCodeBehind</SubType>\r
+    </Compile>\r
+    <Compile Include="Mvc\ViewPage.cs">\r
+      <SubType>ASPXCodeBehind</SubType>\r
+    </Compile>\r
+    <Compile Include="Mvc\ViewPage`1.cs">\r
+      <SubType>ASPXCodeBehind</SubType>\r
+    </Compile>\r
+    <Compile Include="Mvc\ViewResult.cs" />\r
+    <Compile Include="Mvc\ViewResultBase.cs" />\r
+    <Compile Include="Mvc\ViewUserControl.cs">\r
+      <SubType>ASPXCodeBehind</SubType>\r
+    </Compile>\r
+    <Compile Include="Mvc\ViewUserControl`1.cs">\r
+      <SubType>ASPXCodeBehind</SubType>\r
+    </Compile>\r
+    <Compile Include="Mvc\VirtualPathProviderViewEngine.cs" />\r
+    <Compile Include="Mvc\WebFormView.cs" />\r
+    <Compile Include="Mvc\WebFormViewEngine.cs" />\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+    <Compile Include="Mvc\Resources\MvcResources.Designer.cs">\r
+      <AutoGen>True</AutoGen>\r
+      <DesignTime>True</DesignTime>\r
+      <DependentUpon>MvcResources.resx</DependentUpon>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <EmbeddedResource Include="Mvc\Resources\MvcResources.resx">\r
+      <Generator>ResXFileCodeGenerator</Generator>\r
+      <LastGenOutput>MvcResources.Designer.cs</LastGenOutput>\r
+      <SubType>Designer</SubType>\r
+    </EmbeddedResource>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <CodeAnalysisDictionary Include="..\CustomDictionary.xml" />\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+</Project>
\ No newline at end of file
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc.dll.sources b/mcs/class/System.Web.Mvc2/System.Web.Mvc.dll.sources
new file mode 100644 (file)
index 0000000..9ecb0aa
--- /dev/null
@@ -0,0 +1,279 @@
+../../build/common/Consts.cs
+../../build/common/MonoTODOAttribute.cs
+
+GlobalSuppressions.cs
+Properties/AssemblyInfo.cs
+System.Web.Mvc/AcceptVerbsAttribute.cs
+System.Web.Mvc/ActionDescriptor.cs
+System.Web.Mvc/ActionExecutedContext.cs
+System.Web.Mvc/ActionExecutingContext.cs
+System.Web.Mvc/ActionFilterAttribute.cs
+System.Web.Mvc/ActionMethodDispatcherCache.cs
+System.Web.Mvc/ActionMethodDispatcher.cs
+System.Web.Mvc/ActionMethodSelectorAttribute.cs
+System.Web.Mvc/ActionMethodSelector.cs
+System.Web.Mvc/ActionNameAttribute.cs
+System.Web.Mvc/ActionNameSelectorAttribute.cs
+System.Web.Mvc/ActionResult.cs
+System.Web.Mvc/ActionSelector.cs
+System.Web.Mvc/Ajax/AjaxExtensions.cs
+System.Web.Mvc/Ajax/AjaxOptions.cs
+System.Web.Mvc/AjaxHelper`1.cs
+System.Web.Mvc/AjaxHelper.cs
+System.Web.Mvc/Ajax/InsertionMode.cs
+System.Web.Mvc/AjaxRequestExtensions.cs
+System.Web.Mvc/AntiForgeryData.cs
+System.Web.Mvc/AntiForgeryDataSerializer.cs
+System.Web.Mvc/AreaHelpers.cs
+System.Web.Mvc/AreaRegistrationContext.cs
+System.Web.Mvc/AreaRegistration.cs
+System.Web.Mvc/AssociatedMetadataProvider.cs
+System.Web.Mvc/AssociatedValidatorProvider.cs
+System.Web.Mvc/Async/ActionDescriptorCreator.cs
+System.Web.Mvc/Async/AsyncActionDescriptor.cs
+System.Web.Mvc/Async/AsyncActionMethodSelector.cs
+System.Web.Mvc/Async/AsyncControllerActionInvoker.cs
+System.Web.Mvc/Async/AsyncManager.cs
+System.Web.Mvc/Async/AsyncResultWrapper.cs
+System.Web.Mvc/Async/AsyncUtil.cs
+System.Web.Mvc/Async/AsyncVoid.cs
+System.Web.Mvc/Async/BeginInvokeDelegate.cs
+System.Web.Mvc/AsyncController.cs
+System.Web.Mvc/Async/EndInvokeDelegate`1.cs
+System.Web.Mvc/Async/EndInvokeDelegate.cs
+System.Web.Mvc/Async/IAsyncActionInvoker.cs
+System.Web.Mvc/Async/IAsyncController.cs
+System.Web.Mvc/Async/IAsyncManagerContainer.cs
+System.Web.Mvc/Async/OperationCounter.cs
+System.Web.Mvc/Async/ReflectedAsyncActionDescriptor.cs
+System.Web.Mvc/Async/ReflectedAsyncControllerDescriptor.cs
+System.Web.Mvc/Async/SimpleAsyncResult.cs
+System.Web.Mvc/Async/SingleEntryGate.cs
+System.Web.Mvc/Async/SynchronizationContextUtil.cs
+System.Web.Mvc/Async/SynchronousOperationException.cs
+System.Web.Mvc/AsyncTimeoutAttribute.cs
+System.Web.Mvc/Async/Trigger.cs
+System.Web.Mvc/Async/TriggerListener.cs
+System.Web.Mvc/AuthorizationContext.cs
+System.Web.Mvc/AuthorizeAttribute.cs
+System.Web.Mvc/BindAttribute.cs
+System.Web.Mvc/BuildManagerWrapper.cs
+System.Web.Mvc/ByteArrayModelBinder.cs
+System.Web.Mvc/ChildActionOnlyAttribute.cs
+System.Web.Mvc/ClientDataTypeModelValidatorProvider.cs
+System.Web.Mvc/ContentResult.cs
+System.Web.Mvc/ControllerActionInvoker.cs
+System.Web.Mvc/ControllerBase.cs
+System.Web.Mvc/ControllerBuilder.cs
+System.Web.Mvc/ControllerContext.cs
+System.Web.Mvc/Controller.cs
+System.Web.Mvc/ControllerDescriptorCache.cs
+System.Web.Mvc/ControllerDescriptor.cs
+System.Web.Mvc/ControllerTypeCache.cs
+System.Web.Mvc/CustomModelBinderAttribute.cs
+System.Web.Mvc/DataAnnotationsModelMetadata.cs
+System.Web.Mvc/DataAnnotationsModelMetadataProvider.cs
+System.Web.Mvc/DataAnnotationsModelValidator`1.cs
+System.Web.Mvc/DataAnnotationsModelValidator.cs
+System.Web.Mvc/DataAnnotationsModelValidatorProvider.cs
+System.Web.Mvc/DataErrorInfoModelValidatorProvider.cs
+System.Web.Mvc/DefaultControllerFactory.cs
+System.Web.Mvc/DefaultModelBinder.cs
+System.Web.Mvc/DefaultViewLocationCache.cs
+System.Web.Mvc/DescriptorUtil.cs
+System.Web.Mvc/DictionaryHelpers.cs
+System.Web.Mvc/DictionaryValueProvider`1.cs
+System.Web.Mvc/DynamicTypeGenerator.cs
+System.Web.Mvc/EmptyModelMetadataProvider.cs
+System.Web.Mvc/EmptyModelValidatorProvider.cs
+System.Web.Mvc/EmptyResult.cs
+System.Web.Mvc/Error.cs
+System.Web.Mvc/ExceptionContext.cs
+System.Web.Mvc/ExpressionHelper.cs
+System.Web.Mvc/ExpressionUtil/BinaryExpressionFingerprint.cs
+System.Web.Mvc/ExpressionUtil/CachedExpressionCompiler.cs
+System.Web.Mvc/ExpressionUtil/CompiledExpressionDelegate`2.cs
+System.Web.Mvc/ExpressionUtil/ConditionalExpressionFingerprint.cs
+System.Web.Mvc/ExpressionUtil/ConstantExpressionFingerprint.cs
+System.Web.Mvc/ExpressionUtil/ExpressionFingerprint.cs
+System.Web.Mvc/ExpressionUtil/ExpressionParser.cs
+System.Web.Mvc/ExpressionUtil/FastTrack`2.cs
+System.Web.Mvc/ExpressionUtil/HashCodeCombiner.cs
+System.Web.Mvc/ExpressionUtil/MemberExpressionFingerprint.cs
+System.Web.Mvc/ExpressionUtil/MethodCallExpressionFingerprint.cs
+System.Web.Mvc/ExpressionUtil/ParameterExpressionFingerprint.cs
+System.Web.Mvc/ExpressionUtil/ParserContext.cs
+System.Web.Mvc/ExpressionUtil/UnaryExpressionFingerprint.cs
+System.Web.Mvc/FieldValidationMetadata.cs
+System.Web.Mvc/FileContentResult.cs
+System.Web.Mvc/FilePathResult.cs
+System.Web.Mvc/FileResult.cs
+System.Web.Mvc/FileStreamResult.cs
+System.Web.Mvc/FilterAttribute.cs
+System.Web.Mvc/FilterInfo.cs
+System.Web.Mvc/FormCollection.cs
+System.Web.Mvc/FormContext.cs
+System.Web.Mvc/FormMethod.cs
+System.Web.Mvc/FormValueProvider.cs
+System.Web.Mvc/FormValueProviderFactory.cs
+System.Web.Mvc/HandleErrorAttribute.cs
+System.Web.Mvc/HandleErrorInfo.cs
+System.Web.Mvc/HiddenInputAttribute.cs
+System.Web.Mvc/Html/ChildActionExtensions.cs
+System.Web.Mvc/Html/DefaultDisplayTemplates.cs
+System.Web.Mvc/Html/DefaultEditorTemplates.cs
+System.Web.Mvc/Html/DisplayExtensions.cs
+System.Web.Mvc/Html/DisplayTextExtensions.cs
+System.Web.Mvc/Html/EditorExtensions.cs
+System.Web.Mvc/Html/FormExtensions.cs
+System.Web.Mvc/HtmlHelper`1.cs
+System.Web.Mvc/HtmlHelper.cs
+System.Web.Mvc/Html/InputExtensions.cs
+System.Web.Mvc/Html/LabelExtensions.cs
+System.Web.Mvc/Html/LinkExtensions.cs
+System.Web.Mvc/Html/MvcForm.cs
+System.Web.Mvc/Html/PartialExtensions.cs
+System.Web.Mvc/Html/RenderPartialExtensions.cs
+System.Web.Mvc/Html/SelectExtensions.cs
+System.Web.Mvc/Html/TemplateHelpers.cs
+System.Web.Mvc/Html/TextAreaExtensions.cs
+System.Web.Mvc/Html/ValidationExtensions.cs
+System.Web.Mvc/HttpAntiForgeryException.cs
+System.Web.Mvc/HttpDeleteAttribute.cs
+System.Web.Mvc/HttpFileCollectionValueProvider.cs
+System.Web.Mvc/HttpFileCollectionValueProviderFactory.cs
+System.Web.Mvc/HttpGetAttribute.cs
+System.Web.Mvc/HttpHandlerUtil.cs
+System.Web.Mvc/HttpPostAttribute.cs
+System.Web.Mvc/HttpPostedFileBaseModelBinder.cs
+System.Web.Mvc/HttpPutAttribute.cs
+System.Web.Mvc/HttpRequestExtensions.cs
+System.Web.Mvc/HttpUnauthorizedResult.cs
+System.Web.Mvc/HttpVerbs.cs
+System.Web.Mvc/IActionFilter.cs
+System.Web.Mvc/IActionInvoker.cs
+System.Web.Mvc/IAuthorizationFilter.cs
+System.Web.Mvc/IBuildManager.cs
+System.Web.Mvc/IController.cs
+System.Web.Mvc/IControllerFactory.cs
+System.Web.Mvc/IExceptionFilter.cs
+System.Web.Mvc/IModelBinder.cs
+System.Web.Mvc/InputType.cs
+System.Web.Mvc/IResultFilter.cs
+System.Web.Mvc/IRouteWithArea.cs
+System.Web.Mvc/ITempDataProvider.cs
+System.Web.Mvc/IValueProvider.cs
+System.Web.Mvc/IView.cs
+System.Web.Mvc/IViewDataContainer.cs
+System.Web.Mvc/IViewEngine.cs
+System.Web.Mvc/IViewLocationCache.cs
+System.Web.Mvc/JavaScriptResult.cs
+System.Web.Mvc/JsonRequestBehavior.cs
+System.Web.Mvc/JsonResult.cs
+System.Web.Mvc/LinqBinaryModelBinder.cs
+System.Web.Mvc/ModelBinderAttribute.cs
+System.Web.Mvc/ModelBinderDictionary.cs
+System.Web.Mvc/ModelBinders.cs
+System.Web.Mvc/ModelBindingContext.cs
+System.Web.Mvc/ModelClientValidationRangeRule.cs
+System.Web.Mvc/ModelClientValidationRegexRule.cs
+System.Web.Mvc/ModelClientValidationRequiredRule.cs
+System.Web.Mvc/ModelClientValidationRule.cs
+System.Web.Mvc/ModelClientValidationStringLengthRule.cs
+System.Web.Mvc/ModelErrorCollection.cs
+System.Web.Mvc/ModelError.cs
+System.Web.Mvc/ModelMetadata.cs
+System.Web.Mvc/ModelMetadataProvider.cs
+System.Web.Mvc/ModelMetadataProviders.cs
+System.Web.Mvc/ModelState.cs
+System.Web.Mvc/ModelStateDictionary.cs
+System.Web.Mvc/ModelValidationResult.cs
+System.Web.Mvc/ModelValidator.cs
+System.Web.Mvc/ModelValidatorProviderCollection.cs
+System.Web.Mvc/ModelValidatorProvider.cs
+System.Web.Mvc/ModelValidatorProviders.cs
+System.Web.Mvc/MultiSelectList.cs
+System.Web.Mvc/MvcHandler.cs
+System.Web.Mvc/MvcHtmlString.cs
+System.Web.Mvc/MvcHttpHandler.cs
+System.Web.Mvc/MvcRouteHandler.cs
+System.Web.Mvc/NameValueCollectionExtensions.cs
+System.Web.Mvc/NameValueCollectionValueProvider.cs
+System.Web.Mvc/NoAsyncTimeoutAttribute.cs
+System.Web.Mvc/NonActionAttribute.cs
+System.Web.Mvc/NullViewLocationCache.cs
+System.Web.Mvc/OutputCacheAttribute.cs
+System.Web.Mvc/ParameterBindingInfo.cs
+System.Web.Mvc/ParameterDescriptor.cs
+System.Web.Mvc/ParameterInfoUtil.cs
+System.Web.Mvc/PartialViewResult.cs
+System.Web.Mvc/PathHelpers.cs
+System.Web.Mvc/QueryStringValueProvider.cs
+System.Web.Mvc/QueryStringValueProviderFactory.cs
+System.Web.Mvc/RangeAttributeAdapter.cs
+System.Web.Mvc/ReaderWriterCache`2.cs
+System.Web.Mvc/RedirectResult.cs
+System.Web.Mvc/RedirectToRouteResult.cs
+System.Web.Mvc/ReflectedActionDescriptor.cs
+System.Web.Mvc/ReflectedControllerDescriptor.cs
+System.Web.Mvc/ReflectedParameterBindingInfo.cs
+System.Web.Mvc/ReflectedParameterDescriptor.cs
+System.Web.Mvc/RegularExpressionAttributeAdapter.cs
+System.Web.Mvc/RequiredAttributeAdapter.cs
+System.Web.Mvc/RequireHttpsAttribute.cs
+System.Web.Mvc/Resources/MvcResources.Designer.cs
+System.Web.Mvc/ResultExecutedContext.cs
+System.Web.Mvc/ResultExecutingContext.cs
+System.Web.Mvc/RouteCollectionExtensions.cs
+System.Web.Mvc/RouteDataValueProvider.cs
+System.Web.Mvc/RouteDataValueProviderFactory.cs
+System.Web.Mvc/RouteValuesHelpers.cs
+System.Web.Mvc/SelectList.cs
+System.Web.Mvc/SelectListItem.cs
+System.Web.Mvc/SessionStateTempDataProvider.cs
+System.Web.Mvc/StringLengthAttributeAdapter.cs
+System.Web.Mvc/TagBuilder.cs
+System.Web.Mvc/TagRenderMode.cs
+System.Web.Mvc/TempDataDictionary.cs
+System.Web.Mvc/TemplateInfo.cs
+System.Web.Mvc/TryGetValueDelegate.cs
+System.Web.Mvc/TypeCacheSerializer.cs
+System.Web.Mvc/TypeCacheUtil.cs
+System.Web.Mvc/TypeDescriptorHelper.cs
+System.Web.Mvc/TypeHelpers.cs
+System.Web.Mvc/UrlHelper.cs
+System.Web.Mvc/UrlParameter.cs
+System.Web.Mvc/ValidateAntiForgeryTokenAttribute.cs
+System.Web.Mvc/ValidateInputAttribute.cs
+System.Web.Mvc/ValueProviderCollection.cs
+System.Web.Mvc/ValueProviderDictionary.cs
+System.Web.Mvc/ValueProviderFactories.cs
+System.Web.Mvc/ValueProviderFactoryCollection.cs
+System.Web.Mvc/ValueProviderFactory.cs
+System.Web.Mvc/ValueProviderResult.cs
+System.Web.Mvc/ValueProviderUtil.cs
+System.Web.Mvc/ViewContext.cs
+System.Web.Mvc/ViewDataDictionary`1.cs
+System.Web.Mvc/ViewDataDictionary.cs
+System.Web.Mvc/ViewDataInfo.cs
+System.Web.Mvc/ViewEngineCollection.cs
+System.Web.Mvc/ViewEngineResult.cs
+System.Web.Mvc/ViewEngines.cs
+System.Web.Mvc/ViewMasterPage`1.cs
+System.Web.Mvc/ViewMasterPage.cs
+System.Web.Mvc/ViewPage`1.cs
+System.Web.Mvc/ViewPageControlBuilder.cs
+System.Web.Mvc/ViewPage.cs
+System.Web.Mvc/ViewResultBase.cs
+System.Web.Mvc/ViewResult.cs
+System.Web.Mvc/ViewTemplateUserControl`1.cs
+System.Web.Mvc/ViewTemplateUserControl.cs
+System.Web.Mvc/ViewTypeControlBuilder.cs
+System.Web.Mvc/ViewType.cs
+System.Web.Mvc/ViewTypeParserFilter.cs
+System.Web.Mvc/ViewUserControl`1.cs
+System.Web.Mvc/ViewUserControlControlBuilder.cs
+System.Web.Mvc/ViewUserControl.cs
+System.Web.Mvc/VirtualPathProviderViewEngine.cs
+System.Web.Mvc/WebFormView.cs
+System.Web.Mvc/WebFormViewEngine.cs
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AcceptVerbsAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AcceptVerbsAttribute.cs
new file mode 100644 (file)
index 0000000..c0924a4
--- /dev/null
@@ -0,0 +1,71 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.ObjectModel;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments",\r
+        Justification = "The accessor is exposed as an ICollection<string>.")]\r
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public sealed class AcceptVerbsAttribute : ActionMethodSelectorAttribute {\r
+        public AcceptVerbsAttribute(HttpVerbs verbs)\r
+            : this(EnumToArray(verbs)) {\r
+        }\r
+\r
+        public AcceptVerbsAttribute(params string[] verbs) {\r
+            if (verbs == null || verbs.Length == 0) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "verbs");\r
+            }\r
+\r
+            Verbs = new ReadOnlyCollection<string>(verbs);\r
+        }\r
+\r
+        public ICollection<string> Verbs {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        private static void AddEntryToList(HttpVerbs verbs, HttpVerbs match, List<string> verbList, string entryText) {\r
+            if ((verbs & match) != 0) {\r
+                verbList.Add(entryText);\r
+            }\r
+        }\r
+\r
+        internal static string[] EnumToArray(HttpVerbs verbs) {\r
+            List<string> verbList = new List<string>();\r
+\r
+            AddEntryToList(verbs, HttpVerbs.Get, verbList, "GET");\r
+            AddEntryToList(verbs, HttpVerbs.Post, verbList, "POST");\r
+            AddEntryToList(verbs, HttpVerbs.Put, verbList, "PUT");\r
+            AddEntryToList(verbs, HttpVerbs.Delete, verbList, "DELETE");\r
+            AddEntryToList(verbs, HttpVerbs.Head, verbList, "HEAD");\r
+\r
+            return verbList.ToArray();\r
+        }\r
+\r
+        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+\r
+            string incomingVerb = controllerContext.HttpContext.Request.GetHttpMethodOverride();\r
+\r
+            return Verbs.Contains(incomingVerb, StringComparer.OrdinalIgnoreCase);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionDescriptor.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionDescriptor.cs
new file mode 100644 (file)
index 0000000..4041d79
--- /dev/null
@@ -0,0 +1,230 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public abstract class ActionDescriptor : ICustomAttributeProvider {\r
+\r
+        private readonly static AllowMultipleAttributesCache _allowMultiplAttributesCache = new AllowMultipleAttributesCache();\r
+        private readonly static ActionMethodDispatcherCache _staticDispatcherCache = new ActionMethodDispatcherCache();\r
+        private ActionMethodDispatcherCache _instanceDispatcherCache;\r
+\r
+        private static readonly ActionSelector[] _emptySelectors = new ActionSelector[0];\r
+\r
+        public abstract string ActionName {\r
+            get;\r
+        }\r
+\r
+        public abstract ControllerDescriptor ControllerDescriptor {\r
+            get;\r
+        }\r
+\r
+        internal ActionMethodDispatcherCache DispatcherCache {\r
+            get {\r
+                if (_instanceDispatcherCache == null) {\r
+                    _instanceDispatcherCache = _staticDispatcherCache;\r
+                }\r
+                return _instanceDispatcherCache;\r
+            }\r
+            set {\r
+                _instanceDispatcherCache = value;\r
+            }\r
+        }\r
+\r
+        public abstract object Execute(ControllerContext controllerContext, IDictionary<string, object> parameters);\r
+\r
+        internal static object ExtractParameterFromDictionary(ParameterInfo parameterInfo, IDictionary<string, object> parameters, MethodInfo methodInfo) {\r
+            object value;\r
+\r
+            if (!parameters.TryGetValue(parameterInfo.Name, out value)) {\r
+                // the key should always be present, even if the parameter value is null\r
+                string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ReflectedActionDescriptor_ParameterNotInDictionary,\r
+                    parameterInfo.Name, parameterInfo.ParameterType, methodInfo, methodInfo.DeclaringType);\r
+                throw new ArgumentException(message, "parameters");\r
+            }\r
+\r
+            if (value == null && !TypeHelpers.TypeAllowsNullValue(parameterInfo.ParameterType)) {\r
+                // tried to pass a null value for a non-nullable parameter type\r
+                string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ReflectedActionDescriptor_ParameterCannotBeNull,\r
+                    parameterInfo.Name, parameterInfo.ParameterType, methodInfo, methodInfo.DeclaringType);\r
+                throw new ArgumentException(message, "parameters");\r
+            }\r
+\r
+            if (value != null && !parameterInfo.ParameterType.IsInstanceOfType(value)) {\r
+                // value was supplied but is not of the proper type\r
+                string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ReflectedActionDescriptor_ParameterValueHasWrongType,\r
+                    parameterInfo.Name, methodInfo, methodInfo.DeclaringType, value.GetType(), parameterInfo.ParameterType);\r
+                throw new ArgumentException(message, "parameters");\r
+            }\r
+\r
+            return value;\r
+        }\r
+\r
+        internal static object ExtractParameterOrDefaultFromDictionary(ParameterInfo parameterInfo, IDictionary<string, object> parameters) {\r
+            Type parameterType = parameterInfo.ParameterType;\r
+\r
+            object value;\r
+            parameters.TryGetValue(parameterInfo.Name, out value);\r
+\r
+            // if wrong type, replace with default instance\r
+            if (parameterType.IsInstanceOfType(value)) {\r
+                return value;\r
+            }\r
+            else {\r
+                object defaultValue;\r
+                if (ParameterInfoUtil.TryGetDefaultValue(parameterInfo, out defaultValue)) {\r
+                    return defaultValue;\r
+                }\r
+                else {\r
+                    return TypeHelpers.GetDefaultValue(parameterType);\r
+                }\r
+            }\r
+        }\r
+\r
+        public virtual object[] GetCustomAttributes(bool inherit) {\r
+            return GetCustomAttributes(typeof(object), inherit);\r
+        }\r
+\r
+        public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) {\r
+            if (attributeType == null) {\r
+                throw new ArgumentNullException("attributeType");\r
+            }\r
+\r
+            return (object[])Array.CreateInstance(attributeType, 0);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",\r
+            Justification = "This method may perform non-trivial work.")]\r
+        public virtual FilterInfo GetFilters() {\r
+            return new FilterInfo();\r
+        }\r
+\r
+        internal static FilterInfo GetFilters(MethodInfo methodInfo) {\r
+            // Enumerable.OrderBy() is a stable sort, so this method preserves scope ordering.\r
+            FilterAttribute[] typeFilters = (FilterAttribute[])methodInfo.ReflectedType.GetCustomAttributes(typeof(FilterAttribute), true /* inherit */);\r
+            FilterAttribute[] methodFilters = (FilterAttribute[])methodInfo.GetCustomAttributes(typeof(FilterAttribute), true /* inherit */);\r
+            List<FilterAttribute> orderedFilters = RemoveOverriddenFilters(typeFilters.Concat(methodFilters)).OrderBy(attr => attr.Order).ToList();\r
+\r
+            FilterInfo filterInfo = new FilterInfo();\r
+            MergeFiltersIntoList(orderedFilters, filterInfo.ActionFilters);\r
+            MergeFiltersIntoList(orderedFilters, filterInfo.AuthorizationFilters);\r
+            MergeFiltersIntoList(orderedFilters, filterInfo.ExceptionFilters);\r
+            MergeFiltersIntoList(orderedFilters, filterInfo.ResultFilters);\r
+            return filterInfo;\r
+        }\r
+\r
+        public abstract ParameterDescriptor[] GetParameters();\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",\r
+            Justification = "This method may perform non-trivial work.")]\r
+        public virtual ICollection<ActionSelector> GetSelectors() {\r
+            return _emptySelectors;\r
+        }\r
+\r
+        public virtual bool IsDefined(Type attributeType, bool inherit) {\r
+            if (attributeType == null) {\r
+                throw new ArgumentNullException("attributeType");\r
+            }\r
+\r
+            return false;\r
+        }\r
+\r
+        internal static void MergeFiltersIntoList<TFilter>(IList<FilterAttribute> allFilters, IList<TFilter> destFilters) where TFilter : class {\r
+            foreach (FilterAttribute filter in allFilters) {\r
+                TFilter castFilter = filter as TFilter;\r
+                if (castFilter != null) {\r
+                    destFilters.Add(castFilter);\r
+                }\r
+            }\r
+        }\r
+\r
+        internal static IEnumerable<FilterAttribute> RemoveOverriddenFilters(IEnumerable<FilterAttribute> filters) {\r
+            // If an attribute is declared on both the controller and on an action method and that attribute's\r
+            // type has AllowMultiple = false (which is the default for attributes), we should ignore the attributes\r
+            // declared on the controller. The CLR's reflection implementation follows a similar algorithm when it\r
+            // encounters an overridden virtual method where both the base and the override contain some\r
+            // AllowMultiple = false attribute.\r
+\r
+            // Key = attribute type\r
+            // Value = -1 if AllowMultiple true, last index of this attribute type if AllowMultiple false\r
+            Dictionary<Type, int> attrsIndexes = new Dictionary<Type, int>();\r
+\r
+            FilterAttribute[] filtersList = filters.ToArray();\r
+            for (int i = 0; i < filtersList.Length; i++) {\r
+                FilterAttribute filter = filtersList[i];\r
+                Type filterType = filter.GetType();\r
+\r
+                int lastIndex;\r
+                if (attrsIndexes.TryGetValue(filterType, out lastIndex)) {\r
+                    if (lastIndex >= 0) {\r
+                        // this filter already exists and AllowMultiple = false, so clear last entry\r
+                        filtersList[lastIndex] = null;\r
+                        attrsIndexes[filterType] = i;\r
+                    }\r
+                }\r
+                else {\r
+                    // not found - add to dictionary\r
+                    // exactly one AttributeUsageAttribute will always be present\r
+                    bool allowMultiple = _allowMultiplAttributesCache.IsMultiUseAttribute(filterType);\r
+                    attrsIndexes[filterType] = (allowMultiple) ? -1 : i;\r
+                }\r
+            }\r
+\r
+            // any duplicated attributes have now been nulled out, so just return remaining attributes\r
+            return filtersList.Where(attr => attr != null);\r
+        }\r
+\r
+        internal static string VerifyActionMethodIsCallable(MethodInfo methodInfo) {\r
+            // we can't call instance methods where the 'this' parameter is a type other than ControllerBase\r
+            if (!methodInfo.IsStatic && !typeof(ControllerBase).IsAssignableFrom(methodInfo.ReflectedType)) {\r
+                return String.Format(CultureInfo.CurrentUICulture, MvcResources.ReflectedActionDescriptor_CannotCallInstanceMethodOnNonControllerType,\r
+                    methodInfo, methodInfo.ReflectedType.FullName);\r
+            }\r
+\r
+            // we can't call methods with open generic type parameters\r
+            if (methodInfo.ContainsGenericParameters) {\r
+                return String.Format(CultureInfo.CurrentUICulture, MvcResources.ReflectedActionDescriptor_CannotCallOpenGenericMethods,\r
+                    methodInfo, methodInfo.ReflectedType.FullName);\r
+            }\r
+\r
+            // we can't call methods with ref/out parameters\r
+            ParameterInfo[] parameterInfos = methodInfo.GetParameters();\r
+            foreach (ParameterInfo parameterInfo in parameterInfos) {\r
+                if (parameterInfo.IsOut || parameterInfo.ParameterType.IsByRef) {\r
+                    return String.Format(CultureInfo.CurrentUICulture, MvcResources.ReflectedActionDescriptor_CannotCallMethodsWithOutOrRefParameters,\r
+                        methodInfo, methodInfo.ReflectedType.FullName, parameterInfo);\r
+                }\r
+            }\r
+\r
+            // we can call this method\r
+            return null;\r
+        }\r
+\r
+        private sealed class AllowMultipleAttributesCache : ReaderWriterCache<Type, bool> {\r
+            public bool IsMultiUseAttribute(Type attributeType) {\r
+                return FetchOrCreateItem(attributeType, () => AttributeUsageAllowsMultiple(attributeType));\r
+            }\r
+\r
+            private static bool AttributeUsageAllowsMultiple(Type type) {\r
+                return (((AttributeUsageAttribute[])type.GetCustomAttributes(typeof(AttributeUsageAttribute), true))[0]).AllowMultiple;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionExecutedContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionExecutedContext.cs
new file mode 100644 (file)
index 0000000..1dfaa17
--- /dev/null
@@ -0,0 +1,68 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public class ActionExecutedContext : ControllerContext {\r
+\r
+        private ActionResult _result;\r
+\r
+        // parameterless constructor used for mocking\r
+        public ActionExecutedContext() {\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
+        public ActionExecutedContext(ControllerContext controllerContext, ActionDescriptor actionDescriptor, bool canceled, Exception exception)\r
+            : base(controllerContext) {\r
+            if (actionDescriptor == null) {\r
+                throw new ArgumentNullException("actionDescriptor");\r
+            }\r
+\r
+            ActionDescriptor = actionDescriptor;\r
+            Canceled = canceled;\r
+            Exception = exception;\r
+        }\r
+\r
+        public virtual ActionDescriptor ActionDescriptor {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual bool Canceled {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual Exception Exception {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public bool ExceptionHandled {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public ActionResult Result {\r
+            get {\r
+                return _result ?? EmptyResult.Instance;\r
+            }\r
+            set {\r
+                _result = value;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionExecutingContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionExecutingContext.cs
new file mode 100644 (file)
index 0000000..4cc21e0
--- /dev/null
@@ -0,0 +1,57 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public class ActionExecutingContext : ControllerContext {\r
+\r
+        // parameterless constructor used for mocking\r
+        public ActionExecutingContext() {\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
+        public ActionExecutingContext(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<string, object> actionParameters)\r
+            : base(controllerContext) {\r
+            if (actionDescriptor == null) {\r
+                throw new ArgumentNullException("actionDescriptor");\r
+            }\r
+            if (actionParameters == null) {\r
+                throw new ArgumentNullException("actionParameters");\r
+            }\r
+\r
+            ActionDescriptor = actionDescriptor;\r
+            ActionParameters = actionParameters;\r
+        }\r
+\r
+        public virtual ActionDescriptor ActionDescriptor {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "The property setter is only here to support mocking this type and should not be called at runtime.")]\r
+        public virtual IDictionary<string, object> ActionParameters {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public ActionResult Result {\r
+            get;\r
+            set;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionFilterAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionFilterAttribute.cs
new file mode 100644 (file)
index 0000000..1069ccc
--- /dev/null
@@ -0,0 +1,34 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]\r
+    public abstract class ActionFilterAttribute : FilterAttribute, IActionFilter, IResultFilter {\r
+\r
+        // The OnXxx() methods are virtual rather than abstract so that a developer need override\r
+        // only the ones that interest him.\r
+\r
+        public virtual void OnActionExecuting(ActionExecutingContext filterContext) {\r
+        }\r
+\r
+        public virtual void OnActionExecuted(ActionExecutedContext filterContext) {\r
+        }\r
+\r
+        public virtual void OnResultExecuting(ResultExecutingContext filterContext) {\r
+        }\r
+\r
+        public virtual void OnResultExecuted(ResultExecutedContext filterContext) {\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodDispatcher.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodDispatcher.cs
new file mode 100644 (file)
index 0000000..0adafe2
--- /dev/null
@@ -0,0 +1,86 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Linq.Expressions;\r
+    using System.Reflection;\r
+\r
+    // The methods in this class don't perform error checking; that is the responsibility of the\r
+    // caller.\r
+    internal sealed class ActionMethodDispatcher {\r
+\r
+        private delegate object ActionExecutor(ControllerBase controller, object[] parameters);\r
+        private delegate void VoidActionExecutor(ControllerBase controller, object[] parameters);\r
+\r
+        private ActionExecutor _executor;\r
+\r
+        public ActionMethodDispatcher(MethodInfo methodInfo) {\r
+            _executor = GetExecutor(methodInfo);\r
+            MethodInfo = methodInfo;\r
+        }\r
+\r
+        public MethodInfo MethodInfo {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public object Execute(ControllerBase controller, object[] parameters) {\r
+            return _executor(controller, parameters);\r
+        }\r
+\r
+        private static ActionExecutor GetExecutor(MethodInfo methodInfo) {\r
+            // Parameters to executor\r
+            ParameterExpression controllerParameter = Expression.Parameter(typeof(ControllerBase), "controller");\r
+            ParameterExpression parametersParameter = Expression.Parameter(typeof(object[]), "parameters");\r
+\r
+            // Build parameter list\r
+            List<Expression> parameters = new List<Expression>();\r
+            ParameterInfo[] paramInfos = methodInfo.GetParameters();\r
+            for (int i = 0; i < paramInfos.Length; i++) {\r
+                ParameterInfo paramInfo = paramInfos[i];\r
+                BinaryExpression valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i));\r
+                UnaryExpression valueCast = Expression.Convert(valueObj, paramInfo.ParameterType);\r
+\r
+                // valueCast is "(Ti) parameters[i]"\r
+                parameters.Add(valueCast);\r
+            }\r
+\r
+            // Call method\r
+            UnaryExpression instanceCast = (!methodInfo.IsStatic) ? Expression.Convert(controllerParameter, methodInfo.ReflectedType) : null;\r
+            MethodCallExpression methodCall = methodCall = Expression.Call(instanceCast, methodInfo, parameters);\r
+\r
+            // methodCall is "((TController) controller) method((T0) parameters[0], (T1) parameters[1], ...)"\r
+            // Create function\r
+            if (methodCall.Type == typeof(void)) {\r
+                Expression<VoidActionExecutor> lambda = Expression.Lambda<VoidActionExecutor>(methodCall, controllerParameter, parametersParameter);\r
+                VoidActionExecutor voidExecutor = lambda.Compile();\r
+                return WrapVoidAction(voidExecutor);\r
+            }\r
+            else {\r
+                // must coerce methodCall to match ActionExecutor signature\r
+                UnaryExpression castMethodCall = Expression.Convert(methodCall, typeof(object));\r
+                Expression<ActionExecutor> lambda = Expression.Lambda<ActionExecutor>(castMethodCall, controllerParameter, parametersParameter);\r
+                return lambda.Compile();\r
+            }\r
+        }\r
+\r
+        private static ActionExecutor WrapVoidAction(VoidActionExecutor executor) {\r
+            return delegate(ControllerBase controller, object[] parameters) {\r
+                executor(controller, parameters);\r
+                return null;\r
+            };\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodDispatcherCache.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodDispatcherCache.cs
new file mode 100644 (file)
index 0000000..61b5333
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+\r
+    internal sealed class ActionMethodDispatcherCache : ReaderWriterCache<MethodInfo,ActionMethodDispatcher> {\r
+\r
+        public ActionMethodDispatcherCache() {\r
+        }\r
+\r
+        public ActionMethodDispatcher GetDispatcher(MethodInfo methodInfo) {\r
+            return FetchOrCreateItem(methodInfo, () => new ActionMethodDispatcher(methodInfo));\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodSelector.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodSelector.cs
new file mode 100644 (file)
index 0000000..4b765db
--- /dev/null
@@ -0,0 +1,125 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Text;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    internal sealed class ActionMethodSelector {\r
+\r
+        public ActionMethodSelector(Type controllerType) {\r
+            ControllerType = controllerType;\r
+            PopulateLookupTables();\r
+        }\r
+\r
+        public Type ControllerType {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public MethodInfo[] AliasedMethods {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ILookup<string, MethodInfo> NonAliasedMethods {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        private AmbiguousMatchException CreateAmbiguousMatchException(List<MethodInfo> ambiguousMethods, string actionName) {\r
+            StringBuilder exceptionMessageBuilder = new StringBuilder();\r
+            foreach (MethodInfo methodInfo in ambiguousMethods) {\r
+                string controllerAction = Convert.ToString(methodInfo, CultureInfo.CurrentUICulture);\r
+                string controllerType = methodInfo.DeclaringType.FullName;\r
+                exceptionMessageBuilder.AppendLine();\r
+                exceptionMessageBuilder.AppendFormat(CultureInfo.CurrentUICulture, MvcResources.ActionMethodSelector_AmbiguousMatchType, controllerAction, controllerType);\r
+            }\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ActionMethodSelector_AmbiguousMatch,\r
+                actionName, ControllerType.Name, exceptionMessageBuilder);\r
+            return new AmbiguousMatchException(message);\r
+        }\r
+\r
+        public MethodInfo FindActionMethod(ControllerContext controllerContext, string actionName) {\r
+            List<MethodInfo> methodsMatchingName = GetMatchingAliasedMethods(controllerContext, actionName);\r
+            methodsMatchingName.AddRange(NonAliasedMethods[actionName]);\r
+            List<MethodInfo> finalMethods = RunSelectionFilters(controllerContext, methodsMatchingName);\r
+\r
+            switch (finalMethods.Count) {\r
+                case 0:\r
+                    return null;\r
+\r
+                case 1:\r
+                    return finalMethods[0];\r
+\r
+                default:\r
+                    throw CreateAmbiguousMatchException(finalMethods, actionName);\r
+            }\r
+        }\r
+\r
+        internal List<MethodInfo> GetMatchingAliasedMethods(ControllerContext controllerContext, string actionName) {\r
+            // find all aliased methods which are opting in to this request\r
+            // to opt in, all attributes defined on the method must return true\r
+\r
+            var methods = from methodInfo in AliasedMethods\r
+                          let attrs = (ActionNameSelectorAttribute[])methodInfo.GetCustomAttributes(typeof(ActionNameSelectorAttribute), true /* inherit */)\r
+                          where attrs.All(attr => attr.IsValidName(controllerContext, actionName, methodInfo))\r
+                          select methodInfo;\r
+            return methods.ToList();\r
+        }\r
+\r
+        private static bool IsMethodDecoratedWithAliasingAttribute(MethodInfo methodInfo) {\r
+            return methodInfo.IsDefined(typeof(ActionNameSelectorAttribute), true /* inherit */);\r
+        }\r
+\r
+        private static bool IsValidActionMethod(MethodInfo methodInfo) {\r
+            return !(methodInfo.IsSpecialName ||\r
+                     methodInfo.GetBaseDefinition().DeclaringType.IsAssignableFrom(typeof(Controller)));\r
+        }\r
+\r
+        private void PopulateLookupTables() {\r
+            MethodInfo[] allMethods = ControllerType.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public);\r
+            MethodInfo[] actionMethods = Array.FindAll(allMethods, IsValidActionMethod);\r
+\r
+            AliasedMethods = Array.FindAll(actionMethods, IsMethodDecoratedWithAliasingAttribute);\r
+            NonAliasedMethods = actionMethods.Except(AliasedMethods).ToLookup(method => method.Name, StringComparer.OrdinalIgnoreCase);\r
+        }\r
+\r
+        private static List<MethodInfo> RunSelectionFilters(ControllerContext controllerContext, List<MethodInfo> methodInfos) {\r
+            // remove all methods which are opting out of this request\r
+            // to opt out, at least one attribute defined on the method must return false\r
+\r
+            List<MethodInfo> matchesWithSelectionAttributes = new List<MethodInfo>();\r
+            List<MethodInfo> matchesWithoutSelectionAttributes = new List<MethodInfo>();\r
+\r
+            foreach (MethodInfo methodInfo in methodInfos) {\r
+                ActionMethodSelectorAttribute[] attrs = (ActionMethodSelectorAttribute[])methodInfo.GetCustomAttributes(typeof(ActionMethodSelectorAttribute), true /* inherit */);\r
+                if (attrs.Length == 0) {\r
+                    matchesWithoutSelectionAttributes.Add(methodInfo);\r
+                }\r
+                else if (attrs.All(attr => attr.IsValidForRequest(controllerContext, methodInfo))) {\r
+                    matchesWithSelectionAttributes.Add(methodInfo);\r
+                }\r
+            }\r
+\r
+            // if a matching action method had a selection attribute, consider it more specific than a matching action method\r
+            // without a selection attribute\r
+            return (matchesWithSelectionAttributes.Count > 0) ? matchesWithSelectionAttributes : matchesWithoutSelectionAttributes;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodSelectorAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionMethodSelectorAttribute.cs
new file mode 100644 (file)
index 0000000..0a2fd29
--- /dev/null
@@ -0,0 +1,21 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+\r
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public abstract class ActionMethodSelectorAttribute : Attribute {\r
+        public abstract bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionNameAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionNameAttribute.cs
new file mode 100644 (file)
index 0000000..46ef66a
--- /dev/null
@@ -0,0 +1,39 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public sealed class ActionNameAttribute : ActionNameSelectorAttribute {\r
+\r
+        public ActionNameAttribute(string name) {\r
+            if (String.IsNullOrEmpty(name)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "name");\r
+            }\r
+\r
+            Name = name;\r
+        }\r
+\r
+        public string Name {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo) {\r
+            return String.Equals(actionName, Name, StringComparison.OrdinalIgnoreCase);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionNameSelectorAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionNameSelectorAttribute.cs
new file mode 100644 (file)
index 0000000..5ec4134
--- /dev/null
@@ -0,0 +1,21 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+\r
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public abstract class ActionNameSelectorAttribute : Attribute {\r
+        public abstract bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionResult.cs
new file mode 100644 (file)
index 0000000..11bc79c
--- /dev/null
@@ -0,0 +1,21 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public abstract class ActionResult {\r
+\r
+        public abstract void ExecuteResult(ControllerContext context);\r
+\r
+    }\r
+\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionSelector.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ActionSelector.cs
new file mode 100644 (file)
index 0000000..59891d6
--- /dev/null
@@ -0,0 +1,17 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public delegate bool ActionSelector(ControllerContext controllerContext);\r
+\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Ajax/AjaxExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Ajax/AjaxExtensions.cs
new file mode 100644 (file)
index 0000000..a34122f
--- /dev/null
@@ -0,0 +1,322 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Ajax {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Web;\r
+    using System.Web.Mvc;\r
+    using System.Web.Mvc.Html;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public static class AjaxExtensions {\r
+        private const string LinkOnClickFormat = "Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), {0});";\r
+        private const string FormOnClickValue = "Sys.Mvc.AsyncForm.handleClick(this, new Sys.UI.DomEvent(event));";\r
+        private const string FormOnSubmitFormat = "Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), {0});";\r
+        private const string _globalizationScript = @"<script type=""text/javascript"" src=""{0}""></script>";\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, AjaxOptions ajaxOptions) {\r
+            return ActionLink(ajaxHelper, linkText, actionName, (string)null /* controllerName */, ajaxOptions);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, object routeValues, AjaxOptions ajaxOptions) {\r
+            return ActionLink(ajaxHelper, linkText, actionName, (string)null /* controllerName */, routeValues, ajaxOptions);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) {\r
+            return ActionLink(ajaxHelper, linkText, actionName, (string)null /* controllerName */, routeValues, ajaxOptions, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions) {\r
+            return ActionLink(ajaxHelper, linkText, actionName, (string)null /* controllerName */, routeValues, ajaxOptions);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            return ActionLink(ajaxHelper, linkText, actionName, (string)null /* controllerName */, routeValues, ajaxOptions, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, AjaxOptions ajaxOptions) {\r
+            return ActionLink(ajaxHelper, linkText, actionName, controllerName, null /* values */, ajaxOptions, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions) {\r
+            return ActionLink(ajaxHelper, linkText, actionName, controllerName, routeValues, ajaxOptions, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) {\r
+            RouteValueDictionary newValues = new RouteValueDictionary(routeValues);\r
+            Dictionary<string, object> newAttributes = ObjectToCaseSensitiveDictionary(htmlAttributes);\r
+            return ActionLink(ajaxHelper, linkText, actionName, controllerName, newValues, ajaxOptions, newAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions) {\r
+            return ActionLink(ajaxHelper, linkText, actionName, controllerName, routeValues, ajaxOptions, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            if (String.IsNullOrEmpty(linkText)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "linkText");\r
+            }\r
+\r
+            string targetUrl = UrlHelper.GenerateUrl(null, actionName, controllerName, routeValues, ajaxHelper.RouteCollection, ajaxHelper.ViewContext.RequestContext, true /* includeImplicitMvcValues */);\r
+\r
+            return MvcHtmlString.Create(GenerateLink(linkText, targetUrl, GetAjaxOptions(ajaxOptions), htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) {\r
+            RouteValueDictionary newValues = new RouteValueDictionary(routeValues);\r
+            Dictionary<string, object> newAttributes = ObjectToCaseSensitiveDictionary(htmlAttributes);\r
+            return ActionLink(ajaxHelper, linkText, actionName, controllerName, protocol, hostName, fragment, newValues, ajaxOptions, newAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            if (String.IsNullOrEmpty(linkText)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "linkText");\r
+            }\r
+\r
+            string targetUrl = UrlHelper.GenerateUrl(null /* routeName */, actionName, controllerName, protocol, hostName, fragment, routeValues, ajaxHelper.RouteCollection, ajaxHelper.ViewContext.RequestContext, true /* includeImplicitMvcValues */);\r
+\r
+            return MvcHtmlString.Create(GenerateLink(linkText, targetUrl, ajaxOptions, htmlAttributes));\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, AjaxOptions ajaxOptions) {\r
+            string formAction = ajaxHelper.ViewContext.HttpContext.Request.RawUrl;\r
+            return FormHelper(ajaxHelper, formAction, ajaxOptions, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, AjaxOptions ajaxOptions) {\r
+            return BeginForm(ajaxHelper, actionName, (string)null /* controllerName */, ajaxOptions);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, object routeValues, AjaxOptions ajaxOptions) {\r
+            return BeginForm(ajaxHelper, actionName, (string)null /* controllerName */, routeValues, ajaxOptions);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) {\r
+            return BeginForm(ajaxHelper, actionName, (string)null /* controllerName */, routeValues, ajaxOptions, htmlAttributes);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions) {\r
+            return BeginForm(ajaxHelper, actionName, (string)null /* controllerName */, routeValues, ajaxOptions);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            return BeginForm(ajaxHelper, actionName, (string)null /* controllerName */, routeValues, ajaxOptions, htmlAttributes);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, AjaxOptions ajaxOptions) {\r
+            return BeginForm(ajaxHelper, actionName, controllerName, null /* values */, ajaxOptions, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions) {\r
+            return BeginForm(ajaxHelper, actionName, controllerName, routeValues, ajaxOptions, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) {\r
+            RouteValueDictionary newValues = new RouteValueDictionary(routeValues);\r
+            Dictionary<string, object> newAttributes = ObjectToCaseSensitiveDictionary(htmlAttributes);\r
+            return BeginForm(ajaxHelper, actionName, controllerName, newValues, ajaxOptions, newAttributes);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions) {\r
+            return BeginForm(ajaxHelper, actionName, controllerName, routeValues, ajaxOptions, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            // get target URL\r
+            string formAction = UrlHelper.GenerateUrl(null, actionName, controllerName, routeValues ?? new RouteValueDictionary(), ajaxHelper.RouteCollection, ajaxHelper.ViewContext.RequestContext, true /* includeImplicitMvcValues */);\r
+            return FormHelper(ajaxHelper, formAction, ajaxOptions, htmlAttributes);\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this AjaxHelper ajaxHelper, string routeName, AjaxOptions ajaxOptions) {\r
+            return BeginRouteForm(ajaxHelper, routeName, null /* routeValues */, ajaxOptions, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this AjaxHelper ajaxHelper, string routeName, object routeValues, AjaxOptions ajaxOptions) {\r
+            return BeginRouteForm(ajaxHelper, routeName, (object)routeValues, ajaxOptions, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this AjaxHelper ajaxHelper, string routeName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) {\r
+            Dictionary<string, object> newAttributes = ObjectToCaseSensitiveDictionary(htmlAttributes);\r
+            return BeginRouteForm(ajaxHelper, routeName, new RouteValueDictionary(routeValues), ajaxOptions, newAttributes);\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this AjaxHelper ajaxHelper, string routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions) {\r
+            return BeginRouteForm(ajaxHelper, routeName, routeValues, ajaxOptions, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this AjaxHelper ajaxHelper, string routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            string formAction = UrlHelper.GenerateUrl(routeName, null /* actionName */, null /* controllerName */, routeValues ?? new RouteValueDictionary(), ajaxHelper.RouteCollection, ajaxHelper.ViewContext.RequestContext, false /* includeImplicitMvcValues */);\r
+            return FormHelper(ajaxHelper, formAction, ajaxOptions, htmlAttributes);\r
+        }\r
+\r
+        private static MvcForm FormHelper(this AjaxHelper ajaxHelper, string formAction, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            TagBuilder builder = new TagBuilder("form");\r
+            builder.MergeAttributes(htmlAttributes);\r
+            builder.MergeAttribute("action", formAction);\r
+            builder.MergeAttribute("method", "post");\r
+            builder.MergeAttribute("onclick", FormOnClickValue);\r
+            builder.MergeAttribute("onsubmit", GenerateAjaxScript(GetAjaxOptions(ajaxOptions), FormOnSubmitFormat));\r
+\r
+            if (ajaxHelper.ViewContext.ClientValidationEnabled) {\r
+                // forms must have an ID for client validation\r
+                builder.GenerateId(ajaxHelper.ViewContext.FormIdGenerator());\r
+            }\r
+\r
+            ajaxHelper.ViewContext.Writer.Write(builder.ToString(TagRenderMode.StartTag));\r
+            MvcForm theForm = new MvcForm(ajaxHelper.ViewContext);\r
+\r
+            if (ajaxHelper.ViewContext.ClientValidationEnabled) {\r
+                ajaxHelper.ViewContext.FormContext.FormId = builder.Attributes["id"];\r
+            }\r
+\r
+            return theForm;\r
+        }\r
+\r
+        public static MvcHtmlString GlobalizationScript(this AjaxHelper ajaxHelper) {\r
+            return GlobalizationScript(ajaxHelper, CultureInfo.CurrentCulture);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "ajaxHelper",\r
+            Justification = "This is an extension method")]\r
+        public static MvcHtmlString GlobalizationScript(this AjaxHelper ajaxHelper, CultureInfo cultureInfo) {\r
+            return GlobalizationScriptHelper(AjaxHelper.GlobalizationScriptPath, cultureInfo);\r
+        }\r
+\r
+        private static MvcHtmlString GlobalizationScriptHelper(string scriptPath, CultureInfo cultureInfo) {\r
+            if (cultureInfo == null) {\r
+                throw new ArgumentNullException("cultureInfo");\r
+            }\r
+\r
+            string src = VirtualPathUtility.AppendTrailingSlash(scriptPath) + cultureInfo.Name + ".js";\r
+            string scriptWithCorrectNewLines = _globalizationScript.Replace("\r\n", Environment.NewLine);\r
+            string formatted = String.Format(CultureInfo.InvariantCulture, scriptWithCorrectNewLines, src);\r
+\r
+            return MvcHtmlString.Create(formatted);\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, object routeValues, AjaxOptions ajaxOptions) {\r
+            return RouteLink(ajaxHelper, linkText, null /* routeName */, new RouteValueDictionary(routeValues), ajaxOptions,\r
+                             new Dictionary<string, object>());\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) {\r
+            return RouteLink(ajaxHelper, linkText, null /* routeName */, new RouteValueDictionary(routeValues), ajaxOptions,\r
+                             ObjectToCaseSensitiveDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, RouteValueDictionary routeValues, AjaxOptions ajaxOptions) {\r
+            return RouteLink(ajaxHelper, linkText, null /* routeName */, routeValues, ajaxOptions,\r
+                             new Dictionary<string, object>());\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            return RouteLink(ajaxHelper, linkText, null /* routeName */, routeValues, ajaxOptions, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, AjaxOptions ajaxOptions) {\r
+            return RouteLink(ajaxHelper, linkText, routeName, new RouteValueDictionary(), ajaxOptions,\r
+                             new Dictionary<string, object>());\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, AjaxOptions ajaxOptions, object htmlAttributes) {\r
+            return RouteLink(ajaxHelper, linkText, routeName, new RouteValueDictionary(), ajaxOptions, ObjectToCaseSensitiveDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            return RouteLink(ajaxHelper, linkText, routeName, new RouteValueDictionary(), ajaxOptions, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, object routeValues, AjaxOptions ajaxOptions) {\r
+            return RouteLink(ajaxHelper, linkText, routeName, new RouteValueDictionary(routeValues), ajaxOptions,\r
+                             new Dictionary<string, object>());\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes) {\r
+            return RouteLink(ajaxHelper, linkText, routeName, new RouteValueDictionary(routeValues), ajaxOptions,\r
+                             ObjectToCaseSensitiveDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions) {\r
+            return RouteLink(ajaxHelper, linkText, routeName, routeValues, ajaxOptions, new Dictionary<string, object>());\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            if (String.IsNullOrEmpty(linkText)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "linkText");\r
+            }\r
+\r
+            string targetUrl = UrlHelper.GenerateUrl(routeName, null /* actionName */, null /* controllerName */, routeValues ?? new RouteValueDictionary(), ajaxHelper.RouteCollection, ajaxHelper.ViewContext.RequestContext, false /* includeImplicitMvcValues */);\r
+\r
+            return MvcHtmlString.Create(GenerateLink(linkText, targetUrl, GetAjaxOptions(ajaxOptions), htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            if (String.IsNullOrEmpty(linkText)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "linkText");\r
+            }\r
+\r
+            string targetUrl = UrlHelper.GenerateUrl(routeName, null /* actionName */, null /* controllerName */, protocol, hostName, fragment, routeValues ?? new RouteValueDictionary(), ajaxHelper.RouteCollection, ajaxHelper.ViewContext.RequestContext, false /* includeImplicitMvcValues */);\r
+\r
+            return MvcHtmlString.Create(GenerateLink(linkText, targetUrl, GetAjaxOptions(ajaxOptions), htmlAttributes));\r
+        }\r
+\r
+        internal static string InsertionModeToString(InsertionMode insertionMode) {\r
+            switch (insertionMode) {\r
+                case InsertionMode.Replace:\r
+                    return "Sys.Mvc.InsertionMode.replace";\r
+                case InsertionMode.InsertBefore:\r
+                    return "Sys.Mvc.InsertionMode.insertBefore";\r
+                case InsertionMode.InsertAfter:\r
+                    return "Sys.Mvc.InsertionMode.insertAfter";\r
+                default:\r
+                    return ((int)insertionMode).ToString(CultureInfo.InvariantCulture);\r
+            }\r
+        }\r
+\r
+        private static Dictionary<string, object> ObjectToCaseSensitiveDictionary(object values) {\r
+            Dictionary<string, object> dict = new Dictionary<string, object>(StringComparer.Ordinal);\r
+            if (values != null) {\r
+                foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(values)) {\r
+                    object val = prop.GetValue(values);\r
+                    dict[prop.Name] = val;\r
+                }\r
+            }\r
+            return dict;\r
+        }\r
+\r
+        private static string GenerateLink(string linkText, string targetUrl, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) {\r
+            TagBuilder tag = new TagBuilder("a") {\r
+                InnerHtml = HttpUtility.HtmlEncode(linkText)\r
+            };\r
+\r
+            tag.MergeAttributes(htmlAttributes);\r
+            tag.MergeAttribute("href", targetUrl);\r
+            tag.MergeAttribute("onclick", GenerateAjaxScript(ajaxOptions, LinkOnClickFormat));\r
+\r
+            return tag.ToString(TagRenderMode.Normal);\r
+        }\r
+\r
+        private static string GenerateAjaxScript(AjaxOptions ajaxOptions, string scriptFormat) {\r
+            string optionsString = ajaxOptions.ToJavascriptString();\r
+            return String.Format(CultureInfo.InvariantCulture, scriptFormat, optionsString);\r
+        }\r
+\r
+        private static AjaxOptions GetAjaxOptions(AjaxOptions ajaxOptions) {\r
+            return (ajaxOptions != null) ? ajaxOptions : new AjaxOptions();\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Ajax/AjaxOptions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Ajax/AjaxOptions.cs
new file mode 100644 (file)
index 0000000..ca04c64
--- /dev/null
@@ -0,0 +1,166 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Ajax {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Text;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class AjaxOptions {\r
+        private string _confirm;\r
+        private string _httpMethod;\r
+        private InsertionMode _insertionMode = InsertionMode.Replace;\r
+        private string _loadingElementId;\r
+        private string _onBegin;\r
+        private string _onComplete;\r
+        private string _onFailure;\r
+        private string _onSuccess;\r
+        private string _updateTargetId;\r
+        private string _url;\r
+\r
+        public string Confirm {\r
+            get {\r
+                return _confirm ?? String.Empty;\r
+            }\r
+            set {\r
+                _confirm = value;\r
+            }\r
+        }\r
+\r
+        public string HttpMethod {\r
+            get {\r
+                return _httpMethod ?? String.Empty;\r
+            }\r
+            set {\r
+                _httpMethod = value;\r
+            }\r
+        }\r
+\r
+        public InsertionMode InsertionMode {\r
+            get {\r
+                return _insertionMode;\r
+            }\r
+            set {\r
+                switch (value) {\r
+                    case InsertionMode.Replace:\r
+                    case InsertionMode.InsertAfter:\r
+                    case InsertionMode.InsertBefore:\r
+                        _insertionMode = value;\r
+                        return;\r
+\r
+                    default:\r
+                        throw new ArgumentOutOfRangeException("value");\r
+                }\r
+            }\r
+        }\r
+\r
+        public string LoadingElementId {\r
+            get {\r
+                return _loadingElementId ?? String.Empty;\r
+            }\r
+            set {\r
+                _loadingElementId = value;\r
+            }\r
+        }\r
+\r
+        public string OnBegin {\r
+            get {\r
+                return _onBegin ?? String.Empty;\r
+            }\r
+            set {\r
+                _onBegin = value;\r
+            }\r
+        }\r
+\r
+        public string OnComplete {\r
+            get {\r
+                return _onComplete ?? String.Empty;\r
+            }\r
+            set {\r
+                _onComplete = value;\r
+            }\r
+        }\r
+\r
+        public string OnFailure {\r
+            get {\r
+                return _onFailure ?? String.Empty;\r
+            }\r
+            set {\r
+                _onFailure = value;\r
+            }\r
+        }\r
+\r
+        public string OnSuccess {\r
+            get {\r
+                return _onSuccess ?? String.Empty;\r
+            }\r
+            set {\r
+                _onSuccess = value;\r
+            }\r
+        }\r
+\r
+        public string UpdateTargetId {\r
+            get {\r
+                return _updateTargetId ?? String.Empty;\r
+            }\r
+            set {\r
+                _updateTargetId = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings",\r
+            Justification = "This property is used by the optionsBuilder which always accepts a string.")]\r
+        public string Url {\r
+            get {\r
+                return _url ?? String.Empty;\r
+            }\r
+            set {\r
+                _url = value;\r
+            }\r
+        }\r
+\r
+        internal string ToJavascriptString() {\r
+            // creates a string of the form { key1: value1, key2 : value2, ... }\r
+            StringBuilder optionsBuilder = new StringBuilder("{");\r
+            optionsBuilder.Append(String.Format(CultureInfo.InvariantCulture, " insertionMode: {0},", AjaxExtensions.InsertionModeToString(InsertionMode)));\r
+            optionsBuilder.Append(PropertyStringIfSpecified("confirm", Confirm));\r
+            optionsBuilder.Append(PropertyStringIfSpecified("httpMethod", HttpMethod));\r
+            optionsBuilder.Append(PropertyStringIfSpecified("loadingElementId", LoadingElementId));\r
+            optionsBuilder.Append(PropertyStringIfSpecified("updateTargetId", UpdateTargetId));\r
+            optionsBuilder.Append(PropertyStringIfSpecified("url", Url));\r
+            optionsBuilder.Append(EventStringIfSpecified("onBegin", OnBegin));\r
+            optionsBuilder.Append(EventStringIfSpecified("onComplete", OnComplete));\r
+            optionsBuilder.Append(EventStringIfSpecified("onFailure", OnFailure));\r
+            optionsBuilder.Append(EventStringIfSpecified("onSuccess", OnSuccess));\r
+            optionsBuilder.Length--;\r
+            optionsBuilder.Append(" }");\r
+            return optionsBuilder.ToString();\r
+        }\r
+\r
+        private static string EventStringIfSpecified(string propertyName, string handler) {\r
+            if (!String.IsNullOrEmpty(handler)) {\r
+                return String.Format(CultureInfo.InvariantCulture, " {0}: Function.createDelegate(this, {1}),", propertyName, handler.ToString());\r
+            }\r
+            return String.Empty;\r
+        }\r
+\r
+        private static string PropertyStringIfSpecified(string propertyName, string propertyValue) {\r
+            if (!String.IsNullOrEmpty(propertyValue)) {\r
+                string escapedPropertyValue = propertyValue.Replace("'", @"\'");\r
+                return String.Format(CultureInfo.InvariantCulture, " {0}: '{1}',", propertyName, escapedPropertyValue);\r
+            }\r
+            return String.Empty;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Ajax/InsertionMode.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Ajax/InsertionMode.cs
new file mode 100644 (file)
index 0000000..de0eb4e
--- /dev/null
@@ -0,0 +1,19 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Ajax {\r
+    public enum InsertionMode {\r
+        Replace = 0,\r
+        InsertBefore = 1,\r
+        InsertAfter = 2\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AjaxHelper.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AjaxHelper.cs
new file mode 100644 (file)
index 0000000..7324a52
--- /dev/null
@@ -0,0 +1,89 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Text;\r
+    using System.Web.Routing;\r
+    using System.Web.Script.Serialization;\r
+\r
+    public class AjaxHelper {\r
+\r
+        private static string _globalizationScriptPath;\r
+\r
+        public AjaxHelper(ViewContext viewContext, IViewDataContainer viewDataContainer)\r
+            : this(viewContext, viewDataContainer, RouteTable.Routes) {\r
+        }\r
+\r
+        public AjaxHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) {\r
+            if (viewContext == null) {\r
+                throw new ArgumentNullException("viewContext");\r
+            }\r
+            if (viewDataContainer == null) {\r
+                throw new ArgumentNullException("viewDataContainer");\r
+            }\r
+            if (routeCollection == null) {\r
+                throw new ArgumentNullException("routeCollection");\r
+            }\r
+            ViewContext = viewContext;\r
+            ViewDataContainer = viewDataContainer;\r
+            RouteCollection = routeCollection;\r
+        }\r
+\r
+        public static string GlobalizationScriptPath {\r
+            get {\r
+                if (String.IsNullOrEmpty(_globalizationScriptPath)) {\r
+                    _globalizationScriptPath = "~/Scripts/Globalization";\r
+                }\r
+                return _globalizationScriptPath;\r
+            }\r
+            set {\r
+                _globalizationScriptPath = value;\r
+            }\r
+        }\r
+\r
+        public RouteCollection RouteCollection {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ViewContext ViewContext {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ViewDataDictionary ViewData {\r
+            get {\r
+                return ViewDataContainer.ViewData;\r
+            }\r
+        }\r
+\r
+        public IViewDataContainer ViewDataContainer {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "Instance method for consistency with other helpers.")]\r
+        public string JavaScriptStringEncode(string message) {\r
+            if (String.IsNullOrEmpty(message)) {\r
+                return message;\r
+            }\r
+            \r
+            StringBuilder builder = new StringBuilder();\r
+            JavaScriptSerializer serializer = new JavaScriptSerializer();\r
+            serializer.Serialize(message, builder);\r
+            return builder.ToString(1, builder.Length - 2); // remove first + last quote\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AjaxHelper`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AjaxHelper`1.cs
new file mode 100644 (file)
index 0000000..1e1f2b9
--- /dev/null
@@ -0,0 +1,35 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Web.Routing;\r
+\r
+    public class AjaxHelper<TModel> : AjaxHelper {\r
+        private ViewDataDictionary<TModel> _viewData;\r
+\r
+        public AjaxHelper(ViewContext viewContext, IViewDataContainer viewDataContainer)\r
+            : this(viewContext, viewDataContainer, RouteTable.Routes) {\r
+        }\r
+\r
+        public AjaxHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection)\r
+            : base(viewContext, viewDataContainer, routeCollection) {\r
+\r
+            _viewData = new ViewDataDictionary<TModel>(viewDataContainer.ViewData);\r
+        }\r
+\r
+        public new ViewDataDictionary<TModel> ViewData {\r
+            get {\r
+                return _viewData;\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AjaxRequestExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AjaxRequestExtensions.cs
new file mode 100644 (file)
index 0000000..411c250
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public static class AjaxRequestExtensions {\r
+\r
+        public static bool IsAjaxRequest(this HttpRequestBase request) {\r
+            if (request == null) {\r
+                throw new ArgumentNullException("request");\r
+            }\r
+            \r
+            return (request["X-Requested-With"] == "XMLHttpRequest") || ((request.Headers != null) && (request.Headers["X-Requested-With"] == "XMLHttpRequest"));\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AntiForgeryData.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AntiForgeryData.cs
new file mode 100644 (file)
index 0000000..82252d4
--- /dev/null
@@ -0,0 +1,129 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Security.Cryptography;\r
+    using System.Security.Principal;\r
+    using System.Text;\r
+\r
+    internal sealed class AntiForgeryData {\r
+\r
+        private const string AntiForgeryTokenFieldName = "__RequestVerificationToken";\r
+\r
+        private const int TokenLength = 128 / 8;\r
+        private readonly static RNGCryptoServiceProvider _prng = new RNGCryptoServiceProvider();\r
+\r
+        private DateTime _creationDate = DateTime.UtcNow;\r
+        private string _salt;\r
+        private string _username;\r
+        private string _value;\r
+\r
+        public AntiForgeryData() {\r
+        }\r
+\r
+        // copy constructor\r
+        public AntiForgeryData(AntiForgeryData token) {\r
+            if (token == null) {\r
+                throw new ArgumentNullException("token");\r
+            }\r
+\r
+            CreationDate = token.CreationDate;\r
+            Salt = token.Salt;\r
+            Username = token.Username;\r
+            Value = token.Value;\r
+        }\r
+\r
+        public DateTime CreationDate {\r
+            get {\r
+                return _creationDate;\r
+            }\r
+            set {\r
+                _creationDate = value;\r
+            }\r
+        }\r
+\r
+        public string Salt {\r
+            get {\r
+                return _salt ?? String.Empty;\r
+            }\r
+            set {\r
+                _salt = value;\r
+            }\r
+        }\r
+\r
+        public string Username {\r
+            get {\r
+                return _username ?? String.Empty;\r
+            }\r
+            set {\r
+                _username = value;\r
+            }\r
+        }\r
+\r
+        public string Value {\r
+            get {\r
+                return _value ?? String.Empty;\r
+            }\r
+            set {\r
+                _value = value;\r
+            }\r
+        }\r
+\r
+        private static string Base64EncodeForCookieName(string s) {\r
+            byte[] rawBytes = Encoding.UTF8.GetBytes(s);\r
+            string base64String = Convert.ToBase64String(rawBytes);\r
+\r
+            // replace base64-specific characters with characters that are safe for a cookie name\r
+            return base64String.Replace('+', '.').Replace('/', '-').Replace('=', '_');\r
+        }\r
+\r
+        private static string GenerateRandomTokenString() {\r
+            byte[] tokenBytes = new byte[TokenLength];\r
+            _prng.GetBytes(tokenBytes);\r
+\r
+            string token = Convert.ToBase64String(tokenBytes);\r
+            return token;\r
+        }\r
+\r
+        // If the app path is provided, we're generating a cookie name rather than a field name, and the cookie names should\r
+        // be unique so that a development server cookie and an IIS cookie - both running on localhost - don't stomp on\r
+        // each other.\r
+        internal static string GetAntiForgeryTokenName(string appPath) {\r
+            if (String.IsNullOrEmpty(appPath)) {\r
+                return AntiForgeryTokenFieldName;\r
+            }\r
+            else {\r
+                return AntiForgeryTokenFieldName + "_" + Base64EncodeForCookieName(appPath);\r
+            }\r
+        }\r
+\r
+        internal static string GetUsername(IPrincipal user) {\r
+            if (user != null) {\r
+                IIdentity identity = user.Identity;\r
+                if (identity != null && identity.IsAuthenticated) {\r
+                    return identity.Name;\r
+                }\r
+            }\r
+\r
+            return String.Empty;\r
+        }\r
+\r
+        public static AntiForgeryData NewToken() {\r
+            string tokenString = GenerateRandomTokenString();\r
+            return new AntiForgeryData() {\r
+                Value = tokenString\r
+            };\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AntiForgeryDataSerializer.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AntiForgeryDataSerializer.cs
new file mode 100644 (file)
index 0000000..cb06831
--- /dev/null
@@ -0,0 +1,128 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.IO;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.UI;\r
+\r
+    internal class AntiForgeryDataSerializer {\r
+\r
+        private IStateFormatter _formatter;\r
+\r
+        protected internal IStateFormatter Formatter {\r
+            get {\r
+                if (_formatter == null) {\r
+                    _formatter = FormatterGenerator.GetFormatter();\r
+                }\r
+                return _formatter;\r
+            }\r
+            set {\r
+                _formatter = value;\r
+            }\r
+        }\r
+\r
+        private static HttpAntiForgeryException CreateValidationException(Exception innerException) {\r
+            return new HttpAntiForgeryException(MvcResources.AntiForgeryToken_ValidationFailed, innerException);\r
+        }\r
+\r
+        public virtual AntiForgeryData Deserialize(string serializedToken) {\r
+            if (String.IsNullOrEmpty(serializedToken)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "serializedToken");\r
+            }\r
+\r
+            // call property getter outside try { } block so that exceptions bubble up for debugging\r
+            IStateFormatter formatter = Formatter;\r
+\r
+            try {\r
+                object[] deserializedObj = (object[])formatter.Deserialize(serializedToken);\r
+                return new AntiForgeryData() {\r
+                    Salt = (string)deserializedObj[0],\r
+                    Value = (string)deserializedObj[1],\r
+                    CreationDate = (DateTime)deserializedObj[2],\r
+                    Username = (string)deserializedObj[3]\r
+                };\r
+            }\r
+            catch (Exception ex) {\r
+                throw CreateValidationException(ex);\r
+            }\r
+        }\r
+\r
+        public virtual string Serialize(AntiForgeryData token) {\r
+            if (token == null) {\r
+                throw new ArgumentNullException("token");\r
+            }\r
+\r
+            object[] objToSerialize = new object[] {\r
+                token.Salt,\r
+                token.Value,\r
+                token.CreationDate,\r
+                token.Username\r
+            };\r
+\r
+            string serializedValue = Formatter.Serialize(objToSerialize);\r
+            return serializedValue;\r
+        }\r
+\r
+        // See http://www.yoda.arachsys.com/csharp/singleton.html (fifth version - fully lazy) for the singleton pattern\r
+        // used here. We need to defer the call to TokenPersister.CreateFormatterGenerator() until we're actually\r
+        // servicing a request, else HttpContext.Current might be invalid in TokenPersister.CreateFormatterGenerator().\r
+        private static class FormatterGenerator {\r
+\r
+            public static readonly Func<IStateFormatter> GetFormatter = TokenPersister.CreateFormatterGenerator();\r
+\r
+            [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline",\r
+                Justification = "This type must not be marked 'beforefieldinit'.")]\r
+            static FormatterGenerator() {\r
+            }\r
+\r
+            // This type is very difficult to unit-test because Page.ProcessRequest() requires mocking\r
+            // much of the hosting environment. For now, we can perform functional tests of this feature.\r
+            private sealed class TokenPersister : PageStatePersister {\r
+                private TokenPersister(Page page)\r
+                    : base(page) {\r
+                }\r
+\r
+                public static Func<IStateFormatter> CreateFormatterGenerator() {\r
+                    // This code instantiates a page and tricks it into thinking that it's servicing\r
+                    // a postback scenario with encrypted ViewState, which is required to make the\r
+                    // StateFormatter properly decrypt data. Specifically, this code sets the\r
+                    // internal Page.ContainsEncryptedViewState flag.\r
+                    TextWriter writer = TextWriter.Null;\r
+                    HttpResponse response = new HttpResponse(writer);\r
+                    HttpRequest request = new HttpRequest("DummyFile.aspx", HttpContext.Current.Request.Url.ToString(), "__EVENTTARGET=true&__VIEWSTATEENCRYPTED=true");\r
+                    HttpContext context = new HttpContext(request, response);\r
+\r
+                    Page page = new Page() {\r
+                        EnableViewStateMac = true,\r
+                        ViewStateEncryptionMode = ViewStateEncryptionMode.Always\r
+                    };\r
+                    page.ProcessRequest(context);\r
+\r
+                    return () => new TokenPersister(page).StateFormatter;\r
+                }\r
+\r
+                public override void Load() {\r
+                    throw new NotImplementedException();\r
+                }\r
+\r
+                public override void Save() {\r
+                    throw new NotImplementedException();\r
+                }\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AreaHelpers.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AreaHelpers.cs
new file mode 100644 (file)
index 0000000..723f834
--- /dev/null
@@ -0,0 +1,43 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web.Routing;\r
+\r
+    internal static class AreaHelpers {\r
+\r
+        public static string GetAreaName(RouteBase route) {\r
+            IRouteWithArea routeWithArea = route as IRouteWithArea;\r
+            if (routeWithArea != null) {\r
+                return routeWithArea.Area;\r
+            }\r
+\r
+            Route castRoute = route as Route;\r
+            if (castRoute != null && castRoute.DataTokens != null) {\r
+                return castRoute.DataTokens["area"] as string;\r
+            }\r
+\r
+            return null;\r
+        }\r
+\r
+        public static string GetAreaName(RouteData routeData) {\r
+            object area;\r
+            if (routeData.DataTokens.TryGetValue("area", out area)) {\r
+                return area as string;\r
+            }\r
+\r
+            return GetAreaName(routeData.Route);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AreaRegistration.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AreaRegistration.cs
new file mode 100644 (file)
index 0000000..5725ddf
--- /dev/null
@@ -0,0 +1,62 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Web.Routing;\r
+\r
+    public abstract class AreaRegistration {\r
+\r
+        private const string _typeCacheName = "MVC-AreaRegistrationTypeCache.xml";\r
+\r
+        public abstract string AreaName {\r
+            get;\r
+        }\r
+\r
+        internal void CreateContextAndRegister(RouteCollection routes, object state) {\r
+            AreaRegistrationContext context = new AreaRegistrationContext(AreaName, routes, state);\r
+\r
+            string thisNamespace = GetType().Namespace;\r
+            if (thisNamespace != null) {\r
+                context.Namespaces.Add(thisNamespace + ".*");\r
+            }\r
+\r
+            RegisterArea(context);\r
+        }\r
+\r
+        private static bool IsAreaRegistrationType(Type type) {\r
+            return\r
+                typeof(AreaRegistration).IsAssignableFrom(type) &&\r
+                type.GetConstructor(Type.EmptyTypes) != null;\r
+        }\r
+\r
+        public static void RegisterAllAreas() {\r
+            RegisterAllAreas(null);\r
+        }\r
+\r
+        public static void RegisterAllAreas(object state) {\r
+            RegisterAllAreas(RouteTable.Routes, new BuildManagerWrapper(), state);\r
+        }\r
+\r
+        internal static void RegisterAllAreas(RouteCollection routes, IBuildManager buildManager, object state) {\r
+            List<Type> areaRegistrationTypes = TypeCacheUtil.GetFilteredTypesFromAssemblies(_typeCacheName, IsAreaRegistrationType, buildManager);\r
+            foreach (Type areaRegistrationType in areaRegistrationTypes) {\r
+                AreaRegistration registration = (AreaRegistration)Activator.CreateInstance(areaRegistrationType);\r
+                registration.CreateContextAndRegister(routes, state);\r
+            }\r
+        }\r
+\r
+        public abstract void RegisterArea(AreaRegistrationContext context);\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AreaRegistrationContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AreaRegistrationContext.cs
new file mode 100644 (file)
index 0000000..869c1ac
--- /dev/null
@@ -0,0 +1,111 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq;\r
+    using System.Web.Routing;\r
+\r
+    public class AreaRegistrationContext {\r
+\r
+        private readonly HashSet<string> _namespaces = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\r
+\r
+        public AreaRegistrationContext(string areaName, RouteCollection routes)\r
+            : this(areaName, routes, null) {\r
+        }\r
+\r
+        public AreaRegistrationContext(string areaName, RouteCollection routes, object state) {\r
+            if (String.IsNullOrEmpty(areaName)) {\r
+                throw Error.ParameterCannotBeNullOrEmpty("areaName");\r
+            }\r
+            if (routes == null) {\r
+                throw new ArgumentNullException("routes");\r
+            }\r
+\r
+            AreaName = areaName;\r
+            Routes = routes;\r
+            State = state;\r
+        }\r
+\r
+        public string AreaName {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ICollection<string> Namespaces {\r
+            get {\r
+                return _namespaces;\r
+            }\r
+        }\r
+\r
+        public RouteCollection Routes {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public object State {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public Route MapRoute(string name, string url) {\r
+            return MapRoute(name, url, (object)null /* defaults */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public Route MapRoute(string name, string url, object defaults) {\r
+            return MapRoute(name, url, defaults, (object)null /* constraints */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public Route MapRoute(string name, string url, object defaults, object constraints) {\r
+            return MapRoute(name, url, defaults, constraints, null /* namespaces */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public Route MapRoute(string name, string url, string[] namespaces) {\r
+            return MapRoute(name, url, (object)null /* defaults */, namespaces);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public Route MapRoute(string name, string url, object defaults, string[] namespaces) {\r
+            return MapRoute(name, url, defaults, null /* constraints */, namespaces);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public Route MapRoute(string name, string url, object defaults, object constraints, string[] namespaces) {\r
+            if (namespaces == null && Namespaces != null) {\r
+                namespaces = Namespaces.ToArray();\r
+            }\r
+\r
+            Route route = Routes.MapRoute(name, url, defaults, constraints, namespaces);\r
+            route.DataTokens["area"] = AreaName;\r
+\r
+            // disabling the namespace lookup fallback mechanism keeps this areas from accidentally picking up\r
+            // controllers belonging to other areas\r
+            bool useNamespaceFallback = (namespaces == null || namespaces.Length == 0);\r
+            route.DataTokens["UseNamespaceFallback"] = useNamespaceFallback;\r
+\r
+            return route;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AssociatedMetadataProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AssociatedMetadataProvider.cs
new file mode 100644 (file)
index 0000000..bd9248f
--- /dev/null
@@ -0,0 +1,95 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel;\r
+    using System.ComponentModel.DataAnnotations;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    // This class provides a good implementation of ModelMetadataProvider for people who will be\r
+    // using traditional classes with properties. It uses the buddy class support from\r
+    // DataAnnotations, and consolidates the three operations down to a single override\r
+    // for reading the attribute values and creating the metadata class.\r
+    public abstract class AssociatedMetadataProvider : ModelMetadataProvider {\r
+        protected abstract ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName);\r
+\r
+        protected virtual IEnumerable<Attribute> FilterAttributes(Type containerType, PropertyDescriptor propertyDescriptor, IEnumerable<Attribute> attributes) {\r
+            if (typeof(ViewPage).IsAssignableFrom(containerType) || typeof(ViewUserControl).IsAssignableFrom(containerType)) {\r
+                return attributes.Where(a => !(a is ReadOnlyAttribute));\r
+            }\r
+\r
+            return attributes;\r
+        }\r
+\r
+        public override IEnumerable<ModelMetadata> GetMetadataForProperties(object container, Type containerType) {\r
+            if (containerType == null) {\r
+                throw new ArgumentNullException("containerType");\r
+            }\r
+\r
+            return GetMetadataForPropertiesImpl(container, containerType);\r
+        }\r
+\r
+        private IEnumerable<ModelMetadata> GetMetadataForPropertiesImpl(object container, Type containerType) {\r
+            foreach (PropertyDescriptor property in GetTypeDescriptor(containerType).GetProperties()) {\r
+                Func<object> modelAccessor = container == null ? null : GetPropertyValueAccessor(container, property);\r
+                yield return GetMetadataForProperty(modelAccessor, containerType, property);\r
+            }\r
+        }\r
+\r
+        public override ModelMetadata GetMetadataForProperty(Func<object> modelAccessor, Type containerType, string propertyName) {\r
+            if (containerType == null) {\r
+                throw new ArgumentNullException("containerType");\r
+            }\r
+            if (String.IsNullOrEmpty(propertyName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "propertyName");\r
+            }\r
+\r
+            ICustomTypeDescriptor typeDescriptor = GetTypeDescriptor(containerType);\r
+            PropertyDescriptor property = typeDescriptor.GetProperties().Find(propertyName, true);\r
+            if (property == null) {\r
+                throw new ArgumentException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentCulture,\r
+                        MvcResources.Common_PropertyNotFound,\r
+                        containerType.FullName, propertyName));\r
+            }\r
+\r
+            return GetMetadataForProperty(modelAccessor, containerType, property);\r
+        }\r
+\r
+        protected virtual ModelMetadata GetMetadataForProperty(Func<object> modelAccessor, Type containerType, PropertyDescriptor propertyDescriptor) {\r
+            IEnumerable<Attribute> attributes = FilterAttributes(containerType, propertyDescriptor, propertyDescriptor.Attributes.Cast<Attribute>());\r
+            return CreateMetadata(attributes, containerType, modelAccessor, propertyDescriptor.PropertyType, propertyDescriptor.Name);\r
+        }\r
+\r
+        public override ModelMetadata GetMetadataForType(Func<object> modelAccessor, Type modelType) {\r
+            if (modelType == null) {\r
+                throw new ArgumentNullException("modelType");\r
+            }\r
+\r
+            IEnumerable<Attribute> attributes = GetTypeDescriptor(modelType).GetAttributes().Cast<Attribute>();\r
+            return CreateMetadata(attributes, null /* containerType */, modelAccessor, modelType, null /* propertyName */);\r
+        }\r
+\r
+        private static Func<object> GetPropertyValueAccessor(object container, PropertyDescriptor property) {\r
+            return () => property.GetValue(container);\r
+        }\r
+\r
+        protected virtual ICustomTypeDescriptor GetTypeDescriptor(Type type) {\r
+            return TypeDescriptorHelper.Get(type);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AssociatedValidatorProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AssociatedValidatorProvider.cs
new file mode 100644 (file)
index 0000000..f7b280a
--- /dev/null
@@ -0,0 +1,63 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel;\r
+    using System.ComponentModel.DataAnnotations;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public abstract class AssociatedValidatorProvider : ModelValidatorProvider {\r
+        protected virtual ICustomTypeDescriptor GetTypeDescriptor(Type type) {\r
+            return TypeDescriptorHelper.Get(type);\r
+        }\r
+\r
+        public override sealed IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context) {\r
+            if (metadata == null) {\r
+                throw new ArgumentNullException("metadata");\r
+            }\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+\r
+            if (metadata.ContainerType != null && !String.IsNullOrEmpty(metadata.PropertyName)) {\r
+                return GetValidatorsForProperty(metadata, context);\r
+            }\r
+\r
+            return GetValidatorsForType(metadata, context);\r
+        }\r
+\r
+        protected abstract IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context, IEnumerable<Attribute> attributes);\r
+\r
+        private IEnumerable<ModelValidator> GetValidatorsForProperty(ModelMetadata metadata, ControllerContext context) {\r
+            ICustomTypeDescriptor typeDescriptor = GetTypeDescriptor(metadata.ContainerType);\r
+            PropertyDescriptor property = typeDescriptor.GetProperties().Find(metadata.PropertyName, true);\r
+            if (property == null) {\r
+                throw new ArgumentException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentCulture,\r
+                        MvcResources.Common_PropertyNotFound,\r
+                        metadata.ContainerType.FullName, metadata.PropertyName),\r
+                    "metadata");\r
+            }\r
+\r
+            return GetValidators(metadata, context, property.Attributes.OfType<Attribute>());\r
+        }\r
+\r
+        private IEnumerable<ModelValidator> GetValidatorsForType(ModelMetadata metadata, ControllerContext context) {\r
+            return GetValidators(metadata, context, GetTypeDescriptor(metadata.ModelType).GetAttributes().Cast<Attribute>());\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/ActionDescriptorCreator.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/ActionDescriptorCreator.cs
new file mode 100644 (file)
index 0000000..19e1179
--- /dev/null
@@ -0,0 +1,18 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+\r
+    internal delegate ActionDescriptor ActionDescriptorCreator(string actionName, ControllerDescriptor controllerDescriptor);\r
+\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncActionDescriptor.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncActionDescriptor.cs
new file mode 100644 (file)
index 0000000..2b9ff2f
--- /dev/null
@@ -0,0 +1,40 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Collections.Generic;\r
+\r
+    public abstract class AsyncActionDescriptor : ActionDescriptor {\r
+\r
+        public abstract IAsyncResult BeginExecute(ControllerContext controllerContext, IDictionary<string, object> parameters, AsyncCallback callback, object state);\r
+\r
+        public abstract object EndExecute(IAsyncResult asyncResult);\r
+\r
+        public override object Execute(ControllerContext controllerContext, IDictionary<string, object> parameters) {\r
+            // execute an asynchronous task synchronously\r
+            IAsyncResult asyncResult = BeginExecute(controllerContext, parameters, null, null);\r
+            AsyncUtil.WaitForAsyncResultCompletion(asyncResult, controllerContext.HttpContext.ApplicationInstance); // blocks\r
+            return EndExecute(asyncResult);\r
+        }\r
+\r
+        internal static AsyncManager GetAsyncManager(ControllerBase controller) {\r
+            IAsyncManagerContainer helperContainer = controller as IAsyncManagerContainer;\r
+            if (helperContainer == null) {\r
+                throw Error.AsyncCommon_ControllerMustImplementIAsyncManagerContainer(controller.GetType());\r
+            }\r
+\r
+            return helperContainer.AsyncManager;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncActionMethodSelector.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncActionMethodSelector.cs
new file mode 100644 (file)
index 0000000..efd00b1
--- /dev/null
@@ -0,0 +1,206 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Text;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    internal sealed class AsyncActionMethodSelector {\r
+\r
+        public AsyncActionMethodSelector(Type controllerType) {\r
+            ControllerType = controllerType;\r
+            PopulateLookupTables();\r
+        }\r
+\r
+        public Type ControllerType {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public MethodInfo[] AliasedMethods {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ILookup<string, MethodInfo> NonAliasedMethods {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        private AmbiguousMatchException CreateAmbiguousActionMatchException(IEnumerable<MethodInfo> ambiguousMethods, string actionName) {\r
+            string ambiguityList = CreateAmbiguousMatchList(ambiguousMethods);\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ActionMethodSelector_AmbiguousMatch,\r
+                actionName, ControllerType.Name, ambiguityList);\r
+            return new AmbiguousMatchException(message);\r
+        }\r
+\r
+        private AmbiguousMatchException CreateAmbiguousMethodMatchException(IEnumerable<MethodInfo> ambiguousMethods, string methodName) {\r
+            string ambiguityList = CreateAmbiguousMatchList(ambiguousMethods);\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.AsyncActionMethodSelector_AmbiguousMethodMatch,\r
+                methodName, ControllerType.Name, ambiguityList);\r
+            return new AmbiguousMatchException(message);\r
+        }\r
+\r
+        private static string CreateAmbiguousMatchList(IEnumerable<MethodInfo> ambiguousMethods) {\r
+            StringBuilder exceptionMessageBuilder = new StringBuilder();\r
+            foreach (MethodInfo methodInfo in ambiguousMethods) {\r
+                exceptionMessageBuilder.AppendLine();\r
+                exceptionMessageBuilder.AppendFormat(CultureInfo.CurrentUICulture, MvcResources.ActionMethodSelector_AmbiguousMatchType, methodInfo, methodInfo.DeclaringType.FullName);\r
+            }\r
+\r
+            return exceptionMessageBuilder.ToString();\r
+        }\r
+\r
+        public ActionDescriptorCreator FindAction(ControllerContext controllerContext, string actionName) {\r
+            List<MethodInfo> methodsMatchingName = GetMatchingAliasedMethods(controllerContext, actionName);\r
+            methodsMatchingName.AddRange(NonAliasedMethods[actionName]);\r
+            List<MethodInfo> finalMethods = RunSelectionFilters(controllerContext, methodsMatchingName);\r
+\r
+            switch (finalMethods.Count) {\r
+                case 0:\r
+                    return null;\r
+\r
+                case 1:\r
+                    MethodInfo entryMethod = finalMethods[0];\r
+                    return GetActionDescriptorDelegate(entryMethod);\r
+\r
+                default:\r
+                    throw CreateAmbiguousActionMatchException(finalMethods, actionName);\r
+            }\r
+        }\r
+\r
+        private ActionDescriptorCreator GetActionDescriptorDelegate(MethodInfo entryMethod) {\r
+            // Is this the FooAsync() / FooCompleted() pattern?\r
+            if (IsAsyncSuffixedMethod(entryMethod)) {\r
+                string completionMethodName = entryMethod.Name.Substring(0, entryMethod.Name.Length - "Async".Length) + "Completed";\r
+                MethodInfo completionMethod = GetMethodByName(completionMethodName);\r
+                if (completionMethod != null) {\r
+                    return (actionName, controllerDescriptor) => new ReflectedAsyncActionDescriptor(entryMethod, completionMethod, actionName, controllerDescriptor);\r
+                }\r
+                else {\r
+                    throw Error.AsyncActionMethodSelector_CouldNotFindMethod(completionMethodName, ControllerType);\r
+                }\r
+            }\r
+\r
+            // Fallback to synchronous method\r
+            return (actionName, controllerDescriptor) => new ReflectedActionDescriptor(entryMethod, actionName, controllerDescriptor);\r
+        }\r
+\r
+        private static string GetCanonicalMethodName(MethodInfo methodInfo) {\r
+            string methodName = methodInfo.Name;\r
+            return (IsAsyncSuffixedMethod(methodInfo))\r
+                ? methodName.Substring(0, methodName.Length - "Async".Length)\r
+                : methodName;\r
+        }\r
+\r
+        internal List<MethodInfo> GetMatchingAliasedMethods(ControllerContext controllerContext, string actionName) {\r
+            // find all aliased methods which are opting in to this request\r
+            // to opt in, all attributes defined on the method must return true\r
+\r
+            var methods = from methodInfo in AliasedMethods\r
+                          let attrs = (ActionNameSelectorAttribute[])methodInfo.GetCustomAttributes(typeof(ActionNameSelectorAttribute), true /* inherit */)\r
+                          where attrs.All(attr => attr.IsValidName(controllerContext, actionName, methodInfo))\r
+                          select methodInfo;\r
+            return methods.ToList();\r
+        }\r
+\r
+        private static bool IsAsyncSuffixedMethod(MethodInfo methodInfo) {\r
+            return methodInfo.Name.EndsWith("Async", StringComparison.OrdinalIgnoreCase);\r
+        }\r
+\r
+        private static bool IsCompletedSuffixedMethod(MethodInfo methodInfo) {\r
+            return methodInfo.Name.EndsWith("Completed", StringComparison.OrdinalIgnoreCase);\r
+        }\r
+\r
+        private static bool IsMethodDecoratedWithAliasingAttribute(MethodInfo methodInfo) {\r
+            return methodInfo.IsDefined(typeof(ActionNameSelectorAttribute), true /* inherit */);\r
+        }\r
+\r
+        private MethodInfo GetMethodByName(string methodName) {\r
+            List<MethodInfo> methods = (from MethodInfo methodInfo in ControllerType.GetMember(methodName, MemberTypes.Method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.IgnoreCase)\r
+                                        where IsValidActionMethod(methodInfo, false /* stripInfrastructureMethods */)\r
+                                        select methodInfo).ToList();\r
+\r
+            switch (methods.Count) {\r
+                case 0:\r
+                    return null;\r
+\r
+                case 1:\r
+                    return methods[0];\r
+\r
+                default:\r
+                    throw CreateAmbiguousMethodMatchException(methods, methodName);\r
+            }\r
+        }\r
+\r
+        private static bool IsValidActionMethod(MethodInfo methodInfo) {\r
+            return IsValidActionMethod(methodInfo, true /* stripInfrastructureMethods */);\r
+        }\r
+\r
+        private static bool IsValidActionMethod(MethodInfo methodInfo, bool stripInfrastructureMethods) {\r
+            if (methodInfo.IsSpecialName) {\r
+                // not a normal method, e.g. a constructor or an event\r
+                return false;\r
+            }\r
+\r
+            if (methodInfo.GetBaseDefinition().DeclaringType.IsAssignableFrom(typeof(AsyncController))) {\r
+                // is a method on Object, ControllerBase, Controller, or AsyncController\r
+                return false;\r
+            };\r
+\r
+            if (stripInfrastructureMethods) {\r
+                if (IsCompletedSuffixedMethod(methodInfo)) {\r
+                    // do not match FooCompleted() methods, as these are infrastructure methods\r
+                    return false;\r
+                }\r
+            }\r
+\r
+            return true;\r
+        }\r
+\r
+        private void PopulateLookupTables() {\r
+            MethodInfo[] allMethods = ControllerType.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public);\r
+            MethodInfo[] actionMethods = Array.FindAll(allMethods, IsValidActionMethod);\r
+\r
+            AliasedMethods = Array.FindAll(actionMethods, IsMethodDecoratedWithAliasingAttribute);\r
+            NonAliasedMethods = actionMethods.Except(AliasedMethods).ToLookup(GetCanonicalMethodName, StringComparer.OrdinalIgnoreCase);\r
+        }\r
+\r
+        private static List<MethodInfo> RunSelectionFilters(ControllerContext controllerContext, List<MethodInfo> methodInfos) {\r
+            // remove all methods which are opting out of this request\r
+            // to opt out, at least one attribute defined on the method must return false\r
+\r
+            List<MethodInfo> matchesWithSelectionAttributes = new List<MethodInfo>();\r
+            List<MethodInfo> matchesWithoutSelectionAttributes = new List<MethodInfo>();\r
+\r
+            foreach (MethodInfo methodInfo in methodInfos) {\r
+                ActionMethodSelectorAttribute[] attrs = (ActionMethodSelectorAttribute[])methodInfo.GetCustomAttributes(typeof(ActionMethodSelectorAttribute), true /* inherit */);\r
+                if (attrs.Length == 0) {\r
+                    matchesWithoutSelectionAttributes.Add(methodInfo);\r
+                }\r
+                else if (attrs.All(attr => attr.IsValidForRequest(controllerContext, methodInfo))) {\r
+                    matchesWithSelectionAttributes.Add(methodInfo);\r
+                }\r
+            }\r
+\r
+            // if a matching action method had a selection attribute, consider it more specific than a matching action method\r
+            // without a selection attribute\r
+            return (matchesWithSelectionAttributes.Count > 0) ? matchesWithSelectionAttributes : matchesWithoutSelectionAttributes;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncControllerActionInvoker.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncControllerActionInvoker.cs
new file mode 100644 (file)
index 0000000..cf1349e
--- /dev/null
@@ -0,0 +1,282 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+    using System.Threading;\r
+\r
+    public class AsyncControllerActionInvoker : ControllerActionInvoker, IAsyncActionInvoker {\r
+\r
+        private static readonly object _invokeActionTag = new object();\r
+        private static readonly object _invokeActionMethodTag = new object();\r
+        private static readonly object _invokeActionMethodWithFiltersTag = new object();\r
+\r
+        public virtual IAsyncResult BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (String.IsNullOrEmpty(actionName)) {\r
+                throw Error.ParameterCannotBeNullOrEmpty("actionName");\r
+            }\r
+\r
+            ControllerDescriptor controllerDescriptor = GetControllerDescriptor(controllerContext);\r
+            ActionDescriptor actionDescriptor = controllerDescriptor.FindAction(controllerContext, actionName);\r
+            if (actionDescriptor != null) {\r
+                FilterInfo filterInfo = GetFilters(controllerContext, actionDescriptor);\r
+                Action continuation = null;\r
+\r
+                BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) {\r
+                    try {\r
+                        AuthorizationContext authContext = InvokeAuthorizationFilters(controllerContext, filterInfo.AuthorizationFilters, actionDescriptor);\r
+                        if (authContext.Result != null) {\r
+                            // the auth filter signaled that we should let it short-circuit the request\r
+                            continuation = () => InvokeActionResult(controllerContext, authContext.Result);\r
+                        }\r
+                        else {\r
+                            if (controllerContext.Controller.ValidateRequest) {\r
+                                ValidateRequest(controllerContext);\r
+                            }\r
+\r
+                            IDictionary<string, object> parameters = GetParameterValues(controllerContext, actionDescriptor);\r
+                            IAsyncResult asyncResult = BeginInvokeActionMethodWithFilters(controllerContext, filterInfo.ActionFilters, actionDescriptor, parameters, asyncCallback, asyncState);\r
+                            continuation = () => {\r
+                                ActionExecutedContext postActionContext = EndInvokeActionMethodWithFilters(asyncResult);\r
+                                InvokeActionResultWithFilters(controllerContext, filterInfo.ResultFilters, postActionContext.Result);\r
+                            };\r
+                            return asyncResult;\r
+                        }\r
+                    }\r
+                    catch (ThreadAbortException) {\r
+                        // This type of exception occurs as a result of Response.Redirect(), but we special-case so that\r
+                        // the filters don't see this as an error.\r
+                        throw;\r
+                    }\r
+                    catch (Exception ex) {\r
+                        // something blew up, so execute the exception filters\r
+                        ExceptionContext exceptionContext = InvokeExceptionFilters(controllerContext, filterInfo.ExceptionFilters, ex);\r
+                        if (!exceptionContext.ExceptionHandled) {\r
+                            throw;\r
+                        }\r
+\r
+                        continuation = () => InvokeActionResult(controllerContext, exceptionContext.Result);\r
+                    }\r
+\r
+                    return BeginInvokeAction_MakeSynchronousAsyncResult(asyncCallback, asyncState);\r
+                };\r
+\r
+                EndInvokeDelegate<bool> endDelegate = delegate(IAsyncResult asyncResult) {\r
+                    try {\r
+                        continuation();\r
+                    }\r
+                    catch (ThreadAbortException) {\r
+                        // This type of exception occurs as a result of Response.Redirect(), but we special-case so that\r
+                        // the filters don't see this as an error.\r
+                        throw;\r
+                    }\r
+                    catch (Exception ex) {\r
+                        // something blew up, so execute the exception filters\r
+                        ExceptionContext exceptionContext = InvokeExceptionFilters(controllerContext, filterInfo.ExceptionFilters, ex);\r
+                        if (!exceptionContext.ExceptionHandled) {\r
+                            throw;\r
+                        }\r
+                        InvokeActionResult(controllerContext, exceptionContext.Result);\r
+                    }\r
+\r
+                    return true;\r
+                };\r
+\r
+                return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _invokeActionTag);\r
+            }\r
+            else {\r
+                // Notify the controller that no action was found.\r
+                return BeginInvokeAction_ActionNotFound(callback, state);\r
+            }\r
+        }\r
+\r
+        private static IAsyncResult BeginInvokeAction_ActionNotFound(AsyncCallback callback, object state) {\r
+            BeginInvokeDelegate beginDelegate = BeginInvokeAction_MakeSynchronousAsyncResult;\r
+\r
+            EndInvokeDelegate<bool> endDelegate = delegate(IAsyncResult asyncResult) {\r
+                return false;\r
+            };\r
+\r
+            return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _invokeActionTag);\r
+        }\r
+\r
+        private static IAsyncResult BeginInvokeAction_MakeSynchronousAsyncResult(AsyncCallback callback, object state) {\r
+            SimpleAsyncResult asyncResult = new SimpleAsyncResult(state);\r
+            asyncResult.MarkCompleted(true /* completedSynchronously */, callback);\r
+            return asyncResult;\r
+        }\r
+\r
+        protected internal virtual IAsyncResult BeginInvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<string, object> parameters, AsyncCallback callback, object state) {\r
+            AsyncActionDescriptor asyncActionDescriptor = actionDescriptor as AsyncActionDescriptor;\r
+            if (asyncActionDescriptor != null) {\r
+                return BeginInvokeAsynchronousActionMethod(controllerContext, asyncActionDescriptor, parameters, callback, state);\r
+            }\r
+            else {\r
+                return BeginInvokeSynchronousActionMethod(controllerContext, actionDescriptor, parameters, callback, state);\r
+            }\r
+        }\r
+\r
+        protected internal virtual IAsyncResult BeginInvokeActionMethodWithFilters(ControllerContext controllerContext, IList<IActionFilter> filters, ActionDescriptor actionDescriptor, IDictionary<string, object> parameters, AsyncCallback callback, object state) {\r
+            Func<ActionExecutedContext> endContinuation = null;\r
+\r
+            BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) {\r
+                ActionExecutingContext preContext = new ActionExecutingContext(controllerContext, actionDescriptor, parameters);\r
+                IAsyncResult innerAsyncResult = null;\r
+\r
+                Func<Func<ActionExecutedContext>> beginContinuation = () => {\r
+                    innerAsyncResult = BeginInvokeActionMethod(controllerContext, actionDescriptor, parameters, asyncCallback, asyncState);\r
+                    return () =>\r
+                        new ActionExecutedContext(controllerContext, actionDescriptor, false /* canceled */, null /* exception */) {\r
+                            Result = EndInvokeActionMethod(innerAsyncResult)\r
+                        };\r
+                };\r
+\r
+                // need to reverse the filter list because the continuations are built up backward\r
+                Func<Func<ActionExecutedContext>> thunk = filters.Reverse().Aggregate(beginContinuation,\r
+                    (next, filter) => () => InvokeActionMethodFilterAsynchronously(filter, preContext, next));\r
+                endContinuation = thunk();\r
+\r
+                if (innerAsyncResult != null) {\r
+                    // we're just waiting for the inner result to complete\r
+                    return innerAsyncResult;\r
+                }\r
+                else {\r
+                    // something was short-circuited and the action was not called, so this was a synchronous operation\r
+                    SimpleAsyncResult newAsyncResult = new SimpleAsyncResult(asyncState);\r
+                    newAsyncResult.MarkCompleted(true /* completedSynchronously */, asyncCallback);\r
+                    return newAsyncResult;\r
+                }\r
+            };\r
+\r
+            EndInvokeDelegate<ActionExecutedContext> endDelegate = delegate(IAsyncResult asyncResult) {\r
+                return endContinuation();\r
+            };\r
+\r
+            return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _invokeActionMethodWithFiltersTag);\r
+        }\r
+\r
+        private IAsyncResult BeginInvokeAsynchronousActionMethod(ControllerContext controllerContext, AsyncActionDescriptor actionDescriptor, IDictionary<string, object> parameters, AsyncCallback callback, object state) {\r
+            BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) {\r
+                return actionDescriptor.BeginExecute(controllerContext, parameters, asyncCallback, asyncState);\r
+            };\r
+\r
+            EndInvokeDelegate<ActionResult> endDelegate = delegate(IAsyncResult asyncResult) {\r
+                object returnValue = actionDescriptor.EndExecute(asyncResult);\r
+                ActionResult result = CreateActionResult(controllerContext, actionDescriptor, returnValue);\r
+                return result;\r
+            };\r
+\r
+            return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _invokeActionMethodTag);\r
+        }\r
+\r
+        private IAsyncResult BeginInvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<string, object> parameters, AsyncCallback callback, object state) {\r
+            return AsyncResultWrapper.BeginSynchronous(callback, state,\r
+                () => InvokeSynchronousActionMethod(controllerContext, actionDescriptor, parameters),\r
+                _invokeActionMethodTag);\r
+        }\r
+\r
+        public virtual bool EndInvokeAction(IAsyncResult asyncResult) {\r
+            return AsyncResultWrapper.End<bool>(asyncResult, _invokeActionTag);\r
+        }\r
+\r
+        protected internal virtual ActionResult EndInvokeActionMethod(IAsyncResult asyncResult) {\r
+            return AsyncResultWrapper.End<ActionResult>(asyncResult, _invokeActionMethodTag);\r
+        }\r
+\r
+        protected internal virtual ActionExecutedContext EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) {\r
+            return AsyncResultWrapper.End<ActionExecutedContext>(asyncResult, _invokeActionMethodWithFiltersTag);\r
+        }\r
+\r
+        protected override ControllerDescriptor GetControllerDescriptor(ControllerContext controllerContext) {\r
+            Type controllerType = controllerContext.Controller.GetType();\r
+            ControllerDescriptor controllerDescriptor = DescriptorCache.GetDescriptor(controllerType, () => new ReflectedAsyncControllerDescriptor(controllerType));\r
+            return controllerDescriptor;\r
+        }\r
+\r
+        internal static Func<ActionExecutedContext> InvokeActionMethodFilterAsynchronously(IActionFilter filter, ActionExecutingContext preContext, Func<Func<ActionExecutedContext>> nextInChain) {\r
+            filter.OnActionExecuting(preContext);\r
+            if (preContext.Result != null) {\r
+                ActionExecutedContext shortCircuitedPostContext = new ActionExecutedContext(preContext, preContext.ActionDescriptor, true /* canceled */, null /* exception */) {\r
+                    Result = preContext.Result\r
+                };\r
+                return () => shortCircuitedPostContext;\r
+            }\r
+\r
+            // There is a nested try / catch block here that contains much the same logic as the outer block.\r
+            // Since an exception can occur on either side of the asynchronous invocation, we need guards on\r
+            // on both sides. In the code below, the second side is represented by the nested delegate. This\r
+            // is really just a parallel of the synchronous ControllerActionInvoker.InvokeActionMethodFilter()\r
+            // method.\r
+\r
+            try {\r
+                Func<ActionExecutedContext> continuation = nextInChain();\r
+\r
+                // add our own continuation, then return the new function\r
+                return () => {\r
+                    ActionExecutedContext postContext;\r
+                    bool wasError = true;\r
+\r
+                    try {\r
+                        postContext = continuation();\r
+                        wasError = false;\r
+                    }\r
+                    catch (ThreadAbortException) {\r
+                        // This type of exception occurs as a result of Response.Redirect(), but we special-case so that\r
+                        // the filters don't see this as an error.\r
+                        postContext = new ActionExecutedContext(preContext, preContext.ActionDescriptor, false /* canceled */, null /* exception */);\r
+                        filter.OnActionExecuted(postContext);\r
+                        throw;\r
+                    }\r
+                    catch (Exception ex) {\r
+                        postContext = new ActionExecutedContext(preContext, preContext.ActionDescriptor, false /* canceled */, ex);\r
+                        filter.OnActionExecuted(postContext);\r
+                        if (!postContext.ExceptionHandled) {\r
+                            throw;\r
+                        }\r
+                    }\r
+                    if (!wasError) {\r
+                        filter.OnActionExecuted(postContext);\r
+                    }\r
+\r
+                    return postContext;\r
+                };\r
+            }\r
+            catch (ThreadAbortException) {\r
+                // This type of exception occurs as a result of Response.Redirect(), but we special-case so that\r
+                // the filters don't see this as an error.\r
+                ActionExecutedContext postContext = new ActionExecutedContext(preContext, preContext.ActionDescriptor, false /* canceled */, null /* exception */);\r
+                filter.OnActionExecuted(postContext);\r
+                throw;\r
+            }\r
+            catch (Exception ex) {\r
+                ActionExecutedContext postContext = new ActionExecutedContext(preContext, preContext.ActionDescriptor, false /* canceled */, ex);\r
+                filter.OnActionExecuted(postContext);\r
+                if (postContext.ExceptionHandled) {\r
+                    return () => postContext;\r
+                }\r
+                else {\r
+                    throw;\r
+                }\r
+            }\r
+        }\r
+\r
+        private ActionResult InvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<string, object> parameters) {\r
+            return base.InvokeActionMethod(controllerContext, actionDescriptor, parameters);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncManager.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncManager.cs
new file mode 100644 (file)
index 0000000..082f460
--- /dev/null
@@ -0,0 +1,79 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Threading;\r
+\r
+    public class AsyncManager {\r
+\r
+        private readonly SynchronizationContext _syncContext;\r
+\r
+        // default timeout is 45 sec\r
+        // from: http://msdn.microsoft.com/en-us/library/system.web.ui.page.asynctimeout.aspx\r
+        private int _timeout = 45 * 1000;\r
+\r
+        public AsyncManager()\r
+            : this(null /* syncContext */) {\r
+        }\r
+\r
+        public AsyncManager(SynchronizationContext syncContext) {\r
+            _syncContext = syncContext ?? SynchronizationContextUtil.GetSynchronizationContext();\r
+\r
+            OutstandingOperations = new OperationCounter();\r
+            OutstandingOperations.Completed += delegate { Finish(); };\r
+\r
+            Parameters = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);\r
+        }\r
+\r
+        public OperationCounter OutstandingOperations {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public IDictionary<string, object> Parameters {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public event EventHandler Finished;\r
+\r
+        // the developer may call this function to signal that all operations are complete instead of\r
+        // waiting for the operation counter to reach zero\r
+        public virtual void Finish() {\r
+            EventHandler handler = Finished;\r
+            if (handler != null) {\r
+                handler(this, EventArgs.Empty);\r
+            }\r
+        }\r
+\r
+        // executes a callback in the current synchronization context, which gives access to HttpContext and related items\r
+        public virtual void Sync(Action action) {\r
+            _syncContext.Sync(action);\r
+        }\r
+\r
+        // measured in milliseconds, Timeout.Infinite means 'no timeout'\r
+        public int Timeout {\r
+            get {\r
+                return _timeout;\r
+            }\r
+            set {\r
+                if (value < -1) {\r
+                    throw Error.AsyncCommon_InvalidTimeout("value");\r
+                }\r
+                _timeout = value;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncResultWrapper.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncResultWrapper.cs
new file mode 100644 (file)
index 0000000..1f42f51
--- /dev/null
@@ -0,0 +1,265 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Threading;\r
+\r
+    // This class is used for the following pattern:\r
+\r
+    // public IAsyncResult BeginInner(..., callback, state);\r
+    // public TInnerResult EndInner(asyncResult);\r
+    // public IAsyncResult BeginOuter(..., callback, state);\r
+    // public TOuterResult EndOuter(asyncResult);\r
+\r
+    // That is, Begin/EndOuter() wrap Begin/EndInner(), potentially with pre- and post-processing.\r
+\r
+    internal static class AsyncResultWrapper {\r
+\r
+        // helper methods\r
+\r
+        private static Func<AsyncVoid> MakeVoidDelegate(Action action) {\r
+            return () => {\r
+                action();\r
+                return default(AsyncVoid);\r
+            };\r
+        }\r
+\r
+        private static EndInvokeDelegate<AsyncVoid> MakeVoidDelegate(EndInvokeDelegate endDelegate) {\r
+            return ar => {\r
+                endDelegate(ar);\r
+                return default(AsyncVoid);\r
+            };\r
+        }\r
+\r
+        // kicks off an asynchronous operation\r
+\r
+        public static IAsyncResult Begin<TResult>(AsyncCallback callback, object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate<TResult> endDelegate) {\r
+            return Begin<TResult>(callback, state, beginDelegate, endDelegate, null /* tag */);\r
+        }\r
+\r
+        public static IAsyncResult Begin<TResult>(AsyncCallback callback, object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate<TResult> endDelegate, object tag) {\r
+            return Begin<TResult>(callback, state, beginDelegate, endDelegate, tag, Timeout.Infinite);\r
+        }\r
+\r
+        public static IAsyncResult Begin<TResult>(AsyncCallback callback, object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate<TResult> endDelegate, object tag, int timeout) {\r
+            WrappedAsyncResult<TResult> asyncResult = new WrappedAsyncResult<TResult>(beginDelegate, endDelegate, tag);\r
+            asyncResult.Begin(callback, state, timeout);\r
+            return asyncResult;\r
+        }\r
+\r
+        public static IAsyncResult Begin(AsyncCallback callback, object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate) {\r
+            return Begin(callback, state, beginDelegate, endDelegate, null /* tag */);\r
+        }\r
+\r
+        public static IAsyncResult Begin(AsyncCallback callback, object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, object tag) {\r
+            return Begin(callback, state, beginDelegate, endDelegate, tag, Timeout.Infinite);\r
+        }\r
+\r
+        public static IAsyncResult Begin(AsyncCallback callback, object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, object tag, int timeout) {\r
+            return Begin<AsyncVoid>(callback, state, beginDelegate, MakeVoidDelegate(endDelegate), tag, timeout);\r
+        }\r
+\r
+        // wraps a synchronous operation in an asynchronous wrapper, but still completes synchronously\r
+\r
+        public static IAsyncResult BeginSynchronous<TResult>(AsyncCallback callback, object state, Func<TResult> func) {\r
+            return BeginSynchronous<TResult>(callback, state, func, null /* tag */);\r
+        }\r
+\r
+        public static IAsyncResult BeginSynchronous<TResult>(AsyncCallback callback, object state, Func<TResult> func, object tag) {\r
+            // Begin() doesn't perform any work on its own and returns immediately.\r
+            BeginInvokeDelegate beginDelegate = (asyncCallback, asyncState) => {\r
+                SimpleAsyncResult innerAsyncResult = new SimpleAsyncResult(asyncState);\r
+                innerAsyncResult.MarkCompleted(true /* completedSynchronously */, asyncCallback);\r
+                return innerAsyncResult;\r
+            };\r
+\r
+            // The End() method blocks.\r
+            EndInvokeDelegate<TResult> endDelegate = _ => {\r
+                return func();\r
+            };\r
+\r
+            WrappedAsyncResult<TResult> asyncResult = new WrappedAsyncResult<TResult>(beginDelegate, endDelegate, tag);\r
+            asyncResult.Begin(callback, state, Timeout.Infinite);\r
+            return asyncResult;\r
+        }\r
+\r
+        public static IAsyncResult BeginSynchronous(AsyncCallback callback, object state, Action action) {\r
+            return BeginSynchronous(callback, state, action, null /* tag */);\r
+        }\r
+\r
+        public static IAsyncResult BeginSynchronous(AsyncCallback callback, object state, Action action, object tag) {\r
+            return BeginSynchronous<AsyncVoid>(callback, state, MakeVoidDelegate(action), tag);\r
+        }\r
+\r
+        // completes an asynchronous operation\r
+\r
+        public static TResult End<TResult>(IAsyncResult asyncResult) {\r
+            return End<TResult>(asyncResult, null /* tag */);\r
+        }\r
+\r
+        public static TResult End<TResult>(IAsyncResult asyncResult, object tag) {\r
+            return WrappedAsyncResult<TResult>.Cast(asyncResult, tag).End();\r
+        }\r
+\r
+        public static void End(IAsyncResult asyncResult) {\r
+            End(asyncResult, null /* tag */);\r
+        }\r
+\r
+        public static void End(IAsyncResult asyncResult, object tag) {\r
+            End<AsyncVoid>(asyncResult, tag);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",\r
+            Justification = "The Timer will be disposed of either when it fires or when the operation completes successfully.")]\r
+        private sealed class WrappedAsyncResult<TResult> : IAsyncResult {\r
+\r
+            private readonly BeginInvokeDelegate _beginDelegate;\r
+            private readonly object _beginDelegateLockObj = new object();\r
+            private readonly EndInvokeDelegate<TResult> _endDelegate;\r
+            private readonly SingleEntryGate _endExecutedGate = new SingleEntryGate(); // prevent End() from being called twice\r
+            private readonly SingleEntryGate _handleCallbackGate = new SingleEntryGate(); // prevent callback from being handled multiple times\r
+            private IAsyncResult _innerAsyncResult;\r
+            private AsyncCallback _originalCallback;\r
+            private readonly object _tag; // prevent an instance of this type from being passed to the wrong End() method\r
+            private volatile bool _timedOut;\r
+            private Timer _timer;\r
+\r
+            public WrappedAsyncResult(BeginInvokeDelegate beginDelegate, EndInvokeDelegate<TResult> endDelegate, object tag) {\r
+                _beginDelegate = beginDelegate;\r
+                _endDelegate = endDelegate;\r
+                _tag = tag;\r
+            }\r
+\r
+            public object AsyncState {\r
+                get {\r
+                    return _innerAsyncResult.AsyncState;\r
+                }\r
+            }\r
+\r
+            public WaitHandle AsyncWaitHandle {\r
+                get {\r
+                    return _innerAsyncResult.AsyncWaitHandle;\r
+                }\r
+            }\r
+\r
+            public bool CompletedSynchronously {\r
+                get {\r
+                    return _innerAsyncResult.CompletedSynchronously;\r
+                }\r
+            }\r
+\r
+            public bool IsCompleted {\r
+                get {\r
+                    return _innerAsyncResult.IsCompleted;\r
+                }\r
+            }\r
+\r
+            // kicks off the process, instantiates a timer if requested\r
+            public void Begin(AsyncCallback callback, object state, int timeout) {\r
+                _originalCallback = callback;\r
+                bool completedSynchronously;\r
+\r
+                // Force the target Begin() operation to complete before the callback can continue,\r
+                // since the target operation might perform post-processing of the data.\r
+                lock (_beginDelegateLockObj) {\r
+                    _innerAsyncResult = _beginDelegate(HandleAsynchronousCompletion, state);\r
+\r
+                    completedSynchronously = _innerAsyncResult.CompletedSynchronously;\r
+                    if (!completedSynchronously) {\r
+                        if (timeout > Timeout.Infinite) {\r
+                            CreateTimer(timeout);\r
+                        }\r
+                    }\r
+                }\r
+\r
+                if (completedSynchronously) {\r
+                    if (callback != null) {\r
+                        callback(this);\r
+                    }\r
+                }\r
+            }\r
+\r
+            public static WrappedAsyncResult<TResult> Cast(IAsyncResult asyncResult, object tag) {\r
+                if (asyncResult == null) {\r
+                    throw new ArgumentNullException("asyncResult");\r
+                }\r
+\r
+                WrappedAsyncResult<TResult> castResult = asyncResult as WrappedAsyncResult<TResult>;\r
+                if (castResult != null && Object.Equals(castResult._tag, tag)) {\r
+                    return castResult;\r
+                }\r
+                else {\r
+                    throw Error.AsyncCommon_InvalidAsyncResult("asyncResult");\r
+                }\r
+            }\r
+\r
+            private void CreateTimer(int timeout) {\r
+                // this method should be called within a lock(_beginDelegateLockObj)\r
+                _timer = new Timer(HandleTimeout, null, timeout, Timeout.Infinite /* disable periodic signaling */);\r
+            }\r
+\r
+            public TResult End() {\r
+                if (!_endExecutedGate.TryEnter()) {\r
+                    throw Error.AsyncCommon_AsyncResultAlreadyConsumed();\r
+                }\r
+\r
+                if (_timedOut) {\r
+                    throw new TimeoutException();\r
+                }\r
+                WaitForBeginToCompleteAndDestroyTimer();\r
+\r
+                return _endDelegate(_innerAsyncResult);\r
+            }\r
+\r
+            private void ExecuteAsynchronousCallback(bool timedOut) {\r
+                WaitForBeginToCompleteAndDestroyTimer();\r
+\r
+                if (_handleCallbackGate.TryEnter()) {\r
+                    _timedOut = timedOut;\r
+                    if (_originalCallback != null) {\r
+                        _originalCallback(this);\r
+                    }\r
+                }\r
+            }\r
+\r
+            private void HandleAsynchronousCompletion(IAsyncResult asyncResult) {\r
+                if (asyncResult.CompletedSynchronously) {\r
+                    // If the operation completed synchronously, the WrappedAsyncResult.Begin() method will handle it.\r
+                    return;\r
+                }\r
+\r
+                ExecuteAsynchronousCallback(false /* timedOut */);\r
+            }\r
+\r
+            private void HandleTimeout(object state) {\r
+                ExecuteAsynchronousCallback(true /* timedOut */);\r
+            }\r
+\r
+            private void WaitForBeginToCompleteAndDestroyTimer() {\r
+                lock (_beginDelegateLockObj) {\r
+                    // Wait for the target Begin() method to complete, as it might be performing\r
+                    // post-processing. This also forces a memory barrier, so _innerAsyncResult\r
+                    // is guaranteed to be non-null at this point.\r
+\r
+                    if (_timer != null) {\r
+                        _timer.Dispose();\r
+                    }\r
+                    _timer = null;\r
+                }\r
+            }\r
+\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncUtil.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncUtil.cs
new file mode 100644 (file)
index 0000000..64484cf
--- /dev/null
@@ -0,0 +1,75 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Threading;\r
+\r
+    internal static class AsyncUtil {\r
+\r
+        public static void WaitForAsyncResultCompletion(IAsyncResult asyncResult, HttpApplication app) {\r
+            // based on HttpServerUtility.ExecuteInternal()\r
+\r
+            if (!asyncResult.IsCompleted) {\r
+                // suspend app lock while waiting, else might deadlock\r
+                bool needToRelock = false;\r
+\r
+                try {\r
+                    // .NET 2.0+ will not allow a ThreadAbortException to be thrown while a\r
+                    // thread is inside a finally block, so this pattern ensures that the\r
+                    // value of 'needToRelock' is correct.\r
+                    try { }\r
+                    finally {\r
+                        Monitor.Exit(app);\r
+                        needToRelock = true;\r
+                    }\r
+\r
+                    WaitHandle waitHandle = asyncResult.AsyncWaitHandle;\r
+\r
+                    if (waitHandle != null) {\r
+                        waitHandle.WaitOne();\r
+                    }\r
+                    else {\r
+                        while (!asyncResult.IsCompleted) {\r
+                            Thread.Sleep(1);\r
+                        }\r
+                    }\r
+                }\r
+                finally {\r
+                    if (needToRelock) {\r
+                        Monitor.Enter(app);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        public static AsyncCallback WrapCallbackForSynchronizedExecution(AsyncCallback callback, SynchronizationContext syncContext) {\r
+            if (callback == null || syncContext == null) {\r
+                return callback;\r
+            }\r
+\r
+            AsyncCallback newCallback = delegate(IAsyncResult asyncResult) {\r
+                if (asyncResult.CompletedSynchronously) {\r
+                    callback(asyncResult);\r
+                }\r
+                else {\r
+                    // Only take the application lock if this request completed asynchronously,\r
+                    // else we might end up in a deadlock situation.\r
+                    syncContext.Sync(() => callback(asyncResult));\r
+                }\r
+            };\r
+\r
+            return newCallback;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncVoid.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/AsyncVoid.cs
new file mode 100644 (file)
index 0000000..95a81ce
--- /dev/null
@@ -0,0 +1,19 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+\r
+    // Dummy type used for passing something resembling 'void' to the async delegate functions\r
+    internal struct AsyncVoid {\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/BeginInvokeDelegate.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/BeginInvokeDelegate.cs
new file mode 100644 (file)
index 0000000..5d568f4
--- /dev/null
@@ -0,0 +1,17 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+\r
+    internal delegate IAsyncResult BeginInvokeDelegate(AsyncCallback callback, object state);\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/EndInvokeDelegate.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/EndInvokeDelegate.cs
new file mode 100644 (file)
index 0000000..11308df
--- /dev/null
@@ -0,0 +1,17 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+\r
+    internal delegate void EndInvokeDelegate(IAsyncResult asyncResult);\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/EndInvokeDelegate`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/EndInvokeDelegate`1.cs
new file mode 100644 (file)
index 0000000..9e83896
--- /dev/null
@@ -0,0 +1,17 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+\r
+    internal delegate TResult EndInvokeDelegate<TResult>(IAsyncResult asyncResult);\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/IAsyncActionInvoker.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/IAsyncActionInvoker.cs
new file mode 100644 (file)
index 0000000..acd624b
--- /dev/null
@@ -0,0 +1,20 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+\r
+    public interface IAsyncActionInvoker : IActionInvoker {\r
+        IAsyncResult BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state);\r
+        bool EndInvokeAction(IAsyncResult asyncResult);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/IAsyncController.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/IAsyncController.cs
new file mode 100644 (file)
index 0000000..fe256e8
--- /dev/null
@@ -0,0 +1,20 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System.Web.Routing;\r
+\r
+    public interface IAsyncController : IController {\r
+        IAsyncResult BeginExecute(RequestContext requestContext, AsyncCallback callback, object state);\r
+        void EndExecute(IAsyncResult asyncResult);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/IAsyncManagerContainer.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/IAsyncManagerContainer.cs
new file mode 100644 (file)
index 0000000..f9aa6ad
--- /dev/null
@@ -0,0 +1,22 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+\r
+    public interface IAsyncManagerContainer {\r
+\r
+        AsyncManager AsyncManager {\r
+            get;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/OperationCounter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/OperationCounter.cs
new file mode 100644 (file)
index 0000000..519f6ed
--- /dev/null
@@ -0,0 +1,62 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Threading;\r
+\r
+    public sealed class OperationCounter {\r
+\r
+        private int _count;\r
+\r
+        public int Count {\r
+            get {\r
+                return Thread.VolatileRead(ref _count);\r
+            }\r
+        }\r
+\r
+        public event EventHandler Completed;\r
+\r
+        private int AddAndExecuteCallbackIfCompleted(int value) {\r
+            int newCount = Interlocked.Add(ref _count, value);\r
+            if (newCount == 0) {\r
+                OnCompleted();\r
+            }\r
+\r
+            return newCount;\r
+        }\r
+\r
+        public int Decrement() {\r
+            return AddAndExecuteCallbackIfCompleted(-1);\r
+        }\r
+\r
+        public int Decrement(int value) {\r
+            return AddAndExecuteCallbackIfCompleted(-value);\r
+        }\r
+\r
+        public int Increment() {\r
+            return AddAndExecuteCallbackIfCompleted(1);\r
+        }\r
+\r
+        public int Increment(int value) {\r
+            return AddAndExecuteCallbackIfCompleted(value);\r
+        }\r
+\r
+        private void OnCompleted() {\r
+            EventHandler handler = Completed;\r
+            if (handler != null) {\r
+                handler(this, EventArgs.Empty);\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/ReflectedAsyncActionDescriptor.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/ReflectedAsyncActionDescriptor.cs
new file mode 100644 (file)
index 0000000..397a5a2
--- /dev/null
@@ -0,0 +1,183 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Threading;\r
+\r
+    public class ReflectedAsyncActionDescriptor : AsyncActionDescriptor {\r
+\r
+        private readonly object _executeTag = new object();\r
+\r
+        private readonly string _actionName;\r
+        private readonly ControllerDescriptor _controllerDescriptor;\r
+        private ParameterDescriptor[] _parametersCache;\r
+\r
+        public ReflectedAsyncActionDescriptor(MethodInfo asyncMethodInfo, MethodInfo completedMethodInfo, string actionName, ControllerDescriptor controllerDescriptor)\r
+            : this(asyncMethodInfo, completedMethodInfo, actionName, controllerDescriptor, true /* validateMethods */) {\r
+        }\r
+\r
+        internal ReflectedAsyncActionDescriptor(MethodInfo asyncMethodInfo, MethodInfo completedMethodInfo, string actionName, ControllerDescriptor controllerDescriptor, bool validateMethods) {\r
+            if (asyncMethodInfo == null) {\r
+                throw new ArgumentNullException("asyncMethodInfo");\r
+            }\r
+            if (completedMethodInfo == null) {\r
+                throw new ArgumentNullException("completedMethodInfo");\r
+            }\r
+            if (String.IsNullOrEmpty(actionName)) {\r
+                throw Error.ParameterCannotBeNullOrEmpty("actionName");\r
+            }\r
+            if (controllerDescriptor == null) {\r
+                throw new ArgumentNullException("controllerDescriptor");\r
+            }\r
+\r
+            if (validateMethods) {\r
+                string asyncFailedMessage = VerifyActionMethodIsCallable(asyncMethodInfo);\r
+                if (asyncFailedMessage != null) {\r
+                    throw new ArgumentException(asyncFailedMessage, "asyncMethodInfo");\r
+                }\r
+\r
+                string completedFailedMessage = VerifyActionMethodIsCallable(completedMethodInfo);\r
+                if (completedFailedMessage != null) {\r
+                    throw new ArgumentException(completedFailedMessage, "completedMethodInfo");\r
+                }\r
+            }\r
+\r
+            AsyncMethodInfo = asyncMethodInfo;\r
+            CompletedMethodInfo = completedMethodInfo;\r
+            _actionName = actionName;\r
+            _controllerDescriptor = controllerDescriptor;\r
+        }\r
+\r
+        public override string ActionName {\r
+            get {\r
+                return _actionName;\r
+            }\r
+        }\r
+\r
+        public MethodInfo AsyncMethodInfo {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public MethodInfo CompletedMethodInfo {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public override ControllerDescriptor ControllerDescriptor {\r
+            get {\r
+                return _controllerDescriptor;\r
+            }\r
+        }\r
+\r
+        public override IAsyncResult BeginExecute(ControllerContext controllerContext, IDictionary<string, object> parameters, AsyncCallback callback, object state) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (parameters == null) {\r
+                throw new ArgumentNullException("parameters");\r
+            }\r
+\r
+            AsyncManager asyncManager = GetAsyncManager(controllerContext.Controller);\r
+\r
+            BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) {\r
+                // call the XxxAsync() method\r
+                ParameterInfo[] parameterInfos = AsyncMethodInfo.GetParameters();\r
+                var rawParameterValues = from parameterInfo in parameterInfos\r
+                                         select ExtractParameterFromDictionary(parameterInfo, parameters, AsyncMethodInfo);\r
+                object[] parametersArray = rawParameterValues.ToArray();\r
+\r
+                TriggerListener listener = new TriggerListener();\r
+                SimpleAsyncResult asyncResult = new SimpleAsyncResult(asyncState);\r
+\r
+                // hook the Finished event to notify us upon completion\r
+                Trigger finishTrigger = listener.CreateTrigger();\r
+                asyncManager.Finished += delegate { finishTrigger.Fire(); };\r
+                asyncManager.OutstandingOperations.Increment();\r
+\r
+                // to simplify the logic, force the rest of the pipeline to execute in an asynchronous callback\r
+                listener.SetContinuation(() => ThreadPool.QueueUserWorkItem(_ => asyncResult.MarkCompleted(false /* completedSynchronously */, asyncCallback)));\r
+\r
+                // the inner operation might complete synchronously, so all setup work has to be done before this point\r
+                ActionMethodDispatcher dispatcher = DispatcherCache.GetDispatcher(AsyncMethodInfo);\r
+                dispatcher.Execute(controllerContext.Controller, parametersArray); // ignore return value from this method\r
+\r
+                // now that the XxxAsync() method has completed, kick off any pending operations\r
+                asyncManager.OutstandingOperations.Decrement();\r
+                listener.Activate();\r
+                return asyncResult;\r
+            };\r
+\r
+            EndInvokeDelegate<object> endDelegate = delegate(IAsyncResult asyncResult) {\r
+                // call the XxxCompleted() method\r
+                ParameterInfo[] completionParametersInfos = CompletedMethodInfo.GetParameters();\r
+                var rawCompletionParameterValues = from parameterInfo in completionParametersInfos\r
+                                                   select ExtractParameterOrDefaultFromDictionary(parameterInfo, asyncManager.Parameters);\r
+                object[] completionParametersArray = rawCompletionParameterValues.ToArray();\r
+\r
+                ActionMethodDispatcher dispatcher = DispatcherCache.GetDispatcher(CompletedMethodInfo);\r
+                object actionReturnValue = dispatcher.Execute(controllerContext.Controller, completionParametersArray);\r
+                return actionReturnValue;\r
+            };\r
+\r
+            return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _executeTag, asyncManager.Timeout);\r
+        }\r
+\r
+        public override object EndExecute(IAsyncResult asyncResult) {\r
+            return AsyncResultWrapper.End<object>(asyncResult, _executeTag);\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(bool inherit) {\r
+            return AsyncMethodInfo.GetCustomAttributes(inherit);\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit) {\r
+            return AsyncMethodInfo.GetCustomAttributes(attributeType, inherit);\r
+        }\r
+\r
+        public override FilterInfo GetFilters() {\r
+            // By default, we only look at filters on the XxxAsync() method.\r
+            return GetFilters(AsyncMethodInfo);\r
+        }\r
+\r
+        public override ParameterDescriptor[] GetParameters() {\r
+            ParameterDescriptor[] parameters = LazilyFetchParametersCollection();\r
+\r
+            // need to clone array so that user modifications aren't accidentally stored\r
+            return (ParameterDescriptor[])parameters.Clone();\r
+        }\r
+\r
+        public override ICollection<ActionSelector> GetSelectors() {\r
+            // By default, we only look at filters on the XxxAsync() method.\r
+\r
+            ActionMethodSelectorAttribute[] attrs = (ActionMethodSelectorAttribute[])AsyncMethodInfo.GetCustomAttributes(typeof(ActionMethodSelectorAttribute), true /* inherit */);\r
+            ActionSelector[] selectors = Array.ConvertAll(attrs, attr => (ActionSelector)(controllerContext => attr.IsValidForRequest(controllerContext, AsyncMethodInfo)));\r
+            return selectors;\r
+        }\r
+\r
+        public override bool IsDefined(Type attributeType, bool inherit) {\r
+            return AsyncMethodInfo.IsDefined(attributeType, inherit);\r
+        }\r
+\r
+        private ParameterDescriptor[] LazilyFetchParametersCollection() {\r
+            return DescriptorUtil.LazilyFetchOrCreateDescriptors<ParameterInfo, ParameterDescriptor>(\r
+                ref _parametersCache /* cacheLocation */,\r
+                AsyncMethodInfo.GetParameters /* initializer */,\r
+                parameterInfo => new ReflectedParameterDescriptor(parameterInfo, this) /* converter */);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/ReflectedAsyncControllerDescriptor.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/ReflectedAsyncControllerDescriptor.cs
new file mode 100644 (file)
index 0000000..ebbc938
--- /dev/null
@@ -0,0 +1,72 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+\r
+    public class ReflectedAsyncControllerDescriptor : ControllerDescriptor {\r
+\r
+        private static readonly ActionDescriptor[] _emptyCanonicalActions = new ActionDescriptor[0];\r
+\r
+        private readonly Type _controllerType;\r
+        private readonly AsyncActionMethodSelector _selector;\r
+\r
+        public ReflectedAsyncControllerDescriptor(Type controllerType) {\r
+            if (controllerType == null) {\r
+                throw new ArgumentNullException("controllerType");\r
+            }\r
+\r
+            _controllerType = controllerType;\r
+            _selector = new AsyncActionMethodSelector(_controllerType);\r
+        }\r
+\r
+        public sealed override Type ControllerType {\r
+            get {\r
+                return _controllerType;\r
+            }\r
+        }\r
+\r
+        public override ActionDescriptor FindAction(ControllerContext controllerContext, string actionName) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (String.IsNullOrEmpty(actionName)) {\r
+                throw Error.ParameterCannotBeNullOrEmpty("actionName");\r
+            }\r
+\r
+            ActionDescriptorCreator creator = _selector.FindAction(controllerContext, actionName);\r
+            if (creator == null) {\r
+                return null;\r
+            }\r
+\r
+            return creator(actionName, this);\r
+        }\r
+\r
+        public override ActionDescriptor[] GetCanonicalActions() {\r
+            // everything is looked up dymanically, so there are no 'canonical' actions\r
+            return _emptyCanonicalActions;\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(bool inherit) {\r
+            return ControllerType.GetCustomAttributes(inherit);\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit) {\r
+            return ControllerType.GetCustomAttributes(attributeType, inherit);\r
+        }\r
+\r
+        public override bool IsDefined(Type attributeType, bool inherit) {\r
+            return ControllerType.IsDefined(attributeType, inherit);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SimpleAsyncResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SimpleAsyncResult.cs
new file mode 100644 (file)
index 0000000..74f39b5
--- /dev/null
@@ -0,0 +1,67 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Threading;\r
+\r
+    internal sealed class SimpleAsyncResult : IAsyncResult {\r
+\r
+        private readonly object _asyncState;\r
+        private bool _completedSynchronously;\r
+        private volatile bool _isCompleted;\r
+\r
+        public SimpleAsyncResult(object asyncState) {\r
+            _asyncState = asyncState;\r
+        }\r
+\r
+        public object AsyncState {\r
+            get {\r
+                return _asyncState;\r
+            }\r
+        }\r
+\r
+        // ASP.NET IAsyncResult objects should never expose a WaitHandle due to potential deadlocking\r
+        public WaitHandle AsyncWaitHandle {\r
+            get {\r
+                return null;\r
+            }\r
+        }\r
+\r
+        public bool CompletedSynchronously {\r
+            get {\r
+                return _completedSynchronously;\r
+            }\r
+        }\r
+\r
+        public bool IsCompleted {\r
+            get {\r
+                return _isCompleted;\r
+            }\r
+        }\r
+\r
+        // Proper order of execution:\r
+        // 1. Set the CompletedSynchronously property to the correct value\r
+        // 2. Set the IsCompleted flag\r
+        // 3. Execute the callback\r
+        // 4. Signal the WaitHandle (which we don't have)\r
+        public void MarkCompleted(bool completedSynchronously, AsyncCallback callback) {\r
+            _completedSynchronously = completedSynchronously;\r
+            _isCompleted = true;\r
+\r
+            if (callback != null) {\r
+                callback(this);\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SingleEntryGate.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SingleEntryGate.cs
new file mode 100644 (file)
index 0000000..c3e63a1
--- /dev/null
@@ -0,0 +1,32 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Threading;\r
+\r
+    // used to synchronize access to a single-use consumable resource\r
+    internal sealed class SingleEntryGate {\r
+\r
+        private const int NOT_ENTERED = 0;\r
+        private const int ENTERED = 1;\r
+\r
+        private int _status;\r
+\r
+        // returns true if this is the first call to TryEnter(), false otherwise\r
+        public bool TryEnter() {\r
+            int oldStatus = Interlocked.Exchange(ref _status, ENTERED);\r
+            return (oldStatus == NOT_ENTERED);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SynchronizationContextUtil.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SynchronizationContextUtil.cs
new file mode 100644 (file)
index 0000000..5988091
--- /dev/null
@@ -0,0 +1,55 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Threading;\r
+\r
+    internal static class SynchronizationContextUtil {\r
+\r
+        public static SynchronizationContext GetSynchronizationContext() {\r
+            // In a runtime environment, SynchronizationContext.Current will be set to an instance\r
+            // of AspNetSynchronizationContext. In a unit test environment, the Current property\r
+            // won't be set and we have to create one on the fly.\r
+            return SynchronizationContext.Current ?? new SynchronizationContext();\r
+        }\r
+\r
+        public static T Sync<T>(this SynchronizationContext syncContext, Func<T> func) {\r
+            T theValue = default(T);\r
+            Exception thrownException = null;\r
+\r
+            syncContext.Send(o => {\r
+                try {\r
+                    theValue = func();\r
+                }\r
+                catch (Exception ex) {\r
+                    // by default, the AspNetSynchronizationContext type will swallow thrown exceptions,\r
+                    // so we need to save and propagate them\r
+                    thrownException = ex;\r
+                }\r
+            }, null);\r
+\r
+            if (thrownException != null) {\r
+                throw Error.SynchronizationContextUtil_ExceptionThrown(thrownException);\r
+            }\r
+            return theValue;\r
+        }\r
+\r
+        public static void Sync(this SynchronizationContext syncContext, Action action) {\r
+            Sync<AsyncVoid>(syncContext, () => {\r
+                action();\r
+                return default(AsyncVoid);\r
+            });\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SynchronousOperationException.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/SynchronousOperationException.cs
new file mode 100644 (file)
index 0000000..8836e26
--- /dev/null
@@ -0,0 +1,39 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Runtime.Serialization;\r
+\r
+    // This exception type is thrown by the SynchronizationContextUtil helper class since the AspNetSynchronizationContext\r
+    // type swallows exceptions. The inner exception contains the data the user cares about.\r
+\r
+    [Serializable]\r
+    public sealed class SynchronousOperationException : HttpException {\r
+\r
+        public SynchronousOperationException() {\r
+        }\r
+\r
+        private SynchronousOperationException(SerializationInfo info, StreamingContext context)\r
+            : base(info, context) {\r
+        }\r
+\r
+        public SynchronousOperationException(string message)\r
+            : base(message) {\r
+        }\r
+\r
+        public SynchronousOperationException(string message, Exception innerException)\r
+            : base(message, innerException) {\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/Trigger.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/Trigger.cs
new file mode 100644 (file)
index 0000000..3ac944c
--- /dev/null
@@ -0,0 +1,33 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Runtime.Serialization;\r
+\r
+    // Provides a trigger for the TriggerListener class.\r
+\r
+    internal sealed class Trigger {\r
+\r
+        private readonly Action _fireAction;\r
+\r
+        // Constructor should only be called by TriggerListener.\r
+        internal Trigger(Action fireAction) {\r
+            _fireAction = fireAction;\r
+        }\r
+\r
+        public void Fire() {\r
+            _fireAction();\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/TriggerListener.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/TriggerListener.cs
new file mode 100644 (file)
index 0000000..eed5096
--- /dev/null
@@ -0,0 +1,68 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Async {\r
+    using System;\r
+    using System.Threading;\r
+\r
+    // This class is used to wait for triggers and a continuation. When the continuation has been provded\r
+    // and all triggers have been fired, the continuation is called. Similar to WaitHandle.WaitAll().\r
+    // New instances of this type are initially in the inactive state; activation is enabled by a call\r
+    // to Activate().\r
+\r
+    // This class is thread-safe.\r
+\r
+    internal sealed class TriggerListener {\r
+\r
+        private readonly Trigger _activateTrigger;\r
+        private volatile Action _continuation;\r
+        private readonly SingleEntryGate _continuationFiredGate = new SingleEntryGate();\r
+        private int _outstandingTriggers;\r
+        private readonly Trigger _setContinuationTrigger;\r
+\r
+        public TriggerListener() {\r
+            _activateTrigger = CreateTrigger();\r
+            _setContinuationTrigger = CreateTrigger();\r
+        }\r
+\r
+        public void Activate() {\r
+            _activateTrigger.Fire();\r
+        }\r
+\r
+        public Trigger CreateTrigger() {\r
+            Interlocked.Increment(ref _outstandingTriggers);\r
+\r
+            SingleEntryGate triggerFiredGate = new SingleEntryGate();\r
+            return new Trigger(() => {\r
+                if (triggerFiredGate.TryEnter()) {\r
+                    HandleTriggerFired();\r
+                }\r
+            });\r
+        }\r
+\r
+        private void HandleTriggerFired() {\r
+            if (Interlocked.Decrement(ref _outstandingTriggers) == 0) {\r
+                if (_continuationFiredGate.TryEnter()) {\r
+                    _continuation();\r
+                }\r
+            }\r
+        }\r
+\r
+        public void SetContinuation(Action continuation) {\r
+            if (continuation != null) {\r
+                _continuation = continuation;\r
+                _setContinuationTrigger.Fire();\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AsyncController.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AsyncController.cs
new file mode 100644 (file)
index 0000000..975ce4f
--- /dev/null
@@ -0,0 +1,111 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web.Mvc.Async;\r
+    using System.Web.Routing;\r
+\r
+    public abstract class AsyncController : Controller, IAsyncManagerContainer, IAsyncController {\r
+\r
+        private static readonly object _executeTag = new object();\r
+        private static readonly object _executeCoreTag = new object();\r
+\r
+        private readonly AsyncManager _asyncManager = new AsyncManager();\r
+\r
+        public AsyncManager AsyncManager {\r
+            get {\r
+                return _asyncManager;\r
+            }\r
+        }\r
+\r
+        protected virtual IAsyncResult BeginExecute(RequestContext requestContext, AsyncCallback callback, object state) {\r
+            if (requestContext == null) {\r
+                throw new ArgumentNullException("requestContext");\r
+            }\r
+\r
+            VerifyExecuteCalledOnce();\r
+            Initialize(requestContext);\r
+            return AsyncResultWrapper.Begin(callback, state, BeginExecuteCore, EndExecuteCore, _executeTag);\r
+        }\r
+\r
+        protected virtual IAsyncResult BeginExecuteCore(AsyncCallback callback, object state) {\r
+            // If code in this method needs to be updated, please also check the ExecuteCore() method\r
+            // of Controller to see if that code also must be updated.\r
+\r
+            PossiblyLoadTempData();\r
+            try {\r
+                string actionName = RouteData.GetRequiredString("action");\r
+                IActionInvoker invoker = ActionInvoker;\r
+                IAsyncActionInvoker asyncInvoker = invoker as IAsyncActionInvoker;\r
+                if (asyncInvoker != null) {\r
+                    // asynchronous invocation\r
+                    BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) {\r
+                        return asyncInvoker.BeginInvokeAction(ControllerContext, actionName, asyncCallback, asyncState);\r
+                    };\r
+\r
+                    EndInvokeDelegate endDelegate = delegate(IAsyncResult asyncResult) {\r
+                        if (!asyncInvoker.EndInvokeAction(asyncResult)) {\r
+                            HandleUnknownAction(actionName);\r
+                        }\r
+                    };\r
+\r
+                    return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _executeCoreTag);\r
+                }\r
+                else {\r
+                    // synchronous invocation\r
+                    Action action = () => {\r
+                        if (!invoker.InvokeAction(ControllerContext, actionName)) {\r
+                            HandleUnknownAction(actionName);\r
+                        }\r
+                    };\r
+                    return AsyncResultWrapper.BeginSynchronous(callback, state, action, _executeCoreTag);\r
+                }\r
+            }\r
+            catch {\r
+                PossiblySaveTempData();\r
+                throw;\r
+            }\r
+        }\r
+\r
+        protected override IActionInvoker CreateActionInvoker() {\r
+            return new AsyncControllerActionInvoker();\r
+        }\r
+\r
+        protected virtual void EndExecute(IAsyncResult asyncResult) {\r
+            AsyncResultWrapper.End(asyncResult, _executeTag);\r
+        }\r
+\r
+        protected virtual void EndExecuteCore(IAsyncResult asyncResult) {\r
+            // If code in this method needs to be updated, please also check the ExecuteCore() method\r
+            // of Controller to see if that code also must be updated.\r
+\r
+            try {\r
+                AsyncResultWrapper.End(asyncResult, _executeCoreTag);\r
+            }\r
+            finally {\r
+                PossiblySaveTempData();\r
+            }\r
+        }\r
+\r
+        #region IAsyncController Members\r
+        IAsyncResult IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, object state) {\r
+            return BeginExecute(requestContext, callback, state);\r
+        }\r
+\r
+        void IAsyncController.EndExecute(IAsyncResult asyncResult) {\r
+            EndExecute(asyncResult);\r
+        }\r
+        #endregion\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AsyncTimeoutAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AsyncTimeoutAttribute.cs
new file mode 100644 (file)
index 0000000..9622e25
--- /dev/null
@@ -0,0 +1,53 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Web.Mvc.Async;\r
+\r
+    [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes",\r
+        Justification = "Unsealed so that subclassed types can set properties in the default constructor.")]\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]\r
+    public class AsyncTimeoutAttribute : ActionFilterAttribute {\r
+\r
+        // duration is specified in milliseconds\r
+        public AsyncTimeoutAttribute(int duration) {\r
+            if (duration < -1) {\r
+                throw Error.AsyncCommon_InvalidTimeout("duration");\r
+            }\r
+\r
+            Duration = duration;\r
+        }\r
+\r
+        public int Duration {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public override void OnActionExecuting(ActionExecutingContext filterContext) {\r
+            if (filterContext == null) {\r
+                throw new ArgumentNullException("filterContext");\r
+            }\r
+\r
+            IAsyncManagerContainer container = filterContext.Controller as IAsyncManagerContainer;\r
+            if (container == null) {\r
+                throw Error.AsyncCommon_ControllerMustImplementIAsyncManagerContainer(filterContext.Controller.GetType());\r
+            }\r
+\r
+            container.AsyncManager.Timeout = Duration;\r
+\r
+            base.OnActionExecuting(filterContext);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AuthorizationContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AuthorizationContext.cs
new file mode 100644 (file)
index 0000000..8cd6808
--- /dev/null
@@ -0,0 +1,50 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public class AuthorizationContext : ControllerContext {\r
+\r
+        // parameterless constructor used for mocking\r
+        public AuthorizationContext() {\r
+        }\r
+\r
+        [Obsolete("The recommended alternative is the constructor AuthorizationContext(ControllerContext controllerContext, ActionDescriptor actionDescriptor).")]\r
+        public AuthorizationContext(ControllerContext controllerContext)\r
+            : base(controllerContext) {\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
+        public AuthorizationContext(ControllerContext controllerContext, ActionDescriptor actionDescriptor)\r
+            : base(controllerContext) {\r
+            if (actionDescriptor == null) {\r
+                throw new ArgumentNullException("actionDescriptor");\r
+            }\r
+\r
+            ActionDescriptor = actionDescriptor;\r
+        }\r
+\r
+        public virtual ActionDescriptor ActionDescriptor {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public ActionResult Result {\r
+            get;\r
+            set;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/AuthorizeAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/AuthorizeAttribute.cs
new file mode 100644 (file)
index 0000000..3b07bca
--- /dev/null
@@ -0,0 +1,135 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq;\r
+    using System.Security.Principal;\r
+    using System.Web;\r
+\r
+    [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes",\r
+        Justification = "Unsealed so that subclassed types can set properties in the default constructor or override our behavior.")]\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]\r
+    public class AuthorizeAttribute : FilterAttribute, IAuthorizationFilter {\r
+\r
+        private readonly object _typeId = new object();\r
+\r
+        private string _roles;\r
+        private string[] _rolesSplit = new string[0];\r
+        private string _users;\r
+        private string[] _usersSplit = new string[0];\r
+\r
+        public string Roles {\r
+            get {\r
+                return _roles ?? String.Empty;\r
+            }\r
+            set {\r
+                _roles = value;\r
+                _rolesSplit = SplitString(value);\r
+            }\r
+        }\r
+\r
+        public override object TypeId {\r
+            get {\r
+                return _typeId;\r
+            }\r
+        }\r
+\r
+        public string Users {\r
+            get {\r
+                return _users ?? String.Empty;\r
+            }\r
+            set {\r
+                _users = value;\r
+                _usersSplit = SplitString(value);\r
+            }\r
+        }\r
+\r
+        // This method must be thread-safe since it is called by the thread-safe OnCacheAuthorization() method.\r
+        protected virtual bool AuthorizeCore(HttpContextBase httpContext) {\r
+            if (httpContext == null) {\r
+                throw new ArgumentNullException("httpContext");\r
+            }\r
+\r
+            IPrincipal user = httpContext.User;\r
+            if (!user.Identity.IsAuthenticated) {\r
+                return false;\r
+            }\r
+\r
+            if (_usersSplit.Length > 0 && !_usersSplit.Contains(user.Identity.Name, StringComparer.OrdinalIgnoreCase)) {\r
+                return false;\r
+            }\r
+\r
+            if (_rolesSplit.Length > 0 && !_rolesSplit.Any(user.IsInRole)) {\r
+                return false;\r
+            }\r
+\r
+            return true;\r
+        }\r
+\r
+        private void CacheValidateHandler(HttpContext context, object data, ref HttpValidationStatus validationStatus) {\r
+            validationStatus = OnCacheAuthorization(new HttpContextWrapper(context));\r
+        }\r
+\r
+        public virtual void OnAuthorization(AuthorizationContext filterContext) {\r
+            if (filterContext == null) {\r
+                throw new ArgumentNullException("filterContext");\r
+            }\r
+\r
+            if (AuthorizeCore(filterContext.HttpContext)) {\r
+                // ** IMPORTANT **\r
+                // Since we're performing authorization at the action level, the authorization code runs\r
+                // after the output caching module. In the worst case this could allow an authorized user\r
+                // to cause the page to be cached, then an unauthorized user would later be served the\r
+                // cached page. We work around this by telling proxies not to cache the sensitive page,\r
+                // then we hook our custom authorization code into the caching mechanism so that we have\r
+                // the final say on whether a page should be served from the cache.\r
+\r
+                HttpCachePolicyBase cachePolicy = filterContext.HttpContext.Response.Cache;\r
+                cachePolicy.SetProxyMaxAge(new TimeSpan(0));\r
+                cachePolicy.AddValidationCallback(CacheValidateHandler, null /* data */);\r
+            }\r
+            else {\r
+                HandleUnauthorizedRequest(filterContext);\r
+            }\r
+        }\r
+\r
+        protected virtual void HandleUnauthorizedRequest(AuthorizationContext filterContext) {\r
+            // Returns HTTP 401 - see comment in HttpUnauthorizedResult.cs.\r
+            filterContext.Result = new HttpUnauthorizedResult();\r
+        }\r
+\r
+        // This method must be thread-safe since it is called by the caching module.\r
+        protected virtual HttpValidationStatus OnCacheAuthorization(HttpContextBase httpContext) {\r
+            if (httpContext == null) {\r
+                throw new ArgumentNullException("httpContext");\r
+            }\r
+\r
+            bool isAuthorized = AuthorizeCore(httpContext);\r
+            return (isAuthorized) ? HttpValidationStatus.Valid : HttpValidationStatus.IgnoreThisRequest;\r
+        }\r
+\r
+        internal static string[] SplitString(string original) {\r
+            if (String.IsNullOrEmpty(original)) {\r
+                return new string[0];\r
+            }\r
+\r
+            var split = from piece in original.Split(',')\r
+                        let trimmed = piece.Trim()\r
+                        where !String.IsNullOrEmpty(trimmed)\r
+                        select trimmed;\r
+            return split.ToArray();\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/BindAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/BindAttribute.cs
new file mode 100644 (file)
index 0000000..5f3b1be
--- /dev/null
@@ -0,0 +1,63 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Linq;\r
+\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]\r
+    public sealed class BindAttribute : Attribute {\r
+\r
+        private string _exclude;\r
+        private string[] _excludeSplit = new string[0];\r
+        private string _include;\r
+        private string[] _includeSplit = new string[0];\r
+\r
+        public string Exclude {\r
+            get {\r
+                return _exclude ?? String.Empty;\r
+            }\r
+            set {\r
+                _exclude = value;\r
+                _excludeSplit = AuthorizeAttribute.SplitString(value);\r
+            }\r
+        }\r
+\r
+        public string Include {\r
+            get {\r
+                return _include ?? String.Empty;\r
+            }\r
+            set {\r
+                _include = value;\r
+                _includeSplit = AuthorizeAttribute.SplitString(value);\r
+            }\r
+        }\r
+\r
+        public string Prefix {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        internal static bool IsPropertyAllowed(string propertyName, string[] includeProperties, string[] excludeProperties) {\r
+            // We allow a property to be bound if its both in the include list AND not in the exclude list.\r
+            // An empty include list implies all properties are allowed.\r
+            // An empty exclude list implies no properties are disallowed.\r
+            bool includeProperty = (includeProperties == null) || (includeProperties.Length == 0) || includeProperties.Contains(propertyName, StringComparer.OrdinalIgnoreCase);\r
+            bool excludeProperty = (excludeProperties != null) && excludeProperties.Contains(propertyName, StringComparer.OrdinalIgnoreCase);\r
+            return includeProperty && !excludeProperty;\r
+        }\r
+\r
+        public bool IsPropertyAllowed(string propertyName) {\r
+            return IsPropertyAllowed(propertyName, _includeSplit, _excludeSplit);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/BuildManagerWrapper.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/BuildManagerWrapper.cs
new file mode 100644 (file)
index 0000000..f8959ec
--- /dev/null
@@ -0,0 +1,43 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections;\r
+    using System.IO;\r
+    using System.Web.Compilation;\r
+\r
+    internal sealed class BuildManagerWrapper : IBuildManager {\r
+        private static readonly Func<string, Stream> _readCachedFileDelegate =\r
+            TypeHelpers.CreateDelegate<Func<string, Stream>>(typeof(BuildManager), "ReadCachedFile", null /* thisParameter */);\r
+        private static readonly Func<string, Stream> _createCachedFileDelegate =\r
+            TypeHelpers.CreateDelegate<Func<string, Stream>>(typeof(BuildManager), "CreateCachedFile", null /* thisParameter */);\r
+\r
+        #region IBuildManager Members\r
+        object IBuildManager.CreateInstanceFromVirtualPath(string virtualPath, Type requiredBaseType) {\r
+            return BuildManager.CreateInstanceFromVirtualPath(virtualPath, requiredBaseType);\r
+        }\r
+\r
+        ICollection IBuildManager.GetReferencedAssemblies() {\r
+            return BuildManager.GetReferencedAssemblies();\r
+        }\r
+\r
+        // ASP.NET 4 methods\r
+        Stream IBuildManager.ReadCachedFile(string fileName) {\r
+            return (_readCachedFileDelegate != null) ? _readCachedFileDelegate(fileName) : null;\r
+        }\r
+\r
+        Stream IBuildManager.CreateCachedFile(string fileName) {\r
+            return (_createCachedFileDelegate != null) ? _createCachedFileDelegate(fileName) : null;\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ByteArrayModelBinder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ByteArrayModelBinder.cs
new file mode 100644 (file)
index 0000000..ad62a13
--- /dev/null
@@ -0,0 +1,43 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public class ByteArrayModelBinder : IModelBinder {\r
+        public virtual object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            if (bindingContext == null) {\r
+                throw new ArgumentNullException("bindingContext");\r
+            }\r
+\r
+            ValueProviderResult valueResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);\r
+\r
+            // case 1: there was no <input ... /> element containing this data\r
+            if (valueResult == null) {\r
+                return null;\r
+            }\r
+\r
+            string value = valueResult.AttemptedValue;\r
+\r
+            // case 2: there was an <input ... /> element but it was left blank\r
+            if (String.IsNullOrEmpty(value)) {\r
+                return null;\r
+            }\r
+\r
+            // Future proofing. If the byte array is actually an instance of System.Data.Linq.Binary\r
+            // then we need to remove these quotes put in place by the ToString() method.\r
+            string realValue = value.Replace("\"", String.Empty);\r
+            return Convert.FromBase64String(realValue);\r
+        }\r
+    }\r
+\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ChildActionOnlyAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ChildActionOnlyAttribute.cs
new file mode 100644 (file)
index 0000000..398546b
--- /dev/null
@@ -0,0 +1,30 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public sealed class ChildActionOnlyAttribute : FilterAttribute, IAuthorizationFilter {\r
+\r
+        public void OnAuthorization(AuthorizationContext filterContext) {\r
+            if (filterContext == null) {\r
+                throw new ArgumentNullException("filterContext");\r
+            }\r
+\r
+            if (!filterContext.IsChildAction) {\r
+                throw Error.ChildActionOnlyAttribute_MustBeInChildRequest(filterContext.ActionDescriptor);\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ClientDataTypeModelValidatorProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ClientDataTypeModelValidatorProvider.cs
new file mode 100644 (file)
index 0000000..54c2519
--- /dev/null
@@ -0,0 +1,79 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ClientDataTypeModelValidatorProvider : ModelValidatorProvider {\r
+\r
+        private static readonly HashSet<Type> _numericTypes = new HashSet<Type>(new Type[] {\r
+            typeof(byte), typeof(sbyte),\r
+            typeof(short), typeof(ushort),\r
+            typeof(int), typeof(uint),\r
+            typeof(long), typeof(ulong),\r
+            typeof(float), typeof(double), typeof(decimal)\r
+        });\r
+\r
+        public override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context) {\r
+            if (metadata == null) {\r
+                throw new ArgumentNullException("metadata");\r
+            }\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+\r
+            return GetValidatorsImpl(metadata, context);\r
+        }\r
+\r
+        private static IEnumerable<ModelValidator> GetValidatorsImpl(ModelMetadata metadata, ControllerContext context) {\r
+            Type type = metadata.ModelType;\r
+            if (IsNumericType(type)) {\r
+                yield return new NumericModelValidator(metadata, context);\r
+            }\r
+        }\r
+\r
+        private static bool IsNumericType(Type type) {\r
+            Type underlyingType = Nullable.GetUnderlyingType(type); // strip off the Nullable<>\r
+            return _numericTypes.Contains(underlyingType ?? type);\r
+        }\r
+\r
+        internal sealed class NumericModelValidator : ModelValidator {\r
+            public NumericModelValidator(ModelMetadata metadata, ControllerContext controllerContext)\r
+                : base(metadata, controllerContext) {\r
+            }\r
+\r
+            public override IEnumerable<ModelClientValidationRule> GetClientValidationRules() {\r
+                ModelClientValidationRule rule = new ModelClientValidationRule() {\r
+                    ValidationType = "number",\r
+                    ErrorMessage = MakeErrorString(Metadata.GetDisplayName())\r
+                };\r
+\r
+                return new ModelClientValidationRule[] { rule };\r
+            }\r
+\r
+            private static string MakeErrorString(string displayName) {\r
+                // use CurrentCulture since this message is intended for the site visitor\r
+                return String.Format(CultureInfo.CurrentCulture, MvcResources.ClientDataTypeModelValidatorProvider_FieldMustBeNumeric, displayName);\r
+            }\r
+\r
+            public override IEnumerable<ModelValidationResult> Validate(object container) {\r
+                // this is not a server-side validator\r
+                return Enumerable.Empty<ModelValidationResult>();\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ContentResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ContentResult.cs
new file mode 100644 (file)
index 0000000..37ecb71
--- /dev/null
@@ -0,0 +1,53 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Text;\r
+    using System.Web;\r
+\r
+    public class ContentResult : ActionResult {\r
+\r
+        public string Content {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public Encoding ContentEncoding {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public string ContentType {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public override void ExecuteResult(ControllerContext context) {\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+\r
+            HttpResponseBase response = context.HttpContext.Response;\r
+\r
+            if (!String.IsNullOrEmpty(ContentType)) {\r
+                response.ContentType = ContentType;\r
+            }\r
+            if (ContentEncoding != null) {\r
+                response.ContentEncoding = ContentEncoding;\r
+            }\r
+            if (Content != null) {\r
+                response.Write(Content);\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Controller.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Controller.cs
new file mode 100644 (file)
index 0000000..04f4bc4
--- /dev/null
@@ -0,0 +1,599 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.IO;\r
+    using System.Security.Principal;\r
+    using System.Text;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public abstract class Controller : ControllerBase, IActionFilter, IAuthorizationFilter, IDisposable, IExceptionFilter, IResultFilter {\r
+\r
+        private IActionInvoker _actionInvoker;\r
+        private ModelBinderDictionary _binders;\r
+        private RouteCollection _routeCollection;\r
+        private ITempDataProvider _tempDataProvider;\r
+\r
+        public IActionInvoker ActionInvoker {\r
+            get {\r
+                if (_actionInvoker == null) {\r
+                    _actionInvoker = CreateActionInvoker();\r
+                }\r
+                return _actionInvoker;\r
+            }\r
+            set {\r
+                _actionInvoker = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "Property is settable so that the dictionary can be provided for unit testing purposes.")]\r
+        protected internal ModelBinderDictionary Binders {\r
+            get {\r
+                if (_binders == null) {\r
+                    _binders = ModelBinders.Binders;\r
+                }\r
+                return _binders;\r
+            }\r
+            set {\r
+                _binders = value;\r
+            }\r
+        }\r
+\r
+        public HttpContextBase HttpContext {\r
+            get {\r
+                return ControllerContext == null ? null : ControllerContext.HttpContext;\r
+            }\r
+        }\r
+\r
+        public ModelStateDictionary ModelState {\r
+            get {\r
+                return ViewData.ModelState;\r
+            }\r
+        }\r
+\r
+        public HttpRequestBase Request {\r
+            get {\r
+                return HttpContext == null ? null : HttpContext.Request;\r
+            }\r
+        }\r
+\r
+        public HttpResponseBase Response {\r
+            get {\r
+                return HttpContext == null ? null : HttpContext.Response;\r
+            }\r
+        }\r
+\r
+        internal RouteCollection RouteCollection {\r
+            get {\r
+                if (_routeCollection == null) {\r
+                    _routeCollection = RouteTable.Routes;\r
+                }\r
+                return _routeCollection;\r
+            }\r
+            set {\r
+                _routeCollection = value;\r
+            }\r
+        }\r
+\r
+        public RouteData RouteData {\r
+            get {\r
+                return ControllerContext == null ? null : ControllerContext.RouteData;\r
+            }\r
+        }\r
+\r
+        public HttpServerUtilityBase Server {\r
+            get {\r
+                return HttpContext == null ? null : HttpContext.Server;\r
+            }\r
+        }\r
+\r
+        public HttpSessionStateBase Session {\r
+            get {\r
+                return HttpContext == null ? null : HttpContext.Session;\r
+            }\r
+        }\r
+\r
+        public ITempDataProvider TempDataProvider {\r
+            get {\r
+                if (_tempDataProvider == null) {\r
+                    _tempDataProvider = CreateTempDataProvider();\r
+                }\r
+                return _tempDataProvider;\r
+            }\r
+            set {\r
+                _tempDataProvider = value;\r
+            }\r
+        }\r
+\r
+        public UrlHelper Url {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public IPrincipal User {\r
+            get {\r
+                return HttpContext == null ? null : HttpContext.User;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames", MessageId = "0#",\r
+            Justification = "'Content' refers to ContentResult type; 'content' refers to ContentResult.Content property.")]\r
+        protected internal ContentResult Content(string content) {\r
+            return Content(content, null /* contentType */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames", MessageId = "0#",\r
+            Justification = "'Content' refers to ContentResult type; 'content' refers to ContentResult.Content property.")]\r
+        protected internal ContentResult Content(string content, string contentType) {\r
+            return Content(content, contentType, null /* contentEncoding */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames", MessageId = "0#",\r
+            Justification = "'Content' refers to ContentResult type; 'content' refers to ContentResult.Content property.")]\r
+        protected internal virtual ContentResult Content(string content, string contentType, Encoding contentEncoding) {\r
+            return new ContentResult {\r
+                Content = content,\r
+                ContentType = contentType,\r
+                ContentEncoding = contentEncoding\r
+            };\r
+        }\r
+\r
+        protected virtual IActionInvoker CreateActionInvoker() {\r
+            return new ControllerActionInvoker();\r
+        }\r
+\r
+        protected virtual ITempDataProvider CreateTempDataProvider() {\r
+            return new SessionStateTempDataProvider();\r
+        }\r
+\r
+        // The default invoker will never match methods defined on the Controller type, so\r
+        // the Dispose() method is not web-callable.  However, in general, since implicitly-\r
+        // implemented interface methods are public, they are web-callable unless decorated with\r
+        // [NonAction].\r
+        public void Dispose() {\r
+            Dispose(true /* disposing */);\r
+            GC.SuppressFinalize(this);\r
+        }\r
+\r
+        protected virtual void Dispose(bool disposing) {\r
+        }\r
+\r
+        protected override void ExecuteCore() {\r
+            // If code in this method needs to be updated, please also check the BeginExecuteCore() and\r
+            // EndExecuteCore() methods of AsyncController to see if that code also must be updated.\r
+\r
+            PossiblyLoadTempData();\r
+            try {\r
+                string actionName = RouteData.GetRequiredString("action");\r
+                if (!ActionInvoker.InvokeAction(ControllerContext, actionName)) {\r
+                    HandleUnknownAction(actionName);\r
+                }\r
+            }\r
+            finally {\r
+                PossiblySaveTempData();\r
+            }\r
+        }\r
+\r
+        protected internal FileContentResult File(byte[] fileContents, string contentType) {\r
+            return File(fileContents, contentType, null /* fileDownloadName */);\r
+        }\r
+\r
+        protected internal virtual FileContentResult File(byte[] fileContents, string contentType, string fileDownloadName) {\r
+            return new FileContentResult(fileContents, contentType) { FileDownloadName = fileDownloadName };\r
+        }\r
+\r
+        protected internal FileStreamResult File(Stream fileStream, string contentType) {\r
+            return File(fileStream, contentType, null /* fileDownloadName */);\r
+        }\r
+\r
+        protected internal virtual FileStreamResult File(Stream fileStream, string contentType, string fileDownloadName) {\r
+            return new FileStreamResult(fileStream, contentType) { FileDownloadName = fileDownloadName };\r
+        }\r
+\r
+        protected internal FilePathResult File(string fileName, string contentType) {\r
+            return File(fileName, contentType, null /* fileDownloadName */);\r
+        }\r
+\r
+        protected internal virtual FilePathResult File(string fileName, string contentType, string fileDownloadName) {\r
+            return new FilePathResult(fileName, contentType) { FileDownloadName = fileDownloadName };\r
+        }\r
+\r
+        protected virtual void HandleUnknownAction(string actionName) {\r
+            throw new HttpException(404, String.Format(CultureInfo.CurrentUICulture,\r
+                MvcResources.Controller_UnknownAction, actionName, GetType().FullName));\r
+        }\r
+\r
+        protected internal virtual JavaScriptResult JavaScript(string script) {\r
+            return new JavaScriptResult { Script = script };\r
+        }\r
+\r
+        protected internal JsonResult Json(object data) {\r
+            return Json(data, null /* contentType */, null /* contentEncoding */, JsonRequestBehavior.DenyGet);\r
+        }\r
+\r
+        protected internal JsonResult Json(object data, string contentType) {\r
+            return Json(data, contentType, null /* contentEncoding */, JsonRequestBehavior.DenyGet);\r
+        }\r
+\r
+        protected internal virtual JsonResult Json(object data, string contentType, Encoding contentEncoding) {\r
+            return Json(data, contentType, contentEncoding, JsonRequestBehavior.DenyGet);\r
+        }\r
+\r
+        protected internal JsonResult Json(object data, JsonRequestBehavior behavior) {\r
+            return Json(data, null /* contentType */, null /* contentEncoding */, behavior);\r
+        }\r
+\r
+        protected internal JsonResult Json(object data, string contentType, JsonRequestBehavior behavior) {\r
+            return Json(data, contentType, null /* contentEncoding */, behavior);\r
+        }\r
+\r
+        protected internal virtual JsonResult Json(object data, string contentType, Encoding contentEncoding, JsonRequestBehavior behavior) {\r
+            return new JsonResult {\r
+                Data = data,\r
+                ContentType = contentType,\r
+                ContentEncoding = contentEncoding,\r
+                JsonRequestBehavior = behavior\r
+            };\r
+        }\r
+\r
+        protected override void Initialize(RequestContext requestContext) {\r
+            base.Initialize(requestContext);\r
+            Url = new UrlHelper(requestContext);\r
+        }\r
+\r
+        protected virtual void OnActionExecuting(ActionExecutingContext filterContext) {\r
+        }\r
+\r
+        protected virtual void OnActionExecuted(ActionExecutedContext filterContext) {\r
+        }\r
+\r
+        protected virtual void OnAuthorization(AuthorizationContext filterContext) {\r
+        }\r
+\r
+        protected virtual void OnException(ExceptionContext filterContext) {\r
+        }\r
+\r
+        protected virtual void OnResultExecuted(ResultExecutedContext filterContext) {\r
+        }\r
+\r
+        protected virtual void OnResultExecuting(ResultExecutingContext filterContext) {\r
+        }\r
+\r
+        protected internal PartialViewResult PartialView() {\r
+            return PartialView(null /* viewName */, null /* model */);\r
+        }\r
+\r
+        protected internal PartialViewResult PartialView(object model) {\r
+            return PartialView(null /* viewName */, model);\r
+        }\r
+\r
+        protected internal PartialViewResult PartialView(string viewName) {\r
+            return PartialView(viewName, null /* model */);\r
+        }\r
+\r
+        protected internal virtual PartialViewResult PartialView(string viewName, object model) {\r
+            if (model != null) {\r
+                ViewData.Model = model;\r
+            }\r
+\r
+            return new PartialViewResult {\r
+                ViewName = viewName,\r
+                ViewData = ViewData,\r
+                TempData = TempData\r
+            };\r
+        }\r
+\r
+        internal void PossiblyLoadTempData() {\r
+            if (!ControllerContext.IsChildAction) {\r
+                TempData.Load(ControllerContext, TempDataProvider);\r
+            }\r
+        }\r
+\r
+        internal void PossiblySaveTempData() {\r
+            if (!ControllerContext.IsChildAction) {\r
+                TempData.Save(ControllerContext, TempDataProvider);\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "Instance method for consistency with other helpers.")]\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#",\r
+            Justification = "Response.Redirect() takes its URI as a string parameter.")]\r
+        protected internal virtual RedirectResult Redirect(string url) {\r
+            if (String.IsNullOrEmpty(url)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "url");\r
+            }\r
+            return new RedirectResult(url);\r
+        }\r
+\r
+        protected internal RedirectToRouteResult RedirectToAction(string actionName) {\r
+            return RedirectToAction(actionName, (RouteValueDictionary)null);\r
+        }\r
+\r
+        protected internal RedirectToRouteResult RedirectToAction(string actionName, object routeValues) {\r
+            return RedirectToAction(actionName, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        protected internal RedirectToRouteResult RedirectToAction(string actionName, RouteValueDictionary routeValues) {\r
+            return RedirectToAction(actionName, null /* controllerName */, routeValues);\r
+        }\r
+\r
+        protected internal RedirectToRouteResult RedirectToAction(string actionName, string controllerName) {\r
+            return RedirectToAction(actionName, controllerName, (RouteValueDictionary)null);\r
+        }\r
+\r
+        protected internal RedirectToRouteResult RedirectToAction(string actionName, string controllerName, object routeValues) {\r
+            return RedirectToAction(actionName, controllerName, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        protected internal virtual RedirectToRouteResult RedirectToAction(string actionName, string controllerName, RouteValueDictionary routeValues) {\r
+            RouteValueDictionary mergedRouteValues;\r
+\r
+            if (RouteData == null) {\r
+                mergedRouteValues = RouteValuesHelpers.MergeRouteValues(actionName, controllerName, null, routeValues, true /* includeImplicitMvcValues */);\r
+            }\r
+            else {\r
+                mergedRouteValues = RouteValuesHelpers.MergeRouteValues(actionName, controllerName, RouteData.Values, routeValues, true /* includeImplicitMvcValues */);\r
+            }\r
+\r
+            return new RedirectToRouteResult(mergedRouteValues);\r
+        }\r
+\r
+        protected internal RedirectToRouteResult RedirectToRoute(object routeValues) {\r
+            return RedirectToRoute(new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        protected internal RedirectToRouteResult RedirectToRoute(RouteValueDictionary routeValues) {\r
+            return RedirectToRoute(null /* routeName */, routeValues);\r
+        }\r
+\r
+        protected internal RedirectToRouteResult RedirectToRoute(string routeName) {\r
+            return RedirectToRoute(routeName, (RouteValueDictionary)null);\r
+        }\r
+\r
+        protected internal RedirectToRouteResult RedirectToRoute(string routeName, object routeValues) {\r
+            return RedirectToRoute(routeName, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        protected internal virtual RedirectToRouteResult RedirectToRoute(string routeName, RouteValueDictionary routeValues) {\r
+            return new RedirectToRouteResult(routeName, RouteValuesHelpers.GetRouteValues(routeValues));\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model) where TModel : class {\r
+            return TryUpdateModel(model, null, null, null, ValueProvider);\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model, string prefix) where TModel : class {\r
+            return TryUpdateModel(model, prefix, null, null, ValueProvider);\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model, string[] includeProperties) where TModel : class {\r
+            return TryUpdateModel(model, null, includeProperties, null, ValueProvider);\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties) where TModel : class {\r
+            return TryUpdateModel(model, prefix, includeProperties, null, ValueProvider);\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) where TModel : class {\r
+            return TryUpdateModel(model, prefix, includeProperties, excludeProperties, ValueProvider);\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model, IValueProvider valueProvider) where TModel : class {\r
+            return TryUpdateModel(model, null, null, null, valueProvider);\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model, string prefix, IValueProvider valueProvider) where TModel : class {\r
+            return TryUpdateModel(model, prefix, null, null, valueProvider);\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model, string[] includeProperties, IValueProvider valueProvider) where TModel : class {\r
+            return TryUpdateModel(model, null, includeProperties, null, valueProvider);\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, IValueProvider valueProvider) where TModel : class {\r
+            return TryUpdateModel(model, prefix, includeProperties, null, valueProvider);\r
+        }\r
+\r
+        protected internal bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties, IValueProvider valueProvider) where TModel : class {\r
+            if (model == null) {\r
+                throw new ArgumentNullException("model");\r
+            }\r
+            if (valueProvider == null) {\r
+                throw new ArgumentNullException("valueProvider");\r
+            }\r
+\r
+            Predicate<string> propertyFilter = propertyName => BindAttribute.IsPropertyAllowed(propertyName, includeProperties, excludeProperties);\r
+            IModelBinder binder = Binders.GetBinder(typeof(TModel));\r
+\r
+            ModelBindingContext bindingContext = new ModelBindingContext() {\r
+                ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, typeof(TModel)),\r
+                ModelName = prefix,\r
+                ModelState = ModelState,\r
+                PropertyFilter = propertyFilter,\r
+                ValueProvider = valueProvider\r
+            };\r
+            binder.BindModel(ControllerContext, bindingContext);\r
+            return ModelState.IsValid;\r
+        }\r
+\r
+        protected internal bool TryValidateModel(object model) {\r
+            return TryValidateModel(model, null /* prefix */);\r
+        }\r
+\r
+        protected internal bool TryValidateModel(object model, string prefix) {\r
+            if (model == null) {\r
+                throw new ArgumentNullException("model");\r
+            }\r
+\r
+            ModelMetadata metadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, model.GetType());\r
+\r
+            foreach (ModelValidationResult validationResult in ModelValidator.GetModelValidator(metadata, ControllerContext).Validate(null)) {\r
+                ModelState.AddModelError(DefaultModelBinder.CreateSubPropertyName(prefix, validationResult.MemberName), validationResult.Message);\r
+            }\r
+\r
+            return ModelState.IsValid;\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model) where TModel : class {\r
+            UpdateModel(model, null, null, null, ValueProvider);\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model, string prefix) where TModel : class {\r
+            UpdateModel(model, prefix, null, null, ValueProvider);\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model, string[] includeProperties) where TModel : class {\r
+            UpdateModel(model, null, includeProperties, null, ValueProvider);\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model, string prefix, string[] includeProperties) where TModel : class {\r
+            UpdateModel(model, prefix, includeProperties, null, ValueProvider);\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) where TModel : class {\r
+            UpdateModel(model, prefix, includeProperties, excludeProperties, ValueProvider);\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model, IValueProvider valueProvider) where TModel : class {\r
+            UpdateModel(model, null, null, null, valueProvider);\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model, string prefix, IValueProvider valueProvider) where TModel : class {\r
+            UpdateModel(model, prefix, null, null, valueProvider);\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model, string[] includeProperties, IValueProvider valueProvider) where TModel : class {\r
+            UpdateModel(model, null, includeProperties, null, valueProvider);\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, IValueProvider valueProvider) where TModel : class {\r
+            UpdateModel(model, prefix, includeProperties, null, valueProvider);\r
+        }\r
+\r
+        protected internal void UpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties, IValueProvider valueProvider) where TModel : class {\r
+            bool success = TryUpdateModel(model, prefix, includeProperties, excludeProperties, valueProvider);\r
+            if (!success) {\r
+                string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.Controller_UpdateModel_UpdateUnsuccessful,\r
+                    typeof(TModel).FullName);\r
+                throw new InvalidOperationException(message);\r
+            }\r
+        }\r
+\r
+        protected internal void ValidateModel(object model) {\r
+            ValidateModel(model, null /* prefix */);\r
+        }\r
+\r
+        protected internal void ValidateModel(object model, string prefix) {\r
+            if (!TryValidateModel(model, prefix)) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.Controller_Validate_ValidationFailed,\r
+                        model.GetType().FullName\r
+                    )\r
+                );\r
+            }\r
+        }\r
+\r
+        protected internal ViewResult View() {\r
+            return View(null /* viewName */, null /* masterName */, null /* model */);\r
+        }\r
+\r
+        protected internal ViewResult View(object model) {\r
+            return View(null /* viewName */, null /* masterName */, model);\r
+        }\r
+\r
+        protected internal ViewResult View(string viewName) {\r
+            return View(viewName, null /* masterName */, null /* model */);\r
+        }\r
+\r
+        protected internal ViewResult View(string viewName, string masterName) {\r
+            return View(viewName, masterName, null /* model */);\r
+        }\r
+\r
+        protected internal ViewResult View(string viewName, object model) {\r
+            return View(viewName, null /* masterName */, model);\r
+        }\r
+\r
+        protected internal virtual ViewResult View(string viewName, string masterName, object model) {\r
+            if (model != null) {\r
+                ViewData.Model = model;\r
+            }\r
+\r
+            return new ViewResult {\r
+                ViewName = viewName,\r
+                MasterName = masterName,\r
+                ViewData = ViewData,\r
+                TempData = TempData\r
+            };\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames", MessageId = "0#",\r
+            Justification = "The method name 'View' is a convenient shorthand for 'CreateViewResult'.")]\r
+        protected internal ViewResult View(IView view) {\r
+            return View(view, null /* model */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames", MessageId = "0#",\r
+            Justification = "The method name 'View' is a convenient shorthand for 'CreateViewResult'.")]\r
+        protected internal virtual ViewResult View(IView view, object model) {\r
+            if (model != null) {\r
+                ViewData.Model = model;\r
+            }\r
+\r
+            return new ViewResult {\r
+                View = view,\r
+                ViewData = ViewData,\r
+                TempData = TempData\r
+            };\r
+        }\r
+\r
+        #region IActionFilter Members\r
+        void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext) {\r
+            OnActionExecuting(filterContext);\r
+        }\r
+\r
+        void IActionFilter.OnActionExecuted(ActionExecutedContext filterContext) {\r
+            OnActionExecuted(filterContext);\r
+        }\r
+        #endregion\r
+\r
+        #region IAuthorizationFilter Members\r
+        void IAuthorizationFilter.OnAuthorization(AuthorizationContext filterContext) {\r
+            OnAuthorization(filterContext);\r
+        }\r
+        #endregion\r
+\r
+        #region IExceptionFilter Members\r
+        void IExceptionFilter.OnException(ExceptionContext filterContext) {\r
+            OnException(filterContext);\r
+        }\r
+        #endregion\r
+\r
+        #region IResultFilter Members\r
+        void IResultFilter.OnResultExecuting(ResultExecutingContext filterContext) {\r
+            OnResultExecuting(filterContext);\r
+        }\r
+\r
+        void IResultFilter.OnResultExecuted(ResultExecutedContext filterContext) {\r
+            OnResultExecuted(filterContext);\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerActionInvoker.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerActionInvoker.cs
new file mode 100644 (file)
index 0000000..aad3e81
--- /dev/null
@@ -0,0 +1,333 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Threading;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ControllerActionInvoker : IActionInvoker {\r
+\r
+        private readonly static ControllerDescriptorCache _staticDescriptorCache = new ControllerDescriptorCache();\r
+\r
+        private ModelBinderDictionary _binders;\r
+        private ControllerDescriptorCache _instanceDescriptorCache;\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "Property is settable so that the dictionary can be provided for unit testing purposes.")]\r
+        protected internal ModelBinderDictionary Binders {\r
+            get {\r
+                if (_binders == null) {\r
+                    _binders = ModelBinders.Binders;\r
+                }\r
+                return _binders;\r
+            }\r
+            set {\r
+                _binders = value;\r
+            }\r
+        }\r
+\r
+        internal ControllerDescriptorCache DescriptorCache {\r
+            get {\r
+                if (_instanceDescriptorCache == null) {\r
+                    _instanceDescriptorCache = _staticDescriptorCache;\r
+                }\r
+                return _instanceDescriptorCache;\r
+            }\r
+            set {\r
+                _instanceDescriptorCache = value;\r
+            }\r
+        }\r
+\r
+        private static void AddControllerToFilterList<TFilter>(ControllerBase controller, IList<TFilter> filterList) where TFilter : class {\r
+            TFilter controllerAsFilter = controller as TFilter;\r
+            if (controllerAsFilter != null) {\r
+                filterList.Insert(0, controllerAsFilter);\r
+            }\r
+        }\r
+\r
+        protected virtual ActionResult CreateActionResult(ControllerContext controllerContext, ActionDescriptor actionDescriptor, object actionReturnValue) {\r
+            if (actionReturnValue == null) {\r
+                return new EmptyResult();\r
+            }\r
+\r
+            ActionResult actionResult = (actionReturnValue as ActionResult) ??\r
+                new ContentResult { Content = Convert.ToString(actionReturnValue, CultureInfo.InvariantCulture) };\r
+            return actionResult;\r
+        }\r
+\r
+        protected virtual ControllerDescriptor GetControllerDescriptor(ControllerContext controllerContext) {\r
+            Type controllerType = controllerContext.Controller.GetType();\r
+            ControllerDescriptor controllerDescriptor = DescriptorCache.GetDescriptor(controllerType, () => new ReflectedControllerDescriptor(controllerType));\r
+            return controllerDescriptor;\r
+        }\r
+\r
+        protected virtual ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName) {\r
+            ActionDescriptor actionDescriptor = controllerDescriptor.FindAction(controllerContext, actionName);\r
+            return actionDescriptor;\r
+        }\r
+\r
+        protected virtual FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) {\r
+            FilterInfo filters = actionDescriptor.GetFilters();\r
+\r
+            // if the current controller implements one of the filter interfaces, it should be added to the list at position 0\r
+            ControllerBase controller = controllerContext.Controller;\r
+            AddControllerToFilterList(controller, filters.ActionFilters);\r
+            AddControllerToFilterList(controller, filters.ResultFilters);\r
+            AddControllerToFilterList(controller, filters.AuthorizationFilters);\r
+            AddControllerToFilterList(controller, filters.ExceptionFilters);\r
+\r
+            return filters;\r
+        }\r
+\r
+        private IModelBinder GetModelBinder(ParameterDescriptor parameterDescriptor) {\r
+            // look on the parameter itself, then look in the global table\r
+            return parameterDescriptor.BindingInfo.Binder ?? Binders.GetBinder(parameterDescriptor.ParameterType);\r
+        }\r
+\r
+        protected virtual object GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) {\r
+            // collect all of the necessary binding properties\r
+            Type parameterType = parameterDescriptor.ParameterType;\r
+            IModelBinder binder = GetModelBinder(parameterDescriptor);\r
+            IValueProvider valueProvider = controllerContext.Controller.ValueProvider;\r
+            string parameterName = parameterDescriptor.BindingInfo.Prefix ?? parameterDescriptor.ParameterName;\r
+            Predicate<string> propertyFilter = GetPropertyFilter(parameterDescriptor);\r
+\r
+            // finally, call into the binder\r
+            ModelBindingContext bindingContext = new ModelBindingContext() {\r
+                FallbackToEmptyPrefix = (parameterDescriptor.BindingInfo.Prefix == null), // only fall back if prefix not specified\r
+                ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, parameterType),\r
+                ModelName = parameterName,\r
+                ModelState = controllerContext.Controller.ViewData.ModelState,\r
+                PropertyFilter = propertyFilter,\r
+                ValueProvider = valueProvider\r
+            };\r
+\r
+            object result = binder.BindModel(controllerContext, bindingContext);\r
+            return result ?? parameterDescriptor.DefaultValue;\r
+        }\r
+\r
+        protected virtual IDictionary<string, object> GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) {\r
+            Dictionary<string, object> parametersDict = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);\r
+            ParameterDescriptor[] parameterDescriptors = actionDescriptor.GetParameters();\r
+\r
+            foreach (ParameterDescriptor parameterDescriptor in parameterDescriptors) {\r
+                parametersDict[parameterDescriptor.ParameterName] = GetParameterValue(controllerContext, parameterDescriptor);\r
+            }\r
+            return parametersDict;\r
+        }\r
+\r
+        private static Predicate<string> GetPropertyFilter(ParameterDescriptor parameterDescriptor) {\r
+            ParameterBindingInfo bindingInfo = parameterDescriptor.BindingInfo;\r
+            return propertyName => BindAttribute.IsPropertyAllowed(propertyName, bindingInfo.Include.ToArray(), bindingInfo.Exclude.ToArray());\r
+        }\r
+\r
+        public virtual bool InvokeAction(ControllerContext controllerContext, string actionName) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (String.IsNullOrEmpty(actionName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName");\r
+            }\r
+\r
+            ControllerDescriptor controllerDescriptor = GetControllerDescriptor(controllerContext);\r
+            ActionDescriptor actionDescriptor = FindAction(controllerContext, controllerDescriptor, actionName);\r
+            if (actionDescriptor != null) {\r
+                FilterInfo filterInfo = GetFilters(controllerContext, actionDescriptor);\r
+\r
+                try {\r
+                    AuthorizationContext authContext = InvokeAuthorizationFilters(controllerContext, filterInfo.AuthorizationFilters, actionDescriptor);\r
+                    if (authContext.Result != null) {\r
+                        // the auth filter signaled that we should let it short-circuit the request\r
+                        InvokeActionResult(controllerContext, authContext.Result);\r
+                    }\r
+                    else {\r
+                        if (controllerContext.Controller.ValidateRequest) {\r
+                            ValidateRequest(controllerContext);\r
+                        }\r
+\r
+                        IDictionary<string, object> parameters = GetParameterValues(controllerContext, actionDescriptor);\r
+                        ActionExecutedContext postActionContext = InvokeActionMethodWithFilters(controllerContext, filterInfo.ActionFilters, actionDescriptor, parameters);\r
+                        InvokeActionResultWithFilters(controllerContext, filterInfo.ResultFilters, postActionContext.Result);\r
+                    }\r
+                }\r
+                catch (ThreadAbortException) {\r
+                    // This type of exception occurs as a result of Response.Redirect(), but we special-case so that\r
+                    // the filters don't see this as an error.\r
+                    throw;\r
+                }\r
+                catch (Exception ex) {\r
+                    // something blew up, so execute the exception filters\r
+                    ExceptionContext exceptionContext = InvokeExceptionFilters(controllerContext, filterInfo.ExceptionFilters, ex);\r
+                    if (!exceptionContext.ExceptionHandled) {\r
+                        throw;\r
+                    }\r
+                    InvokeActionResult(controllerContext, exceptionContext.Result);\r
+                }\r
+\r
+                return true;\r
+            }\r
+\r
+            // notify controller that no method matched\r
+            return false;\r
+        }\r
+\r
+        protected virtual ActionResult InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<string, object> parameters) {\r
+            object returnValue = actionDescriptor.Execute(controllerContext, parameters);\r
+            ActionResult result = CreateActionResult(controllerContext, actionDescriptor, returnValue);\r
+            return result;\r
+        }\r
+\r
+        internal static ActionExecutedContext InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func<ActionExecutedContext> continuation) {\r
+            filter.OnActionExecuting(preContext);\r
+            if (preContext.Result != null) {\r
+                return new ActionExecutedContext(preContext, preContext.ActionDescriptor, true /* canceled */, null /* exception */) {\r
+                    Result = preContext.Result\r
+                };\r
+            }\r
+\r
+            bool wasError = false;\r
+            ActionExecutedContext postContext = null;\r
+            try {\r
+                postContext = continuation();\r
+            }\r
+            catch (ThreadAbortException) {\r
+                // This type of exception occurs as a result of Response.Redirect(), but we special-case so that\r
+                // the filters don't see this as an error.\r
+                postContext = new ActionExecutedContext(preContext, preContext.ActionDescriptor, false /* canceled */, null /* exception */);\r
+                filter.OnActionExecuted(postContext);\r
+                throw;\r
+            }\r
+            catch (Exception ex) {\r
+                wasError = true;\r
+                postContext = new ActionExecutedContext(preContext, preContext.ActionDescriptor, false /* canceled */, ex);\r
+                filter.OnActionExecuted(postContext);\r
+                if (!postContext.ExceptionHandled) {\r
+                    throw;\r
+                }\r
+            }\r
+            if (!wasError) {\r
+                filter.OnActionExecuted(postContext);\r
+            }\r
+            return postContext;\r
+        }\r
+\r
+        protected virtual ActionExecutedContext InvokeActionMethodWithFilters(ControllerContext controllerContext, IList<IActionFilter> filters, ActionDescriptor actionDescriptor, IDictionary<string, object> parameters) {\r
+            ActionExecutingContext preContext = new ActionExecutingContext(controllerContext, actionDescriptor, parameters);\r
+            Func<ActionExecutedContext> continuation = () =>\r
+                new ActionExecutedContext(controllerContext, actionDescriptor, false /* canceled */, null /* exception */) {\r
+                    Result = InvokeActionMethod(controllerContext, actionDescriptor, parameters)\r
+                };\r
+\r
+            // need to reverse the filter list because the continuations are built up backward\r
+            Func<ActionExecutedContext> thunk = filters.Reverse().Aggregate(continuation,\r
+                (next, filter) => () => InvokeActionMethodFilter(filter, preContext, next));\r
+            return thunk();\r
+        }\r
+\r
+        protected virtual void InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) {\r
+            actionResult.ExecuteResult(controllerContext);\r
+        }\r
+\r
+        internal static ResultExecutedContext InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func<ResultExecutedContext> continuation) {\r
+            filter.OnResultExecuting(preContext);\r
+            if (preContext.Cancel) {\r
+                return new ResultExecutedContext(preContext, preContext.Result, true /* canceled */, null /* exception */);\r
+            }\r
+\r
+            bool wasError = false;\r
+            ResultExecutedContext postContext = null;\r
+            try {\r
+                postContext = continuation();\r
+            }\r
+            catch (ThreadAbortException) {\r
+                // This type of exception occurs as a result of Response.Redirect(), but we special-case so that\r
+                // the filters don't see this as an error.\r
+                postContext = new ResultExecutedContext(preContext, preContext.Result, false /* canceled */, null /* exception */);\r
+                filter.OnResultExecuted(postContext);\r
+                throw;\r
+            }\r
+            catch (Exception ex) {\r
+                wasError = true;\r
+                postContext = new ResultExecutedContext(preContext, preContext.Result, false /* canceled */, ex);\r
+                filter.OnResultExecuted(postContext);\r
+                if (!postContext.ExceptionHandled) {\r
+                    throw;\r
+                }\r
+            }\r
+            if (!wasError) {\r
+                filter.OnResultExecuted(postContext);\r
+            }\r
+            return postContext;\r
+        }\r
+\r
+        protected virtual ResultExecutedContext InvokeActionResultWithFilters(ControllerContext controllerContext, IList<IResultFilter> filters, ActionResult actionResult) {\r
+            ResultExecutingContext preContext = new ResultExecutingContext(controllerContext, actionResult);\r
+            Func<ResultExecutedContext> continuation = delegate {\r
+                InvokeActionResult(controllerContext, actionResult);\r
+                return new ResultExecutedContext(controllerContext, actionResult, false /* canceled */, null /* exception */);\r
+            };\r
+\r
+            // need to reverse the filter list because the continuations are built up backward\r
+            Func<ResultExecutedContext> thunk = filters.Reverse().Aggregate(continuation,\r
+                (next, filter) => () => InvokeActionResultFilter(filter, preContext, next));\r
+            return thunk();\r
+        }\r
+\r
+        protected virtual AuthorizationContext InvokeAuthorizationFilters(ControllerContext controllerContext, IList<IAuthorizationFilter> filters, ActionDescriptor actionDescriptor) {\r
+            AuthorizationContext context = new AuthorizationContext(controllerContext, actionDescriptor);\r
+            foreach (IAuthorizationFilter filter in filters) {\r
+                filter.OnAuthorization(context);\r
+                // short-circuit evaluation\r
+                if (context.Result != null) {\r
+                    break;\r
+                }\r
+            }\r
+\r
+            return context;\r
+        }\r
+\r
+        protected virtual ExceptionContext InvokeExceptionFilters(ControllerContext controllerContext, IList<IExceptionFilter> filters, Exception exception) {\r
+            ExceptionContext context = new ExceptionContext(controllerContext, exception);\r
+            foreach (IExceptionFilter filter in filters) {\r
+                filter.OnException(context);\r
+            }\r
+\r
+            return context;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "rawUrl",\r
+            Justification = "We only care about the property getter's side effects, not the returned value.")]\r
+        internal static void ValidateRequest(ControllerContext controllerContext) {\r
+            if (controllerContext.IsChildAction) {\r
+                return;\r
+            }\r
+\r
+            // DevDiv 214040: Enable Request Validation by default for all controller requests\r
+            // \r
+            // Note that we grab the Request's RawUrl to force it to be validated. Calling ValidateInput()\r
+            // doesn't actually validate anything. It just sets flags indicating that on the next usage of\r
+            // certain inputs that they should be validated. We special case RawUrl because the URL has already\r
+            // been consumed by routing and thus might contain dangerous data. By forcing the RawUrl to be\r
+            // re-read we're making sure that it gets validated by ASP.NET.\r
+\r
+            controllerContext.HttpContext.Request.ValidateInput();\r
+            string rawUrl = controllerContext.HttpContext.Request.RawUrl;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerBase.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerBase.cs
new file mode 100644 (file)
index 0000000..b5902bd
--- /dev/null
@@ -0,0 +1,116 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Web.Mvc.Async;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public abstract class ControllerBase : IController {\r
+\r
+        private readonly SingleEntryGate _executeWasCalledGate = new SingleEntryGate();\r
+\r
+        private TempDataDictionary _tempDataDictionary;\r
+        private bool _validateRequest = true;\r
+        private IValueProvider _valueProvider;\r
+        private ViewDataDictionary _viewDataDictionary;\r
+\r
+        public ControllerContext ControllerContext {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "This property is settable so that unit tests can provide mock implementations.")]\r
+        public TempDataDictionary TempData {\r
+            get {\r
+                if (ControllerContext != null && ControllerContext.IsChildAction) {\r
+                    return ControllerContext.ParentActionViewContext.TempData;\r
+                }\r
+                if (_tempDataDictionary == null) {\r
+                    _tempDataDictionary = new TempDataDictionary();\r
+                }\r
+                return _tempDataDictionary;\r
+            }\r
+            set {\r
+                _tempDataDictionary = value;\r
+            }\r
+        }\r
+\r
+        public bool ValidateRequest {\r
+            get {\r
+                return _validateRequest;\r
+            }\r
+            set {\r
+                _validateRequest = value;\r
+            }\r
+        }\r
+\r
+        public IValueProvider ValueProvider {\r
+            get {\r
+                if (_valueProvider == null) {\r
+                    _valueProvider = ValueProviderFactories.Factories.GetValueProvider(ControllerContext);\r
+                }\r
+                return _valueProvider;\r
+            }\r
+            set {\r
+                _valueProvider = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "This property is settable so that unit tests can provide mock implementations.")]\r
+        public ViewDataDictionary ViewData {\r
+            get {\r
+                if (_viewDataDictionary == null) {\r
+                    _viewDataDictionary = new ViewDataDictionary();\r
+                }\r
+                return _viewDataDictionary;\r
+            }\r
+            set {\r
+                _viewDataDictionary = value;\r
+            }\r
+        }\r
+\r
+        protected virtual void Execute(RequestContext requestContext) {\r
+            if (requestContext == null) {\r
+                throw new ArgumentNullException("requestContext");\r
+            }\r
+\r
+            VerifyExecuteCalledOnce();\r
+            Initialize(requestContext);\r
+            ExecuteCore();\r
+        }\r
+\r
+        protected abstract void ExecuteCore();\r
+\r
+        protected virtual void Initialize(RequestContext requestContext) {\r
+            ControllerContext = new ControllerContext(requestContext, this);\r
+        }\r
+\r
+        internal void VerifyExecuteCalledOnce() {\r
+            if (!_executeWasCalledGate.TryEnter()) {\r
+                string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ControllerBase_CannotHandleMultipleRequests, GetType());\r
+                throw new InvalidOperationException(message);\r
+            }\r
+        }\r
+\r
+        #region IController Members\r
+        void IController.Execute(RequestContext requestContext) {\r
+            Execute(requestContext);\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerBuilder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerBuilder.cs
new file mode 100644 (file)
index 0000000..c86f740
--- /dev/null
@@ -0,0 +1,87 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ControllerBuilder {\r
+\r
+        private Func<IControllerFactory> _factoryThunk;\r
+        private static ControllerBuilder _instance = new ControllerBuilder();\r
+        private HashSet<string> _namespaces = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\r
+\r
+        public ControllerBuilder() {\r
+            SetControllerFactory(new DefaultControllerFactory() {\r
+                ControllerBuilder = this\r
+            });\r
+        }\r
+\r
+        public static ControllerBuilder Current {\r
+            get {\r
+                return _instance;\r
+            }\r
+        }\r
+\r
+        public HashSet<string> DefaultNamespaces {\r
+            get {\r
+                return _namespaces;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",\r
+            Justification = "Calling method multiple times might return different objects.")]\r
+        public IControllerFactory GetControllerFactory() {\r
+            IControllerFactory controllerFactoryInstance = _factoryThunk();\r
+            return controllerFactoryInstance;\r
+        }\r
+\r
+        public void SetControllerFactory(IControllerFactory controllerFactory) {\r
+            if (controllerFactory == null) {\r
+                throw new ArgumentNullException("controllerFactory");\r
+            }\r
+\r
+            _factoryThunk = () => controllerFactory;\r
+        }\r
+\r
+        public void SetControllerFactory(Type controllerFactoryType) {\r
+            if (controllerFactoryType == null) {\r
+                throw new ArgumentNullException("controllerFactoryType");\r
+            }\r
+            if (!typeof(IControllerFactory).IsAssignableFrom(controllerFactoryType)) {\r
+                throw new ArgumentException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.ControllerBuilder_MissingIControllerFactory,\r
+                        controllerFactoryType),\r
+                    "controllerFactoryType");\r
+            }\r
+\r
+            _factoryThunk = delegate() {\r
+                try {\r
+                    return (IControllerFactory)Activator.CreateInstance(controllerFactoryType);\r
+                }\r
+                catch (Exception ex) {\r
+                    throw new InvalidOperationException(\r
+                        String.Format(\r
+                            CultureInfo.CurrentUICulture,\r
+                            MvcResources.ControllerBuilder_ErrorCreatingControllerFactory,\r
+                            controllerFactoryType),\r
+                        ex);\r
+                }\r
+            };\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerContext.cs
new file mode 100644 (file)
index 0000000..2262501
--- /dev/null
@@ -0,0 +1,134 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Web;\r
+    using System.Web.Routing;\r
+    using System.Web.Mvc.Html;\r
+\r
+    // Though many of the properties on ControllerContext and its subclassed types are virtual, there are still sealed\r
+    // properties (like ControllerContext.RequestContext, ActionExecutingContext.Result, etc.). If these properties\r
+    // were virtual, a mocking framework might override them with incorrect behavior (property getters would return\r
+    // null, property setters would be no-ops). By sealing these properties, we are forcing them to have the default\r
+    // "get or store a value" semantics that they were intended to have.\r
+\r
+    public class ControllerContext {\r
+\r
+        private HttpContextBase _httpContext;\r
+        private RequestContext _requestContext;\r
+        private RouteData _routeData;\r
+\r
+        internal const string PARENT_ACTION_VIEWCONTEXT = "ParentActionViewContext";\r
+\r
+        // parameterless constructor used for mocking\r
+        public ControllerContext() {\r
+        }\r
+\r
+        // copy constructor - allows for subclassed types to take an existing ControllerContext as a parameter\r
+        // and we'll automatically set the appropriate properties\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
+        protected ControllerContext(ControllerContext controllerContext) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+\r
+            Controller = controllerContext.Controller;\r
+            RequestContext = controllerContext.RequestContext;\r
+        }\r
+\r
+        public ControllerContext(HttpContextBase httpContext, RouteData routeData, ControllerBase controller)\r
+            : this(new RequestContext(httpContext, routeData), controller) {\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
+        public ControllerContext(RequestContext requestContext, ControllerBase controller) {\r
+            if (requestContext == null) {\r
+                throw new ArgumentNullException("requestContext");\r
+            }\r
+            if (controller == null) {\r
+                throw new ArgumentNullException("controller");\r
+            }\r
+\r
+            RequestContext = requestContext;\r
+            Controller = controller;\r
+        }\r
+\r
+        public virtual ControllerBase Controller {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual HttpContextBase HttpContext {\r
+            get {\r
+                if (_httpContext == null) {\r
+                    _httpContext = (_requestContext != null) ? _requestContext.HttpContext : new EmptyHttpContext();\r
+                }\r
+                return _httpContext;\r
+            }\r
+            set {\r
+                _httpContext = value;\r
+            }\r
+        }\r
+\r
+        public virtual bool IsChildAction {\r
+            get {\r
+                RouteData routeData = RouteData;\r
+                if (routeData == null) {\r
+                    return false;\r
+                }\r
+                return routeData.DataTokens.ContainsKey(PARENT_ACTION_VIEWCONTEXT);\r
+            }\r
+        }\r
+\r
+        public ViewContext ParentActionViewContext {\r
+            get {\r
+                return RouteData.DataTokens[PARENT_ACTION_VIEWCONTEXT] as ViewContext;\r
+            }\r
+        }\r
+\r
+        public RequestContext RequestContext {\r
+            get {\r
+                if (_requestContext == null) {\r
+                    // still need explicit calls to constructors since the property getters are virtual and might return null\r
+                    HttpContextBase httpContext = HttpContext ?? new EmptyHttpContext();\r
+                    RouteData routeData = RouteData ?? new RouteData();\r
+\r
+                    _requestContext = new RequestContext(httpContext, routeData);\r
+                }\r
+                return _requestContext;\r
+            }\r
+            set {\r
+                _requestContext = value;\r
+            }\r
+        }\r
+\r
+        public virtual RouteData RouteData {\r
+            get {\r
+                if (_routeData == null) {\r
+                    _routeData = (_requestContext != null) ? _requestContext.RouteData : new RouteData();\r
+                }\r
+                return _routeData;\r
+            }\r
+            set {\r
+                _routeData = value;\r
+            }\r
+        }\r
+\r
+        private sealed class EmptyHttpContext : HttpContextBase {\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerDescriptor.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerDescriptor.cs
new file mode 100644 (file)
index 0000000..abb7c23
--- /dev/null
@@ -0,0 +1,59 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+\r
+    public abstract class ControllerDescriptor : ICustomAttributeProvider {\r
+\r
+        public virtual string ControllerName {\r
+            get {\r
+                string typeName = ControllerType.Name;\r
+                if (typeName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase)) {\r
+                    return typeName.Substring(0, typeName.Length - "Controller".Length);\r
+                }\r
+\r
+                return typeName;\r
+            }\r
+        }\r
+\r
+        public abstract Type ControllerType {\r
+            get;\r
+        }\r
+\r
+        public abstract ActionDescriptor FindAction(ControllerContext controllerContext, string actionName);\r
+\r
+        public abstract ActionDescriptor[] GetCanonicalActions();\r
+\r
+        public virtual object[] GetCustomAttributes(bool inherit) {\r
+            return GetCustomAttributes(typeof(object), inherit);\r
+        }\r
+\r
+        public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) {\r
+            if (attributeType == null) {\r
+                throw new ArgumentNullException("attributeType");\r
+            }\r
+\r
+            return (object[])Array.CreateInstance(attributeType, 0);\r
+        }\r
+\r
+        public virtual bool IsDefined(Type attributeType, bool inherit) {\r
+            if (attributeType == null) {\r
+                throw new ArgumentNullException("attributeType");\r
+            }\r
+\r
+            return false;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerDescriptorCache.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerDescriptorCache.cs
new file mode 100644 (file)
index 0000000..43ed25e
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    internal sealed class ControllerDescriptorCache : ReaderWriterCache<Type, ControllerDescriptor> {\r
+\r
+        public ControllerDescriptorCache() {\r
+        }\r
+\r
+        public ControllerDescriptor GetDescriptor(Type controllerType, Func<ControllerDescriptor> creator) {\r
+            return FetchOrCreateItem(controllerType, creator);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerTypeCache.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerTypeCache.cs
new file mode 100644 (file)
index 0000000..bea8005
--- /dev/null
@@ -0,0 +1,127 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+\r
+    internal sealed class ControllerTypeCache {\r
+\r
+        private const string _typeCacheName = "MVC-ControllerTypeCache.xml";\r
+\r
+        private Dictionary<string, ILookup<string, Type>> _cache;\r
+        private object _lockObj = new object();\r
+\r
+        internal int Count {\r
+            get {\r
+                int count = 0;\r
+                foreach (var lookup in _cache.Values) {\r
+                    foreach (var grouping in lookup) {\r
+                        count += grouping.Count();\r
+                    }\r
+                }\r
+                return count;\r
+            }\r
+        }\r
+\r
+        public void EnsureInitialized(IBuildManager buildManager) {\r
+            if (_cache == null) {\r
+                lock (_lockObj) {\r
+                    if (_cache == null) {\r
+                        List<Type> controllerTypes = TypeCacheUtil.GetFilteredTypesFromAssemblies(_typeCacheName, IsControllerType, buildManager);\r
+                        var groupedByName = controllerTypes.GroupBy(\r
+                            t => t.Name.Substring(0, t.Name.Length - "Controller".Length),\r
+                            StringComparer.OrdinalIgnoreCase);\r
+                        _cache = groupedByName.ToDictionary(\r
+                            g => g.Key,\r
+                            g => g.ToLookup(t => t.Namespace ?? String.Empty, StringComparer.OrdinalIgnoreCase),\r
+                            StringComparer.OrdinalIgnoreCase);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        public ICollection<Type> GetControllerTypes(string controllerName, HashSet<string> namespaces) {\r
+            HashSet<Type> matchingTypes = new HashSet<Type>();\r
+\r
+            ILookup<string, Type> nsLookup;\r
+            if (_cache.TryGetValue(controllerName, out nsLookup)) {\r
+                // this friendly name was located in the cache, now cycle through namespaces\r
+                if (namespaces != null) {\r
+                    foreach (string requestedNamespace in namespaces) {\r
+                        foreach (var targetNamespaceGrouping in nsLookup) {\r
+                            if (IsNamespaceMatch(requestedNamespace, targetNamespaceGrouping.Key)) {\r
+                                matchingTypes.UnionWith(targetNamespaceGrouping);\r
+                            }\r
+                        }\r
+                    }\r
+                }\r
+                else {\r
+                    // if the namespaces parameter is null, search *every* namespace\r
+                    foreach (var nsGroup in nsLookup) {\r
+                        matchingTypes.UnionWith(nsGroup);\r
+                    }\r
+                }\r
+            }\r
+\r
+            return matchingTypes;\r
+        }\r
+\r
+        internal static bool IsControllerType(Type t) {\r
+            return\r
+                t != null &&\r
+                t.IsPublic &&\r
+                t.Name.EndsWith("Controller", StringComparison.OrdinalIgnoreCase) &&\r
+                !t.IsAbstract &&\r
+                typeof(IController).IsAssignableFrom(t);\r
+        }\r
+\r
+        internal static bool IsNamespaceMatch(string requestedNamespace, string targetNamespace) {\r
+            // degenerate cases\r
+            if (requestedNamespace == null) {\r
+                return false;\r
+            }\r
+            else if (requestedNamespace.Length == 0) {\r
+                return true;\r
+            }\r
+\r
+            if (!requestedNamespace.EndsWith(".*", StringComparison.OrdinalIgnoreCase)) {\r
+                // looking for exact namespace match\r
+                return String.Equals(requestedNamespace, targetNamespace, StringComparison.OrdinalIgnoreCase);\r
+            }\r
+            else {\r
+                // looking for exact or sub-namespace match\r
+                requestedNamespace = requestedNamespace.Substring(0, requestedNamespace.Length - ".*".Length);\r
+                if (!targetNamespace.StartsWith(requestedNamespace, StringComparison.OrdinalIgnoreCase)) {\r
+                    return false;\r
+                }\r
+\r
+                if (requestedNamespace.Length == targetNamespace.Length) {\r
+                    // exact match\r
+                    return true;\r
+                }\r
+                else if (targetNamespace[requestedNamespace.Length] == '.') {\r
+                    // good prefix match, e.g. requestedNamespace = "Foo.Bar" and targetNamespace = "Foo.Bar.Baz"\r
+                    return true;\r
+                }\r
+                else {\r
+                    // bad prefix match, e.g. requestedNamespace = "Foo.Bar" and targetNamespace = "Foo.Bar2"\r
+                    return false;\r
+                }\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/CustomModelBinderAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/CustomModelBinderAttribute.cs
new file mode 100644 (file)
index 0000000..c086781
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    [AttributeUsage(ValidTargets, AllowMultiple = false, Inherited = false)]\r
+    public abstract class CustomModelBinderAttribute : Attribute {\r
+\r
+        internal const AttributeTargets ValidTargets = AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Struct;\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",\r
+            Justification = "This method can potentially perform a non-trivial amount of work.")]\r
+        public abstract IModelBinder GetBinder();\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelMetadata.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelMetadata.cs
new file mode 100644 (file)
index 0000000..aba69fa
--- /dev/null
@@ -0,0 +1,63 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.ComponentModel.DataAnnotations;\r
+    using System.Globalization;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class DataAnnotationsModelMetadata : ModelMetadata {\r
+        private DisplayColumnAttribute _displayColumnAttribute;\r
+\r
+        public DataAnnotationsModelMetadata(DataAnnotationsModelMetadataProvider provider, Type containerType,\r
+                                            Func<object> modelAccessor, Type modelType, string propertyName,\r
+                                            DisplayColumnAttribute displayColumnAttribute)\r
+            : base(provider, containerType, modelAccessor, modelType, propertyName) {\r
+            _displayColumnAttribute = displayColumnAttribute;\r
+        }\r
+\r
+        protected override string GetSimpleDisplayText() {\r
+            if (Model != null) {\r
+                if (_displayColumnAttribute != null && !String.IsNullOrEmpty(_displayColumnAttribute.DisplayColumn)) {\r
+                    PropertyInfo displayColumnProperty = ModelType.GetProperty(_displayColumnAttribute.DisplayColumn, BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance);\r
+                    ValidateDisplayColumnAttribute(_displayColumnAttribute, displayColumnProperty, ModelType);\r
+\r
+                    object simpleDisplayTextValue = displayColumnProperty.GetValue(Model, new object[0]);\r
+                    if (simpleDisplayTextValue != null) {\r
+                        return simpleDisplayTextValue.ToString();\r
+                    }\r
+                }\r
+            }\r
+\r
+            return base.GetSimpleDisplayText();\r
+        }\r
+\r
+        private static void ValidateDisplayColumnAttribute(DisplayColumnAttribute displayColumnAttribute, PropertyInfo displayColumnProperty, Type modelType) {\r
+            if (displayColumnProperty == null) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentCulture,\r
+                        MvcResources.DataAnnotationsModelMetadataProvider_UnknownProperty,\r
+                        modelType.FullName, displayColumnAttribute.DisplayColumn));\r
+            }\r
+            if (displayColumnProperty.GetGetMethod() == null) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentCulture,\r
+                        MvcResources.DataAnnotationsModelMetadataProvider_UnreadableProperty,\r
+                        modelType.FullName, displayColumnAttribute.DisplayColumn));\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelMetadataProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelMetadataProvider.cs
new file mode 100644 (file)
index 0000000..7dffa9b
--- /dev/null
@@ -0,0 +1,83 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel;\r
+    using System.ComponentModel.DataAnnotations;\r
+    using System.Linq;\r
+\r
+    public class DataAnnotationsModelMetadataProvider : AssociatedMetadataProvider {\r
+        protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName) {\r
+            List<Attribute> attributeList = new List<Attribute>(attributes);\r
+            DisplayColumnAttribute displayColumnAttribute = attributeList.OfType<DisplayColumnAttribute>().FirstOrDefault();\r
+            DataAnnotationsModelMetadata result = new DataAnnotationsModelMetadata(this, containerType, modelAccessor, modelType, propertyName, displayColumnAttribute);\r
+\r
+            // Do [HiddenInput] before [UIHint], so you can override the template hint\r
+            HiddenInputAttribute hiddenInputAttribute = attributeList.OfType<HiddenInputAttribute>().FirstOrDefault();\r
+            if (hiddenInputAttribute != null) {\r
+                result.TemplateHint = "HiddenInput";\r
+                result.HideSurroundingHtml = !hiddenInputAttribute.DisplayValue;\r
+            }\r
+\r
+            // We prefer [UIHint("...", PresentationLayer = "MVC")] but will fall back to [UIHint("...")]\r
+            IEnumerable<UIHintAttribute> uiHintAttributes = attributeList.OfType<UIHintAttribute>();\r
+            UIHintAttribute uiHintAttribute = uiHintAttributes.FirstOrDefault(a => String.Equals(a.PresentationLayer, "MVC", StringComparison.OrdinalIgnoreCase))\r
+                                           ?? uiHintAttributes.FirstOrDefault(a => String.IsNullOrEmpty(a.PresentationLayer));\r
+            if (uiHintAttribute != null) {\r
+                result.TemplateHint = uiHintAttribute.UIHint;\r
+            }\r
+\r
+            DataTypeAttribute dataTypeAttribute = attributeList.OfType<DataTypeAttribute>().FirstOrDefault();\r
+            if (dataTypeAttribute != null) {\r
+                result.DataTypeName = dataTypeAttribute.GetDataTypeName();\r
+            }\r
+\r
+            ReadOnlyAttribute readOnlyAttribute = attributeList.OfType<ReadOnlyAttribute>().FirstOrDefault();\r
+            if (readOnlyAttribute != null) {\r
+                result.IsReadOnly = readOnlyAttribute.IsReadOnly;\r
+            }\r
+\r
+            DisplayFormatAttribute displayFormatAttribute = attributeList.OfType<DisplayFormatAttribute>().FirstOrDefault();\r
+            if (displayFormatAttribute == null && dataTypeAttribute != null) {\r
+                displayFormatAttribute = dataTypeAttribute.DisplayFormat;\r
+            }\r
+            if (displayFormatAttribute != null) {\r
+                result.NullDisplayText = displayFormatAttribute.NullDisplayText;\r
+                result.DisplayFormatString = displayFormatAttribute.DataFormatString;\r
+                result.ConvertEmptyStringToNull = displayFormatAttribute.ConvertEmptyStringToNull;\r
+\r
+                if (displayFormatAttribute.ApplyFormatInEditMode) {\r
+                    result.EditFormatString = displayFormatAttribute.DataFormatString;\r
+                }\r
+            }\r
+\r
+            ScaffoldColumnAttribute scaffoldColumnAttribute = attributeList.OfType<ScaffoldColumnAttribute>().FirstOrDefault();\r
+            if (scaffoldColumnAttribute != null) {\r
+                result.ShowForDisplay = result.ShowForEdit = scaffoldColumnAttribute.Scaffold;\r
+            }\r
+\r
+            DisplayNameAttribute displayNameAttribute = attributeList.OfType<DisplayNameAttribute>().FirstOrDefault();\r
+            if (displayNameAttribute != null) {\r
+                result.DisplayName = displayNameAttribute.DisplayName;\r
+            }\r
+\r
+            RequiredAttribute requiredAttribute = attributeList.OfType<RequiredAttribute>().FirstOrDefault();\r
+            if (requiredAttribute != null) {\r
+                result.IsRequired = true;\r
+            }\r
+\r
+            return result;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelValidator.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelValidator.cs
new file mode 100644 (file)
index 0000000..7b83c66
--- /dev/null
@@ -0,0 +1,55 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel.DataAnnotations;\r
+\r
+    public class DataAnnotationsModelValidator : ModelValidator {\r
+        public DataAnnotationsModelValidator(ModelMetadata metadata, ControllerContext context, ValidationAttribute attribute)\r
+            : base(metadata, context) {\r
+\r
+            if (attribute == null) {\r
+                throw new ArgumentNullException("attribute");\r
+            }\r
+\r
+            Attribute = attribute;\r
+        }\r
+\r
+        protected internal ValidationAttribute Attribute { get; private set; }\r
+\r
+        protected internal string ErrorMessage {\r
+            get {\r
+                return Attribute.FormatErrorMessage(Metadata.GetDisplayName());\r
+            }\r
+        }\r
+\r
+        public override bool IsRequired {\r
+            get {\r
+                return Attribute is RequiredAttribute;\r
+            }\r
+        }\r
+\r
+        internal static ModelValidator Create(ModelMetadata metadata, ControllerContext context, ValidationAttribute attribute) {\r
+            return new DataAnnotationsModelValidator(metadata, context, attribute);\r
+        }\r
+\r
+        public override IEnumerable<ModelValidationResult> Validate(object container) {\r
+            if (!Attribute.IsValid(Metadata.Model)) {\r
+                yield return new ModelValidationResult {\r
+                    Message = ErrorMessage\r
+                };\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelValidatorProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelValidatorProvider.cs
new file mode 100644 (file)
index 0000000..3e0c97f
--- /dev/null
@@ -0,0 +1,187 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel.DataAnnotations;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Threading;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public delegate ModelValidator DataAnnotationsModelValidationFactory(ModelMetadata metadata, ControllerContext context, ValidationAttribute attribute);\r
+\r
+    public class DataAnnotationsModelValidatorProvider : AssociatedValidatorProvider {\r
+        private static bool _addImplicitRequiredAttributeForValueTypes = true;\r
+        private static ReaderWriterLockSlim _adaptersLock = new ReaderWriterLockSlim();\r
+\r
+        internal static DataAnnotationsModelValidationFactory DefaultAttributeFactory = DataAnnotationsModelValidator.Create;\r
+        internal static Dictionary<Type, DataAnnotationsModelValidationFactory> AttributeFactories = new Dictionary<Type, DataAnnotationsModelValidationFactory>() {\r
+            {\r
+                typeof(RangeAttribute),\r
+                (metadata, context, attribute) => new RangeAttributeAdapter(metadata, context, (RangeAttribute)attribute)\r
+            },\r
+            {\r
+                typeof(RegularExpressionAttribute),\r
+                (metadata, context, attribute) => new RegularExpressionAttributeAdapter(metadata, context, (RegularExpressionAttribute)attribute)\r
+            },\r
+            {\r
+                typeof(RequiredAttribute),\r
+                (metadata, context, attribute) => new RequiredAttributeAdapter(metadata, context, (RequiredAttribute)attribute)\r
+            },\r
+            {\r
+                typeof(StringLengthAttribute),\r
+                (metadata, context, attribute) => new StringLengthAttributeAdapter(metadata, context, (StringLengthAttribute)attribute)\r
+            },\r
+        };\r
+\r
+        public static bool AddImplicitRequiredAttributeForValueTypes {\r
+            get {\r
+                return _addImplicitRequiredAttributeForValueTypes;\r
+            }\r
+            set {\r
+                _addImplicitRequiredAttributeForValueTypes = value;\r
+            }\r
+        }\r
+\r
+        protected override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context, IEnumerable<Attribute> attributes) {\r
+            _adaptersLock.EnterReadLock();\r
+\r
+            try {\r
+                List<ModelValidator> results = new List<ModelValidator>();\r
+\r
+                if (AddImplicitRequiredAttributeForValueTypes &&\r
+                        metadata.IsRequired &&\r
+                        !attributes.Any(a => a is RequiredAttribute)) {\r
+                    attributes = attributes.Concat(new[] { new RequiredAttribute() });\r
+                }\r
+\r
+                foreach (ValidationAttribute attribute in attributes.OfType<ValidationAttribute>()) {\r
+                    DataAnnotationsModelValidationFactory factory;\r
+                    if (!AttributeFactories.TryGetValue(attribute.GetType(), out factory)) {\r
+                        factory = DefaultAttributeFactory;\r
+                    }\r
+                    results.Add(factory(metadata, context, attribute));\r
+                }\r
+\r
+                return results;\r
+            }\r
+            finally {\r
+                _adaptersLock.ExitReadLock();\r
+            }\r
+        }\r
+\r
+        public static void RegisterAdapter(Type attributeType, Type adapterType) {\r
+            ValidateAttributeType(attributeType);\r
+            ValidateAdapterType(adapterType);\r
+            ConstructorInfo constructor = GetAdapterConstructor(attributeType, adapterType);\r
+\r
+            _adaptersLock.EnterWriteLock();\r
+\r
+            try {\r
+                AttributeFactories[attributeType] = (metadata, context, attribute) => (ModelValidator)constructor.Invoke(new object[] { metadata, context, attribute });\r
+            }\r
+            finally {\r
+                _adaptersLock.ExitWriteLock();\r
+            }\r
+        }\r
+\r
+        public static void RegisterAdapterFactory(Type attributeType, DataAnnotationsModelValidationFactory factory) {\r
+            ValidateAttributeType(attributeType);\r
+            ValidateFactory(factory);\r
+\r
+            _adaptersLock.EnterWriteLock();\r
+\r
+            try {\r
+                AttributeFactories[attributeType] = factory;\r
+            }\r
+            finally {\r
+                _adaptersLock.ExitWriteLock();\r
+            }\r
+        }\r
+\r
+        public static void RegisterDefaultAdapter(Type adapterType) {\r
+            ValidateAdapterType(adapterType);\r
+            ConstructorInfo constructor = GetAdapterConstructor(typeof(ValidationAttribute), adapterType);\r
+\r
+            DefaultAttributeFactory = (metadata, context, attribute) => (ModelValidator)constructor.Invoke(new object[] { metadata, context, attribute });\r
+        }\r
+\r
+        public static void RegisterDefaultAdapterFactory(DataAnnotationsModelValidationFactory factory) {\r
+            ValidateFactory(factory);\r
+\r
+            DefaultAttributeFactory = factory;\r
+        }\r
+\r
+        // Helpers\r
+\r
+        private static ConstructorInfo GetAdapterConstructor(Type attributeType, Type adapterType) {\r
+            ConstructorInfo constructor = adapterType.GetConstructor(new[] { typeof(ModelMetadata), typeof(ControllerContext), attributeType });\r
+            if (constructor == null) {\r
+                throw new ArgumentException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentCulture,\r
+                        MvcResources.DataAnnotationsModelValidatorProvider_ConstructorRequirements,\r
+                        adapterType.FullName,\r
+                        typeof(ModelMetadata).FullName,\r
+                        typeof(ControllerContext).FullName,\r
+                        attributeType.FullName\r
+                    ),\r
+                    "adapterType"\r
+                );\r
+            }\r
+\r
+            return constructor;\r
+        }\r
+\r
+        private static void ValidateAdapterType(Type adapterType) {\r
+            if (adapterType == null) {\r
+                throw new ArgumentNullException("adapterType");\r
+            }\r
+            if (!typeof(ModelValidator).IsAssignableFrom(adapterType)) {\r
+                throw new ArgumentException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentCulture,\r
+                        MvcResources.Common_TypeMustDriveFromType,\r
+                        adapterType.FullName,\r
+                        typeof(ModelValidator).FullName\r
+                    ),\r
+                    "adapterType"\r
+                );\r
+            }\r
+        }\r
+\r
+        private static void ValidateAttributeType(Type attributeType) {\r
+            if (attributeType == null) {\r
+                throw new ArgumentNullException("attributeType");\r
+            }\r
+            if (!typeof(ValidationAttribute).IsAssignableFrom(attributeType)) {\r
+                throw new ArgumentException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentCulture,\r
+                        MvcResources.Common_TypeMustDriveFromType,\r
+                        attributeType.FullName,\r
+                        typeof(ValidationAttribute).FullName\r
+                    ),\r
+                    "attributeType");\r
+            }\r
+        }\r
+\r
+        private static void ValidateFactory(DataAnnotationsModelValidationFactory factory) {\r
+            if (factory == null) {\r
+                throw new ArgumentNullException("factory");\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelValidator`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataAnnotationsModelValidator`1.cs
new file mode 100644 (file)
index 0000000..d8d9812
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.ComponentModel.DataAnnotations;\r
+\r
+    public class DataAnnotationsModelValidator<TAttribute> : DataAnnotationsModelValidator where TAttribute : ValidationAttribute {\r
+        public DataAnnotationsModelValidator(ModelMetadata metadata, ControllerContext context, TAttribute attribute)\r
+            : base(metadata, context, attribute) { }\r
+\r
+        protected new TAttribute Attribute {\r
+            get {\r
+                return (TAttribute)base.Attribute;\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataErrorInfoModelValidatorProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DataErrorInfoModelValidatorProvider.cs
new file mode 100644 (file)
index 0000000..eb10e5a
--- /dev/null
@@ -0,0 +1,87 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel;\r
+    using System.Linq;\r
+\r
+    public class DataErrorInfoModelValidatorProvider : ModelValidatorProvider {\r
+\r
+        public override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context) {\r
+            if (metadata == null) {\r
+                throw new ArgumentNullException("metadata");\r
+            }\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+\r
+            return GetValidatorsImpl(metadata, context);\r
+        }\r
+\r
+        private static IEnumerable<ModelValidator> GetValidatorsImpl(ModelMetadata metadata, ControllerContext context) {\r
+            // If the metadata describes a model that implements IDataErrorInfo, we should call its\r
+            // Error property at the appropriate time.\r
+            if (TypeImplementsIDataErrorInfo(metadata.ModelType)) {\r
+                yield return new DataErrorInfoClassModelValidator(metadata, context);\r
+            }\r
+\r
+            // If the metadata describes a property of a container that implements IDataErrorInfo,\r
+            // we should call its Item indexer at the appropriate time.\r
+            if (TypeImplementsIDataErrorInfo(metadata.ContainerType)) {\r
+                yield return new DataErrorInfoPropertyModelValidator(metadata, context);\r
+            }\r
+        }\r
+\r
+        private static bool TypeImplementsIDataErrorInfo(Type type) {\r
+            return typeof(IDataErrorInfo).IsAssignableFrom(type);\r
+        }\r
+\r
+        internal sealed class DataErrorInfoClassModelValidator : ModelValidator {\r
+            public DataErrorInfoClassModelValidator(ModelMetadata metadata, ControllerContext controllerContext)\r
+                : base(metadata, controllerContext) {\r
+            }\r
+            public override IEnumerable<ModelValidationResult> Validate(object container) {\r
+                IDataErrorInfo castModel = Metadata.Model as IDataErrorInfo;\r
+                if (castModel != null) {\r
+                    string errorMessage = castModel.Error;\r
+                    if (!String.IsNullOrEmpty(errorMessage)) {\r
+                        return new ModelValidationResult[] {\r
+                            new ModelValidationResult() { Message = errorMessage }\r
+                        };\r
+                    }\r
+                }\r
+                return Enumerable.Empty<ModelValidationResult>();\r
+            }\r
+        }\r
+\r
+        internal sealed class DataErrorInfoPropertyModelValidator : ModelValidator {\r
+            public DataErrorInfoPropertyModelValidator(ModelMetadata metadata, ControllerContext controllerContext)\r
+                : base(metadata, controllerContext) {\r
+            }\r
+            public override IEnumerable<ModelValidationResult> Validate(object container) {\r
+                IDataErrorInfo castContainer = container as IDataErrorInfo;\r
+                if (castContainer != null && !String.Equals(Metadata.PropertyName, "error", StringComparison.OrdinalIgnoreCase)) {\r
+                    string errorMessage = castContainer[Metadata.PropertyName];\r
+                    if (!String.IsNullOrEmpty(errorMessage)) {\r
+                        return new ModelValidationResult[] {\r
+                            new ModelValidationResult() { Message = errorMessage }\r
+                        };\r
+                    }\r
+                }\r
+                return Enumerable.Empty<ModelValidationResult>();\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DefaultControllerFactory.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DefaultControllerFactory.cs
new file mode 100644 (file)
index 0000000..bb65189
--- /dev/null
@@ -0,0 +1,187 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Text;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public class DefaultControllerFactory : IControllerFactory {\r
+\r
+        private IBuildManager _buildManager;\r
+        private ControllerBuilder _controllerBuilder;\r
+        private ControllerTypeCache _instanceControllerTypeCache;\r
+        private static ControllerTypeCache _staticControllerTypeCache = new ControllerTypeCache();\r
+\r
+        internal IBuildManager BuildManager {\r
+            get {\r
+                if (_buildManager == null) {\r
+                    _buildManager = new BuildManagerWrapper();\r
+                }\r
+                return _buildManager;\r
+            }\r
+            set {\r
+                _buildManager = value;\r
+            }\r
+        }\r
+\r
+        internal ControllerBuilder ControllerBuilder {\r
+            get {\r
+                return _controllerBuilder ?? ControllerBuilder.Current;\r
+            }\r
+            set {\r
+                _controllerBuilder = value;\r
+            }\r
+        }\r
+\r
+        internal ControllerTypeCache ControllerTypeCache {\r
+            get {\r
+                return _instanceControllerTypeCache ?? _staticControllerTypeCache;\r
+            }\r
+            set {\r
+                _instanceControllerTypeCache = value;\r
+            }\r
+        }\r
+\r
+        internal static InvalidOperationException CreateAmbiguousControllerException(RouteBase route, string controllerName, ICollection<Type> matchingTypes) {\r
+            // we need to generate an exception containing all the controller types\r
+            StringBuilder typeList = new StringBuilder();\r
+            foreach (Type matchedType in matchingTypes) {\r
+                typeList.AppendLine();\r
+                typeList.Append(matchedType.FullName);\r
+            }\r
+\r
+            string errorText;\r
+            Route castRoute = route as Route;\r
+            if (castRoute != null) {\r
+                errorText = String.Format(CultureInfo.CurrentUICulture, MvcResources.DefaultControllerFactory_ControllerNameAmbiguous_WithRouteUrl,\r
+                    controllerName, castRoute.Url, typeList);\r
+            }\r
+            else {\r
+                errorText = String.Format(CultureInfo.CurrentUICulture, MvcResources.DefaultControllerFactory_ControllerNameAmbiguous_WithoutRouteUrl,\r
+                    controllerName, typeList);\r
+            }\r
+\r
+            return new InvalidOperationException(errorText);\r
+        }\r
+\r
+        public virtual IController CreateController(RequestContext requestContext, string controllerName) {\r
+            if (requestContext == null) {\r
+                throw new ArgumentNullException("requestContext");\r
+            }\r
+            if (String.IsNullOrEmpty(controllerName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "controllerName");\r
+            }\r
+            Type controllerType = GetControllerType(requestContext, controllerName);\r
+            IController controller = GetControllerInstance(requestContext, controllerType);\r
+            return controller;\r
+        }\r
+\r
+        protected internal virtual IController GetControllerInstance(RequestContext requestContext, Type controllerType) {\r
+            if (controllerType == null) {\r
+                throw new HttpException(404,\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.DefaultControllerFactory_NoControllerFound,\r
+                        requestContext.HttpContext.Request.Path));\r
+            }\r
+            if (!typeof(IController).IsAssignableFrom(controllerType)) {\r
+                throw new ArgumentException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.DefaultControllerFactory_TypeDoesNotSubclassControllerBase,\r
+                        controllerType),\r
+                    "controllerType");\r
+            }\r
+            try {\r
+                return (IController)Activator.CreateInstance(controllerType);\r
+            }\r
+            catch (Exception ex) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.DefaultControllerFactory_ErrorCreatingController,\r
+                        controllerType),\r
+                    ex);\r
+            }\r
+        }\r
+\r
+        protected internal virtual Type GetControllerType(RequestContext requestContext, string controllerName) {\r
+            if (String.IsNullOrEmpty(controllerName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "controllerName");\r
+            }\r
+\r
+            // first search in the current route's namespace collection\r
+            object routeNamespacesObj;\r
+            Type match;\r
+            if (requestContext != null && requestContext.RouteData.DataTokens.TryGetValue("Namespaces", out routeNamespacesObj)) {\r
+                IEnumerable<string> routeNamespaces = routeNamespacesObj as IEnumerable<string>;\r
+                if (routeNamespaces != null && routeNamespaces.Any()) {\r
+                    HashSet<string> nsHash = new HashSet<string>(routeNamespaces, StringComparer.OrdinalIgnoreCase);\r
+                    match = GetControllerTypeWithinNamespaces(requestContext.RouteData.Route, controllerName, nsHash);\r
+\r
+                    // the UseNamespaceFallback key might not exist, in which case its value is implicitly "true"\r
+                    if (match != null || false.Equals(requestContext.RouteData.DataTokens["UseNamespaceFallback"])) {\r
+                        // got a match or the route requested we stop looking\r
+                        return match;\r
+                    }\r
+                }\r
+            }\r
+\r
+            // then search in the application's default namespace collection\r
+            if (ControllerBuilder.DefaultNamespaces.Count > 0) {\r
+                HashSet<string> nsDefaults = new HashSet<string>(ControllerBuilder.DefaultNamespaces, StringComparer.OrdinalIgnoreCase);\r
+                match = GetControllerTypeWithinNamespaces(requestContext.RouteData.Route, controllerName, nsDefaults);\r
+                if (match != null) {\r
+                    return match;\r
+                }\r
+            }\r
+\r
+            // if all else fails, search every namespace\r
+            return GetControllerTypeWithinNamespaces(requestContext.RouteData.Route, controllerName, null /* namespaces */);\r
+        }\r
+\r
+        private Type GetControllerTypeWithinNamespaces(RouteBase route, string controllerName, HashSet<string> namespaces) {\r
+            // Once the master list of controllers has been created we can quickly index into it\r
+            ControllerTypeCache.EnsureInitialized(BuildManager);\r
+\r
+            ICollection<Type> matchingTypes = ControllerTypeCache.GetControllerTypes(controllerName, namespaces);\r
+            switch (matchingTypes.Count) {\r
+                case 0:\r
+                    // no matching types\r
+                    return null;\r
+\r
+                case 1:\r
+                    // single matching type\r
+                    return matchingTypes.First();\r
+\r
+                default:\r
+                    // multiple matching types\r
+                    throw CreateAmbiguousControllerException(route, controllerName, matchingTypes);\r
+            }\r
+        }\r
+\r
+        public virtual void ReleaseController(IController controller) {\r
+            IDisposable disposable = controller as IDisposable;\r
+            if (disposable != null) {\r
+                disposable.Dispose();\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DefaultModelBinder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DefaultModelBinder.cs
new file mode 100644 (file)
index 0000000..02507e6
--- /dev/null
@@ -0,0 +1,709 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Runtime.CompilerServices;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class DefaultModelBinder : IModelBinder {\r
+\r
+        private ModelBinderDictionary _binders;\r
+        private static string _resourceClassKey;\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "Property is settable so that the dictionary can be provided for unit testing purposes.")]\r
+        protected internal ModelBinderDictionary Binders {\r
+            get {\r
+                if (_binders == null) {\r
+                    _binders = ModelBinders.Binders;\r
+                }\r
+                return _binders;\r
+            }\r
+            set {\r
+                _binders = value;\r
+            }\r
+        }\r
+\r
+        public static string ResourceClassKey {\r
+            get {\r
+                return _resourceClassKey ?? String.Empty;\r
+            }\r
+            set {\r
+                _resourceClassKey = value;\r
+            }\r
+        }\r
+\r
+        private static void AddValueRequiredMessageToModelState(ControllerContext controllerContext, ModelStateDictionary modelState, string modelStateKey, Type elementType, object value) {\r
+            if (value == null && !TypeHelpers.TypeAllowsNullValue(elementType) && modelState.IsValidField(modelStateKey)) {\r
+                modelState.AddModelError(modelStateKey, GetValueRequiredResource(controllerContext));\r
+            }\r
+        }\r
+\r
+        internal void BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, object model) {\r
+            // need to replace the property filter + model object and create an inner binding context\r
+            ModelBindingContext newBindingContext = CreateComplexElementalModelBindingContext(controllerContext, bindingContext, model);\r
+\r
+            // validation\r
+            if (OnModelUpdating(controllerContext, newBindingContext)) {\r
+                BindProperties(controllerContext, newBindingContext);\r
+                OnModelUpdated(controllerContext, newBindingContext);\r
+            }\r
+        }\r
+\r
+        internal object BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            object model = bindingContext.Model;\r
+            Type modelType = bindingContext.ModelType;\r
+\r
+            // if we're being asked to create an array, create a list instead, then coerce to an array after the list is created\r
+            if (model == null && modelType.IsArray) {\r
+                Type elementType = modelType.GetElementType();\r
+                Type listType = typeof(List<>).MakeGenericType(elementType);\r
+                object collection = CreateModel(controllerContext, bindingContext, listType);\r
+\r
+                ModelBindingContext arrayBindingContext = new ModelBindingContext() {\r
+                    ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => collection, listType),\r
+                    ModelName = bindingContext.ModelName,\r
+                    ModelState = bindingContext.ModelState,\r
+                    PropertyFilter = bindingContext.PropertyFilter,\r
+                    ValueProvider = bindingContext.ValueProvider\r
+                };\r
+                IList list = (IList)UpdateCollection(controllerContext, arrayBindingContext, elementType);\r
+\r
+                if (list == null) {\r
+                    return null;\r
+                }\r
+\r
+                Array array = Array.CreateInstance(elementType, list.Count);\r
+                list.CopyTo(array, 0);\r
+                return array;\r
+            }\r
+\r
+            if (model == null) {\r
+                model = CreateModel(controllerContext, bindingContext, modelType);\r
+            }\r
+\r
+            // special-case IDictionary<,> and ICollection<>\r
+            Type dictionaryType = TypeHelpers.ExtractGenericInterface(modelType, typeof(IDictionary<,>));\r
+            if (dictionaryType != null) {\r
+                Type[] genericArguments = dictionaryType.GetGenericArguments();\r
+                Type keyType = genericArguments[0];\r
+                Type valueType = genericArguments[1];\r
+\r
+                ModelBindingContext dictionaryBindingContext = new ModelBindingContext() {\r
+                    ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, modelType),\r
+                    ModelName = bindingContext.ModelName,\r
+                    ModelState = bindingContext.ModelState,\r
+                    PropertyFilter = bindingContext.PropertyFilter,\r
+                    ValueProvider = bindingContext.ValueProvider\r
+                };\r
+                object dictionary = UpdateDictionary(controllerContext, dictionaryBindingContext, keyType, valueType);\r
+                return dictionary;\r
+            }\r
+\r
+            Type enumerableType = TypeHelpers.ExtractGenericInterface(modelType, typeof(IEnumerable<>));\r
+            if (enumerableType != null) {\r
+                Type elementType = enumerableType.GetGenericArguments()[0];\r
+\r
+                Type collectionType = typeof(ICollection<>).MakeGenericType(elementType);\r
+                if (collectionType.IsInstanceOfType(model)) {\r
+                    ModelBindingContext collectionBindingContext = new ModelBindingContext() {\r
+                        ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, modelType),\r
+                        ModelName = bindingContext.ModelName,\r
+                        ModelState = bindingContext.ModelState,\r
+                        PropertyFilter = bindingContext.PropertyFilter,\r
+                        ValueProvider = bindingContext.ValueProvider\r
+                    };\r
+                    object collection = UpdateCollection(controllerContext, collectionBindingContext, elementType);\r
+                    return collection;\r
+                }\r
+            }\r
+\r
+            // otherwise, just update the properties on the complex type\r
+            BindComplexElementalModel(controllerContext, bindingContext, model);\r
+            return model;\r
+        }\r
+\r
+        public virtual object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            if (bindingContext == null) {\r
+                throw new ArgumentNullException("bindingContext");\r
+            }\r
+\r
+            bool performedFallback = false;\r
+\r
+            if (!String.IsNullOrEmpty(bindingContext.ModelName) && !bindingContext.ValueProvider.ContainsPrefix(bindingContext.ModelName)) {\r
+                // We couldn't find any entry that began with the prefix. If this is the top-level element, fall back\r
+                // to the empty prefix.\r
+                if (bindingContext.FallbackToEmptyPrefix) {\r
+                    bindingContext = new ModelBindingContext() {\r
+                        ModelMetadata = bindingContext.ModelMetadata,\r
+                        ModelState = bindingContext.ModelState,\r
+                        PropertyFilter = bindingContext.PropertyFilter,\r
+                        ValueProvider = bindingContext.ValueProvider\r
+                    };\r
+                    performedFallback = true;\r
+                }\r
+                else {\r
+                    return null;\r
+                }\r
+            }\r
+\r
+            // Simple model = int, string, etc.; determined by calling TypeConverter.CanConvertFrom(typeof(string))\r
+            // or by seeing if a value in the request exactly matches the name of the model we're binding.\r
+            // Complex type = everything else.\r
+            if (!performedFallback) {\r
+                ValueProviderResult vpResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);\r
+                if (vpResult != null) {\r
+                    return BindSimpleModel(controllerContext, bindingContext, vpResult);\r
+                }\r
+            }\r
+            if (!bindingContext.ModelMetadata.IsComplexType) {\r
+                return null;\r
+            }\r
+\r
+            return BindComplexModel(controllerContext, bindingContext);\r
+        }\r
+\r
+        private void BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            IEnumerable<PropertyDescriptor> properties = GetFilteredModelProperties(controllerContext, bindingContext);\r
+            foreach (PropertyDescriptor property in properties) {\r
+                BindProperty(controllerContext, bindingContext, property);\r
+            }\r
+        }\r
+\r
+        protected virtual void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) {\r
+            // need to skip properties that aren't part of the request, else we might hit a StackOverflowException\r
+            string fullPropertyKey = CreateSubPropertyName(bindingContext.ModelName, propertyDescriptor.Name);\r
+            if (!bindingContext.ValueProvider.ContainsPrefix(fullPropertyKey)) {\r
+                return;\r
+            }\r
+\r
+            // call into the property's model binder\r
+            IModelBinder propertyBinder = Binders.GetBinder(propertyDescriptor.PropertyType);\r
+            object originalPropertyValue = propertyDescriptor.GetValue(bindingContext.Model);\r
+            ModelMetadata propertyMetadata = bindingContext.PropertyMetadata[propertyDescriptor.Name];\r
+            propertyMetadata.Model = originalPropertyValue;\r
+            ModelBindingContext innerBindingContext = new ModelBindingContext() {\r
+                ModelMetadata = propertyMetadata,\r
+                ModelName = fullPropertyKey,\r
+                ModelState = bindingContext.ModelState,\r
+                ValueProvider = bindingContext.ValueProvider\r
+            };\r
+            object newPropertyValue = GetPropertyValue(controllerContext, innerBindingContext, propertyDescriptor, propertyBinder);\r
+            propertyMetadata.Model = newPropertyValue;\r
+\r
+            // validation\r
+            ModelState modelState = bindingContext.ModelState[fullPropertyKey];\r
+            if (modelState == null || modelState.Errors.Count == 0) {\r
+                if (OnPropertyValidating(controllerContext, bindingContext, propertyDescriptor, newPropertyValue)) {\r
+                    SetProperty(controllerContext, bindingContext, propertyDescriptor, newPropertyValue);\r
+                    OnPropertyValidated(controllerContext, bindingContext, propertyDescriptor, newPropertyValue);\r
+                }\r
+            }\r
+            else {\r
+                SetProperty(controllerContext, bindingContext, propertyDescriptor, newPropertyValue);\r
+\r
+                // Convert FormatExceptions (type conversion failures) into InvalidValue messages\r
+                foreach (ModelError error in modelState.Errors.Where(err => String.IsNullOrEmpty(err.ErrorMessage) && err.Exception != null).ToList()) {\r
+                    for (Exception exception = error.Exception; exception != null; exception = exception.InnerException) {\r
+                        if (exception is FormatException) {\r
+                            string displayName = propertyMetadata.GetDisplayName();\r
+                            string errorMessageTemplate = GetValueInvalidResource(controllerContext);\r
+                            string errorMessage = String.Format(CultureInfo.CurrentUICulture, errorMessageTemplate, modelState.Value.AttemptedValue, displayName);\r
+                            modelState.Errors.Remove(error);\r
+                            modelState.Errors.Add(errorMessage);\r
+                            break;\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        internal object BindSimpleModel(ControllerContext controllerContext, ModelBindingContext bindingContext, ValueProviderResult valueProviderResult) {\r
+            bindingContext.ModelState.SetModelValue(bindingContext.ModelName, valueProviderResult);\r
+\r
+            // if the value provider returns an instance of the requested data type, we can just short-circuit\r
+            // the evaluation and return that instance\r
+            if (bindingContext.ModelType.IsInstanceOfType(valueProviderResult.RawValue)) {\r
+                return valueProviderResult.RawValue;\r
+            }\r
+\r
+            // since a string is an IEnumerable<char>, we want it to skip the two checks immediately following\r
+            if (bindingContext.ModelType != typeof(string)) {\r
+\r
+                // conversion results in 3 cases, as below\r
+                if (bindingContext.ModelType.IsArray) {\r
+                    // case 1: user asked for an array\r
+                    // ValueProviderResult.ConvertTo() understands array types, so pass in the array type directly\r
+                    object modelArray = ConvertProviderResult(bindingContext.ModelState, bindingContext.ModelName, valueProviderResult, bindingContext.ModelType);\r
+                    return modelArray;\r
+                }\r
+\r
+                Type enumerableType = TypeHelpers.ExtractGenericInterface(bindingContext.ModelType, typeof(IEnumerable<>));\r
+                if (enumerableType != null) {\r
+                    // case 2: user asked for a collection rather than an array\r
+                    // need to call ConvertTo() on the array type, then copy the array to the collection\r
+                    object modelCollection = CreateModel(controllerContext, bindingContext, bindingContext.ModelType);\r
+                    Type elementType = enumerableType.GetGenericArguments()[0];\r
+                    Type arrayType = elementType.MakeArrayType();\r
+                    object modelArray = ConvertProviderResult(bindingContext.ModelState, bindingContext.ModelName, valueProviderResult, arrayType);\r
+\r
+                    Type collectionType = typeof(ICollection<>).MakeGenericType(elementType);\r
+                    if (collectionType.IsInstanceOfType(modelCollection)) {\r
+                        CollectionHelpers.ReplaceCollection(elementType, modelCollection, modelArray);\r
+                    }\r
+                    return modelCollection;\r
+                }\r
+            }\r
+\r
+            // case 3: user asked for an individual element\r
+            object model = ConvertProviderResult(bindingContext.ModelState, bindingContext.ModelName, valueProviderResult, bindingContext.ModelType);\r
+            return model;\r
+        }\r
+\r
+        private static bool CanUpdateReadonlyTypedReference(Type type) {\r
+            // value types aren't strictly immutable, but because they have copy-by-value semantics\r
+            // we can't update a value type that is marked readonly\r
+            if (type.IsValueType) {\r
+                return false;\r
+            }\r
+\r
+            // arrays are mutable, but because we can't change their length we shouldn't try\r
+            // to update an array that is referenced readonly\r
+            if (type.IsArray) {\r
+                return false;\r
+            }\r
+\r
+            // special-case known common immutable types\r
+            if (type == typeof(string)) {\r
+                return false;\r
+            }\r
+\r
+            return true;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.Web.Mvc.ValueProviderResult.ConvertTo(System.Type)",\r
+            Justification = "The target object should make the correct culture determination, not this method.")]\r
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",\r
+            Justification = "We're recording this exception so that we can act on it later.")]\r
+        private static object ConvertProviderResult(ModelStateDictionary modelState, string modelStateKey, ValueProviderResult valueProviderResult, Type destinationType) {\r
+            try {\r
+                object convertedValue = valueProviderResult.ConvertTo(destinationType);\r
+                return convertedValue;\r
+            }\r
+            catch (Exception ex) {\r
+                modelState.AddModelError(modelStateKey, ex);\r
+                return null;\r
+            }\r
+        }\r
+\r
+        internal ModelBindingContext CreateComplexElementalModelBindingContext(ControllerContext controllerContext, ModelBindingContext bindingContext, object model) {\r
+            BindAttribute bindAttr = (BindAttribute)GetTypeDescriptor(controllerContext, bindingContext).GetAttributes()[typeof(BindAttribute)];\r
+            Predicate<string> newPropertyFilter = (bindAttr != null)\r
+                ? propertyName => bindAttr.IsPropertyAllowed(propertyName) && bindingContext.PropertyFilter(propertyName)\r
+                : bindingContext.PropertyFilter;\r
+\r
+            ModelBindingContext newBindingContext = new ModelBindingContext() {\r
+                ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, bindingContext.ModelType),\r
+                ModelName = bindingContext.ModelName,\r
+                ModelState = bindingContext.ModelState,\r
+                PropertyFilter = newPropertyFilter,\r
+                ValueProvider = bindingContext.ValueProvider\r
+            };\r
+\r
+            return newBindingContext;\r
+        }\r
+\r
+        protected virtual object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) {\r
+            Type typeToCreate = modelType;\r
+\r
+            // we can understand some collection interfaces, e.g. IList<>, IDictionary<,>\r
+            if (modelType.IsGenericType) {\r
+                Type genericTypeDefinition = modelType.GetGenericTypeDefinition();\r
+                if (genericTypeDefinition == typeof(IDictionary<,>)) {\r
+                    typeToCreate = typeof(Dictionary<,>).MakeGenericType(modelType.GetGenericArguments());\r
+                }\r
+                else if (genericTypeDefinition == typeof(IEnumerable<>) || genericTypeDefinition == typeof(ICollection<>) || genericTypeDefinition == typeof(IList<>)) {\r
+                    typeToCreate = typeof(List<>).MakeGenericType(modelType.GetGenericArguments());\r
+                }\r
+            }\r
+\r
+            // fallback to the type's default constructor\r
+            return Activator.CreateInstance(typeToCreate);\r
+        }\r
+\r
+        protected static string CreateSubIndexName(string prefix, int index) {\r
+            return String.Format(CultureInfo.InvariantCulture, "{0}[{1}]", prefix, index);\r
+        }\r
+\r
+        protected static string CreateSubIndexName(string prefix, string index) {\r
+            return String.Format(CultureInfo.InvariantCulture, "{0}[{1}]", prefix, index);\r
+        }\r
+\r
+        protected internal static string CreateSubPropertyName(string prefix, string propertyName) {\r
+            if (String.IsNullOrEmpty(prefix)) {\r
+                return propertyName;\r
+            }\r
+            else if (String.IsNullOrEmpty(propertyName)) {\r
+                return prefix;\r
+            }\r
+            else {\r
+                return prefix + "." + propertyName;\r
+            }\r
+        }\r
+\r
+        protected IEnumerable<PropertyDescriptor> GetFilteredModelProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            PropertyDescriptorCollection properties = GetModelProperties(controllerContext, bindingContext);\r
+            Predicate<string> propertyFilter = bindingContext.PropertyFilter;\r
+\r
+            return from PropertyDescriptor property in properties\r
+                   where ShouldUpdateProperty(property, propertyFilter)\r
+                   select property;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.Web.Mvc.ValueProviderResult.ConvertTo(System.Type)",\r
+            Justification = "ValueProviderResult already handles culture conversion appropriately.")]\r
+        private static void GetIndexes(ModelBindingContext bindingContext, out bool stopOnIndexNotFound, out IEnumerable<string> indexes) {\r
+            string indexKey = CreateSubPropertyName(bindingContext.ModelName, "index");\r
+            ValueProviderResult vpResult = bindingContext.ValueProvider.GetValue(indexKey);\r
+\r
+            if (vpResult != null) {\r
+                string[] indexesArray = vpResult.ConvertTo(typeof(string[])) as string[];\r
+                if (indexesArray != null) {\r
+                    stopOnIndexNotFound = false;\r
+                    indexes = indexesArray;\r
+                    return;\r
+                }\r
+            }\r
+\r
+            // just use a simple zero-based system\r
+            stopOnIndexNotFound = true;\r
+            indexes = GetZeroBasedIndexes();\r
+        }\r
+\r
+        protected virtual PropertyDescriptorCollection GetModelProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            return GetTypeDescriptor(controllerContext, bindingContext).GetProperties();\r
+        }\r
+\r
+        protected virtual object GetPropertyValue(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, IModelBinder propertyBinder) {\r
+            object value = propertyBinder.BindModel(controllerContext, bindingContext);\r
+\r
+            if (bindingContext.ModelMetadata.ConvertEmptyStringToNull && Object.Equals(value, String.Empty)) {\r
+                return null;\r
+            }\r
+\r
+            return value;\r
+        }\r
+\r
+        protected virtual ICustomTypeDescriptor GetTypeDescriptor(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            return TypeDescriptorHelper.Get(bindingContext.ModelType);\r
+        }\r
+\r
+        // If the user specified a ResourceClassKey try to load the resource they specified.\r
+        // If the class key is invalid, an exception will be thrown.\r
+        // If the class key is valid but the resource is not found, it returns null, in which\r
+        // case it will fall back to the MVC default error message.\r
+        private static string GetUserResourceString(ControllerContext controllerContext, string resourceName) {\r
+            string result = null;\r
+\r
+            if (!String.IsNullOrEmpty(ResourceClassKey) && (controllerContext != null) && (controllerContext.HttpContext != null)) {\r
+                result = controllerContext.HttpContext.GetGlobalResourceObject(ResourceClassKey, resourceName, CultureInfo.CurrentUICulture) as string;\r
+            }\r
+\r
+            return result;\r
+        }\r
+\r
+        private static string GetValueInvalidResource(ControllerContext controllerContext) {\r
+            return GetUserResourceString(controllerContext, "PropertyValueInvalid") ?? MvcResources.DefaultModelBinder_ValueInvalid;\r
+        }\r
+\r
+        private static string GetValueRequiredResource(ControllerContext controllerContext) {\r
+            return GetUserResourceString(controllerContext, "PropertyValueRequired") ?? MvcResources.DefaultModelBinder_ValueRequired;\r
+        }\r
+\r
+        private static IEnumerable<string> GetZeroBasedIndexes() {\r
+            for (int i = 0; ; i++) {\r
+                yield return i.ToString(CultureInfo.InvariantCulture);\r
+            }\r
+        }\r
+\r
+        protected static bool IsModelValid(ModelBindingContext bindingContext) {\r
+            if (bindingContext == null) {\r
+                throw new ArgumentNullException("bindingContext");\r
+            }\r
+            if (String.IsNullOrEmpty(bindingContext.ModelName)) {\r
+                return bindingContext.ModelState.IsValid;\r
+            }\r
+            return bindingContext.ModelState.IsValidField(bindingContext.ModelName);\r
+        }\r
+\r
+        protected virtual void OnModelUpdated(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            Dictionary<string, bool> startedValid = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);\r
+\r
+            foreach (ModelValidationResult validationResult in ModelValidator.GetModelValidator(bindingContext.ModelMetadata, controllerContext).Validate(null)) {\r
+                string subPropertyName = CreateSubPropertyName(bindingContext.ModelName, validationResult.MemberName);\r
+\r
+                if (!startedValid.ContainsKey(subPropertyName)) {\r
+                    startedValid[subPropertyName] = bindingContext.ModelState.IsValidField(subPropertyName);\r
+                }\r
+\r
+                if (startedValid[subPropertyName]) {\r
+                    bindingContext.ModelState.AddModelError(subPropertyName, validationResult.Message);\r
+                }\r
+            }\r
+        }\r
+\r
+        protected virtual bool OnModelUpdating(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            // default implementation does nothing\r
+            return true;\r
+        }\r
+\r
+        protected virtual void OnPropertyValidated(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, object value) {\r
+            // default implementation does nothing\r
+        }\r
+\r
+        protected virtual bool OnPropertyValidating(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, object value) {\r
+            // default implementation does nothing\r
+            return true;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",\r
+            Justification = "We're recording this exception so that we can act on it later.")]\r
+        protected virtual void SetProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, object value) {\r
+\r
+            ModelMetadata propertyMetadata = bindingContext.PropertyMetadata[propertyDescriptor.Name];\r
+            propertyMetadata.Model = value;\r
+            string modelStateKey = CreateSubPropertyName(bindingContext.ModelName, propertyMetadata.PropertyName);\r
+\r
+            // If the value is null, and the validation system can find a Required validator for\r
+            // us, we'd prefer to run it before we attempt to set the value; otherwise, property\r
+            // setters which throw on null (f.e., Entity Framework properties which are backed by\r
+            // non-nullable strings in the DB) will get their error message in ahead of us.\r
+            //\r
+            // We are effectively using the special validator -- Required -- as a helper to the\r
+            // binding system, which is why this code is here instead of in the Validating/Validated\r
+            // methods, which are really the old-school validation hooks.\r
+            if (value == null && bindingContext.ModelState.IsValidField(modelStateKey)) {\r
+                ModelValidator requiredValidator = ModelValidatorProviders.Providers.GetValidators(propertyMetadata, controllerContext).Where(v => v.IsRequired).FirstOrDefault();\r
+                if (requiredValidator != null) {\r
+                    foreach (ModelValidationResult validationResult in requiredValidator.Validate(bindingContext.Model)) {\r
+                        bindingContext.ModelState.AddModelError(modelStateKey, validationResult.Message);\r
+                    }\r
+                }\r
+            }\r
+\r
+            bool isNullValueOnNonNullableType =\r
+                value == null &&\r
+                !TypeHelpers.TypeAllowsNullValue(propertyDescriptor.PropertyType);\r
+\r
+            // Try to set a value into the property unless we know it will fail (read-only\r
+            // properties and null values with non-nullable types)\r
+            if (!propertyDescriptor.IsReadOnly && !isNullValueOnNonNullableType) {\r
+                try {\r
+                    propertyDescriptor.SetValue(bindingContext.Model, value);\r
+                }\r
+                catch (Exception ex) {\r
+                    // Only add if we're not already invalid\r
+                    if (bindingContext.ModelState.IsValidField(modelStateKey)) {\r
+                        bindingContext.ModelState.AddModelError(modelStateKey, ex);\r
+                    }\r
+                }\r
+            }\r
+\r
+            // Last chance for an error on null values with non-nullable types, we'll use\r
+            // the default "A value is required." message.\r
+            if (isNullValueOnNonNullableType && bindingContext.ModelState.IsValidField(modelStateKey)) {\r
+                bindingContext.ModelState.AddModelError(modelStateKey, GetValueRequiredResource(controllerContext));\r
+            }\r
+        }\r
+\r
+        private static bool ShouldUpdateProperty(PropertyDescriptor property, Predicate<string> propertyFilter) {\r
+            if (property.IsReadOnly && !CanUpdateReadonlyTypedReference(property.PropertyType)) {\r
+                return false;\r
+            }\r
+\r
+            // if this property is rejected by the filter, move on\r
+            if (!propertyFilter(property.Name)) {\r
+                return false;\r
+            }\r
+\r
+            // otherwise, allow\r
+            return true;\r
+        }\r
+\r
+        internal object UpdateCollection(ControllerContext controllerContext, ModelBindingContext bindingContext, Type elementType) {\r
+            bool stopOnIndexNotFound;\r
+            IEnumerable<string> indexes;\r
+            GetIndexes(bindingContext, out stopOnIndexNotFound, out indexes);\r
+            IModelBinder elementBinder = Binders.GetBinder(elementType);\r
+\r
+            // build up a list of items from the request\r
+            List<object> modelList = new List<object>();\r
+            foreach (string currentIndex in indexes) {\r
+                string subIndexKey = CreateSubIndexName(bindingContext.ModelName, currentIndex);\r
+                if (!bindingContext.ValueProvider.ContainsPrefix(subIndexKey)) {\r
+                    if (stopOnIndexNotFound) {\r
+                        // we ran out of elements to pull\r
+                        break;\r
+                    }\r
+                    else {\r
+                        continue;\r
+                    }\r
+                }\r
+\r
+                ModelBindingContext innerContext = new ModelBindingContext() {\r
+                    ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, elementType),\r
+                    ModelName = subIndexKey,\r
+                    ModelState = bindingContext.ModelState,\r
+                    PropertyFilter = bindingContext.PropertyFilter,\r
+                    ValueProvider = bindingContext.ValueProvider\r
+                };\r
+                object thisElement = elementBinder.BindModel(controllerContext, innerContext);\r
+\r
+                // we need to merge model errors up\r
+                AddValueRequiredMessageToModelState(controllerContext, bindingContext.ModelState, subIndexKey, elementType, thisElement);\r
+                modelList.Add(thisElement);\r
+            }\r
+\r
+            // if there weren't any elements at all in the request, just return\r
+            if (modelList.Count == 0) {\r
+                return null;\r
+            }\r
+\r
+            // replace the original collection\r
+            object collection = bindingContext.Model;\r
+            CollectionHelpers.ReplaceCollection(elementType, collection, modelList);\r
+            return collection;\r
+        }\r
+\r
+        internal object UpdateDictionary(ControllerContext controllerContext, ModelBindingContext bindingContext, Type keyType, Type valueType) {\r
+            bool stopOnIndexNotFound;\r
+            IEnumerable<string> indexes;\r
+            GetIndexes(bindingContext, out stopOnIndexNotFound, out indexes);\r
+\r
+            IModelBinder keyBinder = Binders.GetBinder(keyType);\r
+            IModelBinder valueBinder = Binders.GetBinder(valueType);\r
+\r
+            // build up a list of items from the request\r
+            List<KeyValuePair<object, object>> modelList = new List<KeyValuePair<object, object>>();\r
+            foreach (string currentIndex in indexes) {\r
+                string subIndexKey = CreateSubIndexName(bindingContext.ModelName, currentIndex);\r
+                string keyFieldKey = CreateSubPropertyName(subIndexKey, "key");\r
+                string valueFieldKey = CreateSubPropertyName(subIndexKey, "value");\r
+\r
+                if (!(bindingContext.ValueProvider.ContainsPrefix(keyFieldKey) && bindingContext.ValueProvider.ContainsPrefix(valueFieldKey))) {\r
+                    if (stopOnIndexNotFound) {\r
+                        // we ran out of elements to pull\r
+                        break;\r
+                    }\r
+                    else {\r
+                        continue;\r
+                    }\r
+                }\r
+\r
+                // bind the key\r
+                ModelBindingContext keyBindingContext = new ModelBindingContext() {\r
+                    ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, keyType),\r
+                    ModelName = keyFieldKey,\r
+                    ModelState = bindingContext.ModelState,\r
+                    ValueProvider = bindingContext.ValueProvider\r
+                };\r
+                object thisKey = keyBinder.BindModel(controllerContext, keyBindingContext);\r
+\r
+                // we need to merge model errors up\r
+                AddValueRequiredMessageToModelState(controllerContext, bindingContext.ModelState, keyFieldKey, keyType, thisKey);\r
+                if (!keyType.IsInstanceOfType(thisKey)) {\r
+                    // we can't add an invalid key, so just move on\r
+                    continue;\r
+                }\r
+\r
+                // bind the value\r
+                ModelBindingContext valueBindingContext = new ModelBindingContext() {\r
+                    ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, valueType),\r
+                    ModelName = valueFieldKey,\r
+                    ModelState = bindingContext.ModelState,\r
+                    PropertyFilter = bindingContext.PropertyFilter,\r
+                    ValueProvider = bindingContext.ValueProvider\r
+                };\r
+                object thisValue = valueBinder.BindModel(controllerContext, valueBindingContext);\r
+\r
+                // we need to merge model errors up\r
+                AddValueRequiredMessageToModelState(controllerContext, bindingContext.ModelState, valueFieldKey, valueType, thisValue);\r
+                KeyValuePair<object, object> kvp = new KeyValuePair<object, object>(thisKey, thisValue);\r
+                modelList.Add(kvp);\r
+            }\r
+\r
+            // if there weren't any elements at all in the request, just return\r
+            if (modelList.Count == 0) {\r
+                return null;\r
+            }\r
+\r
+            // replace the original collection\r
+            object dictionary = bindingContext.Model;\r
+            CollectionHelpers.ReplaceDictionary(keyType, valueType, dictionary, modelList);\r
+            return dictionary;\r
+        }\r
+\r
+        // This helper type is used because we're working with strongly-typed collections, but we don't know the Ts\r
+        // ahead of time. By using the generic methods below, we can consolidate the collection-specific code in a\r
+        // single helper type rather than having reflection-based calls spread throughout the DefaultModelBinder type.\r
+        // There is a single point of entry to each of the methods below, so they're fairly simple to maintain.\r
+\r
+        private static class CollectionHelpers {\r
+\r
+            private static readonly MethodInfo _replaceCollectionMethod = typeof(CollectionHelpers).GetMethod("ReplaceCollectionImpl", BindingFlags.Static | BindingFlags.NonPublic);\r
+            private static readonly MethodInfo _replaceDictionaryMethod = typeof(CollectionHelpers).GetMethod("ReplaceDictionaryImpl", BindingFlags.Static | BindingFlags.NonPublic);\r
+\r
+            [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]\r
+            public static void ReplaceCollection(Type collectionType, object collection, object newContents) {\r
+                MethodInfo targetMethod = _replaceCollectionMethod.MakeGenericMethod(collectionType);\r
+                targetMethod.Invoke(null, new object[] { collection, newContents });\r
+            }\r
+\r
+            private static void ReplaceCollectionImpl<T>(ICollection<T> collection, IEnumerable newContents) {\r
+                collection.Clear();\r
+                if (newContents != null) {\r
+                    foreach (object item in newContents) {\r
+                        // if the item was not a T, some conversion failed. the error message will be propagated,\r
+                        // but in the meanwhile we need to make a placeholder element in the array.\r
+                        T castItem = (item is T) ? (T)item : default(T);\r
+                        collection.Add(castItem);\r
+                    }\r
+                }\r
+            }\r
+\r
+            [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]\r
+            public static void ReplaceDictionary(Type keyType, Type valueType, object dictionary, object newContents) {\r
+                MethodInfo targetMethod = _replaceDictionaryMethod.MakeGenericMethod(keyType, valueType);\r
+                targetMethod.Invoke(null, new object[] { dictionary, newContents });\r
+            }\r
+\r
+            private static void ReplaceDictionaryImpl<TKey, TValue>(IDictionary<TKey, TValue> dictionary, IEnumerable<KeyValuePair<object, object>> newContents) {\r
+                dictionary.Clear();\r
+                foreach (KeyValuePair<object, object> item in newContents) {\r
+                    // if the item was not a T, some conversion failed. the error message will be propagated,\r
+                    // but in the meanwhile we need to make a placeholder element in the dictionary.\r
+                    TKey castKey = (TKey)item.Key; // this cast shouldn't fail\r
+                    TValue castValue = (item.Value is TValue) ? (TValue)item.Value : default(TValue);\r
+                    dictionary[castKey] = castValue;\r
+                }\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DefaultViewLocationCache.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DefaultViewLocationCache.cs
new file mode 100644 (file)
index 0000000..f0479f4
--- /dev/null
@@ -0,0 +1,60 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Web.Caching;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [SuppressMessage("Microsoft.Security", "CA2112:SecuredTypesShouldNotExposeFields",\r
+        Justification = "The Null field does not have access to secure information")]\r
+    public class DefaultViewLocationCache : IViewLocationCache {\r
+        private static readonly TimeSpan _defaultTimeSpan = new TimeSpan(0, 15, 0);\r
+\r
+        public DefaultViewLocationCache()\r
+            : this(_defaultTimeSpan) {\r
+        }\r
+\r
+        public DefaultViewLocationCache(TimeSpan timeSpan) {\r
+            if (timeSpan.Ticks < 0) {\r
+                throw new InvalidOperationException(MvcResources.DefaultViewLocationCache_NegativeTimeSpan);\r
+            }\r
+            TimeSpan = timeSpan;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",\r
+            Justification = "The reference type is immutable. ")]\r
+        public static readonly IViewLocationCache Null = new NullViewLocationCache();\r
+\r
+        public TimeSpan TimeSpan {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        #region IViewLocationCache Members\r
+        public string GetViewLocation(HttpContextBase httpContext, string key) {\r
+            if (httpContext == null) {\r
+                throw new ArgumentNullException("httpContext");\r
+            }\r
+            return (string)httpContext.Cache[key];\r
+        }\r
+\r
+        public void InsertViewLocation(HttpContextBase httpContext, string key, string virtualPath) {\r
+            if (httpContext == null) {\r
+                throw new ArgumentNullException("httpContext");\r
+            }\r
+            httpContext.Cache.Insert(key, virtualPath, null /* dependencies */, Cache.NoAbsoluteExpiration, TimeSpan);\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DescriptorUtil.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DescriptorUtil.cs
new file mode 100644 (file)
index 0000000..a19c90f
--- /dev/null
@@ -0,0 +1,34 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Linq;\r
+    using System.Threading;\r
+\r
+    internal static class DescriptorUtil {\r
+\r
+        public static TDescriptor[] LazilyFetchOrCreateDescriptors<TReflection, TDescriptor>(ref TDescriptor[] cacheLocation, Func<TReflection[]> initializer, Func<TReflection, TDescriptor> converter) {\r
+            // did we already calculate this once?\r
+            TDescriptor[] existingCache = Interlocked.CompareExchange(ref cacheLocation, null, null);\r
+            if (existingCache != null) {\r
+                return existingCache;\r
+            }\r
+\r
+            TReflection[] memberInfos = initializer();\r
+            TDescriptor[] descriptors = memberInfos.Select(converter).Where(descriptor => descriptor != null).ToArray();\r
+            TDescriptor[] updatedCache = Interlocked.CompareExchange(ref cacheLocation, descriptors, null);\r
+            return updatedCache ?? descriptors;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DictionaryHelpers.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DictionaryHelpers.cs
new file mode 100644 (file)
index 0000000..7eb761f
--- /dev/null
@@ -0,0 +1,52 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+\r
+    internal static class DictionaryHelpers {\r
+\r
+        public static IEnumerable<KeyValuePair<string, TValue>> FindKeysWithPrefix<TValue>(IDictionary<string, TValue> dictionary, string prefix) {\r
+            TValue exactMatchValue;\r
+            if (dictionary.TryGetValue(prefix, out exactMatchValue)) {\r
+                yield return new KeyValuePair<string, TValue>(prefix, exactMatchValue);\r
+            }\r
+\r
+            foreach (var entry in dictionary) {\r
+                string key = entry.Key;\r
+\r
+                if (key.Length <= prefix.Length) {\r
+                    continue;\r
+                }\r
+\r
+                if (!key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) {\r
+                    continue;\r
+                }\r
+\r
+                char charAfterPrefix = key[prefix.Length];\r
+                switch (charAfterPrefix) {\r
+                    case '[':\r
+                    case '.':\r
+                        yield return entry;\r
+                        break;\r
+                }\r
+            }\r
+        }\r
+\r
+        public static bool DoesAnyKeyHavePrefix<TValue>(IDictionary<string, TValue> dictionary, string prefix) {\r
+            return FindKeysWithPrefix(dictionary, prefix).Any();\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DictionaryValueProvider`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DictionaryValueProvider`1.cs
new file mode 100644 (file)
index 0000000..b1e8845
--- /dev/null
@@ -0,0 +1,64 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+\r
+    public class DictionaryValueProvider<TValue> : IValueProvider {\r
+\r
+        private readonly HashSet<string> _prefixes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\r
+        private readonly Dictionary<string, ValueProviderResult> _values = new Dictionary<string, ValueProviderResult>(StringComparer.OrdinalIgnoreCase);\r
+\r
+        public DictionaryValueProvider(IDictionary<string, TValue> dictionary, CultureInfo culture) {\r
+            if (dictionary == null) {\r
+                throw new ArgumentNullException("dictionary");\r
+            }\r
+\r
+            AddValues(dictionary, culture);\r
+        }\r
+\r
+        private void AddValues(IDictionary<string, TValue> dictionary, CultureInfo culture) {\r
+            if (dictionary.Count > 0) {\r
+                _prefixes.Add("");\r
+            }\r
+\r
+            foreach (var entry in dictionary) {\r
+                _prefixes.UnionWith(ValueProviderUtil.GetPrefixes(entry.Key));\r
+\r
+                object rawValue = entry.Value;\r
+                string attemptedValue = Convert.ToString(rawValue, culture);\r
+                _values[entry.Key] = new ValueProviderResult(rawValue, attemptedValue, culture);\r
+            }\r
+        }\r
+\r
+        public virtual bool ContainsPrefix(string prefix) {\r
+            if (prefix == null) {\r
+                throw new ArgumentNullException("prefix");\r
+            }\r
+\r
+            return _prefixes.Contains(prefix);\r
+        }\r
+\r
+        public virtual ValueProviderResult GetValue(string key) {\r
+            if (key == null) {\r
+                throw new ArgumentNullException("key");\r
+            }\r
+\r
+            ValueProviderResult vpResult;\r
+            _values.TryGetValue(key, out vpResult);\r
+            return vpResult;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/DynamicTypeGenerator.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/DynamicTypeGenerator.cs
new file mode 100644 (file)
index 0000000..eefc9f8
--- /dev/null
@@ -0,0 +1,125 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Reflection.Emit;\r
+    using System.Security;\r
+\r
+    internal static class DynamicTypeGenerator {\r
+\r
+        private static readonly ModuleBuilder _dynamicModule = CreateDynamicModule();\r
+\r
+        private static ModuleBuilder CreateDynamicModule() {\r
+            // DDB 226615 - since MVC is [SecurityTransparent], the dynamic assembly must declare itself likewise\r
+            CustomAttributeBuilder builder = new CustomAttributeBuilder(\r
+                typeof(SecurityTransparentAttribute).GetConstructor(Type.EmptyTypes), new object[0]);\r
+            CustomAttributeBuilder[] assemblyAttributes = new CustomAttributeBuilder[] { builder };\r
+            AssemblyBuilder dynamicAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(\r
+                new AssemblyName("System.Web.Mvc.{Dynamic}"), AssemblyBuilderAccess.Run, assemblyAttributes);\r
+            ModuleBuilder dynamicModule = dynamicAssembly.DefineDynamicModule("System.Web.Mvc.{Dynamic}.dll");\r
+            return dynamicModule;\r
+        }\r
+\r
+        // Creates a new dynamic type that is a subclassed type of baseType and also implements methods of the specified\r
+        // interfaces. The base type must already have method signatures that implicitly implement the given\r
+        // interfaces. The signatures of all public (e.g. not private / internal) constructors from the baseType\r
+        // will be duplicated for the subclassed type and the new constructors made public.\r
+        public static Type GenerateType(string dynamicTypeName, Type baseType, IEnumerable<Type> interfaceTypes) {\r
+            TypeBuilder newType = _dynamicModule.DefineType(\r
+                "System.Web.Mvc.{Dynamic}." + dynamicTypeName,\r
+                TypeAttributes.AutoLayout | TypeAttributes.Public | TypeAttributes.Class,\r
+                baseType);\r
+\r
+            foreach (Type interfaceType in interfaceTypes) {\r
+                newType.AddInterfaceImplementation(interfaceType);\r
+                foreach (MethodInfo interfaceMethod in interfaceType.GetMethods()) {\r
+                    ImplementInterfaceMethod(newType, interfaceMethod);\r
+                }\r
+            }\r
+\r
+            // generate new constructors for each accessible base constructor\r
+            foreach (ConstructorInfo ctor in baseType.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {\r
+                switch (ctor.Attributes & MethodAttributes.MemberAccessMask) {\r
+                    case MethodAttributes.Family:\r
+                    case MethodAttributes.Public:\r
+                    case MethodAttributes.FamORAssem:\r
+                        ImplementConstructor(newType, ctor);\r
+                        break;\r
+                }\r
+            }\r
+\r
+            Type bakedType = newType.CreateType();\r
+            return bakedType;\r
+        }\r
+\r
+        // generates this constructor:\r
+        // public NewType(param0, param1, ...) : base(param0, param1, ...) { }\r
+        private static void ImplementConstructor(TypeBuilder newType, ConstructorInfo baseCtor) {\r
+            ParameterInfo[] parameters = baseCtor.GetParameters();\r
+            Type[] parameterTypes = (from p in parameters select p.ParameterType).ToArray();\r
+\r
+            ConstructorBuilder newCtor = newType.DefineConstructor(\r
+                (baseCtor.Attributes & ~MethodAttributes.MemberAccessMask) | MethodAttributes.Public /* force public constructor */,\r
+                baseCtor.CallingConvention, parameterTypes);\r
+\r
+            // parameter 0 is 'this', so we start at index 1\r
+            for (int i = 0; i < parameters.Length; i++) {\r
+                newCtor.DefineParameter(i + 1, parameters[i].Attributes, parameters[i].Name);\r
+            }\r
+\r
+            // load all arguments (including 'this') in proper order, then call and return\r
+            ILGenerator ilGen = newCtor.GetILGenerator();\r
+            for (int i = 0; i <= parameterTypes.Length; i++) {\r
+                ilGen.Emit(OpCodes.Ldarg_S, (byte)i);\r
+            }\r
+            ilGen.Emit(OpCodes.Call, baseCtor);\r
+            ilGen.Emit(OpCodes.Ret);\r
+        }\r
+\r
+        // generates this explicit interface method:\r
+        // public new Interface.Method(param0, param1, ...) {\r
+        //   return base.Method(param0, param1, ...);\r
+        // }\r
+        private static void ImplementInterfaceMethod(TypeBuilder newType, MethodInfo interfaceMethod) {\r
+            ParameterInfo[] parameters = interfaceMethod.GetParameters();\r
+            Type[] parameterTypes = (from p in parameters select p.ParameterType).ToArray();\r
+\r
+            // based on http://msdn.microsoft.com/en-us/library/system.reflection.emit.typebuilder.definemethodoverride.aspx\r
+            MethodBuilder newMethod = newType.DefineMethod(interfaceMethod.DeclaringType.Name + "." + interfaceMethod.Name,\r
+                MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual | MethodAttributes.Final,\r
+                interfaceMethod.ReturnType, parameterTypes);\r
+\r
+            MethodInfo baseMethod = newType.BaseType.GetMethod(interfaceMethod.Name, parameterTypes);\r
+\r
+            // parameter 0 is 'this', so we start at index 1\r
+            for (int i = 0; i < parameters.Length; i++) {\r
+                newMethod.DefineParameter(i + 1, parameters[i].Attributes, parameters[i].Name);\r
+            }\r
+\r
+            // load all arguments (including 'this') in proper order, then call and return\r
+            ILGenerator ilGen = newMethod.GetILGenerator();\r
+            for (int i = 0; i <= parameterTypes.Length; i++) {\r
+                ilGen.Emit(OpCodes.Ldarg_S, (byte)i);\r
+            }\r
+            ilGen.Emit(OpCodes.Call, baseMethod);\r
+            ilGen.Emit(OpCodes.Ret);\r
+\r
+            // finally, hook the new method up to the interface mapping\r
+            newType.DefineMethodOverride(newMethod, interfaceMethod);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/EmptyModelMetadataProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/EmptyModelMetadataProvider.cs
new file mode 100644 (file)
index 0000000..984924b
--- /dev/null
@@ -0,0 +1,23 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Reflection;\r
+\r
+    public class EmptyModelMetadataProvider : AssociatedMetadataProvider {\r
+        protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName) {\r
+            return new ModelMetadata(this, containerType, modelAccessor, modelType, propertyName);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/EmptyModelValidatorProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/EmptyModelValidatorProvider.cs
new file mode 100644 (file)
index 0000000..63fb1a2
--- /dev/null
@@ -0,0 +1,22 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+\r
+    public class EmptyModelValidatorProvider : ModelValidatorProvider {\r
+        public override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context) {\r
+            return Enumerable.Empty<ModelValidator>();\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/EmptyResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/EmptyResult.cs
new file mode 100644 (file)
index 0000000..3fef8ee
--- /dev/null
@@ -0,0 +1,29 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    // represents a result that doesn't do anything, like a controller action returning null\r
+    public class EmptyResult : ActionResult {\r
+\r
+        private static readonly EmptyResult _singleton = new EmptyResult();\r
+\r
+        internal static EmptyResult Instance {\r
+            get {\r
+                return _singleton;\r
+            }\r
+        }\r
+\r
+        public override void ExecuteResult(ControllerContext context) {\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Error.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Error.cs
new file mode 100644 (file)
index 0000000..26e86f8
--- /dev/null
@@ -0,0 +1,84 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Globalization;\r
+    using System.Web.Mvc.Async;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    internal static class Error {\r
+\r
+        public static InvalidOperationException AsyncActionMethodSelector_CouldNotFindMethod(string methodName, Type controllerType) {\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.AsyncActionMethodSelector_CouldNotFindMethod,\r
+                methodName, controllerType);\r
+            return new InvalidOperationException(message);\r
+        }\r
+\r
+        public static InvalidOperationException AsyncCommon_AsyncResultAlreadyConsumed() {\r
+            return new InvalidOperationException(MvcResources.AsyncCommon_AsyncResultAlreadyConsumed);\r
+        }\r
+\r
+        public static InvalidOperationException AsyncCommon_ControllerMustImplementIAsyncManagerContainer(Type actualControllerType) {\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.AsyncCommon_ControllerMustImplementIAsyncManagerContainer,\r
+                actualControllerType);\r
+            return new InvalidOperationException(message);\r
+        }\r
+\r
+        public static ArgumentException AsyncCommon_InvalidAsyncResult(string parameterName) {\r
+            return new ArgumentException(MvcResources.AsyncCommon_InvalidAsyncResult, parameterName);\r
+        }\r
+\r
+        public static ArgumentOutOfRangeException AsyncCommon_InvalidTimeout(string parameterName) {\r
+            return new ArgumentOutOfRangeException(parameterName, MvcResources.AsyncCommon_InvalidTimeout);\r
+        }\r
+\r
+        public static InvalidOperationException ReflectedAsyncActionDescriptor_CannotExecuteSynchronously(string actionName) {\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ReflectedAsyncActionDescriptor_CannotExecuteSynchronously,\r
+                actionName);\r
+            return new InvalidOperationException(message);\r
+        }\r
+\r
+        public static InvalidOperationException ChildActionOnlyAttribute_MustBeInChildRequest(ActionDescriptor actionDescriptor) {\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ChildActionOnlyAttribute_MustBeInChildRequest,\r
+                actionDescriptor.ActionName);\r
+            return new InvalidOperationException(message);\r
+        }\r
+\r
+        public static ArgumentException ParameterCannotBeNullOrEmpty(string parameterName) {\r
+            return new ArgumentException(MvcResources.Common_NullOrEmpty, parameterName);\r
+        }\r
+\r
+        public static InvalidOperationException PropertyCannotBeNullOrEmpty(string propertyName) {\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.Common_PropertyCannotBeNullOrEmpty,\r
+                propertyName);\r
+            return new InvalidOperationException(message);\r
+        }\r
+\r
+        public static SynchronousOperationException SynchronizationContextUtil_ExceptionThrown(Exception innerException) {\r
+            return new SynchronousOperationException(MvcResources.SynchronizationContextUtil_ExceptionThrown, innerException);\r
+        }\r
+\r
+        public static InvalidOperationException ViewDataDictionary_WrongTModelType(Type valueType, Type modelType) {\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ViewDataDictionary_WrongTModelType,\r
+                valueType, modelType);\r
+            return new InvalidOperationException(message);\r
+        }\r
+\r
+        public static InvalidOperationException ViewDataDictionary_ModelCannotBeNull(Type modelType) {\r
+            string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ViewDataDictionary_ModelCannotBeNull,\r
+                modelType);\r
+            return new InvalidOperationException(message);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExceptionContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExceptionContext.cs
new file mode 100644 (file)
index 0000000..937dd23
--- /dev/null
@@ -0,0 +1,56 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public class ExceptionContext : ControllerContext {\r
+\r
+        private ActionResult _result;\r
+\r
+        // parameterless constructor used for mocking\r
+        public ExceptionContext() {\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
+        public ExceptionContext(ControllerContext controllerContext, Exception exception)\r
+            : base(controllerContext) {\r
+            if (exception == null) {\r
+                throw new ArgumentNullException("exception");\r
+            }\r
+\r
+            Exception = exception;\r
+        }\r
+\r
+        public virtual Exception Exception {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public bool ExceptionHandled {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public ActionResult Result {\r
+            get {\r
+                return _result ?? EmptyResult.Instance;\r
+            }\r
+            set {\r
+                _result = value;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionHelper.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionHelper.cs
new file mode 100644 (file)
index 0000000..e72d94d
--- /dev/null
@@ -0,0 +1,123 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Linq.Expressions;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public static class ExpressionHelper {\r
+        public static string GetExpressionText(string expression) {\r
+            return\r
+                String.Equals(expression, "model", StringComparison.OrdinalIgnoreCase)\r
+                    ? String.Empty    // If it's exactly "model", then give them an empty string, to replicate the lambda behavior\r
+                    : expression;\r
+        }\r
+\r
+        public static string GetExpressionText(LambdaExpression expression) {\r
+            // Crack the expression string for property/field accessors to create its name\r
+            Stack<string> nameParts = new Stack<string>();\r
+            Expression part = expression.Body;\r
+\r
+            while (part != null) {\r
+                if (part.NodeType == ExpressionType.Call) {\r
+                    MethodCallExpression methodExpression = (MethodCallExpression)part;\r
+\r
+                    if (!IsSingleArgumentIndexer(methodExpression)) {\r
+                        break;\r
+                    }\r
+\r
+                    nameParts.Push(\r
+                        GetIndexerInvocation(\r
+                            methodExpression.Arguments.Single(),\r
+                            expression.Parameters.ToArray()\r
+                        )\r
+                    );\r
+\r
+                    part = methodExpression.Object;\r
+                }\r
+                else if (part.NodeType == ExpressionType.ArrayIndex) {\r
+                    BinaryExpression binaryExpression = (BinaryExpression)part;\r
+\r
+                    nameParts.Push(\r
+                        GetIndexerInvocation(\r
+                            binaryExpression.Right,\r
+                            expression.Parameters.ToArray()\r
+                        )\r
+                    );\r
+\r
+                    part = binaryExpression.Left;\r
+                }\r
+                else if (part.NodeType == ExpressionType.MemberAccess) {\r
+                    MemberExpression memberExpressionPart = (MemberExpression)part;\r
+                    nameParts.Push("." + memberExpressionPart.Member.Name);\r
+                    part = memberExpressionPart.Expression;\r
+                }\r
+                else {\r
+                    break;\r
+                }\r
+            }\r
+\r
+            // If it starts with "model", then strip that away\r
+            if (nameParts.Count > 0 && String.Equals(nameParts.Peek(), ".model", StringComparison.OrdinalIgnoreCase)) {\r
+                nameParts.Pop();\r
+            }\r
+\r
+            if (nameParts.Count > 0) {\r
+                return nameParts.Aggregate((left, right) => left + right).TrimStart('.');\r
+            }\r
+\r
+            return String.Empty;\r
+        }\r
+\r
+        private static string GetIndexerInvocation(Expression expression, ParameterExpression[] parameters) {\r
+            Expression converted = Expression.Convert(expression, typeof(object));\r
+            ParameterExpression fakeParameter = Expression.Parameter(typeof(object), null);\r
+            Expression<Func<object, object>> lambda = Expression.Lambda<Func<object, object>>(converted, fakeParameter);\r
+            Func<object, object> func;\r
+\r
+            try {\r
+                func = ExpressionUtil.CachedExpressionCompiler.Process(lambda);\r
+            }\r
+            catch (InvalidOperationException ex) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.ExpressionHelper_InvalidIndexerExpression,\r
+                        expression,\r
+                        parameters[0].Name\r
+                    ),\r
+                    ex\r
+                );\r
+            }\r
+\r
+            return "[" + Convert.ToString(func(null), CultureInfo.InvariantCulture) + "]";\r
+        }\r
+\r
+        internal static bool IsSingleArgumentIndexer(Expression expression) {\r
+            MethodCallExpression methodExpression = expression as MethodCallExpression;\r
+            if (methodExpression == null || methodExpression.Arguments.Count != 1) {\r
+                return false;\r
+            }\r
+\r
+            return methodExpression.Method\r
+                                   .DeclaringType\r
+                                   .GetDefaultMembers()\r
+                                   .OfType<PropertyInfo>()\r
+                                   .Any(p => p.GetGetMethod() == methodExpression.Method);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/BinaryExpressionFingerprint.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/BinaryExpressionFingerprint.cs
new file mode 100644 (file)
index 0000000..90e1fd4
--- /dev/null
@@ -0,0 +1,111 @@
+#pragma warning disable 659 // overrides AddToHashCodeCombiner instead\r
+\r
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq.Expressions;\r
+    using System.Reflection;\r
+\r
+    // BinaryExpression fingerprint class\r
+    // Useful for things like array[index]\r
+    //\r
+    // This particular fingerprint doesn't support the BinaryExpression.Conversion property,\r
+    // which is used in some coalescing operations.\r
+    [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals",\r
+        Justification = "Overrides AddToHashCodeCombiner() instead.")]\r
+    internal sealed class BinaryExpressionFingerprint : ExpressionFingerprint {\r
+\r
+        private BinaryExpressionFingerprint(BinaryExpression expression)\r
+            : base(expression) {\r
+            // don't care about UnaryExpression.IsLifted since it's not necessary to uniquely describe the expression,\r
+            // but IsLiftedToNull *is* required\r
+\r
+            IsLiftedToNull = expression.IsLiftedToNull;\r
+            Method = expression.Method;\r
+        }\r
+\r
+        public bool IsLiftedToNull {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ExpressionFingerprint Left {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public MethodInfo Method {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ExpressionFingerprint Right {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        internal override void AddToHashCodeCombiner(HashCodeCombiner combiner) {\r
+            base.AddToHashCodeCombiner(combiner);\r
+\r
+            combiner.AddInt32(IsLiftedToNull.GetHashCode());\r
+            combiner.AddFingerprint(Left);\r
+            combiner.AddObject(Method);\r
+            combiner.AddFingerprint(Right);\r
+        }\r
+\r
+        public static BinaryExpressionFingerprint Create(BinaryExpression expression, ParserContext parserContext) {\r
+            if (expression.Conversion != null) {\r
+                // we don't support the Conversion property\r
+                return null;\r
+            }\r
+\r
+            // if any fingerprinting fails, bail out\r
+            ExpressionFingerprint left = Create(expression.Left, parserContext);\r
+            if (left == null && expression.Left != null) {\r
+                return null;\r
+            }\r
+\r
+            ExpressionFingerprint right = Create(expression.Right, parserContext);\r
+            if (right == null && expression.Right != null) {\r
+                return null;\r
+            }\r
+\r
+            return new BinaryExpressionFingerprint(expression) {\r
+                Left = left,\r
+                Right = right\r
+            };\r
+        }\r
+\r
+        public override bool Equals(object obj) {\r
+            BinaryExpressionFingerprint other = obj as BinaryExpressionFingerprint;\r
+            if (other == null) {\r
+                return false;\r
+            }\r
+\r
+            return (this.IsLiftedToNull == other.IsLiftedToNull\r
+                && Object.Equals(this.Left, other.Left)\r
+                && this.Method == other.Method\r
+                && Object.Equals(this.Right, other.Right)\r
+                && base.Equals(other));\r
+        }\r
+\r
+        public override Expression ToExpression(ParserContext parserContext) {\r
+            Expression leftExpr = ToExpression(Left, parserContext);\r
+            Expression rightExpr = ToExpression(Right, parserContext);\r
+            return Expression.MakeBinary(NodeType, leftExpr, rightExpr, IsLiftedToNull, Method);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/CachedExpressionCompiler.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/CachedExpressionCompiler.cs
new file mode 100644 (file)
index 0000000..29078b6
--- /dev/null
@@ -0,0 +1,86 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Linq.Expressions;\r
+\r
+    internal static class CachedExpressionCompiler {\r
+\r
+        // This is the entry point to the cached expression tree compiler. The processor will perform a series of checks\r
+        // and optimizations in order to return a fully-compiled func as quickly as possible to the caller. If the\r
+        // input expression is particularly obscure, the system will fall back to a slow but correct compilation step.\r
+        public static Func<TModel, TValue> Process<TModel, TValue>(Expression<Func<TModel, TValue>> lambdaExpression) {\r
+            return Processor<TModel, TValue>.GetFunc(lambdaExpression);\r
+        }\r
+\r
+        private static class Processor<TModel, TValue> {\r
+\r
+            private static readonly Cache _cache = new Cache();\r
+\r
+            public static Func<TModel, TValue> GetFunc(Expression<Func<TModel, TValue>> lambdaExpression) {\r
+                // look for common patterns that don't need to be fingerprinted\r
+                Func<TModel, TValue> func = GetFuncFastTrack(lambdaExpression);\r
+                if (func != null) {\r
+                    return func;\r
+                }\r
+\r
+                // not a common pattern, so try fingerprinting (slower, but cached)\r
+                func = GetFuncFingerprinted(lambdaExpression);\r
+                if (func != null) {\r
+                    return func;\r
+                }\r
+\r
+                // pattern not recognized by fingerprinting routine, so compile directly (slowest)\r
+                return GetFuncSlow(lambdaExpression);\r
+            }\r
+\r
+            private static Func<TModel, TValue> GetFuncFastTrack(Expression<Func<TModel, TValue>> lambdaExpression) {\r
+                ParameterExpression modelParameter = lambdaExpression.Parameters[0];\r
+                Expression body = lambdaExpression.Body;\r
+\r
+                return FastTrack<TModel, TValue>.GetFunc(modelParameter, body);\r
+            }\r
+\r
+            private static Func<TModel, TValue> GetFuncFingerprinted(Expression<Func<TModel, TValue>> lambdaExpression) {\r
+                ParserContext context = ExpressionParser.Parse(lambdaExpression);\r
+                if (context.Fingerprint == null) {\r
+                    // fingerprinting failed\r
+                    return null;\r
+                }\r
+\r
+                object[] hoistedValues = context.HoistedValues.ToArray();\r
+                var del = _cache.GetDelegate(context);\r
+                return model => del(model, hoistedValues);\r
+            }\r
+\r
+            private static Func<TModel, TValue> GetFuncSlow(Expression<Func<TModel, TValue>> lambdaExpression) {\r
+                Func<TModel, TValue> del = lambdaExpression.Compile();\r
+                return del;\r
+            }\r
+\r
+            private sealed class Cache : ReaderWriterCache<ExpressionFingerprint, CompiledExpressionDelegate<TModel, TValue>> {\r
+                private static CompiledExpressionDelegate<TModel, TValue> CreateDelegate(ParserContext context) {\r
+                    var bodyExpr = context.Fingerprint.ToExpression(context);\r
+                    var lambdaExpr = Expression.Lambda<CompiledExpressionDelegate<TModel, TValue>>(bodyExpr, context.ModelParameter, ParserContext.HoistedValuesParameter);\r
+                    var del = lambdaExpr.Compile();\r
+                    return del;\r
+                }\r
+                public CompiledExpressionDelegate<TModel, TValue> GetDelegate(ParserContext context) {\r
+                    return FetchOrCreateItem(context.Fingerprint, () => CreateDelegate(context));\r
+                }\r
+            }\r
+\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/CompiledExpressionDelegate`2.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/CompiledExpressionDelegate`2.cs
new file mode 100644 (file)
index 0000000..dc95a90
--- /dev/null
@@ -0,0 +1,18 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+\r
+    internal delegate TValue CompiledExpressionDelegate<TModel, TValue>(TModel model, object[] hoistedValues);\r
+\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ConditionalExpressionFingerprint.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ConditionalExpressionFingerprint.cs
new file mode 100644 (file)
index 0000000..80e29f0
--- /dev/null
@@ -0,0 +1,97 @@
+#pragma warning disable 659 // overrides AddToHashCodeCombiner instead\r
+\r
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq.Expressions;\r
+\r
+    // ConditionalExpression fingerprint class\r
+    // Expression of form (test) ? ifTrue : ifFalse\r
+    [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals",\r
+        Justification = "Overrides AddToHashCodeCombiner() instead.")]\r
+    internal sealed class ConditionalExpressionFingerprint : ExpressionFingerprint {\r
+\r
+        private ConditionalExpressionFingerprint(ConditionalExpression expression)\r
+            : base(expression) {\r
+        }\r
+\r
+        public ExpressionFingerprint Test {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ExpressionFingerprint IfTrue {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ExpressionFingerprint IfFalse {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        internal override void AddToHashCodeCombiner(HashCodeCombiner combiner) {\r
+            base.AddToHashCodeCombiner(combiner);\r
+\r
+            combiner.AddFingerprint(Test);\r
+            combiner.AddFingerprint(IfTrue);\r
+            combiner.AddFingerprint(IfFalse);\r
+        }\r
+\r
+        public static ConditionalExpressionFingerprint Create(ConditionalExpression expression, ParserContext parserContext) {\r
+            // if any fingerprinting fails, bail out\r
+            ExpressionFingerprint test = Create(expression.Test, parserContext);\r
+            if (test == null && expression.Test != null) {\r
+                return null;\r
+            }\r
+\r
+            ExpressionFingerprint ifTrue = Create(expression.IfTrue, parserContext);\r
+            if (ifTrue == null && expression.IfTrue != null) {\r
+                return null;\r
+            }\r
+\r
+            ExpressionFingerprint ifFalse = Create(expression.IfFalse, parserContext);\r
+            if (ifFalse == null && expression.IfFalse != null) {\r
+                return null;\r
+            }\r
+\r
+            return new ConditionalExpressionFingerprint(expression) {\r
+                Test = test,\r
+                IfTrue = ifTrue,\r
+                IfFalse = ifFalse\r
+            };\r
+        }\r
+\r
+        public override bool Equals(object obj) {\r
+            ConditionalExpressionFingerprint other = obj as ConditionalExpressionFingerprint;\r
+            if (other == null) {\r
+                return false;\r
+            }\r
+\r
+            return (Object.Equals(this.Test, other.Test)\r
+                && Object.Equals(this.IfTrue, other.IfTrue)\r
+                && Object.Equals(this.IfFalse, other.IfFalse)\r
+                && base.Equals(other));\r
+        }\r
+\r
+        public override Expression ToExpression(ParserContext parserContext) {\r
+            Expression testExpr = ToExpression(Test, parserContext);\r
+            Expression ifTrueExpr = ToExpression(IfTrue, parserContext);\r
+            Expression ifFalseExpr = ToExpression(IfFalse, parserContext);\r
+            return Expression.Condition(testExpr, ifTrueExpr, ifFalseExpr);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ConstantExpressionFingerprint.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ConstantExpressionFingerprint.cs
new file mode 100644 (file)
index 0000000..96e08bc
--- /dev/null
@@ -0,0 +1,72 @@
+#pragma warning disable 659 // overrides AddToHashCodeCombiner instead\r
+\r
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq.Expressions;\r
+\r
+    // ConstantExpression fingerprint class\r
+    //\r
+    // A ConstantExpression might represent a captured local variable, so we can't compile\r
+    // the value directly into the cached function. Instead, a placeholder is generated\r
+    // and the value is hoisted into a local variables array. This placeholder can then\r
+    // be compiled and cached, and the array lookup happens at runtime.\r
+    [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals",\r
+        Justification = "Overrides AddToHashCodeCombiner() instead.")]\r
+    internal sealed class ConstantExpressionFingerprint : ExpressionFingerprint {\r
+\r
+        private ConstantExpressionFingerprint(ConstantExpression expression)\r
+            : base(expression) {\r
+        }\r
+\r
+        public int HoistedLocalsIndex {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        internal override void AddToHashCodeCombiner(HashCodeCombiner combiner) {\r
+            base.AddToHashCodeCombiner(combiner);\r
+\r
+            combiner.AddInt32(HoistedLocalsIndex);\r
+        }\r
+\r
+        public static ConstantExpressionFingerprint Create(ConstantExpression expression, ParserContext parserContext) {\r
+            ConstantExpressionFingerprint fingerprint = new ConstantExpressionFingerprint(expression) {\r
+                HoistedLocalsIndex = parserContext.HoistedValues.Count\r
+            };\r
+\r
+            parserContext.HoistedValues.Add(expression.Value);\r
+            return fingerprint;\r
+        }\r
+\r
+        public override bool Equals(object obj) {\r
+            ConstantExpressionFingerprint other = obj as ConstantExpressionFingerprint;\r
+            if (other == null) {\r
+                return false;\r
+            }\r
+\r
+            return (this.HoistedLocalsIndex == other.HoistedLocalsIndex\r
+                && base.Equals(other));\r
+        }\r
+\r
+        public override Expression ToExpression(ParserContext parserContext) {\r
+            // (Type) HoistedValues[HoistedLocalsIndex]\r
+            BinaryExpression arrayIndex = Expression.ArrayIndex(ParserContext.HoistedValuesParameter, Expression.Constant(HoistedLocalsIndex));\r
+            UnaryExpression castExpr = Expression.Convert(arrayIndex, Type);\r
+            return castExpr;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ExpressionFingerprint.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ExpressionFingerprint.cs
new file mode 100644 (file)
index 0000000..c942d9b
--- /dev/null
@@ -0,0 +1,174 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.ObjectModel;\r
+    using System.Linq;\r
+    using System.Linq.Expressions;\r
+\r
+    // Expression fingerprint class\r
+    // Contains information used for generalizing, comparing, and recreating Expression instances\r
+    //\r
+    // Since Expression objects are immutable and are recreated for every invocation of an expression\r
+    // helper method, they can't be compared directly. Fingerprinting Expression objects allows\r
+    // information about them to be abstracted away, and the fingerprints can be directly compared.\r
+    // Consider the process of fingerprinting that all values (parameters, constants, etc.) are hoisted\r
+    // and replaced with dummies. What remains can be decomposed into a sequence of operations on specific\r
+    // types and specific inputs.\r
+    //\r
+    // Some sample fingerprints:\r
+    //\r
+    // 2 + 4 -> OP_ADD(CONST:int, CONST:int):int\r
+    // 2 + 8 -> OP_ADD(CONST:int, CONST:int):int\r
+    // 2.0 + 4.0 -> OP_ADD(CONST:double, CONST:double):double\r
+    //\r
+    // 2 + 4 and 2 + 8 have the same fingerprint, but 2.0 + 4.0 has a different fingerprint since its\r
+    // underlying types differ.\r
+    //\r
+    // "Hello " + "world" -> OP_ADD(CONST:string, CONST:string):string\r
+    // "Hello " + {model} -> OP_ADD(CONST:string, PARAM:string):string\r
+    //\r
+    // These string concatenations have different fingerprints since the inputs are provided differently:\r
+    // one is a hoisted local, the other is a parameter.\r
+    //\r
+    // ({model} ?? "sample").Length -> MEMBER_ACCESS(String.Length, OP_COALESCE(PARAM:string, CONST:string):string):int\r
+    // ({model} ?? "other sample").Length -> MEMBER_ACCESS(String.Length, OP_COALESCE(PARAM:string, CONST:string):string):int\r
+    //\r
+    // These expressions have the same fingerprint.\r
+    internal abstract class ExpressionFingerprint {\r
+\r
+        protected ExpressionFingerprint(Expression expression) {\r
+            // since the fingerprints are cached potentially forever, don't keep a reference\r
+            // to the original expression\r
+\r
+            NodeType = expression.NodeType;\r
+            Type = expression.Type;\r
+        }\r
+\r
+        // the type of expression node, e.g. OP_ADD, MEMBER_ACCESS, etc.\r
+        public ExpressionType NodeType {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        // the CLR type resulting from this expression, e.g. int, string, etc.\r
+        public Type Type {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        internal virtual void AddToHashCodeCombiner(HashCodeCombiner combiner) {\r
+            combiner.AddObject(NodeType);\r
+            combiner.AddObject(Type);\r
+        }\r
+\r
+        public static ExpressionFingerprint Create(Expression expression, ParserContext parserContext) {\r
+            {\r
+                BinaryExpression binaryExpression = expression as BinaryExpression;\r
+                if (binaryExpression != null) {\r
+                    return BinaryExpressionFingerprint.Create(binaryExpression, parserContext);\r
+                }\r
+            }\r
+\r
+            {\r
+                ConditionalExpression conditionalExpression = expression as ConditionalExpression;\r
+                if (conditionalExpression != null) {\r
+                    return ConditionalExpressionFingerprint.Create(conditionalExpression, parserContext);\r
+                }\r
+            }\r
+\r
+            {\r
+                ConstantExpression constantExpression = expression as ConstantExpression;\r
+                if (constantExpression != null) {\r
+                    return ConstantExpressionFingerprint.Create(constantExpression, parserContext);\r
+                }\r
+            }\r
+\r
+            {\r
+                MemberExpression memberExpression = expression as MemberExpression;\r
+                if (memberExpression != null) {\r
+                    return MemberExpressionFingerprint.Create(memberExpression, parserContext);\r
+                }\r
+            }\r
+\r
+            {\r
+                MethodCallExpression methodCallExpression = expression as MethodCallExpression;\r
+                if (methodCallExpression != null) {\r
+                    return MethodCallExpressionFingerprint.Create(methodCallExpression, parserContext);\r
+                }\r
+            }\r
+\r
+            {\r
+                ParameterExpression parameterExpression = expression as ParameterExpression;\r
+                if (parameterExpression != null) {\r
+                    return ParameterExpressionFingerprint.Create(parameterExpression, parserContext);\r
+                }\r
+            }\r
+\r
+            {\r
+                UnaryExpression unaryExpression = expression as UnaryExpression;\r
+                if (unaryExpression != null) {\r
+                    return UnaryExpressionFingerprint.Create(unaryExpression, parserContext);\r
+                }\r
+            }\r
+\r
+            // unknown expression\r
+            return null;\r
+        }\r
+\r
+        public static ReadOnlyCollection<ExpressionFingerprint> Create(IEnumerable<Expression> expressions, ParserContext parserContext) {\r
+            List<ExpressionFingerprint> fingerprints = new List<ExpressionFingerprint>();\r
+            foreach (Expression expression in expressions) {\r
+                ExpressionFingerprint fingerprint = Create(expression, parserContext);\r
+                if (fingerprint == null && expression != null) {\r
+                    // something couldn't be parsed properly\r
+                    return null;\r
+                }\r
+                else {\r
+                    fingerprints.Add(fingerprint);\r
+                }\r
+            }\r
+            return new ReadOnlyCollection<ExpressionFingerprint>(fingerprints);\r
+        }\r
+\r
+        public override int GetHashCode() {\r
+            HashCodeCombiner combiner = new HashCodeCombiner();\r
+            combiner.AddObject(GetType());\r
+            AddToHashCodeCombiner(combiner);\r
+            return combiner.CombinedHash;\r
+        }\r
+\r
+        public override bool Equals(object obj) {\r
+            ExpressionFingerprint other = obj as ExpressionFingerprint;\r
+            if (other == null) {\r
+                return false;\r
+            }\r
+\r
+            return (this.NodeType == other.NodeType\r
+                && this.Type == other.Type\r
+                && this.GetType() == other.GetType());\r
+        }\r
+\r
+        protected static Expression ToExpression(ExpressionFingerprint fingerprint, ParserContext parserContext) {\r
+            return (fingerprint != null) ? fingerprint.ToExpression(parserContext) : null;\r
+        }\r
+\r
+        protected static IEnumerable<Expression> ToExpression(IEnumerable<ExpressionFingerprint> fingerprints, ParserContext parserContext) {\r
+            return from fingerprint in fingerprints select ToExpression(fingerprint, parserContext);\r
+        }\r
+\r
+        public abstract Expression ToExpression(ParserContext parserContext);\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ExpressionParser.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ExpressionParser.cs
new file mode 100644 (file)
index 0000000..f277a9f
--- /dev/null
@@ -0,0 +1,30 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Linq.Expressions;\r
+\r
+    internal static class ExpressionParser {\r
+\r
+        public static ParserContext Parse<TModel, TValue>(Expression<Func<TModel, TValue>> expression) {\r
+            ParserContext context = new ParserContext() {\r
+                ModelParameter = expression.Parameters[0]\r
+            };\r
+\r
+            Expression body = expression.Body;\r
+            context.Fingerprint = ExpressionFingerprint.Create(body, context);\r
+            return context;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/FastTrack`2.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/FastTrack`2.cs
new file mode 100644 (file)
index 0000000..ec20c8c
--- /dev/null
@@ -0,0 +1,112 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Linq.Expressions;\r
+    using System.Reflection;\r
+\r
+    internal static class FastTrack<TModel, TValue> {\r
+\r
+        private static Func<TModel, TValue> _identityFunc;\r
+\r
+        private static readonly ConstMemberLookupCache _constMemberLookupCache = new ConstMemberLookupCache();\r
+        private static readonly ModelMemberLookupCache _modelMemberLookupCache = new ModelMemberLookupCache();\r
+\r
+        public static Func<TModel, TValue> GetFunc(ParameterExpression modelParameter, Expression body) {\r
+            { // model => model\r
+                if (modelParameter == body) {\r
+                    return GetIdentityFunc();\r
+                }\r
+            }\r
+\r
+            { // model => {const}\r
+                ConstantExpression constantExpression = body as ConstantExpression;\r
+                if (constantExpression != null) {\r
+                    TValue value = (TValue)constantExpression.Value;\r
+                    return _ => value;\r
+                }\r
+            }\r
+\r
+            {\r
+                MemberExpression memberExpression = body as MemberExpression;\r
+                if (memberExpression != null) {\r
+                    if (memberExpression.Expression == null) {\r
+                        // model => {static member}\r
+                        return GetModelMemberLookupFunc(memberExpression.Member, true /* isStatic */);\r
+                    }\r
+                    else if (memberExpression.Expression == modelParameter) {\r
+                        // model => model.Member\r
+                        return GetModelMemberLookupFunc(memberExpression.Member, false /* isStatic */);\r
+                    }\r
+                    else {\r
+                        ConstantExpression constantExpression = memberExpression.Expression as ConstantExpression;\r
+                        if (constantExpression != null) {\r
+                            // model => {const}.Member, e.g. captured local variable in a foreach\r
+                            return GetConstMemberLookupFunc(memberExpression.Member, constantExpression.Value);\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+\r
+            // don't know how to fast-track\r
+            return null;\r
+        }\r
+\r
+        private static Func<TModel, TValue> GetIdentityFunc() {\r
+            // don't need to worry about locking since all identity funcs are the same\r
+            if (_identityFunc == null) {\r
+                ParameterExpression modelParameter = Expression.Parameter(typeof(TModel), "model");\r
+                Expression<Func<TModel, TValue>> identityLambda = Expression.Lambda<Func<TModel, TValue>>(modelParameter, modelParameter);\r
+                _identityFunc = identityLambda.Compile();\r
+            }\r
+\r
+            return _identityFunc;\r
+        }\r
+\r
+        private static Func<TModel, TValue> GetModelMemberLookupFunc(MemberInfo member, bool isStatic) {\r
+            return _modelMemberLookupCache.GetFunc(member, isStatic);\r
+        }\r
+\r
+        private static Func<TModel, TValue> GetConstMemberLookupFunc(MemberInfo member, object constValue) {\r
+            Func<object, TValue> innerFunc = _constMemberLookupCache.GetFunc(member);\r
+            return _ => innerFunc(constValue);\r
+        }\r
+\r
+        private sealed class ConstMemberLookupCache : ReaderWriterCache<MemberInfo, Func<object, TValue>> {\r
+            private static Func<object, TValue> CreateFunc(MemberInfo member) {\r
+                ParameterExpression constParam = Expression.Parameter(typeof(object), "constValue");\r
+                // cast is necessary since the constant value comes in as a standard 'object'\r
+                UnaryExpression castExpr = Expression.Convert(constParam, member.DeclaringType);\r
+                MemberExpression memberExpr = Expression.MakeMemberAccess(castExpr, member);\r
+                Expression<Func<object, TValue>> lambda = Expression.Lambda<Func<object, TValue>>(memberExpr, constParam);\r
+                return lambda.Compile();\r
+            }\r
+            public Func<object, TValue> GetFunc(MemberInfo member) {\r
+                return FetchOrCreateItem(member, () => CreateFunc(member));\r
+            }\r
+        }\r
+\r
+        private sealed class ModelMemberLookupCache : ReaderWriterCache<MemberInfo, Func<TModel, TValue>> {\r
+            private static Func<TModel, TValue> CreateFunc(MemberInfo member, bool isStatic) {\r
+                ParameterExpression modelParam = Expression.Parameter(typeof(TModel), "model");\r
+                MemberExpression memberExpr = Expression.MakeMemberAccess((!isStatic) ? modelParam : null, member);\r
+                Expression<Func<TModel, TValue>> lambda = Expression.Lambda<Func<TModel, TValue>>(memberExpr, modelParam);\r
+                return lambda.Compile();\r
+            }\r
+            public Func<TModel, TValue> GetFunc(MemberInfo member, bool isStatic) {\r
+                return FetchOrCreateItem(member, () => CreateFunc(member, isStatic));\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/HashCodeCombiner.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/HashCodeCombiner.cs
new file mode 100644 (file)
index 0000000..5abdded
--- /dev/null
@@ -0,0 +1,61 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Collections;\r
+\r
+    // based on System.Web.Util.HashCodeCombiner\r
+    internal class HashCodeCombiner {\r
+\r
+        private long _combinedHash64 = 0x1505L;\r
+\r
+        public void AddFingerprint(ExpressionFingerprint fingerprint) {\r
+            if (fingerprint != null) {\r
+                fingerprint.AddToHashCodeCombiner(this);\r
+            }\r
+            else {\r
+                AddInt32(0);\r
+            }\r
+        }\r
+\r
+        public void AddEnumerable(IEnumerable e) {\r
+            if (e == null) {\r
+                AddInt32(0);\r
+            }\r
+            else {\r
+                int count = 0;\r
+                foreach (object o in e) {\r
+                    AddObject(o);\r
+                    count++;\r
+                }\r
+                AddInt32(count);\r
+            }\r
+        }\r
+\r
+        public void AddInt32(int i) {\r
+            _combinedHash64 = ((_combinedHash64 << 5) + _combinedHash64) ^ i;\r
+        }\r
+\r
+        public void AddObject(object o) {\r
+            int oHashCode = (o != null) ? o.GetHashCode() : 0;\r
+            AddInt32(oHashCode);\r
+        }\r
+\r
+        public int CombinedHash {\r
+            get {\r
+                return _combinedHash64.GetHashCode();\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/MemberExpressionFingerprint.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/MemberExpressionFingerprint.cs
new file mode 100644 (file)
index 0000000..6a55769
--- /dev/null
@@ -0,0 +1,78 @@
+#pragma warning disable 659 // overrides AddToHashCodeCombiner instead\r
+\r
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq.Expressions;\r
+    using System.Reflection;\r
+\r
+    // MemberExpression fingerprint class\r
+    // Expression of form xxx.FieldOrProperty\r
+    [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals",\r
+        Justification = "Overrides AddToHashCodeCombiner() instead.")]\r
+    internal sealed class MemberExpressionFingerprint : ExpressionFingerprint {\r
+\r
+        private MemberExpressionFingerprint(MemberExpression expression)\r
+            : base(expression) {\r
+\r
+            Member = expression.Member;\r
+        }\r
+\r
+        public MemberInfo Member {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ExpressionFingerprint Target {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        internal override void AddToHashCodeCombiner(HashCodeCombiner combiner) {\r
+            base.AddToHashCodeCombiner(combiner);\r
+\r
+            combiner.AddObject(Member);\r
+            combiner.AddFingerprint(Target);\r
+        }\r
+\r
+        public static MemberExpressionFingerprint Create(MemberExpression expression, ParserContext parserContext) {\r
+            ExpressionFingerprint target = Create(expression.Expression, parserContext);\r
+            if (target == null && expression.Expression != null) {\r
+                return null;\r
+            }\r
+\r
+            return new MemberExpressionFingerprint(expression) {\r
+                Target = target\r
+            };\r
+        }\r
+\r
+        public override bool Equals(object obj) {\r
+            MemberExpressionFingerprint other = obj as MemberExpressionFingerprint;\r
+            if (other == null) {\r
+                return false;\r
+            }\r
+\r
+            return (this.Member == other.Member\r
+                && Object.Equals(this.Target, other.Target)\r
+                && base.Equals(other));\r
+        }\r
+\r
+        public override Expression ToExpression(ParserContext parserContext) {\r
+            Expression targetExpr = ToExpression(Target, parserContext);\r
+            return Expression.MakeMemberAccess(targetExpr, Member);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/MethodCallExpressionFingerprint.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/MethodCallExpressionFingerprint.cs
new file mode 100644 (file)
index 0000000..7b8455c
--- /dev/null
@@ -0,0 +1,95 @@
+#pragma warning disable 659 // overrides AddToHashCodeCombiner instead\r
+\r
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.ObjectModel;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq;\r
+    using System.Linq.Expressions;\r
+    using System.Reflection;\r
+\r
+    // MethodCallExpression fingerprint class\r
+    // Expression of form xxx.Foo(...), xxx[...] (get_Item()), etc.\r
+    [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals",\r
+        Justification = "Overrides AddToHashCodeCombiner() instead.")]\r
+    internal sealed class MethodCallExpressionFingerprint : ExpressionFingerprint {\r
+\r
+        private MethodCallExpressionFingerprint(MethodCallExpression expression)\r
+            : base(expression) {\r
+\r
+            Method = expression.Method;\r
+        }\r
+\r
+        public ReadOnlyCollection<ExpressionFingerprint> Arguments {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public MethodInfo Method {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ExpressionFingerprint Target {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        internal override void AddToHashCodeCombiner(HashCodeCombiner combiner) {\r
+            base.AddToHashCodeCombiner(combiner);\r
+\r
+            combiner.AddEnumerable(Arguments);\r
+            combiner.AddObject(Method);\r
+            combiner.AddFingerprint(Target);\r
+        }\r
+\r
+        public static MethodCallExpressionFingerprint Create(MethodCallExpression expression, ParserContext parserContext) {\r
+            ReadOnlyCollection<ExpressionFingerprint> arguments = Create(expression.Arguments, parserContext);\r
+            if (arguments == null) {\r
+                return null;\r
+            }\r
+\r
+            ExpressionFingerprint target = Create(expression.Object, parserContext);\r
+            if (target == null && expression.Object != null) {\r
+                return null;\r
+            }\r
+\r
+            return new MethodCallExpressionFingerprint(expression) {\r
+                Arguments = arguments,\r
+                Target = target\r
+            };\r
+        }\r
+\r
+        public override bool Equals(object obj) {\r
+            MethodCallExpressionFingerprint other = obj as MethodCallExpressionFingerprint;\r
+            if (other == null) {\r
+                return false;\r
+            }\r
+\r
+            return (this.Arguments.SequenceEqual(other.Arguments)\r
+                && this.Method == other.Method\r
+                && Object.Equals(this.Target, other.Target)\r
+                && base.Equals(other));\r
+        }\r
+\r
+        public override Expression ToExpression(ParserContext parserContext) {\r
+            Expression targetExpr = ToExpression(Target, parserContext);\r
+            IEnumerable<Expression> argumentsExpr = ToExpression(Arguments, parserContext);\r
+            return Expression.Call(targetExpr, Method, argumentsExpr);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ParameterExpressionFingerprint.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ParameterExpressionFingerprint.cs
new file mode 100644 (file)
index 0000000..399f686
--- /dev/null
@@ -0,0 +1,42 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Linq.Expressions;\r
+\r
+    // ParameterExpression fingerprint class\r
+    // Specifically, instances of this type represent the model parameter\r
+    internal sealed class ParameterExpressionFingerprint : ExpressionFingerprint {\r
+\r
+        private ParameterExpressionFingerprint(ParameterExpression expression)\r
+            : base(expression) {\r
+        }\r
+\r
+        public static ParameterExpressionFingerprint Create(ParameterExpression expression, ParserContext parserContext) {\r
+            if (expression == parserContext.ModelParameter) {\r
+                return new ParameterExpressionFingerprint(expression);\r
+            }\r
+            else {\r
+                // degenerate case - uncaptured parameter expression passed into the system\r
+                return null;\r
+            }\r
+        }\r
+\r
+        public override Expression ToExpression(ParserContext parserContext) {\r
+            // The only time an instance of this class exists is if it represents the actual model parameter,\r
+            // so just return it directly.\r
+            return parserContext.ModelParameter;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ParserContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/ParserContext.cs
new file mode 100644 (file)
index 0000000..38281c3
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Linq.Expressions;\r
+    using System.Collections.Generic;\r
+\r
+    internal class ParserContext {\r
+\r
+        public static readonly ParameterExpression HoistedValuesParameter = Expression.Parameter(typeof(object[]), "hoistedValues");\r
+\r
+        public ExpressionFingerprint Fingerprint;\r
+        public readonly List<object> HoistedValues = new List<object>();\r
+        public ParameterExpression ModelParameter;\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/UnaryExpressionFingerprint.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ExpressionUtil/UnaryExpressionFingerprint.cs
new file mode 100644 (file)
index 0000000..8ba8cfa
--- /dev/null
@@ -0,0 +1,87 @@
+#pragma warning disable 659 // overrides AddToHashCodeCombiner instead\r
+\r
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.ExpressionUtil {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq.Expressions;\r
+    using System.Reflection;\r
+\r
+    // UnaryExpression fingerprint class\r
+    // The most common appearance of a UnaryExpression is a cast or other conversion operator\r
+    [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals",\r
+        Justification = "Overrides AddToHashCodeCombiner() instead.")]\r
+    internal sealed class UnaryExpressionFingerprint : ExpressionFingerprint {\r
+\r
+        private UnaryExpressionFingerprint(UnaryExpression expression)\r
+            : base(expression) {\r
+            // don't care about UnaryExpression.IsLifted / IsLiftedToNull since they're not necessary to uniquely describe the expression\r
+\r
+            Method = expression.Method;\r
+        }\r
+\r
+        public MethodInfo Method {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ExpressionFingerprint Operand {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        internal override void AddToHashCodeCombiner(HashCodeCombiner combiner) {\r
+            base.AddToHashCodeCombiner(combiner);\r
+\r
+            combiner.AddObject(Method);\r
+            combiner.AddFingerprint(Operand);\r
+        }\r
+\r
+        public static UnaryExpressionFingerprint Create(UnaryExpression expression, ParserContext parserContext) {\r
+            ExpressionFingerprint operand = Create(expression.Operand, parserContext);\r
+            if (operand == null && expression.Operand != null) {\r
+                // couldn't convert the operand, so bail\r
+                return null;\r
+            }\r
+\r
+            return new UnaryExpressionFingerprint(expression) {\r
+                Operand = operand\r
+            };\r
+        }\r
+\r
+        public override bool Equals(object obj) {\r
+            UnaryExpressionFingerprint other = obj as UnaryExpressionFingerprint;\r
+            if (other == null) {\r
+                return false;\r
+            }\r
+\r
+            return (this.Method == other.Method\r
+                && Object.Equals(this.Operand, other.Operand)\r
+                && base.Equals(other));\r
+        }\r
+\r
+        public override Expression ToExpression(ParserContext parserContext) {\r
+            Expression operandExpr = ToExpression(Operand, parserContext);\r
+\r
+            // in .NET 3.5 SP1, Expression.MakeUnary() throws if NodeType is UnaryPlus, so special-case\r
+            if (NodeType == ExpressionType.UnaryPlus) {\r
+                return Expression.UnaryPlus(operandExpr, Method);\r
+            }\r
+            else {\r
+                return Expression.MakeUnary(NodeType, operandExpr, Type, Method);\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FieldValidationMetadata.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FieldValidationMetadata.cs
new file mode 100644 (file)
index 0000000..5dda044
--- /dev/null
@@ -0,0 +1,49 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.ObjectModel;\r
+\r
+    public class FieldValidationMetadata {\r
+\r
+        private string _fieldName;\r
+        private readonly Collection<ModelClientValidationRule> _validationRules = new Collection<ModelClientValidationRule>();\r
+\r
+        public string FieldName {\r
+            get {\r
+                return _fieldName ?? String.Empty;\r
+            }\r
+            set {\r
+                _fieldName = value;\r
+            }\r
+        }\r
+\r
+        public bool ReplaceValidationMessageContents {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public string ValidationMessageId {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public ICollection<ModelClientValidationRule> ValidationRules {\r
+            get {\r
+                return _validationRules;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FileContentResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FileContentResult.cs
new file mode 100644 (file)
index 0000000..8a2fdc0
--- /dev/null
@@ -0,0 +1,41 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Web;\r
+\r
+    public class FileContentResult : FileResult {\r
+\r
+        public FileContentResult(byte[] fileContents, string contentType)\r
+            : base(contentType) {\r
+            if (fileContents == null) {\r
+                throw new ArgumentNullException("fileContents");\r
+            }\r
+\r
+            FileContents = fileContents;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays",\r
+            Justification = "There's no reason to tamper-proof this array since it's supplied to the type's constructor.")]\r
+        public byte[] FileContents {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        protected override void WriteFile(HttpResponseBase response) {\r
+            response.OutputStream.Write(FileContents, 0, FileContents.Length);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FilePathResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FilePathResult.cs
new file mode 100644 (file)
index 0000000..550113f
--- /dev/null
@@ -0,0 +1,39 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class FilePathResult : FileResult {\r
+\r
+        public FilePathResult(string fileName, string contentType)\r
+            : base(contentType) {\r
+            if (String.IsNullOrEmpty(fileName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "fileName");\r
+            }\r
+\r
+            FileName = fileName;\r
+        }\r
+\r
+        public string FileName {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        protected override void WriteFile(HttpResponseBase response) {\r
+            response.TransmitFile(FileName);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FileResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FileResult.cs
new file mode 100644 (file)
index 0000000..8127e46
--- /dev/null
@@ -0,0 +1,143 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Net.Mime;\r
+    using System.Text;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public abstract class FileResult : ActionResult {\r
+\r
+        protected FileResult(string contentType) {\r
+            if (String.IsNullOrEmpty(contentType)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "contentType");\r
+            }\r
+\r
+            ContentType = contentType;\r
+        }\r
+\r
+        private string _fileDownloadName;\r
+\r
+        public string ContentType {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public string FileDownloadName {\r
+            get {\r
+                return _fileDownloadName ?? String.Empty;\r
+            }\r
+            set {\r
+                _fileDownloadName = value;\r
+            }\r
+        }\r
+\r
+        public override void ExecuteResult(ControllerContext context) {\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+\r
+            HttpResponseBase response = context.HttpContext.Response;\r
+            response.ContentType = ContentType;\r
+\r
+            if (!String.IsNullOrEmpty(FileDownloadName)) {\r
+                // From RFC 2183, Sec. 2.3:\r
+                // The sender may want to suggest a filename to be used if the entity is\r
+                // detached and stored in a separate file. If the receiving MUA writes\r
+                // the entity to a file, the suggested filename should be used as a\r
+                // basis for the actual filename, where possible.\r
+                string headerValue = ContentDispositionUtil.GetHeaderValue(FileDownloadName);\r
+                context.HttpContext.Response.AddHeader("Content-Disposition", headerValue);\r
+            }\r
+\r
+            WriteFile(response);\r
+        }\r
+\r
+        protected abstract void WriteFile(HttpResponseBase response);\r
+\r
+        private static class ContentDispositionUtil {\r
+            private const string _hexDigits = "0123456789ABCDEF";\r
+\r
+            private static void AddByteToStringBuilder(byte b, StringBuilder builder) {\r
+                builder.Append('%');\r
+\r
+                int i = b;\r
+                AddHexDigitToStringBuilder(i >> 4, builder);\r
+                AddHexDigitToStringBuilder(i % 16, builder);\r
+            }\r
+\r
+            private static void AddHexDigitToStringBuilder(int digit, StringBuilder builder) {\r
+                builder.Append(_hexDigits[digit]);\r
+            }\r
+\r
+            private static string CreateRfc2231HeaderValue(string filename) {\r
+                StringBuilder builder = new StringBuilder("attachment; filename*=UTF-8''");\r
+\r
+                byte[] filenameBytes = Encoding.UTF8.GetBytes(filename);\r
+                foreach (byte b in filenameBytes) {\r
+                    if (IsByteValidHeaderValueCharacter(b)) {\r
+                        builder.Append((char)b);\r
+                    }\r
+                    else {\r
+                        AddByteToStringBuilder(b, builder);\r
+                    }\r
+                }\r
+\r
+                return builder.ToString();\r
+            }\r
+\r
+            public static string GetHeaderValue(string fileName) {\r
+                try {\r
+                    // first, try using the .NET built-in generator\r
+                    ContentDisposition disposition = new ContentDisposition() { FileName = fileName };\r
+                    return disposition.ToString();\r
+                }\r
+                catch (FormatException) {\r
+                    // otherwise, fall back to RFC 2231 extensions generator\r
+                    return CreateRfc2231HeaderValue(fileName);\r
+                }\r
+            }\r
+\r
+            // Application of RFC 2231 Encoding to Hypertext Transfer Protocol (HTTP) Header Fields, sec. 3.2\r
+            // http://greenbytes.de/tech/webdav/draft-reschke-rfc2231-in-http-latest.html\r
+            private static bool IsByteValidHeaderValueCharacter(byte b) {\r
+                if ((byte)'0' <= b && b <= (byte)'9') {\r
+                    return true; // is digit\r
+                }\r
+                if ((byte)'a' <= b && b <= (byte)'z') {\r
+                    return true; // lowercase letter\r
+                }\r
+                if ((byte)'A' <= b && b <= (byte)'Z') {\r
+                    return true; // uppercase letter\r
+                }\r
+\r
+                switch (b) {\r
+                    case (byte)'-':\r
+                    case (byte)'.':\r
+                    case (byte)'_':\r
+                    case (byte)'~':\r
+                    case (byte)':':\r
+                    case (byte)'!':\r
+                    case (byte)'$':\r
+                    case (byte)'&':\r
+                    case (byte)'+':\r
+                        return true;\r
+                }\r
+\r
+                return false;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FileStreamResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FileStreamResult.cs
new file mode 100644 (file)
index 0000000..a6e1a6f
--- /dev/null
@@ -0,0 +1,56 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.IO;\r
+    using System.Web;\r
+\r
+    public class FileStreamResult : FileResult {\r
+\r
+        // default buffer size as defined in BufferedStream type\r
+        private const int _bufferSize = 0x1000;\r
+\r
+        public FileStreamResult(Stream fileStream, string contentType)\r
+            : base(contentType) {\r
+            if (fileStream == null) {\r
+                throw new ArgumentNullException("fileStream");\r
+            }\r
+\r
+            FileStream = fileStream;\r
+        }\r
+\r
+        public Stream FileStream {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        protected override void WriteFile(HttpResponseBase response) {\r
+            // grab chunks of data and write to the output stream\r
+            Stream outputStream = response.OutputStream;\r
+            using (FileStream) {\r
+                byte[] buffer = new byte[_bufferSize];\r
+\r
+                while (true) {\r
+                    int bytesRead = FileStream.Read(buffer, 0, _bufferSize);\r
+                    if (bytesRead == 0) {\r
+                        // no more data\r
+                        break;\r
+                    }\r
+\r
+                    outputStream.Write(buffer, 0, bytesRead);\r
+                }\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FilterAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FilterAttribute.cs
new file mode 100644 (file)
index 0000000..1cda086
--- /dev/null
@@ -0,0 +1,35 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]\r
+    public abstract class FilterAttribute : Attribute {\r
+\r
+        private int _order = -1;\r
+\r
+        public int Order {\r
+            get {\r
+                return _order;\r
+            }\r
+            set {\r
+                if (value < -1) {\r
+                    throw new ArgumentOutOfRangeException("value",\r
+                        MvcResources.FilterAttribute_OrderOutOfRange);\r
+                }\r
+                _order = value;\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FilterInfo.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FilterInfo.cs
new file mode 100644 (file)
index 0000000..031ffe3
--- /dev/null
@@ -0,0 +1,48 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+\r
+    public class FilterInfo {\r
+\r
+        private List<IActionFilter> _actionFilters = new List<IActionFilter>();\r
+        private List<IAuthorizationFilter> _authorizationFilters = new List<IAuthorizationFilter>();\r
+        private List<IExceptionFilter> _exceptionFilters = new List<IExceptionFilter>();\r
+        private List<IResultFilter> _resultFilters = new List<IResultFilter>();\r
+\r
+        public IList<IActionFilter> ActionFilters {\r
+            get {\r
+                return _actionFilters;\r
+            }\r
+        }\r
+\r
+        public IList<IAuthorizationFilter> AuthorizationFilters {\r
+            get {\r
+                return _authorizationFilters;\r
+            }\r
+        }\r
+\r
+        public IList<IExceptionFilter> ExceptionFilters {\r
+            get {\r
+                return _exceptionFilters;\r
+            }\r
+        }\r
+\r
+        public IList<IResultFilter> ResultFilters {\r
+            get {\r
+                return _resultFilters;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormCollection.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormCollection.cs
new file mode 100644 (file)
index 0000000..3736bae
--- /dev/null
@@ -0,0 +1,89 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Specialized;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable",\r
+        Justification = "It is not anticipated that users will need to serialize this type.")]\r
+    [SuppressMessage("Microsoft.Design", "CA1035:ICollectionImplementationsHaveStronglyTypedMembers",\r
+        Justification = "It is not anticipated that users will call FormCollection.CopyTo().")]\r
+    [FormCollectionBinder]\r
+    public sealed class FormCollection : NameValueCollection, IValueProvider {\r
+\r
+        public FormCollection() {\r
+        }\r
+\r
+        public FormCollection(NameValueCollection collection) {\r
+            if (collection == null) {\r
+                throw new ArgumentNullException("collection");\r
+            }\r
+\r
+            Add(collection);\r
+        }\r
+\r
+        public ValueProviderResult GetValue(string name) {\r
+            if (name == null) {\r
+                throw new ArgumentNullException("name");\r
+            }\r
+\r
+            string[] rawValue = GetValues(name);\r
+            if (rawValue == null) {\r
+                return null;\r
+            }\r
+\r
+            string attemptedValue = this[name];\r
+            return new ValueProviderResult(rawValue, attemptedValue, CultureInfo.CurrentCulture);\r
+        }\r
+\r
+        public IValueProvider ToValueProvider() {\r
+            return this;\r
+        }\r
+\r
+        #region IValueProvider Members\r
+        bool IValueProvider.ContainsPrefix(string prefix) {\r
+            return ValueProviderUtil.CollectionContainsPrefix(AllKeys, prefix);\r
+        }\r
+\r
+        ValueProviderResult IValueProvider.GetValue(string key) {\r
+            return GetValue(key);\r
+        }\r
+        #endregion\r
+\r
+        private sealed class FormCollectionBinderAttribute : CustomModelBinderAttribute {\r
+\r
+            // since the FormCollectionModelBinder.BindModel() method is thread-safe, we only need to keep\r
+            // a single instance of the binder around\r
+            private static readonly FormCollectionModelBinder _binder = new FormCollectionModelBinder();\r
+\r
+            public override IModelBinder GetBinder() {\r
+                return _binder;\r
+            }\r
+\r
+            // this class is used for generating a FormCollection object\r
+            private sealed class FormCollectionModelBinder : IModelBinder {\r
+                public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+                    if (controllerContext == null) {\r
+                        throw new ArgumentNullException("controllerContext");\r
+                    }\r
+\r
+                    return new FormCollection(controllerContext.HttpContext.Request.Form);\r
+                }\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormContext.cs
new file mode 100644 (file)
index 0000000..a2c6ec8
--- /dev/null
@@ -0,0 +1,84 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Web.Script.Serialization;\r
+\r
+    public class FormContext {\r
+\r
+        private readonly Dictionary<string, FieldValidationMetadata> _fieldValidators = new Dictionary<string, FieldValidationMetadata>();\r
+\r
+        public IDictionary<string, FieldValidationMetadata> FieldValidators {\r
+            get {\r
+                return _fieldValidators;\r
+            }\r
+        }\r
+\r
+        public string FormId {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public bool ReplaceValidationSummary {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public string ValidationSummaryId {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",\r
+            Justification = "Performs a potentially time-consuming conversion.")]\r
+        public string GetJsonValidationMetadata() {\r
+            JavaScriptSerializer serializer = new JavaScriptSerializer();\r
+\r
+            SortedDictionary<string, object> dict = new SortedDictionary<string, object>() {\r
+                { "Fields", FieldValidators.Values },\r
+                { "FormId", FormId }\r
+            };\r
+            if (!String.IsNullOrEmpty(ValidationSummaryId)) {\r
+                dict["ValidationSummaryId"] = ValidationSummaryId;\r
+            }\r
+            dict["ReplaceValidationSummary"] = ReplaceValidationSummary;\r
+\r
+            return serializer.Serialize(dict);\r
+        }\r
+\r
+        public FieldValidationMetadata GetValidationMetadataForField(string fieldName) {\r
+            return GetValidationMetadataForField(fieldName, false /* createIfNotFound */);\r
+        }\r
+\r
+        public FieldValidationMetadata GetValidationMetadataForField(string fieldName, bool createIfNotFound) {\r
+            if (String.IsNullOrEmpty(fieldName)) {\r
+                throw Error.ParameterCannotBeNullOrEmpty("fieldName");\r
+            }\r
+\r
+            FieldValidationMetadata metadata;\r
+            if (!FieldValidators.TryGetValue(fieldName, out metadata)) {\r
+                if (createIfNotFound) {\r
+                    metadata = new FieldValidationMetadata() {\r
+                        FieldName = fieldName\r
+                    };\r
+                    FieldValidators[fieldName] = metadata;\r
+                }\r
+            }\r
+            return metadata;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormMethod.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormMethod.cs
new file mode 100644 (file)
index 0000000..0c9ebc8
--- /dev/null
@@ -0,0 +1,18 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public enum FormMethod {\r
+        Get,\r
+        Post\r
+    }\r
+}
\ No newline at end of file
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormValueProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormValueProvider.cs
new file mode 100644 (file)
index 0000000..7349734
--- /dev/null
@@ -0,0 +1,25 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Specialized;\r
+    using System.Globalization;\r
+\r
+    public sealed class FormValueProvider : NameValueCollectionValueProvider {\r
+\r
+        public FormValueProvider(ControllerContext controllerContext)\r
+            : base(controllerContext.HttpContext.Request.Form, CultureInfo.CurrentCulture) {\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormValueProviderFactory.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/FormValueProviderFactory.cs
new file mode 100644 (file)
index 0000000..686f3ab
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public sealed class FormValueProviderFactory : ValueProviderFactory {\r
+\r
+        public override IValueProvider GetValueProvider(ControllerContext controllerContext) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+\r
+            return new FormValueProvider(controllerContext);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HandleErrorAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HandleErrorAttribute.cs
new file mode 100644 (file)
index 0000000..99b40cf
--- /dev/null
@@ -0,0 +1,119 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes",\r
+        Justification = "This attribute is AllowMultiple = true and users might want to override behavior.")]\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]\r
+    public class HandleErrorAttribute : FilterAttribute, IExceptionFilter {\r
+\r
+        private const string _defaultView = "Error";\r
+\r
+        private readonly object _typeId = new object();\r
+\r
+        private Type _exceptionType = typeof(Exception);\r
+        private string _master;\r
+        private string _view;\r
+\r
+        public Type ExceptionType {\r
+            get {\r
+                return _exceptionType;\r
+            }\r
+            set {\r
+                if (value == null) {\r
+                    throw new ArgumentNullException("value");\r
+                }\r
+                if (!typeof(Exception).IsAssignableFrom(value)) {\r
+                    throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture,\r
+                        MvcResources.ExceptionViewAttribute_NonExceptionType, value.FullName));\r
+                }\r
+\r
+                _exceptionType = value;\r
+            }\r
+        }\r
+\r
+        public string Master {\r
+            get {\r
+                return _master ?? String.Empty;\r
+            }\r
+            set {\r
+                _master = value;\r
+            }\r
+        }\r
+\r
+        public override object TypeId {\r
+            get {\r
+                return _typeId;\r
+            }\r
+        }\r
+\r
+        public string View {\r
+            get {\r
+                return (!String.IsNullOrEmpty(_view)) ? _view : _defaultView;\r
+            }\r
+            set {\r
+                _view = value;\r
+            }\r
+        }\r
+\r
+        public virtual void OnException(ExceptionContext filterContext) {\r
+            if (filterContext == null) {\r
+                throw new ArgumentNullException("filterContext");\r
+            }\r
+            if (filterContext.IsChildAction) {\r
+                return;\r
+            }\r
+\r
+            // If custom errors are disabled, we need to let the normal ASP.NET exception handler\r
+            // execute so that the user can see useful debugging information.\r
+            if (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled) {\r
+                return;\r
+            }\r
+\r
+            Exception exception = filterContext.Exception;\r
+\r
+            // If this is not an HTTP 500 (for example, if somebody throws an HTTP 404 from an action method),\r
+            // ignore it.\r
+            if (new HttpException(null, exception).GetHttpCode() != 500) {\r
+                return;\r
+            }\r
+\r
+            if (!ExceptionType.IsInstanceOfType(exception)) {\r
+                return;\r
+            }\r
+\r
+            string controllerName = (string)filterContext.RouteData.Values["controller"];\r
+            string actionName = (string)filterContext.RouteData.Values["action"];\r
+            HandleErrorInfo model = new HandleErrorInfo(filterContext.Exception, controllerName, actionName);\r
+            filterContext.Result = new ViewResult {\r
+                ViewName = View,\r
+                MasterName = Master,\r
+                ViewData = new ViewDataDictionary<HandleErrorInfo>(model),\r
+                TempData = filterContext.Controller.TempData\r
+            };\r
+            filterContext.ExceptionHandled = true;\r
+            filterContext.HttpContext.Response.Clear();\r
+            filterContext.HttpContext.Response.StatusCode = 500;\r
+\r
+            // Certain versions of IIS will sometimes use their own error page when\r
+            // they detect a server error. Setting this property indicates that we\r
+            // want it to try to render ASP.NET MVC's error page instead.\r
+            filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HandleErrorInfo.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HandleErrorInfo.cs
new file mode 100644 (file)
index 0000000..d02f911
--- /dev/null
@@ -0,0 +1,51 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class HandleErrorInfo {\r
+\r
+        public HandleErrorInfo(Exception exception, string controllerName, string actionName) {\r
+            if (exception == null) {\r
+                throw new ArgumentNullException("exception");\r
+            }\r
+            if (String.IsNullOrEmpty(controllerName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "controllerName");\r
+            }\r
+            if (string.IsNullOrEmpty(actionName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName");\r
+            }\r
+\r
+            Exception = exception;\r
+            ControllerName = controllerName;\r
+            ActionName = actionName;\r
+        }\r
+\r
+        public string ActionName {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public string ControllerName {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public Exception Exception {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HiddenInputAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HiddenInputAttribute.cs
new file mode 100644 (file)
index 0000000..b1778d4
--- /dev/null
@@ -0,0 +1,24 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]\r
+    public sealed class HiddenInputAttribute : Attribute {\r
+        public HiddenInputAttribute() {\r
+            DisplayValue = true;\r
+        }\r
+\r
+        public bool DisplayValue { get; set; }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/ChildActionExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/ChildActionExtensions.cs
new file mode 100644 (file)
index 0000000..cd22769
--- /dev/null
@@ -0,0 +1,150 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.IO;\r
+    using System.Linq;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public static class ChildActionExtensions {\r
+\r
+        // Action\r
+\r
+        public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName) {\r
+            return Action(htmlHelper, actionName, null /* controllerName */, null /* routeValues */);\r
+        }\r
+\r
+        public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, object routeValues) {\r
+            return Action(htmlHelper, actionName, null /* controllerName */, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, RouteValueDictionary routeValues) {\r
+            return Action(htmlHelper, actionName, null /* controllerName */, routeValues);\r
+        }\r
+\r
+        public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, string controllerName) {\r
+            return Action(htmlHelper, actionName, controllerName, null /* routeValues */);\r
+        }\r
+\r
+        public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues) {\r
+            return Action(htmlHelper, actionName, controllerName, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues) {\r
+            StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);\r
+            ActionHelper(htmlHelper, actionName, controllerName, routeValues, writer);\r
+            return MvcHtmlString.Create(writer.ToString());\r
+        }\r
+\r
+        // RenderAction\r
+\r
+        public static void RenderAction(this HtmlHelper htmlHelper, string actionName) {\r
+            RenderAction(htmlHelper, actionName, null /* controllerName */, null /* routeValues */);\r
+        }\r
+\r
+        public static void RenderAction(this HtmlHelper htmlHelper, string actionName, object routeValues) {\r
+            RenderAction(htmlHelper, actionName, null /* controllerName */, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        public static void RenderAction(this HtmlHelper htmlHelper, string actionName, RouteValueDictionary routeValues) {\r
+            RenderAction(htmlHelper, actionName, null /* controllerName */, routeValues);\r
+        }\r
+\r
+        public static void RenderAction(this HtmlHelper htmlHelper, string actionName, string controllerName) {\r
+            RenderAction(htmlHelper, actionName, controllerName, null /* routeValues */);\r
+        }\r
+\r
+        public static void RenderAction(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues) {\r
+            RenderAction(htmlHelper, actionName, controllerName, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        public static void RenderAction(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues) {\r
+            ActionHelper(htmlHelper, actionName, controllerName, routeValues, htmlHelper.ViewContext.Writer);\r
+        }\r
+\r
+        // Helpers\r
+\r
+        internal static void ActionHelper(HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, TextWriter textWriter) {\r
+            if (htmlHelper == null) {\r
+                throw new ArgumentNullException("htmlHelper");\r
+            }\r
+            if (String.IsNullOrEmpty(actionName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName");\r
+            }\r
+\r
+            routeValues = MergeDictionaries(routeValues, htmlHelper.ViewContext.RouteData.Values);\r
+            routeValues["action"] = actionName;\r
+            if (!String.IsNullOrEmpty(controllerName)) {\r
+                routeValues["controller"] = controllerName;\r
+            }\r
+\r
+            bool usingAreas;\r
+            VirtualPathData vpd = htmlHelper.RouteCollection.GetVirtualPathForArea(htmlHelper.ViewContext.RequestContext, null /* name */, routeValues, out usingAreas);\r
+            if (vpd == null) {\r
+                throw new InvalidOperationException(MvcResources.Common_NoRouteMatched);\r
+            }\r
+\r
+            if (usingAreas) {\r
+                routeValues.Remove("area");\r
+            }\r
+            RouteData routeData = CreateRouteData(vpd.Route, routeValues, vpd.DataTokens, htmlHelper.ViewContext);\r
+            HttpContextBase httpContext = htmlHelper.ViewContext.HttpContext;\r
+            RequestContext requestContext = new RequestContext(httpContext, routeData);\r
+            ChildActionMvcHandler handler = new ChildActionMvcHandler(requestContext);\r
+            httpContext.Server.Execute(HttpHandlerUtil.WrapForServerExecute(handler), textWriter, true /* preserveForm */);\r
+        }\r
+\r
+        private static RouteData CreateRouteData(RouteBase route, RouteValueDictionary routeValues, RouteValueDictionary dataTokens, ViewContext parentViewContext) {\r
+            RouteData routeData = new RouteData();\r
+\r
+            foreach (KeyValuePair<string, object> kvp in routeValues) {\r
+                routeData.Values.Add(kvp.Key, kvp.Value);\r
+            }\r
+\r
+            foreach (KeyValuePair<string, object> kvp in dataTokens) {\r
+                routeData.DataTokens.Add(kvp.Key, kvp.Value);\r
+            }\r
+\r
+            routeData.Route = route;\r
+            routeData.DataTokens[ControllerContext.PARENT_ACTION_VIEWCONTEXT] = parentViewContext;\r
+            return routeData;\r
+        }\r
+\r
+        private static RouteValueDictionary MergeDictionaries(params RouteValueDictionary[] dictionaries) {\r
+            // Merge existing route values with the user provided values\r
+            var result = new RouteValueDictionary();\r
+\r
+            foreach (RouteValueDictionary dictionary in dictionaries.Where(d => d != null)) {\r
+                foreach (KeyValuePair<string, object> kvp in dictionary) {\r
+                    if (!result.ContainsKey(kvp.Key)) {\r
+                        result.Add(kvp.Key, kvp.Value);\r
+                    }\r
+                }\r
+            }\r
+\r
+            return result;\r
+        }\r
+\r
+        internal class ChildActionMvcHandler : MvcHandler {\r
+            public ChildActionMvcHandler(RequestContext context)\r
+                : base(context) {\r
+            }\r
+\r
+            protected internal override void AddVersionHeader(HttpContextBase httpContext) {\r
+                // No version header for child actions\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DefaultDisplayTemplates.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DefaultDisplayTemplates.cs
new file mode 100644 (file)
index 0000000..7edcb3b
--- /dev/null
@@ -0,0 +1,206 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Data;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Text;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.UI.WebControls;\r
+\r
+    internal static class DefaultDisplayTemplates {\r
+        internal static string BooleanTemplate(HtmlHelper html) {\r
+            bool? value = null;\r
+            if (html.ViewContext.ViewData.Model != null) {\r
+                value = Convert.ToBoolean(html.ViewContext.ViewData.Model, CultureInfo.InvariantCulture);\r
+            }\r
+\r
+            return html.ViewContext.ViewData.ModelMetadata.IsNullableValueType\r
+                        ? BooleanTemplateDropDownList(value)\r
+                        : BooleanTemplateCheckbox(value ?? false);\r
+        }\r
+\r
+        private static string BooleanTemplateCheckbox(bool value) {\r
+            TagBuilder inputTag = new TagBuilder("input");\r
+            inputTag.AddCssClass("check-box");\r
+            inputTag.Attributes["disabled"] = "disabled";\r
+            inputTag.Attributes["type"] = "checkbox";\r
+            if (value) {\r
+                inputTag.Attributes["checked"] = "checked";\r
+            }\r
+\r
+            return inputTag.ToString(TagRenderMode.SelfClosing);\r
+        }\r
+\r
+        private static string BooleanTemplateDropDownList(bool? value) {\r
+            StringBuilder builder = new StringBuilder();\r
+\r
+            TagBuilder selectTag = new TagBuilder("select");\r
+            selectTag.AddCssClass("list-box");\r
+            selectTag.AddCssClass("tri-state");\r
+            selectTag.Attributes["disabled"] = "disabled";\r
+            builder.Append(selectTag.ToString(TagRenderMode.StartTag));\r
+\r
+            foreach (SelectListItem item in DefaultEditorTemplates.TriStateValues(value)) {\r
+                builder.Append(SelectExtensions.ListItemToOption(item));\r
+            }\r
+\r
+            builder.Append(selectTag.ToString(TagRenderMode.EndTag));\r
+            return builder.ToString();\r
+        }\r
+\r
+        internal static string CollectionTemplate(HtmlHelper html) {\r
+            return CollectionTemplate(html, TemplateHelpers.TemplateHelper);\r
+        }\r
+\r
+        internal static string CollectionTemplate(HtmlHelper html, TemplateHelpers.TemplateHelperDelegate templateHelper) {\r
+            object model = html.ViewContext.ViewData.ModelMetadata.Model;\r
+            if (model == null) {\r
+                return String.Empty;\r
+            }\r
+\r
+            IEnumerable collection = model as IEnumerable;\r
+            if (collection == null) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentCulture,\r
+                        MvcResources.Templates_TypeMustImplementIEnumerable,\r
+                        model.GetType().FullName\r
+                    )\r
+                );\r
+            }\r
+\r
+            Type typeInCollection = typeof(string);\r
+            Type genericEnumerableType = TypeHelpers.ExtractGenericInterface(collection.GetType(), typeof(IEnumerable<>));\r
+            if (genericEnumerableType != null) {\r
+                typeInCollection = genericEnumerableType.GetGenericArguments()[0];\r
+            }\r
+            bool typeInCollectionIsNullableValueType = TypeHelpers.IsNullableValueType(typeInCollection);\r
+\r
+            string oldPrefix = html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix;\r
+\r
+            try {\r
+                html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = String.Empty;\r
+\r
+                string fieldNameBase = oldPrefix;\r
+                StringBuilder result = new StringBuilder();\r
+                int index = 0;\r
+\r
+                foreach (object item in collection) {\r
+                    Type itemType = typeInCollection;\r
+                    if (item != null && !typeInCollectionIsNullableValueType) {\r
+                        itemType = item.GetType();\r
+                    }\r
+                    ModelMetadata metadata = ModelMetadataProviders.Current.GetMetadataForType(() => item, itemType);\r
+                    string fieldName = String.Format(CultureInfo.InvariantCulture, "{0}[{1}]", fieldNameBase, index++);\r
+                    string output = templateHelper(html, metadata, fieldName, null /* templateName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
+                    result.Append(output);\r
+                }\r
+\r
+                return result.ToString();\r
+            }\r
+            finally {\r
+                html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = oldPrefix;\r
+            }\r
+        }\r
+\r
+        internal static string DecimalTemplate(HtmlHelper html) {\r
+            if (html.ViewContext.ViewData.TemplateInfo.FormattedModelValue == html.ViewContext.ViewData.ModelMetadata.Model) {\r
+                html.ViewContext.ViewData.TemplateInfo.FormattedModelValue = String.Format(CultureInfo.CurrentCulture, "{0:0.00}", html.ViewContext.ViewData.ModelMetadata.Model);\r
+            }\r
+\r
+            return StringTemplate(html);\r
+        }\r
+\r
+        internal static string EmailAddressTemplate(HtmlHelper html) {\r
+            return String.Format(CultureInfo.InvariantCulture,\r
+                                 "<a href=\"mailto:{0}\">{1}</a>",\r
+                                 html.AttributeEncode(html.ViewContext.ViewData.Model),\r
+                                 html.Encode(html.ViewContext.ViewData.TemplateInfo.FormattedModelValue));\r
+        }\r
+\r
+        internal static string HiddenInputTemplate(HtmlHelper html) {\r
+            if (html.ViewContext.ViewData.ModelMetadata.HideSurroundingHtml) {\r
+                return String.Empty;\r
+            }\r
+            return StringTemplate(html);\r
+        }\r
+\r
+        internal static string HtmlTemplate(HtmlHelper html) {\r
+            return html.ViewContext.ViewData.TemplateInfo.FormattedModelValue.ToString();\r
+        }\r
+\r
+        internal static string ObjectTemplate(HtmlHelper html) {\r
+            return ObjectTemplate(html, TemplateHelpers.TemplateHelper);\r
+        }\r
+\r
+        internal static string ObjectTemplate(HtmlHelper html, TemplateHelpers.TemplateHelperDelegate templateHelper) {\r
+            ViewDataDictionary viewData = html.ViewContext.ViewData;\r
+            TemplateInfo templateInfo = viewData.TemplateInfo;\r
+            ModelMetadata modelMetadata = viewData.ModelMetadata;\r
+            StringBuilder builder = new StringBuilder();\r
+\r
+            if (modelMetadata.Model == null) {    // DDB #225237\r
+                return modelMetadata.NullDisplayText;\r
+            }\r
+\r
+            if (templateInfo.TemplateDepth > 1) {    // DDB #224751\r
+                return modelMetadata.SimpleDisplayText;\r
+            }\r
+\r
+            foreach (ModelMetadata propertyMetadata in modelMetadata.Properties.Where(pm => ShouldShow(pm, templateInfo))) {\r
+                if (!propertyMetadata.HideSurroundingHtml) {\r
+                    string label = propertyMetadata.GetDisplayName();\r
+                    if (!String.IsNullOrEmpty(label)) {\r
+                        builder.AppendFormat(CultureInfo.InvariantCulture, "<div class=\"display-label\">{0}</div>", label);\r
+                        builder.AppendLine();\r
+                    }\r
+\r
+                    builder.Append("<div class=\"display-field\">");\r
+                }\r
+\r
+                builder.Append(templateHelper(html, propertyMetadata, propertyMetadata.PropertyName, null /* templateName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */));\r
+\r
+                if (!propertyMetadata.HideSurroundingHtml) {\r
+                    builder.AppendLine("</div>");\r
+                }\r
+            }\r
+\r
+            return builder.ToString();\r
+        }\r
+\r
+        private static bool ShouldShow(ModelMetadata metadata, TemplateInfo templateInfo) {\r
+            return\r
+                metadata.ShowForDisplay\r
+#if false
+                && metadata.ModelType != typeof(EntityState)\r
+#endif
+                && !metadata.IsComplexType\r
+                && !templateInfo.Visited(metadata);\r
+        }\r
+\r
+        internal static string StringTemplate(HtmlHelper html) {\r
+            return html.Encode(html.ViewContext.ViewData.TemplateInfo.FormattedModelValue);\r
+        }\r
+\r
+        internal static string UrlTemplate(HtmlHelper html) {\r
+            return String.Format(CultureInfo.InvariantCulture,\r
+                                 "<a href=\"{0}\">{1}</a>",\r
+                                 html.AttributeEncode(html.ViewContext.ViewData.Model),\r
+                                 html.Encode(html.ViewContext.ViewData.TemplateInfo.FormattedModelValue));\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DefaultEditorTemplates.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DefaultEditorTemplates.cs
new file mode 100644 (file)
index 0000000..a478dbc
--- /dev/null
@@ -0,0 +1,215 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Data;\r
+    using System.Data.Linq;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Text;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.UI.WebControls;\r
+\r
+    internal static class DefaultEditorTemplates {\r
+        internal static string BooleanTemplate(HtmlHelper html) {\r
+            bool? value = null;\r
+            if (html.ViewContext.ViewData.Model != null) {\r
+                value = Convert.ToBoolean(html.ViewContext.ViewData.Model, CultureInfo.InvariantCulture);\r
+            }\r
+\r
+            return html.ViewContext.ViewData.ModelMetadata.IsNullableValueType\r
+                        ? BooleanTemplateDropDownList(html, value)\r
+                        : BooleanTemplateCheckbox(html, value ?? false);\r
+        }\r
+\r
+        private static string BooleanTemplateCheckbox(HtmlHelper html, bool value) {\r
+            return html.CheckBox(String.Empty, value, CreateHtmlAttributes("check-box")).ToHtmlString();\r
+        }\r
+\r
+        private static string BooleanTemplateDropDownList(HtmlHelper html, bool? value) {\r
+            return html.DropDownList(String.Empty, TriStateValues(value), CreateHtmlAttributes("list-box tri-state")).ToHtmlString();\r
+\r
+        }\r
+\r
+        internal static string CollectionTemplate(HtmlHelper html) {\r
+            return CollectionTemplate(html, TemplateHelpers.TemplateHelper);\r
+        }\r
+\r
+        internal static string CollectionTemplate(HtmlHelper html, TemplateHelpers.TemplateHelperDelegate templateHelper) {\r
+            object model = html.ViewContext.ViewData.ModelMetadata.Model;\r
+            if (model == null) {\r
+                return String.Empty;\r
+            }\r
+\r
+            IEnumerable collection = model as IEnumerable;\r
+            if (collection == null) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentCulture,\r
+                        MvcResources.Templates_TypeMustImplementIEnumerable,\r
+                        model.GetType().FullName\r
+                    )\r
+                );\r
+            }\r
+\r
+            Type typeInCollection = typeof(string);\r
+            Type genericEnumerableType = TypeHelpers.ExtractGenericInterface(collection.GetType(), typeof(IEnumerable<>));\r
+            if (genericEnumerableType != null) {\r
+                typeInCollection = genericEnumerableType.GetGenericArguments()[0];\r
+            }\r
+            bool typeInCollectionIsNullableValueType = TypeHelpers.IsNullableValueType(typeInCollection);\r
+\r
+            string oldPrefix = html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix;\r
+\r
+            try {\r
+                html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = String.Empty;\r
+\r
+                string fieldNameBase = oldPrefix;\r
+                StringBuilder result = new StringBuilder();\r
+                int index = 0;\r
+\r
+                foreach (object item in collection) {\r
+                    Type itemType = typeInCollection;\r
+                    if (item != null && !typeInCollectionIsNullableValueType) {\r
+                        itemType = item.GetType();\r
+                    }\r
+                    ModelMetadata metadata = ModelMetadataProviders.Current.GetMetadataForType(() => item, itemType);\r
+                    string fieldName = String.Format(CultureInfo.InvariantCulture, "{0}[{1}]", fieldNameBase, index++);\r
+                    string output = templateHelper(html, metadata, fieldName, null /* templateName */, DataBoundControlMode.Edit, null /* additionalViewData */);\r
+                    result.Append(output);\r
+                }\r
+\r
+                return result.ToString();\r
+            }\r
+            finally {\r
+                html.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = oldPrefix;\r
+            }\r
+        }\r
+\r
+        internal static string DecimalTemplate(HtmlHelper html) {\r
+            if (html.ViewContext.ViewData.TemplateInfo.FormattedModelValue == html.ViewContext.ViewData.ModelMetadata.Model) {\r
+                html.ViewContext.ViewData.TemplateInfo.FormattedModelValue = String.Format(CultureInfo.CurrentCulture, "{0:0.00}", html.ViewContext.ViewData.ModelMetadata.Model);\r
+            }\r
+\r
+            return StringTemplate(html);\r
+        }\r
+\r
+        internal static string HiddenInputTemplate(HtmlHelper html) {\r
+            string result;\r
+\r
+            if (html.ViewContext.ViewData.ModelMetadata.HideSurroundingHtml) {\r
+                result = String.Empty;\r
+            }\r
+            else {\r
+                result = DefaultDisplayTemplates.StringTemplate(html);\r
+            }\r
+\r
+            object model = html.ViewContext.ViewData.Model;\r
+\r
+            Binary modelAsBinary = model as Binary;\r
+            if (modelAsBinary != null) {\r
+                model = Convert.ToBase64String(modelAsBinary.ToArray());\r
+            }\r
+            else {\r
+                byte[] modelAsByteArray = model as byte[];\r
+                if (modelAsByteArray != null) {\r
+                    model = Convert.ToBase64String(modelAsByteArray);\r
+                }\r
+            }\r
+\r
+            result += html.Hidden(String.Empty, model).ToHtmlString();\r
+            return result;\r
+        }\r
+\r
+        internal static string MultilineTextTemplate(HtmlHelper html) {\r
+            return html.TextArea(String.Empty,\r
+                                 html.ViewContext.ViewData.TemplateInfo.FormattedModelValue.ToString(),\r
+                                 0 /* rows */, 0 /* columns */,\r
+                                 CreateHtmlAttributes("text-box multi-line")).ToHtmlString();\r
+        }\r
+\r
+        private static IDictionary<string, object> CreateHtmlAttributes(string className) {\r
+            return new Dictionary<string, object>() {\r
+                { "class", className }\r
+            };\r
+        }\r
+\r
+        internal static string ObjectTemplate(HtmlHelper html) {\r
+            return ObjectTemplate(html, TemplateHelpers.TemplateHelper);\r
+        }\r
+\r
+        internal static string ObjectTemplate(HtmlHelper html, TemplateHelpers.TemplateHelperDelegate templateHelper) {\r
+            ViewDataDictionary viewData = html.ViewContext.ViewData;\r
+            TemplateInfo templateInfo = viewData.TemplateInfo;\r
+            ModelMetadata modelMetadata = viewData.ModelMetadata;\r
+            StringBuilder builder = new StringBuilder();\r
+\r
+            if (templateInfo.TemplateDepth > 1) {    // DDB #224751\r
+                return modelMetadata.Model == null ? modelMetadata.NullDisplayText : modelMetadata.SimpleDisplayText;\r
+            }\r
+\r
+            foreach (ModelMetadata propertyMetadata in modelMetadata.Properties.Where(pm => ShouldShow(pm, templateInfo))) {\r
+                if (!propertyMetadata.HideSurroundingHtml) {\r
+                    string label = LabelExtensions.LabelHelper(html, propertyMetadata, propertyMetadata.PropertyName).ToHtmlString();\r
+                    if (!String.IsNullOrEmpty(label)) {\r
+                        builder.AppendFormat(CultureInfo.InvariantCulture, "<div class=\"editor-label\">{0}</div>\r\n", label);\r
+                    }\r
+\r
+                    builder.Append("<div class=\"editor-field\">");\r
+                }\r
+\r
+                builder.Append(templateHelper(html, propertyMetadata, propertyMetadata.PropertyName, null /* templateName */, DataBoundControlMode.Edit, null /* additionalViewData */));\r
+\r
+                if (!propertyMetadata.HideSurroundingHtml) {\r
+                    builder.Append(" ");\r
+                    builder.Append(html.ValidationMessage(propertyMetadata.PropertyName));\r
+                    builder.Append("</div>\r\n");\r
+                }\r
+            }\r
+\r
+            return builder.ToString();\r
+        }\r
+\r
+        internal static string PasswordTemplate(HtmlHelper html) {\r
+            return html.Password(String.Empty,\r
+                                 html.ViewContext.ViewData.TemplateInfo.FormattedModelValue,\r
+                                 CreateHtmlAttributes("text-box single-line password")).ToHtmlString();\r
+        }\r
+\r
+        private static bool ShouldShow(ModelMetadata metadata, TemplateInfo templateInfo) {\r
+            return\r
+                metadata.ShowForEdit\r
+#if false
+                && metadata.ModelType != typeof(EntityState)\r
+#endif
+                && !metadata.IsComplexType\r
+                && !templateInfo.Visited(metadata);\r
+        }\r
+\r
+        internal static string StringTemplate(HtmlHelper html) {\r
+            return html.TextBox(String.Empty,\r
+                                html.ViewContext.ViewData.TemplateInfo.FormattedModelValue,\r
+                                CreateHtmlAttributes("text-box single-line")).ToHtmlString();\r
+        }\r
+\r
+        internal static List<SelectListItem> TriStateValues(bool? value) {\r
+            return new List<SelectListItem> {\r
+                new SelectListItem { Text = MvcResources.Common_TriState_NotSet, Value = String.Empty, Selected = !value.HasValue },\r
+                new SelectListItem { Text = MvcResources.Common_TriState_True, Value = "true", Selected = value.HasValue && value.Value },\r
+                new SelectListItem { Text = MvcResources.Common_TriState_False, Value = "false", Selected = value.HasValue && !value.Value },\r
+            };\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DisplayExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DisplayExtensions.cs
new file mode 100644 (file)
index 0000000..372caf0
--- /dev/null
@@ -0,0 +1,102 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System.Linq.Expressions;\r
+    using System.Web.UI.WebControls;\r
+\r
+    public static class DisplayExtensions {\r
+        public static MvcHtmlString Display(this HtmlHelper html, string expression) {\r
+            return TemplateHelpers.Template(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
+        }\r
+\r
+        public static MvcHtmlString Display(this HtmlHelper html, string expression, object additionalViewData) {\r
+            return TemplateHelpers.Template(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, additionalViewData);\r
+        }\r
+\r
+        public static MvcHtmlString Display(this HtmlHelper html, string expression, string templateName) {\r
+            return TemplateHelpers.Template(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
+        }\r
+\r
+        public static MvcHtmlString Display(this HtmlHelper html, string expression, string templateName, object additionalViewData) {\r
+            return TemplateHelpers.Template(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, additionalViewData);\r
+        }\r
+\r
+        public static MvcHtmlString Display(this HtmlHelper html, string expression, string templateName, string htmlFieldName) {\r
+            return TemplateHelpers.Template(html, expression, templateName, htmlFieldName, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
+        }\r
+\r
+        public static MvcHtmlString Display(this HtmlHelper html, string expression, string templateName, string htmlFieldName, object additionalViewData) {\r
+            return TemplateHelpers.Template(html, expression, templateName, htmlFieldName, DataBoundControlMode.ReadOnly, additionalViewData);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression) {\r
+            return TemplateHelpers.TemplateFor(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, object additionalViewData) {\r
+            return TemplateHelpers.TemplateFor(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, additionalViewData);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName) {\r
+            return TemplateHelpers.TemplateFor(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, object additionalViewData) {\r
+            return TemplateHelpers.TemplateFor(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, additionalViewData);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName) {\r
+            return TemplateHelpers.TemplateFor(html, expression, templateName, htmlFieldName, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName, object additionalViewData) {\r
+            return TemplateHelpers.TemplateFor(html, expression, templateName, htmlFieldName, DataBoundControlMode.ReadOnly, additionalViewData);\r
+        }\r
+\r
+        public static MvcHtmlString DisplayForModel(this HtmlHelper html) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, null /* templateName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */));\r
+        }\r
+\r
+        public static MvcHtmlString DisplayForModel(this HtmlHelper html, object additionalViewData) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, null /* templateName */, DataBoundControlMode.ReadOnly, additionalViewData));\r
+        }\r
+\r
+        public static MvcHtmlString DisplayForModel(this HtmlHelper html, string templateName) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, templateName, DataBoundControlMode.ReadOnly, null /* additionalViewData */));\r
+        }\r
+\r
+        public static MvcHtmlString DisplayForModel(this HtmlHelper html, string templateName, object additionalViewData) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, templateName, DataBoundControlMode.ReadOnly,   additionalViewData ));\r
+        }\r
+\r
+        public static MvcHtmlString DisplayForModel(this HtmlHelper html, string templateName, string htmlFieldName) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, htmlFieldName, templateName, DataBoundControlMode.ReadOnly, null /* additionalViewData */));\r
+        }\r
+\r
+        public static MvcHtmlString DisplayForModel(this HtmlHelper html, string templateName, string htmlFieldName, object additionalViewData) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, htmlFieldName, templateName, DataBoundControlMode.ReadOnly, additionalViewData));\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DisplayTextExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/DisplayTextExtensions.cs
new file mode 100644 (file)
index 0000000..272ab0e
--- /dev/null
@@ -0,0 +1,32 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Linq.Expressions;\r
+\r
+    public static class DisplayTextExtensions {\r
+        public static MvcHtmlString DisplayText(this HtmlHelper html, string name) {\r
+            return DisplayTextHelper(ModelMetadata.FromStringExpression(name, html.ViewContext.ViewData));\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DisplayTextFor<TModel, TResult>(this HtmlHelper<TModel> html, Expression<Func<TModel, TResult>> expression) {\r
+            return DisplayTextHelper(ModelMetadata.FromLambdaExpression(expression, html.ViewData));\r
+        }\r
+\r
+        private static MvcHtmlString DisplayTextHelper(ModelMetadata metadata) {\r
+            return MvcHtmlString.Create(metadata.SimpleDisplayText);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/EditorExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/EditorExtensions.cs
new file mode 100644 (file)
index 0000000..b022f5c
--- /dev/null
@@ -0,0 +1,103 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Linq.Expressions;\r
+    using System.Web.UI.WebControls;\r
+\r
+    public static class EditorExtensions {\r
+        public static MvcHtmlString Editor(this HtmlHelper html, string expression) {\r
+            return TemplateHelpers.Template(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.Edit, null /* additionalViewData */);\r
+        }\r
+\r
+        public static MvcHtmlString Editor(this HtmlHelper html, string expression, object additionalViewData) {\r
+            return TemplateHelpers.Template(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.Edit, additionalViewData);\r
+        }\r
+\r
+        public static MvcHtmlString Editor(this HtmlHelper html, string expression, string templateName) {\r
+            return TemplateHelpers.Template(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.Edit, null /* additionalViewData */);\r
+        }\r
+\r
+        public static MvcHtmlString Editor(this HtmlHelper html, string expression, string templateName, object additionalViewData) {\r
+            return TemplateHelpers.Template(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.Edit, additionalViewData);\r
+        }\r
+\r
+        public static MvcHtmlString Editor(this HtmlHelper html, string expression, string templateName, string htmlFieldName) {\r
+            return TemplateHelpers.Template(html, expression, templateName, htmlFieldName, DataBoundControlMode.Edit, null /* additionalViewData */);\r
+        }\r
+\r
+        public static MvcHtmlString Editor(this HtmlHelper html, string expression, string templateName, string htmlFieldName, object additionalViewData) {\r
+            return TemplateHelpers.Template(html, expression, templateName, htmlFieldName, DataBoundControlMode.Edit, additionalViewData);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString EditorFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression) {\r
+            return TemplateHelpers.TemplateFor(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.Edit, null /* additionalViewData */);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString EditorFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, object additionalViewData) {\r
+            return TemplateHelpers.TemplateFor(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.Edit, additionalViewData);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString EditorFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName) {\r
+            return TemplateHelpers.TemplateFor(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.Edit, null /* additionalViewData */);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString EditorFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, object additionalViewData) {\r
+            return TemplateHelpers.TemplateFor(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.Edit, additionalViewData);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString EditorFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName) {\r
+            return TemplateHelpers.TemplateFor(html, expression, templateName, htmlFieldName, DataBoundControlMode.Edit, null /* additionalViewData */);\r
+        }\r
+\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
+            Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString EditorFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName, object additionalViewData) {\r
+            return TemplateHelpers.TemplateFor(html, expression, templateName, htmlFieldName, DataBoundControlMode.Edit, additionalViewData);\r
+        }\r
+\r
+        public static MvcHtmlString EditorForModel(this HtmlHelper html) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, null /* templateName */, DataBoundControlMode.Edit, null /* additionalViewData */));\r
+        }\r
+\r
+        public static MvcHtmlString EditorForModel(this HtmlHelper html, object additionalViewData) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, null /* templateName */, DataBoundControlMode.Edit, additionalViewData));\r
+        }\r
+\r
+        public static MvcHtmlString EditorForModel(this HtmlHelper html, string templateName) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, templateName, DataBoundControlMode.Edit, null /* additionalViewData */));\r
+        }\r
+\r
+        public static MvcHtmlString EditorForModel(this HtmlHelper html, string templateName, object additionalViewData) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, templateName, DataBoundControlMode.Edit, additionalViewData));\r
+        }\r
+\r
+        public static MvcHtmlString EditorForModel(this HtmlHelper html, string templateName, string htmlFieldName) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, htmlFieldName, templateName, DataBoundControlMode.Edit, null /* additionalViewData */));\r
+        }\r
+\r
+        public static MvcHtmlString EditorForModel(this HtmlHelper html, string templateName, string htmlFieldName, object additionalViewData) {\r
+            return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, htmlFieldName, templateName, DataBoundControlMode.Edit, additionalViewData));\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/FormExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/FormExtensions.cs
new file mode 100644 (file)
index 0000000..b5df159
--- /dev/null
@@ -0,0 +1,152 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System.Collections.Generic;\r
+    using System.Web.Routing;\r
+    using System.Globalization;\r
+\r
+    public static class FormExtensions {\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper) {\r
+            // generates <form action="{current url}" method="post">...</form>\r
+            string formAction = htmlHelper.ViewContext.HttpContext.Request.RawUrl;\r
+            return FormHelper(htmlHelper, formAction, FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, object routeValues) {\r
+            return BeginForm(htmlHelper, null, null, new RouteValueDictionary(routeValues), FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, RouteValueDictionary routeValues) {\r
+            return BeginForm(htmlHelper, null, null, routeValues, FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName) {\r
+            return BeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(), FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues) {\r
+            return BeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(routeValues), FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues) {\r
+            return BeginForm(htmlHelper, actionName, controllerName, routeValues, FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method) {\r
+            return BeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(), method, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, FormMethod method) {\r
+            return BeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(routeValues), method, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method) {\r
+            return BeginForm(htmlHelper, actionName, controllerName, routeValues, method, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, object htmlAttributes) {\r
+            return BeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(), method, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, IDictionary<string, object> htmlAttributes) {\r
+            return BeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(), method, htmlAttributes);\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, FormMethod method, object htmlAttributes) {\r
+            return BeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(routeValues), method, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, IDictionary<string, object> htmlAttributes) {\r
+            string formAction = UrlHelper.GenerateUrl(null /* routeName */, actionName, controllerName, routeValues, htmlHelper.RouteCollection, htmlHelper.ViewContext.RequestContext, true /* includeImplicitMvcValues */);\r
+            return FormHelper(htmlHelper, formAction, method, htmlAttributes);\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, object routeValues) {\r
+            return BeginRouteForm(htmlHelper, null /* routeName */, new RouteValueDictionary(routeValues), FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, RouteValueDictionary routeValues) {\r
+            return BeginRouteForm(htmlHelper, null /* routeName */, routeValues, FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName) {\r
+            return BeginRouteForm(htmlHelper, routeName, new RouteValueDictionary(), FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, object routeValues) {\r
+            return BeginRouteForm(htmlHelper, routeName, new RouteValueDictionary(routeValues), FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues) {\r
+            return BeginRouteForm(htmlHelper, routeName, routeValues, FormMethod.Post, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, FormMethod method) {\r
+            return BeginRouteForm(htmlHelper, routeName, new RouteValueDictionary(), method, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, object routeValues, FormMethod method) {\r
+            return BeginRouteForm(htmlHelper, routeName, new RouteValueDictionary(routeValues), method, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues, FormMethod method) {\r
+            return BeginRouteForm(htmlHelper, routeName, routeValues, method, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, FormMethod method, object htmlAttributes) {\r
+            return BeginRouteForm(htmlHelper, routeName, new RouteValueDictionary(), method, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, FormMethod method, IDictionary<string, object> htmlAttributes) {\r
+            return BeginRouteForm(htmlHelper, routeName, new RouteValueDictionary(), method, htmlAttributes);\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, object routeValues, FormMethod method, object htmlAttributes) {\r
+            return BeginRouteForm(htmlHelper, routeName, new RouteValueDictionary(routeValues), method, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues, FormMethod method, IDictionary<string, object> htmlAttributes) {\r
+            string formAction = UrlHelper.GenerateUrl(routeName, null, null, routeValues, htmlHelper.RouteCollection, htmlHelper.ViewContext.RequestContext, false /* includeImplicitMvcValues */);\r
+            return FormHelper(htmlHelper, formAction, method, htmlAttributes);\r
+        }\r
+\r
+        public static void EndForm(this HtmlHelper htmlHelper) {\r
+            htmlHelper.ViewContext.Writer.Write("</form>");\r
+            htmlHelper.ViewContext.OutputClientValidation();\r
+        }\r
+\r
+        private static MvcForm FormHelper(this HtmlHelper htmlHelper, string formAction, FormMethod method, IDictionary<string, object> htmlAttributes) {\r
+            TagBuilder tagBuilder = new TagBuilder("form");\r
+            tagBuilder.MergeAttributes(htmlAttributes);\r
+            // action is implicitly generated, so htmlAttributes take precedence.\r
+            tagBuilder.MergeAttribute("action", formAction);\r
+            // method is an explicit parameter, so it takes precedence over the htmlAttributes.\r
+            tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true);\r
+\r
+            if (htmlHelper.ViewContext.ClientValidationEnabled) {\r
+                // forms must have an ID for client validation\r
+                tagBuilder.GenerateId(htmlHelper.ViewContext.FormIdGenerator());\r
+            }\r
+\r
+            htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag));\r
+            MvcForm theForm = new MvcForm(htmlHelper.ViewContext);\r
+\r
+            if (htmlHelper.ViewContext.ClientValidationEnabled) {\r
+                htmlHelper.ViewContext.FormContext.FormId = tagBuilder.Attributes["id"];\r
+            }\r
+\r
+            return theForm;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/InputExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/InputExtensions.cs
new file mode 100644 (file)
index 0000000..5d56f83
--- /dev/null
@@ -0,0 +1,398 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Data.Linq;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq.Expressions;\r
+    using System.Text;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public static class InputExtensions {\r
+        // CheckBox\r
+\r
+        public static MvcHtmlString CheckBox(this HtmlHelper htmlHelper, string name) {\r
+            return CheckBox(htmlHelper, name, (object)null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString CheckBox(this HtmlHelper htmlHelper, string name, bool isChecked) {\r
+            return CheckBox(htmlHelper, name, isChecked, (object)null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString CheckBox(this HtmlHelper htmlHelper, string name, bool isChecked, object htmlAttributes) {\r
+            return CheckBox(htmlHelper, name, isChecked, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString CheckBox(this HtmlHelper htmlHelper, string name, object htmlAttributes) {\r
+            return CheckBox(htmlHelper, name, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString CheckBox(this HtmlHelper htmlHelper, string name, IDictionary<string, object> htmlAttributes) {\r
+            return CheckBoxHelper(htmlHelper, name, null /* isChecked */, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString CheckBox(this HtmlHelper htmlHelper, string name, bool isChecked, IDictionary<string, object> htmlAttributes) {\r
+            return CheckBoxHelper(htmlHelper, name, isChecked, htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString CheckBoxFor<TModel>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, bool>> expression) {\r
+            return CheckBoxFor(htmlHelper, expression, null /* htmlAttributes */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString CheckBoxFor<TModel>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, bool>> expression, object htmlAttributes) {\r
+            return CheckBoxFor(htmlHelper, expression, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString CheckBoxFor<TModel>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, bool>> expression, IDictionary<string, object> htmlAttributes) {\r
+            if (expression == null) {\r
+                throw new ArgumentNullException("expression");\r
+            }\r
+\r
+            ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);\r
+            bool? isChecked = null;\r
+            if (metadata.Model != null) {\r
+                bool modelChecked;\r
+                if (Boolean.TryParse(metadata.Model.ToString(), out modelChecked)) {\r
+                    isChecked = modelChecked;\r
+                }\r
+            }\r
+\r
+            return CheckBoxHelper(htmlHelper, ExpressionHelper.GetExpressionText(expression), isChecked, htmlAttributes);\r
+        }\r
+\r
+        private static MvcHtmlString CheckBoxHelper(HtmlHelper htmlHelper, string name, bool? isChecked, IDictionary<string, object> htmlAttributes) {\r
+            RouteValueDictionary attributes =\r
+                htmlAttributes == null ? new RouteValueDictionary()\r
+                                       : new RouteValueDictionary(htmlAttributes);\r
+\r
+            bool explicitValue = isChecked.HasValue;\r
+            if (explicitValue) {\r
+                attributes.Remove("checked");    // Explicit value must override dictionary\r
+            }\r
+\r
+            return InputHelper(htmlHelper, InputType.CheckBox, name, "true", !explicitValue /* useViewData */, isChecked ?? false, true /* setId */, false /* isExplicitValue */, attributes);\r
+        }\r
+\r
+        // Hidden\r
+\r
+        public static MvcHtmlString Hidden(this HtmlHelper htmlHelper, string name) {\r
+            return Hidden(htmlHelper, name, null /* value */, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString Hidden(this HtmlHelper htmlHelper, string name, object value) {\r
+            return Hidden(htmlHelper, name, value, null /* hmtlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString Hidden(this HtmlHelper htmlHelper, string name, object value, object htmlAttributes) {\r
+            return Hidden(htmlHelper, name, value, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString Hidden(this HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes) {\r
+            return HiddenHelper(htmlHelper,\r
+                                value,\r
+                                value == null /* useViewData */,\r
+                                name,\r
+                                htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString HiddenFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) {\r
+            return HiddenFor(htmlHelper, expression, (IDictionary<string, object>)null);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString HiddenFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) {\r
+            return HiddenFor(htmlHelper, expression, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString HiddenFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes) {\r
+            return HiddenHelper(htmlHelper,\r
+                                ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).Model,\r
+                                false,\r
+                                ExpressionHelper.GetExpressionText(expression),\r
+                                htmlAttributes);\r
+        }\r
+\r
+        private static MvcHtmlString HiddenHelper(HtmlHelper htmlHelper, object value, bool useViewData, string expression, IDictionary<string, object> htmlAttributes) {\r
+            Binary binaryValue = value as Binary;\r
+            if (binaryValue != null) {\r
+                value = binaryValue.ToArray();\r
+            }\r
+\r
+            byte[] byteArrayValue = value as byte[];\r
+            if (byteArrayValue != null) {\r
+                value = Convert.ToBase64String(byteArrayValue);\r
+            }\r
+\r
+            return InputHelper(htmlHelper, InputType.Hidden, expression, value, useViewData, false /* isChecked */, true /* setId */, true /* isExplicitValue */, htmlAttributes);\r
+        }\r
+\r
+        // Password\r
+\r
+        public static MvcHtmlString Password(this HtmlHelper htmlHelper, string name) {\r
+            return Password(htmlHelper, name, null /* value */);\r
+        }\r
+\r
+        public static MvcHtmlString Password(this HtmlHelper htmlHelper, string name, object value) {\r
+            return Password(htmlHelper, name, value, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString Password(this HtmlHelper htmlHelper, string name, object value, object htmlAttributes) {\r
+            return Password(htmlHelper, name, value, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString Password(this HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes) {\r
+            return PasswordHelper(htmlHelper, name, value, htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString PasswordFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) {\r
+            return PasswordFor(htmlHelper, expression, null /* htmlAttributes */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString PasswordFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) {\r
+            return PasswordFor(htmlHelper, expression, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Users cannot use anonymous methods with the LambdaExpression type")]\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString PasswordFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes) {\r
+            if (expression == null) {\r
+                throw new ArgumentNullException("expression");\r
+            }\r
+\r
+            return PasswordHelper(htmlHelper,\r
+                                  ExpressionHelper.GetExpressionText(expression),\r
+                                  null /* value */,\r
+                                  htmlAttributes);\r
+        }\r
+\r
+        private static MvcHtmlString PasswordHelper(HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes) {\r
+            return InputHelper(htmlHelper, InputType.Password, name, value, false /* useViewData */, false /* isChecked */, true /* setId */, true /* isExplicitValue */, htmlAttributes);\r
+        }\r
+\r
+        // RadioButton\r
+\r
+        public static MvcHtmlString RadioButton(this HtmlHelper htmlHelper, string name, object value) {\r
+            return RadioButton(htmlHelper, name, value, (object)null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString RadioButton(this HtmlHelper htmlHelper, string name, object value, object htmlAttributes) {\r
+            return RadioButton(htmlHelper, name, value, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RadioButton(this HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes) {\r
+            // Determine whether or not to render the checked attribute based on the contents of ViewData.\r
+            string valueString = Convert.ToString(value, CultureInfo.CurrentCulture);\r
+            bool isChecked = (!String.IsNullOrEmpty(name)) && (String.Equals(htmlHelper.EvalString(name), valueString, StringComparison.OrdinalIgnoreCase));\r
+            // checked attributes is implicit, so we need to ensure that the dictionary takes precedence.\r
+            RouteValueDictionary attributes = htmlAttributes == null ? new RouteValueDictionary() : new RouteValueDictionary(htmlAttributes);\r
+            if (attributes.ContainsKey("checked")) {\r
+                return InputHelper(htmlHelper, InputType.Radio, name, value, false, false, true, true /* isExplicitValue */, attributes);\r
+            }\r
+\r
+            return RadioButton(htmlHelper, name, value, isChecked, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString RadioButton(this HtmlHelper htmlHelper, string name, object value, bool isChecked) {\r
+            return RadioButton(htmlHelper, name, value, isChecked, (object)null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString RadioButton(this HtmlHelper htmlHelper, string name, object value, bool isChecked, object htmlAttributes) {\r
+            return RadioButton(htmlHelper, name, value, isChecked, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RadioButton(this HtmlHelper htmlHelper, string name, object value, bool isChecked, IDictionary<string, object> htmlAttributes) {\r
+            if (value == null) {\r
+                throw new ArgumentNullException("value");\r
+            }\r
+            // checked attribute is an explicit parameter so it takes precedence.\r
+            RouteValueDictionary attributes = htmlAttributes == null ? new RouteValueDictionary() : new RouteValueDictionary(htmlAttributes);\r
+            attributes.Remove("checked");\r
+            return InputHelper(htmlHelper, InputType.Radio, name, value, false, isChecked, true, true /* isExplicitValue */, attributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString RadioButtonFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object value) {\r
+            return RadioButtonFor(htmlHelper, expression, value, null /* htmlAttributes */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString RadioButtonFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object value, object htmlAttributes) {\r
+            return RadioButtonFor(htmlHelper, expression, value, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString RadioButtonFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object value, IDictionary<string, object> htmlAttributes) {\r
+            return RadioButtonHelper(htmlHelper,\r
+                                     ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).Model,\r
+                                     ExpressionHelper.GetExpressionText(expression),\r
+                                     value,\r
+                                     null /* isChecked */,\r
+                                     htmlAttributes);\r
+        }\r
+\r
+        private static MvcHtmlString RadioButtonHelper(HtmlHelper htmlHelper, object model, string name, object value, bool? isChecked, IDictionary<string, object> htmlAttributes) {\r
+            if (value == null) {\r
+                throw new ArgumentNullException("value");\r
+            }\r
+\r
+            RouteValueDictionary attributes =\r
+                htmlAttributes == null ? new RouteValueDictionary()\r
+                                       : new RouteValueDictionary(htmlAttributes);\r
+\r
+            bool explicitValue = isChecked.HasValue;\r
+            if (explicitValue) {\r
+                attributes.Remove("checked");    // Explicit value must override dictionary\r
+            }\r
+            else {\r
+                string valueString = Convert.ToString(value, CultureInfo.CurrentCulture);\r
+                isChecked = model != null &&\r
+                            !String.IsNullOrEmpty(name) &&\r
+                            String.Equals(model.ToString(), valueString, StringComparison.OrdinalIgnoreCase);\r
+            }\r
+\r
+            return InputHelper(htmlHelper, InputType.Radio, name, value, false /* useViewData */, isChecked ?? false, true /* setId */, true /* isExplicitValue */, attributes);\r
+        }\r
+\r
+        // TextBox\r
+\r
+        public static MvcHtmlString TextBox(this HtmlHelper htmlHelper, string name) {\r
+            return TextBox(htmlHelper, name, null /* value */);\r
+        }\r
+\r
+        public static MvcHtmlString TextBox(this HtmlHelper htmlHelper, string name, object value) {\r
+            return TextBox(htmlHelper, name, value, (object)null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString TextBox(this HtmlHelper htmlHelper, string name, object value, object htmlAttributes) {\r
+            return TextBox(htmlHelper, name, value, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString TextBox(this HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes) {\r
+            return InputHelper(htmlHelper, InputType.Text, name, value, (value == null) /* useViewData */, false /* isChecked */, true /* setId */, true /* isExplicitValue */, htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString TextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) {\r
+            return htmlHelper.TextBoxFor(expression, (IDictionary<string, object>)null);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString TextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) {\r
+            return htmlHelper.TextBoxFor(expression, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString TextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes) {\r
+            return TextBoxHelper(htmlHelper,\r
+                                 ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).Model,\r
+                                 ExpressionHelper.GetExpressionText(expression),\r
+                                 htmlAttributes);\r
+        }\r
+\r
+        private static MvcHtmlString TextBoxHelper(this HtmlHelper htmlHelper, object model, string expression, IDictionary<string, object> htmlAttributes) {\r
+            return InputHelper(htmlHelper, InputType.Text, expression, model, false /* useViewData */, false /* isChecked */, true /* setId */, true /* isExplicitValue */, htmlAttributes);\r
+        }\r
+\r
+        // Helper methods\r
+\r
+        private static MvcHtmlString InputHelper(HtmlHelper htmlHelper, InputType inputType, string name, object value, bool useViewData, bool isChecked, bool setId, bool isExplicitValue, IDictionary<string, object> htmlAttributes) {\r
+            name = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);\r
+            if (String.IsNullOrEmpty(name)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "name");\r
+            }\r
+\r
+            TagBuilder tagBuilder = new TagBuilder("input");\r
+            tagBuilder.MergeAttributes(htmlAttributes);\r
+            tagBuilder.MergeAttribute("type", HtmlHelper.GetInputTypeString(inputType));\r
+            tagBuilder.MergeAttribute("name", name, true);\r
+\r
+            string valueParameter = Convert.ToString(value, CultureInfo.CurrentCulture);\r
+            bool usedModelState = false;\r
+\r
+            switch (inputType) {\r
+                case InputType.CheckBox:\r
+                    bool? modelStateWasChecked = htmlHelper.GetModelStateValue(name, typeof(bool)) as bool?;\r
+                    if (modelStateWasChecked.HasValue) {\r
+                        isChecked = modelStateWasChecked.Value;\r
+                        usedModelState = true;\r
+                    }\r
+                    goto case InputType.Radio;\r
+                case InputType.Radio:\r
+                    if (!usedModelState) {\r
+                        string modelStateValue = htmlHelper.GetModelStateValue(name, typeof(string)) as string;\r
+                        if (modelStateValue != null) {\r
+                            isChecked = String.Equals(modelStateValue, valueParameter, StringComparison.Ordinal);\r
+                            usedModelState = true;\r
+                        }\r
+                    }\r
+                    if (!usedModelState && useViewData) {\r
+                        isChecked = htmlHelper.EvalBoolean(name);\r
+                    }\r
+                    if (isChecked) {\r
+                        tagBuilder.MergeAttribute("checked", "checked");\r
+                    }\r
+                    tagBuilder.MergeAttribute("value", valueParameter, isExplicitValue);\r
+                    break;\r
+                case InputType.Password:\r
+                    if (value != null) {\r
+                        tagBuilder.MergeAttribute("value", valueParameter, isExplicitValue);\r
+                    }\r
+                    break;\r
+                default:\r
+                    string attemptedValue = (string)htmlHelper.GetModelStateValue(name, typeof(string));\r
+                    tagBuilder.MergeAttribute("value", attemptedValue ?? ((useViewData) ? htmlHelper.EvalString(name) : valueParameter), isExplicitValue);\r
+                    break;\r
+            }\r
+\r
+            if (setId) {\r
+                tagBuilder.GenerateId(name);\r
+            }\r
+\r
+            // If there are any errors for a named field, we add the css attribute.\r
+            ModelState modelState;\r
+            if (htmlHelper.ViewData.ModelState.TryGetValue(name, out modelState)) {\r
+                if (modelState.Errors.Count > 0) {\r
+                    tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName);\r
+                }\r
+            }\r
+\r
+            if (inputType == InputType.CheckBox) {\r
+                // Render an additional <input type="hidden".../> for checkboxes. This\r
+                // addresses scenarios where unchecked checkboxes are not sent in the request.\r
+                // Sending a hidden input makes it possible to know that the checkbox was present\r
+                // on the page when the request was submitted.\r
+                StringBuilder inputItemBuilder = new StringBuilder();\r
+                inputItemBuilder.Append(tagBuilder.ToString(TagRenderMode.SelfClosing));\r
+\r
+                TagBuilder hiddenInput = new TagBuilder("input");\r
+                hiddenInput.MergeAttribute("type", HtmlHelper.GetInputTypeString(InputType.Hidden));\r
+                hiddenInput.MergeAttribute("name", name);\r
+                hiddenInput.MergeAttribute("value", "false");\r
+                inputItemBuilder.Append(hiddenInput.ToString(TagRenderMode.SelfClosing));\r
+                return MvcHtmlString.Create(inputItemBuilder.ToString());\r
+            }\r
+\r
+            return tagBuilder.ToMvcHtmlString(TagRenderMode.SelfClosing);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/LabelExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/LabelExtensions.cs
new file mode 100644 (file)
index 0000000..4af88ea
--- /dev/null
@@ -0,0 +1,49 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq;\r
+    using System.Linq.Expressions;\r
+\r
+    public static class LabelExtensions {\r
+        public static MvcHtmlString Label(this HtmlHelper html, string expression) {\r
+            return LabelHelper(html,\r
+                               ModelMetadata.FromStringExpression(expression, html.ViewData),\r
+                               expression);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression) {\r
+            return LabelHelper(html, \r
+                               ModelMetadata.FromLambdaExpression(expression, html.ViewData), \r
+                               ExpressionHelper.GetExpressionText(expression));\r
+        }\r
+\r
+        public static MvcHtmlString LabelForModel(this HtmlHelper html) {\r
+            return LabelHelper(html, html.ViewData.ModelMetadata, String.Empty);\r
+        }\r
+\r
+        internal static MvcHtmlString LabelHelper(HtmlHelper html, ModelMetadata metadata, string htmlFieldName) {\r
+            string labelText = metadata.DisplayName ?? metadata.PropertyName ?? htmlFieldName.Split('.').Last();\r
+            if (String.IsNullOrEmpty(labelText)) {\r
+                return MvcHtmlString.Empty;\r
+            }\r
+\r
+            TagBuilder tag = new TagBuilder("label");\r
+            tag.Attributes.Add("for", html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName));\r
+            tag.SetInnerText(labelText);\r
+            return tag.ToMvcHtmlString(TagRenderMode.Normal);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/LinkExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/LinkExtensions.cs
new file mode 100644 (file)
index 0000000..8250ff3
--- /dev/null
@@ -0,0 +1,116 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public static class LinkExtensions {\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName) {\r
+            return ActionLink(htmlHelper, linkText, actionName, null /* controllerName */, new RouteValueDictionary(), new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues) {\r
+            return ActionLink(htmlHelper, linkText, actionName, null /* controllerName */, new RouteValueDictionary(routeValues), new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes) {\r
+            return ActionLink(htmlHelper, linkText, actionName, null /* controllerName */, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues) {\r
+            return ActionLink(htmlHelper, linkText, actionName, null /* controllerName */, routeValues, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            return ActionLink(htmlHelper, linkText, actionName, null /* controllerName */, routeValues, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName) {\r
+            return ActionLink(htmlHelper, linkText, actionName, controllerName, new RouteValueDictionary(), new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes) {\r
+            return ActionLink(htmlHelper, linkText, actionName, controllerName, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            if (String.IsNullOrEmpty(linkText)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "linkText");\r
+            }\r
+            return MvcHtmlString.Create(HtmlHelper.GenerateLink(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection, linkText, null/* routeName */, actionName, controllerName, routeValues, htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes) {\r
+            return ActionLink(htmlHelper, linkText, actionName, controllerName, protocol, hostName, fragment, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            if (String.IsNullOrEmpty(linkText)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "linkText");\r
+            }\r
+            return MvcHtmlString.Create(HtmlHelper.GenerateLink(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection, linkText, null /* routeName */, actionName, controllerName, protocol, hostName, fragment, routeValues, htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, object routeValues) {\r
+            return RouteLink(htmlHelper, linkText, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, RouteValueDictionary routeValues) {\r
+            return RouteLink(htmlHelper, linkText, routeValues, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName) {\r
+            return RouteLink(htmlHelper, linkText, routeName, (object)null /* routeValues */ );\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, object routeValues) {\r
+            return RouteLink(htmlHelper, linkText, routeName, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, RouteValueDictionary routeValues) {\r
+            return RouteLink(htmlHelper, linkText, routeName, routeValues, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, object routeValues, object htmlAttributes) {\r
+            return RouteLink(htmlHelper, linkText, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            return RouteLink(htmlHelper, linkText, null /* routeName */, routeValues, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, object routeValues, object htmlAttributes) {\r
+            return RouteLink(htmlHelper, linkText, routeName, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            if (String.IsNullOrEmpty(linkText)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "linkText");\r
+            }\r
+            return MvcHtmlString.Create(HtmlHelper.GenerateRouteLink(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection, linkText, routeName, routeValues, htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes) {\r
+            return RouteLink(htmlHelper, linkText, routeName, protocol, hostName, fragment, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, string linkText, string routeName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            if (String.IsNullOrEmpty(linkText)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "linkText");\r
+            }\r
+            return MvcHtmlString.Create(HtmlHelper.GenerateRouteLink(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection, linkText, routeName, protocol, hostName, fragment, routeValues, htmlAttributes));\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/MvcForm.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/MvcForm.cs
new file mode 100644 (file)
index 0000000..6aa1d99
--- /dev/null
@@ -0,0 +1,69 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.IO;\r
+\r
+    public class MvcForm : IDisposable {\r
+\r
+        private bool _disposed;\r
+        private readonly FormContext _originalFormContext;\r
+        private readonly ViewContext _viewContext;\r
+        private readonly TextWriter _writer;\r
+\r
+        [Obsolete("The recommended alternative is the constructor MvcForm(ViewContext viewContext).", true /* error */)]\r
+        public MvcForm(HttpResponseBase httpResponse) {\r
+            if (httpResponse == null) {\r
+                throw new ArgumentNullException("httpResponse");\r
+            }\r
+\r
+            _writer = httpResponse.Output;\r
+        }\r
+\r
+        public MvcForm(ViewContext viewContext) {\r
+            if (viewContext == null) {\r
+                throw new ArgumentNullException("viewContext");\r
+            }\r
+\r
+            _viewContext = viewContext;\r
+            _writer = viewContext.Writer;\r
+\r
+            // push the new FormContext\r
+            _originalFormContext = viewContext.FormContext;\r
+            viewContext.FormContext = new FormContext();\r
+        }\r
+\r
+        public void Dispose() {\r
+            Dispose(true /* disposing */);\r
+            GC.SuppressFinalize(this);\r
+        }\r
+\r
+        protected virtual void Dispose(bool disposing) {\r
+            if (!_disposed) {\r
+                _disposed = true;\r
+                _writer.Write("</form>");\r
+\r
+                // output client validation and restore the original form context\r
+                if (_viewContext != null) {\r
+                    _viewContext.OutputClientValidation();\r
+                    _viewContext.FormContext = _originalFormContext;\r
+                }\r
+            }\r
+        }\r
+\r
+        public void EndForm() {\r
+            Dispose(true);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/PartialExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/PartialExtensions.cs
new file mode 100644 (file)
index 0000000..8f488c6
--- /dev/null
@@ -0,0 +1,36 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System.Globalization;\r
+    using System.IO;\r
+\r
+    public static class PartialExtensions {\r
+        public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName) {\r
+            return Partial(htmlHelper, partialViewName, null /* model */, htmlHelper.ViewData);\r
+        }\r
+\r
+        public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, ViewDataDictionary viewData) {\r
+            return Partial(htmlHelper, partialViewName, null /* model */, viewData);\r
+        }\r
+\r
+        public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, object model) {\r
+            return Partial(htmlHelper, partialViewName, model, htmlHelper.ViewData);\r
+        }\r
+\r
+        public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, object model, ViewDataDictionary viewData) {\r
+            StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);\r
+            htmlHelper.RenderPartialInternal(partialViewName, viewData, model, writer, ViewEngines.Engines);\r
+            return MvcHtmlString.Create(writer.ToString());\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/RenderPartialExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/RenderPartialExtensions.cs
new file mode 100644 (file)
index 0000000..3d25070
--- /dev/null
@@ -0,0 +1,35 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    public static class RenderPartialExtensions {\r
+        // Renders the partial view with the parent's view data and model\r
+        public static void RenderPartial(this HtmlHelper htmlHelper, string partialViewName) {\r
+            htmlHelper.RenderPartialInternal(partialViewName, htmlHelper.ViewData, null /* model */, htmlHelper.ViewContext.Writer, ViewEngines.Engines);\r
+        }\r
+\r
+        // Renders the partial view with the given view data and, implicitly, the given view data's model\r
+        public static void RenderPartial(this HtmlHelper htmlHelper, string partialViewName, ViewDataDictionary viewData) {\r
+            htmlHelper.RenderPartialInternal(partialViewName, viewData, null /* model */, htmlHelper.ViewContext.Writer, ViewEngines.Engines);\r
+        }\r
+\r
+        // Renders the partial view with an empty view data and the given model\r
+        public static void RenderPartial(this HtmlHelper htmlHelper, string partialViewName, object model) {\r
+            htmlHelper.RenderPartialInternal(partialViewName, htmlHelper.ViewData, model, htmlHelper.ViewContext.Writer, ViewEngines.Engines);\r
+        }\r
+\r
+        // Renders the partial view with a copy of the given view data plus the given model\r
+        public static void RenderPartial(this HtmlHelper htmlHelper, string partialViewName, object model, ViewDataDictionary viewData) {\r
+            htmlHelper.RenderPartialInternal(partialViewName, viewData, model, htmlHelper.ViewContext.Writer, ViewEngines.Engines);\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/SelectExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/SelectExtensions.cs
new file mode 100644 (file)
index 0000000..e3cf48b
--- /dev/null
@@ -0,0 +1,256 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Linq.Expressions;\r
+    using System.Text;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public static class SelectExtensions {\r
+\r
+        // DropDownList\r
+\r
+        public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name) {\r
+            return DropDownList(htmlHelper, name, null /* selectList */, null /* optionLabel */, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, string optionLabel) {\r
+            return DropDownList(htmlHelper, name, null /* selectList */, optionLabel, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList) {\r
+            return DropDownList(htmlHelper, name, selectList, null /* optionLabel */, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, object htmlAttributes) {\r
+            return DropDownList(htmlHelper, name, selectList, null /* optionLabel */, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes) {\r
+            return DropDownList(htmlHelper, name, selectList, null /* optionLabel */, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, string optionLabel) {\r
+            return DropDownList(htmlHelper, name, selectList, optionLabel, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes) {\r
+            return DropDownList(htmlHelper, name, selectList, optionLabel, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString DropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, string optionLabel, IDictionary<string, object> htmlAttributes) {\r
+            return DropDownListHelper(htmlHelper, name, selectList, optionLabel, htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList) {\r
+            return DropDownListFor(htmlHelper, expression, selectList, null /* optionLabel */, null /* htmlAttributes */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, object htmlAttributes) {\r
+            return DropDownListFor(htmlHelper, expression, selectList, null /* optionLabel */, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes) {\r
+            return DropDownListFor(htmlHelper, expression, selectList, null /* optionLabel */, htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel) {\r
+            return DropDownListFor(htmlHelper, expression, selectList, optionLabel, null /* htmlAttributes */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes) {\r
+            return DropDownListFor(htmlHelper, expression, selectList, optionLabel, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Users cannot use anonymous methods with the LambdaExpression type")]\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel, IDictionary<string, object> htmlAttributes) {\r
+            if (expression == null) {\r
+                throw new ArgumentNullException("expression");\r
+            }\r
+\r
+            return DropDownListHelper(htmlHelper, ExpressionHelper.GetExpressionText(expression), selectList, optionLabel, htmlAttributes);\r
+        }\r
+\r
+        private static MvcHtmlString DropDownListHelper(HtmlHelper htmlHelper, string expression, IEnumerable<SelectListItem> selectList, string optionLabel, IDictionary<string, object> htmlAttributes) {\r
+            return SelectInternal(htmlHelper, optionLabel, expression, selectList, false /* allowMultiple */, htmlAttributes);\r
+        }\r
+\r
+        // ListBox\r
+\r
+        public static MvcHtmlString ListBox(this HtmlHelper htmlHelper, string name) {\r
+            return ListBox(htmlHelper, name, null /* selectList */, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString ListBox(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList) {\r
+            return ListBox(htmlHelper, name, selectList, (IDictionary<string, object>)null);\r
+        }\r
+\r
+        public static MvcHtmlString ListBox(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, object htmlAttributes) {\r
+            return ListBox(htmlHelper, name, selectList, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString ListBox(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes) {\r
+            return ListBoxHelper(htmlHelper, name, selectList, htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString ListBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList) {\r
+            return ListBoxFor(htmlHelper, expression, selectList, null /* htmlAttributes */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString ListBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, object htmlAttributes) {\r
+            return ListBoxFor(htmlHelper, expression, selectList, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Users cannot use anonymous methods with the LambdaExpression type")]\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString ListBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes) {\r
+            if (expression == null) {\r
+                throw new ArgumentNullException("expression");\r
+            }\r
+\r
+            return ListBoxHelper(htmlHelper,\r
+                                 ExpressionHelper.GetExpressionText(expression),\r
+                                 selectList,\r
+                                 htmlAttributes);\r
+        }\r
+\r
+        private static MvcHtmlString ListBoxHelper(HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes) {\r
+            return SelectInternal(htmlHelper, null /* optionLabel */, name, selectList, true /* allowMultiple */, htmlAttributes);\r
+        }\r
+\r
+        // Helper methods\r
+\r
+        private static IEnumerable<SelectListItem> GetSelectData(this HtmlHelper htmlHelper, string name) {\r
+            object o = null;\r
+            if (htmlHelper.ViewData != null) {\r
+                o = htmlHelper.ViewData.Eval(name);\r
+            }\r
+            if (o == null) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.HtmlHelper_MissingSelectData,\r
+                        name,\r
+                        "IEnumerable<SelectListItem>"));\r
+            }\r
+            IEnumerable<SelectListItem> selectList = o as IEnumerable<SelectListItem>;\r
+            if (selectList == null) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.HtmlHelper_WrongSelectDataType,\r
+                        name,\r
+                        o.GetType().FullName,\r
+                        "IEnumerable<SelectListItem>"));\r
+            }\r
+            return selectList;\r
+        }\r
+\r
+        internal static string ListItemToOption(SelectListItem item) {\r
+            TagBuilder builder = new TagBuilder("option") {\r
+                InnerHtml = HttpUtility.HtmlEncode(item.Text)\r
+            };\r
+            if (item.Value != null) {\r
+                builder.Attributes["value"] = item.Value;\r
+            }\r
+            if (item.Selected) {\r
+                builder.Attributes["selected"] = "selected";\r
+            }\r
+            return builder.ToString(TagRenderMode.Normal);\r
+        }\r
+\r
+        private static MvcHtmlString SelectInternal(this HtmlHelper htmlHelper, string optionLabel, string name, IEnumerable<SelectListItem> selectList, bool allowMultiple, IDictionary<string, object> htmlAttributes) {\r
+            name = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);\r
+            if (String.IsNullOrEmpty(name)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "name");\r
+            }\r
+\r
+            bool usedViewData = false;\r
+\r
+            // If we got a null selectList, try to use ViewData to get the list of items.\r
+            if (selectList == null) {\r
+                selectList = htmlHelper.GetSelectData(name);\r
+                usedViewData = true;\r
+            }\r
+\r
+            object defaultValue = (allowMultiple) ? htmlHelper.GetModelStateValue(name, typeof(string[])) : htmlHelper.GetModelStateValue(name, typeof(string));\r
+\r
+            // If we haven't already used ViewData to get the entire list of items then we need to\r
+            // use the ViewData-supplied value before using the parameter-supplied value.\r
+            if (!usedViewData) {\r
+                if (defaultValue == null) {\r
+                    defaultValue = htmlHelper.ViewData.Eval(name);\r
+                }\r
+            }\r
+\r
+            if (defaultValue != null) {\r
+                IEnumerable defaultValues = (allowMultiple) ? defaultValue as IEnumerable : new[] { defaultValue };\r
+                IEnumerable<string> values = from object value in defaultValues select Convert.ToString(value, CultureInfo.CurrentCulture);\r
+                HashSet<string> selectedValues = new HashSet<string>(values, StringComparer.OrdinalIgnoreCase);\r
+                List<SelectListItem> newSelectList = new List<SelectListItem>();\r
+\r
+                foreach (SelectListItem item in selectList) {\r
+                    item.Selected = (item.Value != null) ? selectedValues.Contains(item.Value) : selectedValues.Contains(item.Text);\r
+                    newSelectList.Add(item);\r
+                }\r
+                selectList = newSelectList;\r
+            }\r
+\r
+            // Convert each ListItem to an <option> tag\r
+            StringBuilder listItemBuilder = new StringBuilder();\r
+\r
+            // Make optionLabel the first item that gets rendered.\r
+            if (optionLabel != null) {\r
+                listItemBuilder.AppendLine(ListItemToOption(new SelectListItem() { Text = optionLabel, Value = String.Empty, Selected = false }));\r
+            }\r
+\r
+            foreach (SelectListItem item in selectList) {\r
+                listItemBuilder.AppendLine(ListItemToOption(item));\r
+            }\r
+\r
+            TagBuilder tagBuilder = new TagBuilder("select") {\r
+                InnerHtml = listItemBuilder.ToString()\r
+            };\r
+            tagBuilder.MergeAttributes(htmlAttributes);\r
+            tagBuilder.MergeAttribute("name", name, true /* replaceExisting */);\r
+            tagBuilder.GenerateId(name);\r
+            if (allowMultiple) {\r
+                tagBuilder.MergeAttribute("multiple", "multiple");\r
+            }\r
+\r
+            // If there are any errors for a named field, we add the css attribute.\r
+            ModelState modelState;\r
+            if (htmlHelper.ViewData.ModelState.TryGetValue(name, out modelState)) {\r
+                if (modelState.Errors.Count > 0) {\r
+                    tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName);\r
+                }\r
+            }\r
+\r
+            return tagBuilder.ToMvcHtmlString(TagRenderMode.Normal);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/TemplateHelpers.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/TemplateHelpers.cs
new file mode 100644 (file)
index 0000000..b220233
--- /dev/null
@@ -0,0 +1,277 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.IO;\r
+    using System.Linq;\r
+    using System.Linq.Expressions;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+    using System.Web.UI.WebControls;\r
+\r
+    internal static class TemplateHelpers {\r
+        static readonly Dictionary<DataBoundControlMode, string> modeViewPaths =\r
+            new Dictionary<DataBoundControlMode, string> {\r
+                { DataBoundControlMode.ReadOnly, "DisplayTemplates" },\r
+                { DataBoundControlMode.Edit,     "EditorTemplates" }\r
+            };\r
+\r
+        static readonly Dictionary<string, Func<HtmlHelper, string>> defaultDisplayActions =\r
+            new Dictionary<string, Func<HtmlHelper, string>>(StringComparer.OrdinalIgnoreCase) {\r
+                { "EmailAddress",       DefaultDisplayTemplates.EmailAddressTemplate },\r
+                { "HiddenInput",        DefaultDisplayTemplates.HiddenInputTemplate },\r
+                { "Html",               DefaultDisplayTemplates.HtmlTemplate },\r
+                { "Text",               DefaultDisplayTemplates.StringTemplate },\r
+                { "Url",                DefaultDisplayTemplates.UrlTemplate },\r
+                { "Collection",         DefaultDisplayTemplates.CollectionTemplate },\r
+                { typeof(bool).Name,    DefaultDisplayTemplates.BooleanTemplate },\r
+                { typeof(decimal).Name, DefaultDisplayTemplates.DecimalTemplate },\r
+                { typeof(string).Name,  DefaultDisplayTemplates.StringTemplate },\r
+                { typeof(object).Name,  DefaultDisplayTemplates.ObjectTemplate },\r
+            };\r
+\r
+        static readonly Dictionary<string, Func<HtmlHelper, string>> defaultEditorActions =\r
+            new Dictionary<string, Func<HtmlHelper, string>>(StringComparer.OrdinalIgnoreCase) {\r
+                { "HiddenInput",        DefaultEditorTemplates.HiddenInputTemplate },\r
+                { "MultilineText",      DefaultEditorTemplates.MultilineTextTemplate },\r
+                { "Password",           DefaultEditorTemplates.PasswordTemplate },\r
+                { "Text",               DefaultEditorTemplates.StringTemplate },\r
+                { "Collection",         DefaultEditorTemplates.CollectionTemplate },\r
+                { typeof(bool).Name,    DefaultEditorTemplates.BooleanTemplate },\r
+                { typeof(decimal).Name, DefaultEditorTemplates.DecimalTemplate },\r
+                { typeof(string).Name,  DefaultEditorTemplates.StringTemplate },\r
+                { typeof(object).Name,  DefaultEditorTemplates.ObjectTemplate },\r
+            };\r
+\r
+        internal static string cacheItemId = Guid.NewGuid().ToString();\r
+\r
+        internal delegate string ExecuteTemplateDelegate(HtmlHelper html, ViewDataDictionary viewData, string templateName, DataBoundControlMode mode, GetViewNamesDelegate getViewNames);\r
+\r
+        internal static string ExecuteTemplate(HtmlHelper html, ViewDataDictionary viewData, string templateName, DataBoundControlMode mode, GetViewNamesDelegate getViewNames) {\r
+            Dictionary<string, ActionCacheItem> actionCache = GetActionCache(html);\r
+            Dictionary<string, Func<HtmlHelper, string>> defaultActions = mode == DataBoundControlMode.ReadOnly ? defaultDisplayActions : defaultEditorActions;\r
+            string modeViewPath = modeViewPaths[mode];\r
+\r
+            foreach (string viewName in getViewNames(viewData.ModelMetadata, templateName, viewData.ModelMetadata.TemplateHint, viewData.ModelMetadata.DataTypeName)) {\r
+                string fullViewName = modeViewPath + "/" + viewName;\r
+                ActionCacheItem cacheItem;\r
+\r
+                if (actionCache.TryGetValue(fullViewName, out cacheItem)) {\r
+                    if (cacheItem != null) {\r
+                        return cacheItem.Execute(html, viewData);\r
+                    }\r
+                }\r
+                else {\r
+                    ViewEngineResult viewEngineResult = ViewEngines.Engines.FindPartialView(html.ViewContext, fullViewName);\r
+                    if (viewEngineResult.View != null) {\r
+                        actionCache[fullViewName] = new ActionCacheViewItem { ViewName = fullViewName };\r
+\r
+                        StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);\r
+                        viewEngineResult.View.Render(new ViewContext(html.ViewContext, viewEngineResult.View, viewData, html.ViewContext.TempData, writer), writer);\r
+                        return writer.ToString();\r
+                    }\r
+\r
+                    Func<HtmlHelper, string> defaultAction;\r
+                    if (defaultActions.TryGetValue(viewName, out defaultAction)) {\r
+                        actionCache[fullViewName] = new ActionCacheCodeItem { Action = defaultAction };\r
+                        return defaultAction(\r
+                            new HtmlHelper(\r
+                                new ViewContext(html.ViewContext, html.ViewContext.View, viewData, html.ViewContext.TempData, html.ViewContext.Writer),\r
+                                html.ViewDataContainer\r
+                            )\r
+                        );\r
+                    }\r
+\r
+                    actionCache[fullViewName] = null;\r
+                }\r
+            }\r
+\r
+            throw new InvalidOperationException(\r
+                String.Format(\r
+                    CultureInfo.CurrentCulture,\r
+                    MvcResources.TemplateHelpers_NoTemplate,\r
+                    viewData.ModelMetadata.RealModelType.FullName\r
+                )\r
+            );\r
+        }\r
+\r
+        internal static Dictionary<string, ActionCacheItem> GetActionCache(HtmlHelper html) {\r
+            HttpContextBase context = html.ViewContext.HttpContext;\r
+            Dictionary<string, ActionCacheItem> result;\r
+\r
+            if (!context.Items.Contains(cacheItemId)) {\r
+                result = new Dictionary<string, ActionCacheItem>();\r
+                context.Items[cacheItemId] = result;\r
+            }\r
+            else {\r
+                result = (Dictionary<string, ActionCacheItem>)context.Items[cacheItemId];\r
+            }\r
+\r
+            return result;\r
+        }\r
+\r
+        internal delegate IEnumerable<string> GetViewNamesDelegate(ModelMetadata metadata, params string[] templateHints);\r
+\r
+        internal static IEnumerable<string> GetViewNames(ModelMetadata metadata, params string[] templateHints) {\r
+            foreach (string templateHint in templateHints.Where(s => !String.IsNullOrEmpty(s))) {\r
+                yield return templateHint;\r
+            }\r
+\r
+            // We don't want to search for Nullable<T>, we want to search for T (which should handle both T and Nullable<T>)\r
+            Type fieldType = Nullable.GetUnderlyingType(metadata.RealModelType) ?? metadata.RealModelType;\r
+\r
+            // TODO: Make better string names for generic types\r
+            yield return fieldType.Name;\r
+\r
+            if (!metadata.IsComplexType) {\r
+                yield return "String";\r
+            }\r
+            else if (fieldType.IsInterface) {\r
+                if (typeof(IEnumerable).IsAssignableFrom(fieldType)) {\r
+                    yield return "Collection";\r
+                }\r
+\r
+                yield return "Object";\r
+            }\r
+            else {\r
+                bool isEnumerable = typeof(IEnumerable).IsAssignableFrom(fieldType);\r
+\r
+                while (true) {\r
+                    fieldType = fieldType.BaseType;\r
+                    if (fieldType == null)\r
+                        break;\r
+\r
+                    if (isEnumerable && fieldType == typeof(Object)) {\r
+                        yield return "Collection";\r
+                    }\r
+\r
+                    yield return fieldType.Name;\r
+                }\r
+            }\r
+        }\r
+\r
+        internal static MvcHtmlString Template(HtmlHelper html, string expression, string templateName, string htmlFieldName, DataBoundControlMode mode, object additionalViewData) {\r
+            return MvcHtmlString.Create(Template(html, expression, templateName, htmlFieldName, mode, additionalViewData, TemplateHelper));\r
+        }\r
+\r
+        // Unit testing version\r
+        internal static string Template(HtmlHelper html, string expression, string templateName, string htmlFieldName,\r
+                                        DataBoundControlMode mode, object additionalViewData, TemplateHelperDelegate templateHelper) {\r
+            return templateHelper(html,\r
+                                  ModelMetadata.FromStringExpression(expression, html.ViewData),\r
+                                  htmlFieldName ?? ExpressionHelper.GetExpressionText(expression),\r
+                                  templateName,\r
+                                  mode,\r
+                                  additionalViewData);\r
+        }\r
+\r
+        internal static MvcHtmlString TemplateFor<TContainer, TValue>(this HtmlHelper<TContainer> html, Expression<Func<TContainer, TValue>> expression,\r
+                                                                      string templateName, string htmlFieldName, DataBoundControlMode mode,\r
+                                                                      object additionalViewData) {\r
+            return MvcHtmlString.Create(TemplateFor(html, expression, templateName, htmlFieldName, mode, additionalViewData, TemplateHelper));\r
+        }\r
+\r
+        // Unit testing version\r
+        internal static string TemplateFor<TContainer, TValue>(this HtmlHelper<TContainer> html, Expression<Func<TContainer, TValue>> expression,\r
+                                                               string templateName, string htmlFieldName, DataBoundControlMode mode,\r
+                                                               object additionalViewData, TemplateHelperDelegate templateHelper) {\r
+            return templateHelper(html,\r
+                                  ModelMetadata.FromLambdaExpression(expression, html.ViewData),\r
+                                  htmlFieldName ?? ExpressionHelper.GetExpressionText(expression),\r
+                                  templateName,\r
+                                  mode,\r
+                                  additionalViewData);\r
+        }\r
+\r
+        internal delegate string TemplateHelperDelegate(HtmlHelper html, ModelMetadata metadata, string htmlFieldName, string templateName, DataBoundControlMode mode, object additionalViewData);\r
+\r
+        internal static string TemplateHelper(HtmlHelper html, ModelMetadata metadata, string htmlFieldName, string templateName, DataBoundControlMode mode, object additionalViewData) {\r
+            return TemplateHelper(html, metadata, htmlFieldName, templateName, mode, additionalViewData, ExecuteTemplate);\r
+        }\r
+\r
+        internal static string TemplateHelper(HtmlHelper html, ModelMetadata metadata, string htmlFieldName, string templateName, DataBoundControlMode mode, object additionalViewData, ExecuteTemplateDelegate executeTemplate) {\r
+            // TODO: Convert Editor into Display if model.IsReadOnly is true? Need to be careful about this because\r
+            // the Model property on the ViewPage/ViewUserControl is get-only, so the type descriptor automatically\r
+            // decorates it with a [ReadOnly] attribute...\r
+\r
+            if (metadata.ConvertEmptyStringToNull && String.Empty.Equals(metadata.Model)) {\r
+                metadata.Model = null;\r
+            }\r
+\r
+            object formattedModelValue = metadata.Model;\r
+            if (metadata.Model == null && mode == DataBoundControlMode.ReadOnly) {\r
+                formattedModelValue = metadata.NullDisplayText;\r
+            }\r
+\r
+            string formatString = mode == DataBoundControlMode.ReadOnly ? metadata.DisplayFormatString : metadata.EditFormatString;\r
+            if (metadata.Model != null && !String.IsNullOrEmpty(formatString)) {\r
+                formattedModelValue = String.Format(CultureInfo.CurrentCulture, formatString, metadata.Model);\r
+            }\r
+\r
+            // Normally this shouldn't happen, unless someone writes their own custom Object templates which\r
+            // don't check to make sure that the object hasn't already been displayed\r
+            object visitedObjectsKey = metadata.Model ?? metadata.RealModelType;\r
+            if (html.ViewDataContainer.ViewData.TemplateInfo.VisitedObjects.Contains(visitedObjectsKey)) {    // DDB #224750\r
+                return String.Empty;\r
+            }\r
+\r
+            ViewDataDictionary viewData = new ViewDataDictionary(html.ViewDataContainer.ViewData) {\r
+                Model = metadata.Model,\r
+                ModelMetadata = metadata,\r
+                TemplateInfo = new TemplateInfo {\r
+                    FormattedModelValue = formattedModelValue,\r
+                    HtmlFieldPrefix = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlFieldName),\r
+                    VisitedObjects = new HashSet<object>(html.ViewContext.ViewData.TemplateInfo.VisitedObjects),    // DDB #224750\r
+                }\r
+            };\r
+\r
+            if (additionalViewData != null) {\r
+                foreach (KeyValuePair<string, object> kvp in new RouteValueDictionary(additionalViewData)) {\r
+                    viewData[kvp.Key] = kvp.Value;\r
+                }\r
+            }\r
+\r
+            viewData.TemplateInfo.VisitedObjects.Add(visitedObjectsKey);    // DDB #224750\r
+\r
+            return executeTemplate(html, viewData, templateName, mode, GetViewNames);\r
+        }\r
+\r
+        internal abstract class ActionCacheItem {\r
+            public abstract string Execute(HtmlHelper html, ViewDataDictionary viewData);\r
+        }\r
+\r
+        internal class ActionCacheCodeItem : ActionCacheItem {\r
+            public Func<HtmlHelper, string> Action { get; set; }\r
+\r
+            public override string Execute(HtmlHelper html, ViewDataDictionary viewData) {\r
+                ViewContext newViewContext = new ViewContext(html.ViewContext, html.ViewContext.View, viewData, html.ViewContext.TempData, html.ViewContext.Writer);\r
+                HtmlHelper newHtmlHelper = new HtmlHelper(newViewContext, html.ViewDataContainer);\r
+                return Action(newHtmlHelper);\r
+            }\r
+        }\r
+\r
+        internal class ActionCacheViewItem : ActionCacheItem {\r
+            public string ViewName { get; set; }\r
+\r
+            public override string Execute(HtmlHelper html, ViewDataDictionary viewData) {\r
+                ViewEngineResult viewEngineResult = ViewEngines.Engines.FindPartialView(html.ViewContext, ViewName);\r
+                StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);\r
+                viewEngineResult.View.Render(new ViewContext(html.ViewContext, viewEngineResult.View, viewData, html.ViewContext.TempData, writer), writer);\r
+                return writer.ToString();\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/TextAreaExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/TextAreaExtensions.cs
new file mode 100644 (file)
index 0000000..4443c43
--- /dev/null
@@ -0,0 +1,172 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq.Expressions;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public static class TextAreaExtensions {\r
+        // These values are similar to the defaults used by WebForms\r
+        // when using <asp:TextBox TextMode="MultiLine"> without specifying\r
+        // the Rows and Columns attributes.\r
+        private const int TextAreaRows = 2;\r
+        private const int TextAreaColumns = 20;\r
+        private static Dictionary<string, object> implicitRowsAndColumns = new Dictionary<string, object> {\r
+            { "rows", TextAreaRows.ToString(CultureInfo.InvariantCulture) },\r
+            { "cols", TextAreaColumns.ToString(CultureInfo.InvariantCulture) },\r
+        };\r
+\r
+        private static Dictionary<string, object> GetRowsAndColumnsDictionary(int rows, int columns) {\r
+            if (rows < 0) {\r
+                throw new ArgumentOutOfRangeException("rows", MvcResources.HtmlHelper_TextAreaParameterOutOfRange);\r
+            }\r
+            if (columns < 0) {\r
+                throw new ArgumentOutOfRangeException("columns", MvcResources.HtmlHelper_TextAreaParameterOutOfRange);\r
+            }\r
+\r
+            Dictionary<string, object> result = new Dictionary<string, object>();\r
+            if (rows > 0) {\r
+                result.Add("rows", rows.ToString(CultureInfo.InvariantCulture));\r
+            }\r
+            if (columns > 0) {\r
+                result.Add("cols", columns.ToString(CultureInfo.InvariantCulture));\r
+            }\r
+\r
+            return result;\r
+        }\r
+\r
+        public static MvcHtmlString TextArea(this HtmlHelper htmlHelper, string name) {\r
+            return TextArea(htmlHelper, name, null /* value */, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString TextArea(this HtmlHelper htmlHelper, string name, object htmlAttributes) {\r
+            return TextArea(htmlHelper, name, null /* value */, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString TextArea(this HtmlHelper htmlHelper, string name, IDictionary<string, object> htmlAttributes) {\r
+            return TextArea(htmlHelper, name, null /* value */, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString TextArea(this HtmlHelper htmlHelper, string name, string value) {\r
+            return TextArea(htmlHelper, name, value, null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString TextArea(this HtmlHelper htmlHelper, string name, string value, object htmlAttributes) {\r
+            return TextArea(htmlHelper, name, value, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString TextArea(this HtmlHelper htmlHelper, string name, string value, IDictionary<string, object> htmlAttributes) {\r
+            ModelMetadata metadata = ModelMetadata.FromStringExpression(name, htmlHelper.ViewContext.ViewData);\r
+            if (value != null) {\r
+                metadata.Model = value;\r
+            }\r
+\r
+            return TextAreaHelper(htmlHelper, metadata, name, implicitRowsAndColumns, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString TextArea(this HtmlHelper htmlHelper, string name, string value, int rows, int columns, object htmlAttributes) {\r
+            return TextArea(htmlHelper, name, value, rows, columns, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString TextArea(this HtmlHelper htmlHelper, string name, string value, int rows, int columns, IDictionary<string, object> htmlAttributes) {\r
+            ModelMetadata metadata = ModelMetadata.FromStringExpression(name, htmlHelper.ViewContext.ViewData);\r
+            if (value != null) {\r
+                metadata.Model = value;\r
+            }\r
+\r
+            return TextAreaHelper(htmlHelper, metadata, name, GetRowsAndColumnsDictionary(rows, columns), htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString TextAreaFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) {\r
+            return TextAreaFor(htmlHelper, expression, (IDictionary<string, object>)null);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString TextAreaFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) {\r
+            return TextAreaFor(htmlHelper, expression, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString TextAreaFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes) {\r
+            if (expression == null) {\r
+                throw new ArgumentNullException("expression");\r
+            }\r
+\r
+            return TextAreaHelper(htmlHelper,\r
+                                  ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData),\r
+                                  ExpressionHelper.GetExpressionText(expression),\r
+                                  implicitRowsAndColumns,\r
+                                  htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString TextAreaFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, int rows, int columns, object htmlAttributes) {\r
+            return TextAreaFor(htmlHelper, expression, rows, columns, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString TextAreaFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, int rows, int columns, IDictionary<string, object> htmlAttributes) {\r
+            if (expression == null) {\r
+                throw new ArgumentNullException("expression");\r
+            }\r
+\r
+            return TextAreaHelper(htmlHelper,\r
+                                  ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData),\r
+                                  ExpressionHelper.GetExpressionText(expression),\r
+                                  GetRowsAndColumnsDictionary(rows, columns),\r
+                                  htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Justification = "If this fails, it is because the string-based version had an empty 'name' parameter")]\r
+        private static MvcHtmlString TextAreaHelper(HtmlHelper htmlHelper, ModelMetadata modelMetadata, string expression, IDictionary<string, object> rowsAndColumns, IDictionary<string, object> htmlAttributes) {\r
+            string name = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expression);\r
+            if (String.IsNullOrEmpty(name)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "name");\r
+            }\r
+\r
+            TagBuilder tagBuilder = new TagBuilder("textarea");\r
+            tagBuilder.GenerateId(name);\r
+            tagBuilder.MergeAttributes(htmlAttributes, true);\r
+            tagBuilder.MergeAttributes(rowsAndColumns, rowsAndColumns != implicitRowsAndColumns);  // Only force explicit rows/cols\r
+            tagBuilder.MergeAttribute("name", name, true);\r
+\r
+            // If there are any errors for a named field, we add the CSS attribute.\r
+            ModelState modelState;\r
+            if (htmlHelper.ViewData.ModelState.TryGetValue(name, out modelState) && modelState.Errors.Count > 0) {\r
+                tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName);\r
+            }\r
+\r
+            string value;\r
+            if (modelState != null && modelState.Value != null) {\r
+                value = modelState.Value.AttemptedValue;\r
+            }\r
+            else if (modelMetadata.Model != null) {\r
+                value = modelMetadata.Model.ToString();\r
+            }\r
+            else {\r
+                value = String.Empty;\r
+            }\r
+\r
+            // The first newline is always trimmed when a TextArea is rendered, so we add an extra one\r
+            // in case the value being rendered is something like "\r\nHello".\r
+            tagBuilder.SetInnerText(Environment.NewLine + value);\r
+\r
+            return tagBuilder.ToMvcHtmlString(TagRenderMode.Normal);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/ValidationExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Html/ValidationExtensions.cs
new file mode 100644 (file)
index 0000000..1284a49
--- /dev/null
@@ -0,0 +1,304 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc.Html {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Linq.Expressions;\r
+    using System.Text;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public static class ValidationExtensions {\r
+\r
+        private const string _hiddenListItem = @"<li style=""display:none""></li>";\r
+        private static string _resourceClassKey;\r
+\r
+        public static string ResourceClassKey {\r
+            get {\r
+                return _resourceClassKey ?? String.Empty;\r
+            }\r
+            set {\r
+                _resourceClassKey = value;\r
+            }\r
+        }\r
+\r
+        private static FieldValidationMetadata ApplyFieldValidationMetadata(HtmlHelper htmlHelper, ModelMetadata modelMetadata, string modelName) {\r
+            FormContext formContext = htmlHelper.ViewContext.FormContext;\r
+            FieldValidationMetadata fieldMetadata = formContext.GetValidationMetadataForField(modelName, true /* createIfNotFound */);\r
+\r
+            // write rules to context object\r
+            IEnumerable<ModelValidator> validators = ModelValidatorProviders.Providers.GetValidators(modelMetadata, htmlHelper.ViewContext);\r
+            foreach (ModelClientValidationRule rule in validators.SelectMany(v => v.GetClientValidationRules())) {\r
+                fieldMetadata.ValidationRules.Add(rule);\r
+            }\r
+\r
+            return fieldMetadata;\r
+        }\r
+\r
+        private static string GetInvalidPropertyValueResource(HttpContextBase httpContext) {\r
+            string resourceValue = null;\r
+            if (!String.IsNullOrEmpty(ResourceClassKey) && (httpContext != null)) {\r
+                // If the user specified a ResourceClassKey try to load the resource they specified.\r
+                // If the class key is invalid, an exception will be thrown.\r
+                // If the class key is valid but the resource is not found, it returns null, in which\r
+                // case it will fall back to the MVC default error message.\r
+                resourceValue = httpContext.GetGlobalResourceObject(ResourceClassKey, "InvalidPropertyValue", CultureInfo.CurrentUICulture) as string;\r
+            }\r
+            return resourceValue ?? MvcResources.Common_ValueNotValidForProperty;\r
+        }\r
+\r
+        private static string GetUserErrorMessageOrDefault(HttpContextBase httpContext, ModelError error, ModelState modelState) {\r
+            if (!String.IsNullOrEmpty(error.ErrorMessage)) {\r
+                return error.ErrorMessage;\r
+            }\r
+            if (modelState == null) {\r
+                return null;\r
+            }\r
+\r
+            string attemptedValue = (modelState.Value != null) ? modelState.Value.AttemptedValue : null;\r
+            return String.Format(CultureInfo.CurrentCulture, GetInvalidPropertyValueResource(httpContext), attemptedValue);\r
+        }\r
+\r
+        // Validate\r
+\r
+        public static void Validate(this HtmlHelper htmlHelper, string modelName) {\r
+            if (modelName == null) {\r
+                throw new ArgumentNullException("modelName");\r
+            }\r
+\r
+            ValidateHelper(htmlHelper,\r
+                ModelMetadata.FromStringExpression(modelName, htmlHelper.ViewContext.ViewData),\r
+                modelName);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static void ValidateFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) {\r
+            ValidateHelper(htmlHelper,\r
+                ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData),\r
+                ExpressionHelper.GetExpressionText(expression));\r
+        }\r
+\r
+        private static void ValidateHelper(HtmlHelper htmlHelper, ModelMetadata modelMetadata, string expression) {\r
+            FormContext formContext = htmlHelper.ViewContext.GetFormContextForClientValidation();\r
+            if (formContext == null) {\r
+                return; // nothing to do\r
+            }\r
+\r
+            string modelName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expression);\r
+            ApplyFieldValidationMetadata(htmlHelper, modelMetadata, modelName);\r
+        }\r
+\r
+        // ValidationMessage\r
+\r
+        public static MvcHtmlString ValidationMessage(this HtmlHelper htmlHelper, string modelName) {\r
+            return ValidationMessage(htmlHelper, modelName, null /* validationMessage */, new RouteValueDictionary());\r
+        }\r
+\r
+        public static MvcHtmlString ValidationMessage(this HtmlHelper htmlHelper, string modelName, object htmlAttributes) {\r
+            return ValidationMessage(htmlHelper, modelName, null /* validationMessage */, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames", Justification = "'validationMessage' refers to the message that will be rendered by the ValidationMessage helper.")]\r
+        public static MvcHtmlString ValidationMessage(this HtmlHelper htmlHelper, string modelName, string validationMessage) {\r
+            return ValidationMessage(htmlHelper, modelName, validationMessage, new RouteValueDictionary());\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames", Justification = "'validationMessage' refers to the message that will be rendered by the ValidationMessage helper.")]\r
+        public static MvcHtmlString ValidationMessage(this HtmlHelper htmlHelper, string modelName, string validationMessage, object htmlAttributes) {\r
+            return ValidationMessage(htmlHelper, modelName, validationMessage, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString ValidationMessage(this HtmlHelper htmlHelper, string modelName, IDictionary<string, object> htmlAttributes) {\r
+            return ValidationMessage(htmlHelper, modelName, null /* validationMessage */, htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames", Justification = "'validationMessage' refers to the message that will be rendered by the ValidationMessage helper.")]\r
+        public static MvcHtmlString ValidationMessage(this HtmlHelper htmlHelper, string modelName, string validationMessage, IDictionary<string, object> htmlAttributes) {\r
+            if (modelName == null) {\r
+                throw new ArgumentNullException("modelName");\r
+            }\r
+\r
+            return ValidationMessageHelper(htmlHelper,\r
+                                           ModelMetadata.FromStringExpression(modelName, htmlHelper.ViewContext.ViewData),\r
+                                           modelName,\r
+                                           validationMessage,\r
+                                           htmlAttributes);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) {\r
+            return ValidationMessageFor(htmlHelper, expression, null /* validationMessage */, new RouteValueDictionary());\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string validationMessage) {\r
+            return ValidationMessageFor(htmlHelper, expression, validationMessage, new RouteValueDictionary());\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string validationMessage, object htmlAttributes) {\r
+            return ValidationMessageFor(htmlHelper, expression, validationMessage, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string validationMessage, IDictionary<string, object> htmlAttributes) {\r
+            return ValidationMessageHelper(htmlHelper,\r
+                                           ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData),\r
+                                           ExpressionHelper.GetExpressionText(expression),\r
+                                           validationMessage,\r
+                                           htmlAttributes);\r
+        }\r
+\r
+        private static MvcHtmlString ValidationMessageHelper(this HtmlHelper htmlHelper, ModelMetadata modelMetadata, string expression, string validationMessage, IDictionary<string, object> htmlAttributes) {\r
+            string modelName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expression);\r
+            FormContext formContext = htmlHelper.ViewContext.GetFormContextForClientValidation();\r
+\r
+            if (!htmlHelper.ViewData.ModelState.ContainsKey(modelName) && formContext == null) {\r
+                return null;\r
+            }\r
+\r
+            ModelState modelState = htmlHelper.ViewData.ModelState[modelName];\r
+            ModelErrorCollection modelErrors = (modelState == null) ? null : modelState.Errors;\r
+            ModelError modelError = ((modelErrors == null) || (modelErrors.Count == 0)) ? null : modelErrors[0];\r
+\r
+            if (modelError == null && formContext == null) {\r
+                return null;\r
+            }\r
+\r
+            TagBuilder builder = new TagBuilder("span");\r
+            builder.MergeAttributes(htmlAttributes);\r
+            builder.AddCssClass((modelError != null) ? HtmlHelper.ValidationMessageCssClassName : HtmlHelper.ValidationMessageValidCssClassName);\r
+\r
+            if (!String.IsNullOrEmpty(validationMessage)) {\r
+                builder.SetInnerText(validationMessage);\r
+            }\r
+            else if (modelError != null) {\r
+                builder.SetInnerText(GetUserErrorMessageOrDefault(htmlHelper.ViewContext.HttpContext, modelError, modelState));\r
+            }\r
+\r
+            if (formContext != null) {\r
+                // client validation always requires an ID\r
+                builder.GenerateId(modelName + ".validationMessage");\r
+\r
+                FieldValidationMetadata fieldMetadata = ApplyFieldValidationMetadata(htmlHelper, modelMetadata, modelName);\r
+                // rules will already have been written to the metadata object\r
+                fieldMetadata.ReplaceValidationMessageContents = (String.IsNullOrEmpty(validationMessage)); // only replace contents if no explicit message was specified\r
+                fieldMetadata.ValidationMessageId = builder.Attributes["id"];\r
+            }\r
+\r
+            return builder.ToMvcHtmlString(TagRenderMode.Normal);\r
+        }\r
+\r
+        // ValidationSummary\r
+\r
+        public static MvcHtmlString ValidationSummary(this HtmlHelper htmlHelper) {\r
+            return ValidationSummary(htmlHelper, false /* excludePropertyErrors */ );\r
+        }\r
+\r
+        public static MvcHtmlString ValidationSummary(this HtmlHelper htmlHelper, bool excludePropertyErrors) {\r
+            return ValidationSummary(htmlHelper, excludePropertyErrors, null /* message */);\r
+        }\r
+\r
+        public static MvcHtmlString ValidationSummary(this HtmlHelper htmlHelper, string message) {\r
+            return ValidationSummary(htmlHelper, false /* excludePropertyErrors */, message, (object)null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString ValidationSummary(this HtmlHelper htmlHelper, bool excludePropertyErrors, string message) {\r
+            return ValidationSummary(htmlHelper, excludePropertyErrors, message, (object)null /* htmlAttributes */);\r
+        }\r
+\r
+        public static MvcHtmlString ValidationSummary(this HtmlHelper htmlHelper, string message, object htmlAttributes) {\r
+            return ValidationSummary(htmlHelper, false /* excludePropertyErrors */, message, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString ValidationSummary(this HtmlHelper htmlHelper, bool excludePropertyErrors, string message, object htmlAttributes) {\r
+            return ValidationSummary(htmlHelper, excludePropertyErrors, message, new RouteValueDictionary(htmlAttributes));\r
+        }\r
+\r
+        public static MvcHtmlString ValidationSummary(this HtmlHelper htmlHelper, string message, IDictionary<string, object> htmlAttributes) {\r
+            return ValidationSummary(htmlHelper, false /* excludePropertyErrors */, message, htmlAttributes);\r
+        }\r
+\r
+        public static MvcHtmlString ValidationSummary(this HtmlHelper htmlHelper, bool excludePropertyErrors, string message, IDictionary<string, object> htmlAttributes) {\r
+            if (htmlHelper == null) {\r
+                throw new ArgumentNullException("htmlHelper");\r
+            }\r
+\r
+            FormContext formContext = htmlHelper.ViewContext.GetFormContextForClientValidation();\r
+            if (formContext == null && htmlHelper.ViewData.ModelState.IsValid) {\r
+                return null;\r
+            }\r
+\r
+            string messageSpan;\r
+            if (!String.IsNullOrEmpty(message)) {\r
+                TagBuilder spanTag = new TagBuilder("span");\r
+                spanTag.SetInnerText(message);\r
+                messageSpan = spanTag.ToString(TagRenderMode.Normal) + Environment.NewLine;\r
+            }\r
+            else {\r
+                messageSpan = null;\r
+            }\r
+\r
+            StringBuilder htmlSummary = new StringBuilder();\r
+            TagBuilder unorderedList = new TagBuilder("ul");\r
+\r
+            IEnumerable<ModelState> modelStates = null;\r
+            if (excludePropertyErrors) {\r
+                ModelState ms;\r
+                htmlHelper.ViewData.ModelState.TryGetValue(htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix, out ms);\r
+                if (ms != null) {\r
+                    modelStates = new ModelState[] { ms };\r
+                }\r
+            }\r
+            else {\r
+                modelStates = htmlHelper.ViewData.ModelState.Values;\r
+            }\r
+\r
+            if (modelStates != null) {\r
+                foreach (ModelState modelState in modelStates) {\r
+                    foreach (ModelError modelError in modelState.Errors) {\r
+                        string errorText = GetUserErrorMessageOrDefault(htmlHelper.ViewContext.HttpContext, modelError, null /* modelState */);\r
+                        if (!String.IsNullOrEmpty(errorText)) {\r
+                            TagBuilder listItem = new TagBuilder("li");\r
+                            listItem.SetInnerText(errorText);\r
+                            htmlSummary.AppendLine(listItem.ToString(TagRenderMode.Normal));\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+\r
+            if (htmlSummary.Length == 0) {\r
+                htmlSummary.AppendLine(_hiddenListItem);\r
+            }\r
+\r
+            unorderedList.InnerHtml = htmlSummary.ToString();\r
+\r
+            TagBuilder divBuilder = new TagBuilder("div");\r
+            divBuilder.MergeAttributes(htmlAttributes);\r
+            divBuilder.AddCssClass((htmlHelper.ViewData.ModelState.IsValid) ? HtmlHelper.ValidationSummaryValidCssClassName : HtmlHelper.ValidationSummaryCssClassName);\r
+            divBuilder.InnerHtml = messageSpan + unorderedList.ToString(TagRenderMode.Normal);\r
+\r
+            if (formContext != null) {\r
+                // client val summaries need an ID\r
+                divBuilder.GenerateId("validationSummary");\r
+                formContext.ValidationSummaryId = divBuilder.Attributes["id"];\r
+                formContext.ReplaceValidationSummary = !excludePropertyErrors;\r
+            }\r
+            return divBuilder.ToMvcHtmlString(TagRenderMode.Normal);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HtmlHelper.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HtmlHelper.cs
new file mode 100644 (file)
index 0000000..ae08fcf
--- /dev/null
@@ -0,0 +1,361 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.IO;\r
+    using System.Text;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    [SuppressMessage("Microsoft.Security", "CA2112:SecuredTypesShouldNotExposeFields",\r
+        Justification = "Public fields for CSS names do not contain secure information.")]\r
+    public class HtmlHelper {\r
+\r
+        private delegate string HtmlEncoder(object value);\r
+        private static readonly HtmlEncoder _htmlEncoder = GetHtmlEncoder();\r
+\r
+        private static string _idAttributeDotReplacement;\r
+\r
+        public static readonly string ValidationInputCssClassName = "input-validation-error";\r
+        public static readonly string ValidationInputValidCssClassName = "input-validation-valid";\r
+        public static readonly string ValidationMessageCssClassName = "field-validation-error";\r
+        public static readonly string ValidationMessageValidCssClassName = "field-validation-valid";\r
+        public static readonly string ValidationSummaryCssClassName = "validation-summary-errors";\r
+        public static readonly string ValidationSummaryValidCssClassName = "validation-summary-valid";\r
+\r
+        private AntiForgeryDataSerializer _serializer;\r
+\r
+        public HtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer)\r
+            : this(viewContext, viewDataContainer, RouteTable.Routes) {\r
+        }\r
+\r
+        public HtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) {\r
+            if (viewContext == null) {\r
+                throw new ArgumentNullException("viewContext");\r
+            }\r
+            if (viewDataContainer == null) {\r
+                throw new ArgumentNullException("viewDataContainer");\r
+            }\r
+            if (routeCollection == null) {\r
+                throw new ArgumentNullException("routeCollection");\r
+            }\r
+            ViewContext = viewContext;\r
+            ViewDataContainer = viewDataContainer;\r
+            RouteCollection = routeCollection;\r
+        }\r
+\r
+        public static string IdAttributeDotReplacement {\r
+            get {\r
+                if (String.IsNullOrEmpty(_idAttributeDotReplacement)) {\r
+                    _idAttributeDotReplacement = "_";\r
+                }\r
+                return _idAttributeDotReplacement;\r
+            }\r
+            set {\r
+                _idAttributeDotReplacement = value;\r
+            }\r
+        }\r
+\r
+        public RouteCollection RouteCollection {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        internal AntiForgeryDataSerializer Serializer {\r
+            get {\r
+                if (_serializer == null) {\r
+                    _serializer = new AntiForgeryDataSerializer();\r
+                }\r
+                return _serializer;\r
+            }\r
+            set {\r
+                _serializer = value;\r
+            }\r
+        }\r
+\r
+        public ViewContext ViewContext {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public ViewDataDictionary ViewData {\r
+            get {\r
+                return ViewDataContainer.ViewData;\r
+            }\r
+        }\r
+\r
+        public IViewDataContainer ViewDataContainer {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public MvcHtmlString AntiForgeryToken() {\r
+            return AntiForgeryToken(null /* salt */);\r
+        }\r
+\r
+        public MvcHtmlString AntiForgeryToken(string salt) {\r
+            return AntiForgeryToken(salt, null /* domain */, null /* path */);\r
+        }\r
+\r
+        public MvcHtmlString AntiForgeryToken(string salt, string domain, string path) {\r
+            string formValue = GetAntiForgeryTokenAndSetCookie(salt, domain, path);\r
+            string fieldName = AntiForgeryData.GetAntiForgeryTokenName(null);\r
+\r
+            TagBuilder builder = new TagBuilder("input");\r
+            builder.Attributes["type"] = "hidden";\r
+            builder.Attributes["name"] = fieldName;\r
+            builder.Attributes["value"] = formValue;\r
+            return builder.ToMvcHtmlString(TagRenderMode.SelfClosing);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "For consistency, all helpers are instance methods.")]\r
+        public string AttributeEncode(string value) {\r
+            return (!String.IsNullOrEmpty(value)) ? HttpUtility.HtmlAttributeEncode(value) : String.Empty;\r
+        }\r
+\r
+        public string AttributeEncode(object value) {\r
+            return AttributeEncode(Convert.ToString(value, CultureInfo.InvariantCulture));\r
+        }\r
+\r
+        public void EnableClientValidation() {\r
+            ViewContext.ClientValidationEnabled = true;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "For consistency, all helpers are instance methods.")]\r
+        public string Encode(string value) {\r
+            return (!String.IsNullOrEmpty(value)) ? HttpUtility.HtmlEncode(value) : String.Empty;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "For consistency, all helpers are instance methods.")]\r
+        public string Encode(object value) {\r
+            return _htmlEncoder(value);\r
+        }\r
+\r
+        // method used if HttpUtility.HtmlEncode(object) method does not exist\r
+        private static string EncodeLegacy(object value) {\r
+            string stringVal = Convert.ToString(value, CultureInfo.CurrentCulture);\r
+            return (!String.IsNullOrEmpty(stringVal)) ? HttpUtility.HtmlEncode(stringVal) : String.Empty;\r
+        }\r
+\r
+        internal string EvalString(string key) {\r
+            return Convert.ToString(ViewData.Eval(key), CultureInfo.CurrentCulture);\r
+        }\r
+\r
+        internal bool EvalBoolean(string key) {\r
+            return Convert.ToBoolean(ViewData.Eval(key), CultureInfo.InvariantCulture);\r
+        }\r
+\r
+        internal static IView FindPartialView(ViewContext viewContext, string partialViewName, ViewEngineCollection viewEngineCollection) {\r
+            ViewEngineResult result = viewEngineCollection.FindPartialView(viewContext, partialViewName);\r
+            if (result.View != null) {\r
+                return result.View;\r
+            }\r
+\r
+            StringBuilder locationsText = new StringBuilder();\r
+            foreach (string location in result.SearchedLocations) {\r
+                locationsText.AppendLine();\r
+                locationsText.Append(location);\r
+            }\r
+\r
+            throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture,\r
+                MvcResources.Common_PartialViewNotFound, partialViewName, locationsText));\r
+        }\r
+\r
+        public static string GenerateIdFromName(string name) {\r
+            return GenerateIdFromName(name, IdAttributeDotReplacement);\r
+        }\r
+\r
+        public static string GenerateIdFromName(string name, string idAttributeDotReplacement) {\r
+            if (name == null) {\r
+                throw new ArgumentNullException("name");\r
+            }\r
+            if (idAttributeDotReplacement == null) {\r
+                throw new ArgumentNullException("idAttributeDotReplacement");\r
+            }\r
+\r
+            return name.Replace(".", idAttributeDotReplacement);\r
+        }\r
+\r
+        public static string GenerateLink(RequestContext requestContext, RouteCollection routeCollection, string linkText, string routeName, string actionName, string controllerName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            return GenerateLink(requestContext, routeCollection, linkText, routeName, actionName, controllerName, null/* protocol */, null/* hostName */, null/* fragment */, routeValues, htmlAttributes);\r
+        }\r
+\r
+        public static string GenerateLink(RequestContext requestContext, RouteCollection routeCollection, string linkText, string routeName, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            return GenerateLinkInternal(requestContext, routeCollection, linkText, routeName, actionName, controllerName, protocol, hostName, fragment, routeValues, htmlAttributes, true /* includeImplicitMvcValues */);\r
+        }\r
+\r
+        private static string GenerateLinkInternal(RequestContext requestContext, RouteCollection routeCollection, string linkText, string routeName, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes, bool includeImplicitMvcValues) {\r
+            string url = UrlHelper.GenerateUrl(routeName, actionName, controllerName, protocol, hostName, fragment, routeValues, routeCollection, requestContext, includeImplicitMvcValues);\r
+            TagBuilder tagBuilder = new TagBuilder("a") {\r
+                InnerHtml = (!String.IsNullOrEmpty(linkText)) ? HttpUtility.HtmlEncode(linkText) : String.Empty\r
+            };\r
+            tagBuilder.MergeAttributes(htmlAttributes);\r
+            tagBuilder.MergeAttribute("href", url);\r
+            return tagBuilder.ToString(TagRenderMode.Normal);\r
+        }\r
+\r
+        public static string GenerateRouteLink(RequestContext requestContext, RouteCollection routeCollection, string linkText, string routeName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            return GenerateRouteLink(requestContext, routeCollection, linkText, routeName, null/* protocol */, null/* hostName */, null/* fragment */, routeValues, htmlAttributes);\r
+        }\r
+\r
+        public static string GenerateRouteLink(RequestContext requestContext, RouteCollection routeCollection, string linkText, string routeName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {\r
+            return GenerateLinkInternal(requestContext, routeCollection, linkText, routeName, null /* actionName */, null /* controllerName */, protocol, hostName, fragment, routeValues, htmlAttributes, false /* includeImplicitMvcValues */);\r
+        }\r
+\r
+        private string GetAntiForgeryTokenAndSetCookie(string salt, string domain, string path) {\r
+            string cookieName = AntiForgeryData.GetAntiForgeryTokenName(ViewContext.HttpContext.Request.ApplicationPath);\r
+\r
+            AntiForgeryData cookieToken;\r
+            HttpCookie cookie = ViewContext.HttpContext.Request.Cookies[cookieName];\r
+            if (cookie != null) {\r
+                cookieToken = Serializer.Deserialize(cookie.Value);\r
+            }\r
+            else {\r
+                cookieToken = AntiForgeryData.NewToken();\r
+                string cookieValue = Serializer.Serialize(cookieToken);\r
+\r
+                HttpCookie newCookie = new HttpCookie(cookieName, cookieValue) { HttpOnly = true, Domain = domain };\r
+                if (!String.IsNullOrEmpty(path)) {\r
+                    newCookie.Path = path;\r
+                }\r
+                ViewContext.HttpContext.Response.Cookies.Set(newCookie);\r
+            }\r
+\r
+            AntiForgeryData formToken = new AntiForgeryData(cookieToken) {\r
+                Salt = salt,\r
+                Username = AntiForgeryData.GetUsername(ViewContext.HttpContext.User)\r
+            };\r
+            string formValue = Serializer.Serialize(formToken);\r
+            return formValue;\r
+        }\r
+\r
+        public static string GetFormMethodString(FormMethod method) {\r
+            switch (method) {\r
+                case FormMethod.Get:\r
+                    return "get";\r
+                case FormMethod.Post:\r
+                    return "post";\r
+                default:\r
+                    return "post";\r
+            }\r
+        }\r
+\r
+        // selects the v3.5 (legacy) or v4 HTML encoder\r
+        private static HtmlEncoder GetHtmlEncoder() {\r
+            return TypeHelpers.CreateDelegate<HtmlEncoder>(TypeHelpers.SystemWebAssembly, "System.Web.HttpUtility", "HtmlEncode", null)\r
+                ?? EncodeLegacy;\r
+        }\r
+\r
+        public static string GetInputTypeString(InputType inputType) {\r
+            switch (inputType) {\r
+                case InputType.CheckBox:\r
+                    return "checkbox";\r
+                case InputType.Hidden:\r
+                    return "hidden";\r
+                case InputType.Password:\r
+                    return "password";\r
+                case InputType.Radio:\r
+                    return "radio";\r
+                case InputType.Text:\r
+                    return "text";\r
+                default:\r
+                    return "text";\r
+            }\r
+        }\r
+\r
+        internal object GetModelStateValue(string key, Type destinationType) {\r
+            ModelState modelState;\r
+            if (ViewData.ModelState.TryGetValue(key, out modelState)) {\r
+                if (modelState.Value != null) {\r
+                    return modelState.Value.ConvertTo(destinationType, null /* culture */);\r
+                }\r
+            }\r
+            return null;\r
+        }\r
+\r
+        public MvcHtmlString HttpMethodOverride(HttpVerbs httpVerb) {\r
+            string httpMethod;\r
+            switch (httpVerb) {\r
+                case HttpVerbs.Delete:\r
+                    httpMethod = "DELETE";\r
+                    break;\r
+                case HttpVerbs.Head:\r
+                    httpMethod = "HEAD";\r
+                    break;\r
+                case HttpVerbs.Put:\r
+                    httpMethod = "PUT";\r
+                    break;\r
+                default:\r
+                    throw new ArgumentException(MvcResources.HtmlHelper_InvalidHttpVerb, "httpVerb");\r
+            }\r
+\r
+            return HttpMethodOverride(httpMethod);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "For consistency, all helpers are instance methods.")]\r
+        public MvcHtmlString HttpMethodOverride(string httpMethod) {\r
+            if (String.IsNullOrEmpty(httpMethod)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "httpMethod");\r
+            }\r
+            if (String.Equals(httpMethod, "GET", StringComparison.OrdinalIgnoreCase) ||\r
+                String.Equals(httpMethod, "POST", StringComparison.OrdinalIgnoreCase)) {\r
+                throw new ArgumentException(MvcResources.HtmlHelper_InvalidHttpMethod, "httpMethod");\r
+            }\r
+\r
+            TagBuilder tagBuilder = new TagBuilder("input");\r
+            tagBuilder.Attributes["type"] = "hidden";\r
+            tagBuilder.Attributes["name"] = HttpRequestExtensions.XHttpMethodOverrideKey;\r
+            tagBuilder.Attributes["value"] = httpMethod;\r
+\r
+            return tagBuilder.ToMvcHtmlString(TagRenderMode.SelfClosing);\r
+        }\r
+\r
+        internal virtual void RenderPartialInternal(string partialViewName, ViewDataDictionary viewData, object model, TextWriter writer, ViewEngineCollection viewEngineCollection) {\r
+            if (String.IsNullOrEmpty(partialViewName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "partialViewName");\r
+            }\r
+\r
+            ViewDataDictionary newViewData = null;\r
+\r
+            if (model == null) {\r
+                if (viewData == null) {\r
+                    newViewData = new ViewDataDictionary(ViewData);\r
+                }\r
+                else {\r
+                    newViewData = new ViewDataDictionary(viewData);\r
+                }\r
+            }\r
+            else {\r
+                if (viewData == null) {\r
+                    newViewData = new ViewDataDictionary(model);\r
+                }\r
+                else {\r
+                    newViewData = new ViewDataDictionary(viewData) { Model = model };\r
+                }\r
+            }\r
+\r
+            ViewContext newViewContext = new ViewContext(ViewContext, ViewContext.View, newViewData, ViewContext.TempData, writer);\r
+            IView view = FindPartialView(newViewContext, partialViewName, viewEngineCollection);\r
+            view.Render(newViewContext, writer);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HtmlHelper`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HtmlHelper`1.cs
new file mode 100644 (file)
index 0000000..243f7f6
--- /dev/null
@@ -0,0 +1,35 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Web.Routing;\r
+\r
+    public class HtmlHelper<TModel> : HtmlHelper {\r
+        private ViewDataDictionary<TModel> _viewData;\r
+\r
+        public HtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer)\r
+            : this(viewContext, viewDataContainer, RouteTable.Routes) {\r
+        }\r
+\r
+        public HtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection)\r
+            : base(viewContext, viewDataContainer, routeCollection) {\r
+\r
+            _viewData = new ViewDataDictionary<TModel>(viewDataContainer.ViewData);\r
+        }\r
+\r
+        public new ViewDataDictionary<TModel> ViewData {\r
+            get {\r
+                return _viewData;\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpAntiForgeryException.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpAntiForgeryException.cs
new file mode 100644 (file)
index 0000000..8a8cf34
--- /dev/null
@@ -0,0 +1,37 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Runtime.Serialization;\r
+    using System.Web;\r
+\r
+    [Serializable]\r
+    public sealed class HttpAntiForgeryException : HttpException {\r
+\r
+        public HttpAntiForgeryException() {\r
+        }\r
+\r
+        private HttpAntiForgeryException(SerializationInfo info, StreamingContext context)\r
+            : base(info, context) {\r
+        }\r
+\r
+        public HttpAntiForgeryException(string message)\r
+            : base(message) {\r
+        }\r
+\r
+        public HttpAntiForgeryException(string message, Exception innerException)\r
+            : base(message, innerException) {\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpDeleteAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpDeleteAttribute.cs
new file mode 100644 (file)
index 0000000..1314f05
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+    using System.Web;\r
+\r
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public sealed class HttpDeleteAttribute : ActionMethodSelectorAttribute {\r
+\r
+        private static readonly AcceptVerbsAttribute _innerAttribute = new AcceptVerbsAttribute(HttpVerbs.Delete);\r
+\r
+        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) {\r
+            return _innerAttribute.IsValidForRequest(controllerContext, methodInfo);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpFileCollectionValueProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpFileCollectionValueProvider.cs
new file mode 100644 (file)
index 0000000..d67ec5e
--- /dev/null
@@ -0,0 +1,52 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+\r
+    public sealed class HttpFileCollectionValueProvider : DictionaryValueProvider<HttpPostedFileBase[]> {\r
+\r
+        private static readonly Dictionary<string, HttpPostedFileBase[]> _emptyDictionary = new Dictionary<string, HttpPostedFileBase[]>();\r
+\r
+        public HttpFileCollectionValueProvider(ControllerContext controllerContext)\r
+            : base(GetHttpPostedFileDictionary(controllerContext), CultureInfo.InvariantCulture) {\r
+        }\r
+\r
+        private static Dictionary<string, HttpPostedFileBase[]> GetHttpPostedFileDictionary(ControllerContext controllerContext) {\r
+            HttpFileCollectionBase files = controllerContext.HttpContext.Request.Files;\r
+\r
+            // fast-track common case of no files\r
+            if (files.Count == 0) {\r
+                return _emptyDictionary;\r
+            }\r
+\r
+            // build up the 1:many file mapping\r
+            List<KeyValuePair<string, HttpPostedFileBase>> mapping = new List<KeyValuePair<string, HttpPostedFileBase>>();\r
+            string[] allKeys = files.AllKeys;\r
+            for (int i = 0; i < files.Count; i++) {\r
+                string key = allKeys[i];\r
+                if (key != null) {\r
+                    HttpPostedFileBase file = HttpPostedFileBaseModelBinder.ChooseFileOrNull(files[i]);\r
+                    mapping.Add(new KeyValuePair<string, HttpPostedFileBase>(key, file));\r
+                }\r
+            }\r
+\r
+            // turn the mapping into a 1:many dictionary\r
+            var grouped = mapping.GroupBy(el => el.Key, el => el.Value, StringComparer.OrdinalIgnoreCase);\r
+            return grouped.ToDictionary(g => g.Key, g => g.ToArray(), StringComparer.OrdinalIgnoreCase);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpFileCollectionValueProviderFactory.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpFileCollectionValueProviderFactory.cs
new file mode 100644 (file)
index 0000000..6eec3ce
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public sealed class HttpFileCollectionValueProviderFactory : ValueProviderFactory {\r
+\r
+        public override IValueProvider GetValueProvider(ControllerContext controllerContext) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+\r
+            return new HttpFileCollectionValueProvider(controllerContext);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpGetAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpGetAttribute.cs
new file mode 100644 (file)
index 0000000..d2f2e9e
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+    using System.Web;\r
+\r
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public sealed class HttpGetAttribute : ActionMethodSelectorAttribute {\r
+\r
+        private static readonly AcceptVerbsAttribute _innerAttribute = new AcceptVerbsAttribute(HttpVerbs.Get);\r
+\r
+        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) {\r
+            return _innerAttribute.IsValidForRequest(controllerContext, methodInfo);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpHandlerUtil.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpHandlerUtil.cs
new file mode 100644 (file)
index 0000000..a9b1f8d
--- /dev/null
@@ -0,0 +1,87 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.UI;\r
+\r
+    internal static class HttpHandlerUtil {\r
+\r
+        // Since Server.Execute() doesn't propagate HttpExceptions where the status code is\r
+        // anything other than 500, we need to wrap these exceptions ourselves.\r
+        public static IHttpHandler WrapForServerExecute(IHttpHandler httpHandler) {\r
+            IHttpAsyncHandler asyncHandler = httpHandler as IHttpAsyncHandler;\r
+            return (asyncHandler != null) ? new ServerExecuteHttpHandlerAsyncWrapper(asyncHandler) : new ServerExecuteHttpHandlerWrapper(httpHandler);\r
+        }\r
+\r
+        // Server.Execute() requires that the provided IHttpHandler subclass Page.\r
+        internal class ServerExecuteHttpHandlerWrapper : Page {\r
+            private readonly IHttpHandler _httpHandler;\r
+\r
+            public ServerExecuteHttpHandlerWrapper(IHttpHandler httpHandler) {\r
+                _httpHandler = httpHandler;\r
+            }\r
+\r
+            internal IHttpHandler InnerHandler {\r
+                get {\r
+                    return _httpHandler;\r
+                }\r
+            }\r
+\r
+            public override void ProcessRequest(HttpContext context) {\r
+                Wrap(() => _httpHandler.ProcessRequest(context));\r
+            }\r
+\r
+            protected static void Wrap(Action action) {\r
+                Wrap(delegate {\r
+                    action();\r
+                    return (object)null;\r
+                });\r
+            }\r
+\r
+            protected static TResult Wrap<TResult>(Func<TResult> func) {\r
+                try {\r
+                    return func();\r
+                }\r
+                catch (HttpException he) {\r
+                    if (he.GetHttpCode() == 500) {\r
+                        throw; // doesn't need to be wrapped\r
+                    }\r
+                    else {\r
+                        HttpException newHe = new HttpException(500, MvcResources.ViewPageHttpHandlerWrapper_ExceptionOccurred, he);\r
+                        throw newHe;\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        private sealed class ServerExecuteHttpHandlerAsyncWrapper : ServerExecuteHttpHandlerWrapper, IHttpAsyncHandler {\r
+            private readonly IHttpAsyncHandler _httpHandler;\r
+\r
+            public ServerExecuteHttpHandlerAsyncWrapper(IHttpAsyncHandler httpHandler)\r
+                : base(httpHandler) {\r
+                _httpHandler = httpHandler;\r
+            }\r
+\r
+            public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) {\r
+                return Wrap(() => _httpHandler.BeginProcessRequest(context, cb, extraData));\r
+            }\r
+\r
+            public void EndProcessRequest(IAsyncResult result) {\r
+                Wrap(() => _httpHandler.EndProcessRequest(result));\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpPostAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpPostAttribute.cs
new file mode 100644 (file)
index 0000000..8a07d95
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+    using System.Web;\r
+\r
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public sealed class HttpPostAttribute : ActionMethodSelectorAttribute {\r
+\r
+        private static readonly AcceptVerbsAttribute _innerAttribute = new AcceptVerbsAttribute(HttpVerbs.Post);\r
+\r
+        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) {\r
+            return _innerAttribute.IsValidForRequest(controllerContext, methodInfo);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpPostedFileBaseModelBinder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpPostedFileBaseModelBinder.cs
new file mode 100644 (file)
index 0000000..4adb369
--- /dev/null
@@ -0,0 +1,48 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web;\r
+\r
+    public class HttpPostedFileBaseModelBinder : IModelBinder {\r
+\r
+        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (bindingContext == null) {\r
+                throw new ArgumentNullException("bindingContext");\r
+            }\r
+\r
+            HttpPostedFileBase theFile = controllerContext.HttpContext.Request.Files[bindingContext.ModelName];\r
+            return ChooseFileOrNull(theFile);\r
+        }\r
+\r
+        // helper that returns the original file if there was content uploaded, null if empty\r
+        internal static HttpPostedFileBase ChooseFileOrNull(HttpPostedFileBase rawFile) {\r
+            // case 1: there was no <input type="file" ... /> element in the post\r
+            if (rawFile == null) {\r
+                return null;\r
+            }\r
+\r
+            // case 2: there was an <input type="file" ... /> element in the post, but it was left blank\r
+            if (rawFile.ContentLength == 0 && String.IsNullOrEmpty(rawFile.FileName)) {\r
+                return null;\r
+            }\r
+\r
+            // case 3: the file was posted\r
+            return rawFile;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpPutAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpPutAttribute.cs
new file mode 100644 (file)
index 0000000..d438f3d
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+    using System.Web;\r
+\r
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public sealed class HttpPutAttribute : ActionMethodSelectorAttribute {\r
+\r
+        private static readonly AcceptVerbsAttribute _innerAttribute = new AcceptVerbsAttribute(HttpVerbs.Put);\r
+\r
+        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) {\r
+            return _innerAttribute.IsValidForRequest(controllerContext, methodInfo);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpRequestExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpRequestExtensions.cs
new file mode 100644 (file)
index 0000000..07a76e1
--- /dev/null
@@ -0,0 +1,56 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public static class HttpRequestExtensions {\r
+        internal const string XHttpMethodOverrideKey = "X-HTTP-Method-Override";\r
+\r
+        public static string GetHttpMethodOverride(this HttpRequestBase request) {\r
+            if (request == null) {\r
+                throw new ArgumentNullException("request");\r
+            }\r
+\r
+            string incomingVerb = request.HttpMethod;\r
+\r
+            if (!String.Equals(incomingVerb, "POST", StringComparison.OrdinalIgnoreCase)) {\r
+                return incomingVerb;\r
+            }\r
+\r
+            string verbOverride = null;\r
+            string headerOverrideValue = request.Headers[XHttpMethodOverrideKey];\r
+            if (!String.IsNullOrEmpty(headerOverrideValue)) {\r
+                verbOverride = headerOverrideValue;\r
+            }\r
+            else {\r
+                string formOverrideValue = request.Form[XHttpMethodOverrideKey];\r
+                if (!String.IsNullOrEmpty(formOverrideValue)) {\r
+                    verbOverride = formOverrideValue;\r
+                }\r
+                else {\r
+                    string queryStringOverrideValue = request.QueryString[XHttpMethodOverrideKey];\r
+                    if (!String.IsNullOrEmpty(queryStringOverrideValue)) {\r
+                        verbOverride = queryStringOverrideValue;\r
+                    }\r
+                }\r
+            }\r
+            if (verbOverride != null) {\r
+                if (!String.Equals(verbOverride, "GET", StringComparison.OrdinalIgnoreCase) &&\r
+                    !String.Equals(verbOverride, "POST", StringComparison.OrdinalIgnoreCase)) {\r
+                    incomingVerb = verbOverride;\r
+                }\r
+            }\r
+            return incomingVerb;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpUnauthorizedResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpUnauthorizedResult.cs
new file mode 100644 (file)
index 0000000..cae9d1d
--- /dev/null
@@ -0,0 +1,30 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public class HttpUnauthorizedResult : ActionResult {\r
+\r
+        public override void ExecuteResult(ControllerContext context) {\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+\r
+            // HTTP 401 is the status code for unauthorized access. Other code might\r
+            // intercept this and perform some special logic. For example, the\r
+            // FormsAuthenticationModule looks for 401 responses and instead redirects\r
+            // the user to the login page.\r
+            context.HttpContext.Response.StatusCode = 401;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpVerbs.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/HttpVerbs.cs
new file mode 100644 (file)
index 0000000..b9506c1
--- /dev/null
@@ -0,0 +1,24 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    [Flags]\r
+    public enum HttpVerbs {\r
+        Get = 1 << 0,\r
+        Post = 1 << 1,\r
+        Put = 1 << 2,\r
+        Delete = 1 << 3,\r
+        Head = 1 << 4\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IActionFilter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IActionFilter.cs
new file mode 100644 (file)
index 0000000..2cc7f3e
--- /dev/null
@@ -0,0 +1,19 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public interface IActionFilter {\r
+        void OnActionExecuting(ActionExecutingContext filterContext);\r
+        void OnActionExecuted(ActionExecutedContext filterContext);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IActionInvoker.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IActionInvoker.cs
new file mode 100644 (file)
index 0000000..9ab878d
--- /dev/null
@@ -0,0 +1,18 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public interface IActionInvoker {\r
+        bool InvokeAction(ControllerContext controllerContext, string actionName);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IAuthorizationFilter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IAuthorizationFilter.cs
new file mode 100644 (file)
index 0000000..93ab7b3
--- /dev/null
@@ -0,0 +1,18 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public interface IAuthorizationFilter {\r
+        void OnAuthorization(AuthorizationContext filterContext);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IBuildManager.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IBuildManager.cs
new file mode 100644 (file)
index 0000000..34eea42
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections;\r
+    using System.IO;\r
+\r
+    // REVIEW: Should we make this public?\r
+    internal interface IBuildManager {\r
+        object CreateInstanceFromVirtualPath(string virtualPath, Type requiredBaseType);\r
+        ICollection GetReferencedAssemblies();\r
+\r
+        // ASP.NET 4 methods\r
+        Stream ReadCachedFile(string fileName);\r
+        Stream CreateCachedFile(string fileName);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IController.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IController.cs
new file mode 100644 (file)
index 0000000..d5bb4ca
--- /dev/null
@@ -0,0 +1,19 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Web.Routing;\r
+\r
+    public interface IController {\r
+        void Execute(RequestContext requestContext);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IControllerFactory.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IControllerFactory.cs
new file mode 100644 (file)
index 0000000..316774f
--- /dev/null
@@ -0,0 +1,20 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Web.Routing;\r
+\r
+    public interface IControllerFactory {\r
+        IController CreateController(RequestContext requestContext, string controllerName);\r
+        void ReleaseController(IController controller);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IExceptionFilter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IExceptionFilter.cs
new file mode 100644 (file)
index 0000000..ede6fd3
--- /dev/null
@@ -0,0 +1,18 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public interface IExceptionFilter {\r
+        void OnException(ExceptionContext filterContext);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IModelBinder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IModelBinder.cs
new file mode 100644 (file)
index 0000000..d6ce039
--- /dev/null
@@ -0,0 +1,18 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public interface IModelBinder {\r
+        object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IResultFilter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IResultFilter.cs
new file mode 100644 (file)
index 0000000..c00395f
--- /dev/null
@@ -0,0 +1,19 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public interface IResultFilter {\r
+        void OnResultExecuting(ResultExecutingContext filterContext);\r
+        void OnResultExecuted(ResultExecutedContext filterContext);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IRouteWithArea.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IRouteWithArea.cs
new file mode 100644 (file)
index 0000000..23eab10
--- /dev/null
@@ -0,0 +1,21 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public interface IRouteWithArea {\r
+\r
+        string Area { get; }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ITempDataProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ITempDataProvider.cs
new file mode 100644 (file)
index 0000000..3361130
--- /dev/null
@@ -0,0 +1,20 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+\r
+    public interface ITempDataProvider {\r
+        IDictionary<string, object> LoadTempData(ControllerContext controllerContext);\r
+        void SaveTempData(ControllerContext controllerContext, IDictionary<string, object> values);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IValueProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IValueProvider.cs
new file mode 100644 (file)
index 0000000..95c7e16
--- /dev/null
@@ -0,0 +1,20 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public interface IValueProvider {\r
+        bool ContainsPrefix(string prefix);\r
+        ValueProviderResult GetValue(string key);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IView.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IView.cs
new file mode 100644 (file)
index 0000000..97d044c
--- /dev/null
@@ -0,0 +1,19 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.IO;\r
+\r
+    public interface IView {\r
+        void Render(ViewContext viewContext, TextWriter writer);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IViewDataContainer.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IViewDataContainer.cs
new file mode 100644 (file)
index 0000000..c1bfacb
--- /dev/null
@@ -0,0 +1,21 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public interface IViewDataContainer {\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "This is the mechanism by which the ViewPage / ViewUserControl get their ViewDataDictionary objects.")]\r
+        ViewDataDictionary ViewData { get; set; }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IViewEngine.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IViewEngine.cs
new file mode 100644 (file)
index 0000000..9950ce7
--- /dev/null
@@ -0,0 +1,20 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public interface IViewEngine {\r
+        ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache);\r
+        ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache);\r
+        void ReleaseView(ControllerContext controllerContext, IView view);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/IViewLocationCache.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/IViewLocationCache.cs
new file mode 100644 (file)
index 0000000..824950b
--- /dev/null
@@ -0,0 +1,20 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Web;\r
+\r
+    public interface IViewLocationCache {\r
+        string GetViewLocation(HttpContextBase httpContext, string key);\r
+        void InsertViewLocation(HttpContextBase httpContext, string key, string virtualPath);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/InputType.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/InputType.cs
new file mode 100644 (file)
index 0000000..a4a39d8
--- /dev/null
@@ -0,0 +1,21 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public enum InputType {\r
+        CheckBox,\r
+        Hidden,\r
+        Password,\r
+        Radio,\r
+        Text\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/JavaScriptResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/JavaScriptResult.cs
new file mode 100644 (file)
index 0000000..4ee833e
--- /dev/null
@@ -0,0 +1,36 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public class JavaScriptResult : ActionResult {\r
+\r
+        public string Script {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public override void ExecuteResult(ControllerContext context) {\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+\r
+            HttpResponseBase response = context.HttpContext.Response;\r
+            response.ContentType = "application/x-javascript";\r
+\r
+            if (Script != null) {\r
+                response.Write(Script);\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/JsonRequestBehavior.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/JsonRequestBehavior.cs
new file mode 100644 (file)
index 0000000..da9ee8f
--- /dev/null
@@ -0,0 +1,18 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public enum JsonRequestBehavior {\r
+        AllowGet,\r
+        DenyGet,\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/JsonResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/JsonResult.cs
new file mode 100644 (file)
index 0000000..3950b09
--- /dev/null
@@ -0,0 +1,72 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Text;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Script.Serialization;\r
+\r
+    public class JsonResult : ActionResult {\r
+\r
+        public JsonResult() {\r
+            JsonRequestBehavior = JsonRequestBehavior.DenyGet;\r
+        }\r
+\r
+        public Encoding ContentEncoding {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public string ContentType {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public object Data {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public JsonRequestBehavior JsonRequestBehavior {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public override void ExecuteResult(ControllerContext context) {\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+            if (JsonRequestBehavior == JsonRequestBehavior.DenyGet &&\r
+                String.Equals(context.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase)) {\r
+                throw new InvalidOperationException(MvcResources.JsonRequest_GetNotAllowed);\r
+            }\r
+\r
+            HttpResponseBase response = context.HttpContext.Response;\r
+\r
+            if (!String.IsNullOrEmpty(ContentType)) {\r
+                response.ContentType = ContentType;\r
+            }\r
+            else {\r
+                response.ContentType = "application/json";\r
+            }\r
+            if (ContentEncoding != null) {\r
+                response.ContentEncoding = ContentEncoding;\r
+            }\r
+            if (Data != null) {\r
+                JavaScriptSerializer serializer = new JavaScriptSerializer();\r
+                response.Write(serializer.Serialize(Data));\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/LinqBinaryModelBinder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/LinqBinaryModelBinder.cs
new file mode 100644 (file)
index 0000000..4d5edcc
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Data.Linq;\r
+\r
+    public class LinqBinaryModelBinder : ByteArrayModelBinder {\r
+        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {\r
+            byte[] byteValue = (byte[])base.BindModel(controllerContext, bindingContext);\r
+            if (byteValue == null) {\r
+                return null;\r
+            }\r
+\r
+            return new Binary(byteValue);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBinderAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBinderAttribute.cs
new file mode 100644 (file)
index 0000000..b057c73
--- /dev/null
@@ -0,0 +1,54 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Globalization;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [AttributeUsage(ValidTargets, AllowMultiple = false, Inherited = false)]\r
+    public sealed class ModelBinderAttribute : CustomModelBinderAttribute {\r
+\r
+        public ModelBinderAttribute(Type binderType) {\r
+            if (binderType == null) {\r
+                throw new ArgumentNullException("binderType");\r
+            }\r
+            if (!typeof(IModelBinder).IsAssignableFrom(binderType)) {\r
+                string message = String.Format(CultureInfo.CurrentUICulture,\r
+                    MvcResources.ModelBinderAttribute_TypeNotIModelBinder, binderType.FullName);\r
+                throw new ArgumentException(message, "binderType");\r
+            }\r
+\r
+            BinderType = binderType;\r
+        }\r
+\r
+        public Type BinderType {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public override IModelBinder GetBinder() {\r
+            try {\r
+                return (IModelBinder)Activator.CreateInstance(BinderType);\r
+            }\r
+            catch (Exception ex) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.ModelBinderAttribute_ErrorCreatingModelBinder,\r
+                        BinderType.FullName),\r
+                    ex);\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBinderDictionary.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBinderDictionary.cs
new file mode 100644 (file)
index 0000000..964db46
--- /dev/null
@@ -0,0 +1,148 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ModelBinderDictionary : IDictionary<Type, IModelBinder> {\r
+\r
+        private IModelBinder _defaultBinder;\r
+        private readonly Dictionary<Type, IModelBinder> _innerDictionary = new Dictionary<Type, IModelBinder>();\r
+\r
+        public int Count {\r
+            get {\r
+                return _innerDictionary.Count;\r
+            }\r
+        }\r
+\r
+        public IModelBinder DefaultBinder {\r
+            get {\r
+                if (_defaultBinder == null) {\r
+                    _defaultBinder = new DefaultModelBinder();\r
+                }\r
+                return _defaultBinder;\r
+            }\r
+            set {\r
+                _defaultBinder = value;\r
+            }\r
+        }\r
+\r
+        public bool IsReadOnly {\r
+            get {\r
+                return ((IDictionary<Type, IModelBinder>)_innerDictionary).IsReadOnly;\r
+            }\r
+        }\r
+\r
+        public ICollection<Type> Keys {\r
+            get {\r
+                return _innerDictionary.Keys;\r
+            }\r
+        }\r
+\r
+        public IModelBinder this[Type key] {\r
+            get {\r
+                IModelBinder binder;\r
+                _innerDictionary.TryGetValue(key, out binder);\r
+                return binder;\r
+            }\r
+            set {\r
+                _innerDictionary[key] = value;\r
+            }\r
+        }\r
+\r
+        public ICollection<IModelBinder> Values {\r
+            get {\r
+                return _innerDictionary.Values;\r
+            }\r
+        }\r
+\r
+        public void Add(KeyValuePair<Type, IModelBinder> item) {\r
+            ((IDictionary<Type, IModelBinder>)_innerDictionary).Add(item);\r
+        }\r
+\r
+        public void Add(Type key, IModelBinder value) {\r
+            _innerDictionary.Add(key, value);\r
+        }\r
+\r
+        public void Clear() {\r
+            _innerDictionary.Clear();\r
+        }\r
+\r
+        public bool Contains(KeyValuePair<Type, IModelBinder> item) {\r
+            return ((IDictionary<Type, IModelBinder>)_innerDictionary).Contains(item);\r
+        }\r
+\r
+        public bool ContainsKey(Type key) {\r
+            return _innerDictionary.ContainsKey(key);\r
+        }\r
+\r
+        public void CopyTo(KeyValuePair<Type, IModelBinder>[] array, int arrayIndex) {\r
+            ((IDictionary<Type, IModelBinder>)_innerDictionary).CopyTo(array, arrayIndex);\r
+        }\r
+\r
+        public IModelBinder GetBinder(Type modelType) {\r
+            return GetBinder(modelType, true /* fallbackToDefault */);\r
+        }\r
+\r
+        public virtual IModelBinder GetBinder(Type modelType, bool fallbackToDefault) {\r
+            if (modelType == null) {\r
+                throw new ArgumentNullException("modelType");\r
+            }\r
+\r
+            return GetBinder(modelType, (fallbackToDefault) ? DefaultBinder : null);\r
+        }\r
+\r
+        private IModelBinder GetBinder(Type modelType, IModelBinder fallbackBinder) {\r
+            // Try to look up a binder for this type. We use this order of precedence:\r
+            // 1. Binder registered in the global table\r
+            // 2. Binder attribute defined on the type\r
+            // 3. Supplied fallback binder\r
+\r
+            IModelBinder binder;\r
+            if (_innerDictionary.TryGetValue(modelType, out binder)) {\r
+                return binder;\r
+            }\r
+\r
+            binder = ModelBinders.GetBinderFromAttributes(modelType,\r
+                () => String.Format(CultureInfo.CurrentUICulture, MvcResources.ModelBinderDictionary_MultipleAttributes, modelType.FullName));\r
+\r
+            return binder ?? fallbackBinder;\r
+        }\r
+\r
+        public IEnumerator<KeyValuePair<Type, IModelBinder>> GetEnumerator() {\r
+            return _innerDictionary.GetEnumerator();\r
+        }\r
+\r
+        public bool Remove(KeyValuePair<Type, IModelBinder> item) {\r
+            return ((IDictionary<Type, IModelBinder>)_innerDictionary).Remove(item);\r
+        }\r
+\r
+        public bool Remove(Type key) {\r
+            return _innerDictionary.Remove(key);\r
+        }\r
+\r
+        public bool TryGetValue(Type key, out IModelBinder value) {\r
+            return _innerDictionary.TryGetValue(key, out value);\r
+        }\r
+\r
+        #region IEnumerable Members\r
+        IEnumerator IEnumerable.GetEnumerator() {\r
+            return ((IEnumerable)_innerDictionary).GetEnumerator();\r
+        }\r
+        #endregion\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBinders.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBinders.cs
new file mode 100644 (file)
index 0000000..f354b9d
--- /dev/null
@@ -0,0 +1,77 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.ComponentModel;\r
+    using System.Data.Linq;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Web;\r
+\r
+    public static class ModelBinders {\r
+\r
+        private static readonly ModelBinderDictionary _binders = CreateDefaultBinderDictionary();\r
+\r
+        public static ModelBinderDictionary Binders {\r
+            get {\r
+                return _binders;\r
+            }\r
+        }\r
+\r
+        internal static IModelBinder GetBinderFromAttributes(Type type, Func<string> errorMessageAccessor) {\r
+            AttributeCollection allAttrs = TypeDescriptorHelper.Get(type).GetAttributes();\r
+            CustomModelBinderAttribute[] filteredAttrs = allAttrs.OfType<CustomModelBinderAttribute>().ToArray();\r
+            return GetBinderFromAttributesImpl(filteredAttrs, errorMessageAccessor);\r
+        }\r
+\r
+        internal static IModelBinder GetBinderFromAttributes(ICustomAttributeProvider element, Func<string> errorMessageAccessor) {\r
+            CustomModelBinderAttribute[] attrs = (CustomModelBinderAttribute[])element.GetCustomAttributes(typeof(CustomModelBinderAttribute), true /* inherit */);\r
+            return GetBinderFromAttributesImpl(attrs, errorMessageAccessor);\r
+        }\r
+\r
+        private static IModelBinder GetBinderFromAttributesImpl(CustomModelBinderAttribute[] attrs, Func<string> errorMessageAccessor) {\r
+            // this method is used to get a custom binder based on the attributes of the element passed to it.\r
+            // it will return null if a binder cannot be detected based on the attributes alone.\r
+\r
+            if (attrs == null) {\r
+                return null;\r
+            }\r
+\r
+            switch (attrs.Length) {\r
+                case 0:\r
+                    return null;\r
+\r
+                case 1:\r
+                    IModelBinder binder = attrs[0].GetBinder();\r
+                    return binder;\r
+\r
+                default:\r
+                    string errorMessage = errorMessageAccessor();\r
+                    throw new InvalidOperationException(errorMessage);\r
+            }\r
+        }\r
+\r
+        private static ModelBinderDictionary CreateDefaultBinderDictionary() {\r
+            // We can't add a binder to the HttpPostedFileBase type as an attribute, so we'll just\r
+            // prepopulate the dictionary as a convenience to users.\r
+\r
+            ModelBinderDictionary binders = new ModelBinderDictionary() {\r
+                { typeof(HttpPostedFileBase), new HttpPostedFileBaseModelBinder() },\r
+                { typeof(byte[]), new ByteArrayModelBinder() },\r
+                { typeof(Binary), new LinqBinaryModelBinder() }\r
+            };\r
+            return binders;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBindingContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelBindingContext.cs
new file mode 100644 (file)
index 0000000..c3f8fbd
--- /dev/null
@@ -0,0 +1,125 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ModelBindingContext {\r
+\r
+        private static readonly Predicate<string> _defaultPropertyFilter = _ => true;\r
+\r
+        private string _modelName;\r
+        private ModelStateDictionary _modelState;\r
+        private Predicate<string> _propertyFilter;\r
+        private Dictionary<string, ModelMetadata> _propertyMetadata;\r
+\r
+        public ModelBindingContext()\r
+            : this(null) {\r
+        }\r
+\r
+        // copies certain values that won't change between parent and child objects,\r
+        // e.g. ValueProvider, ModelState\r
+        public ModelBindingContext(ModelBindingContext bindingContext) {\r
+            if (bindingContext != null) {\r
+                ModelState = bindingContext.ModelState;\r
+                ValueProvider = bindingContext.ValueProvider;\r
+            }\r
+        }\r
+\r
+        public bool FallbackToEmptyPrefix {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value", Justification = "Cannot remove setter as that's a breaking change")]\r
+        public object Model {\r
+            get {\r
+                return ModelMetadata.Model;\r
+            }\r
+            set {\r
+                throw new InvalidOperationException(MvcResources.ModelMetadata_PropertyNotSettable);\r
+            }\r
+        }\r
+\r
+        public ModelMetadata ModelMetadata {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public string ModelName {\r
+            get {\r
+                if (_modelName == null) {\r
+                    _modelName = String.Empty;\r
+                }\r
+                return _modelName;\r
+            }\r
+            set {\r
+                _modelName = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "The containing type is mutable.")]\r
+        public ModelStateDictionary ModelState {\r
+            get {\r
+                if (_modelState == null) {\r
+                    _modelState = new ModelStateDictionary();\r
+                }\r
+                return _modelState;\r
+            }\r
+            set {\r
+                _modelState = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value", Justification = "Cannot remove setter as that's a breaking change")]\r
+        public Type ModelType {\r
+            get {\r
+                return ModelMetadata.ModelType;\r
+            }\r
+            set {\r
+                throw new InvalidOperationException(MvcResources.ModelMetadata_PropertyNotSettable);\r
+            }\r
+        }\r
+\r
+        public Predicate<string> PropertyFilter {\r
+            get {\r
+                if (_propertyFilter == null) {\r
+                    _propertyFilter = _defaultPropertyFilter;\r
+                }\r
+                return _propertyFilter;\r
+            }\r
+            set {\r
+                _propertyFilter = value;\r
+            }\r
+        }\r
+\r
+        public IDictionary<string, ModelMetadata> PropertyMetadata {\r
+            get {\r
+                if (_propertyMetadata == null) {\r
+                    _propertyMetadata = ModelMetadata.Properties.ToDictionary(m => m.PropertyName, StringComparer.OrdinalIgnoreCase);\r
+                }\r
+\r
+                return _propertyMetadata;\r
+            }\r
+        }\r
+\r
+        public IValueProvider ValueProvider {\r
+            get;\r
+            set;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRangeRule.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRangeRule.cs
new file mode 100644 (file)
index 0000000..0d12858
--- /dev/null
@@ -0,0 +1,22 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public class ModelClientValidationRangeRule : ModelClientValidationRule {\r
+        public ModelClientValidationRangeRule(string errorMessage, object minValue, object maxValue) {\r
+            ErrorMessage = errorMessage;\r
+            ValidationType = "range";\r
+            ValidationParameters["minimum"] = minValue;\r
+            ValidationParameters["maximum"] = maxValue;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRegexRule.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRegexRule.cs
new file mode 100644 (file)
index 0000000..a012da6
--- /dev/null
@@ -0,0 +1,21 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public class ModelClientValidationRegexRule : ModelClientValidationRule {\r
+        public ModelClientValidationRegexRule(string errorMessage, string pattern) {\r
+            ErrorMessage = errorMessage;\r
+            ValidationType = "regularExpression";\r
+            ValidationParameters.Add("pattern", pattern);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRequiredRule.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRequiredRule.cs
new file mode 100644 (file)
index 0000000..6ae6dc9
--- /dev/null
@@ -0,0 +1,20 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public class ModelClientValidationRequiredRule : ModelClientValidationRule {\r
+        public ModelClientValidationRequiredRule(string errorMessage) {\r
+            ErrorMessage = errorMessage;\r
+            ValidationType = "required";\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRule.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationRule.cs
new file mode 100644 (file)
index 0000000..99ed578
--- /dev/null
@@ -0,0 +1,43 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+\r
+    public class ModelClientValidationRule {\r
+\r
+        private readonly Dictionary<string, object> _validationParameters = new Dictionary<string, object>();\r
+        private string _validationType;\r
+\r
+        public string ErrorMessage {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public IDictionary<string, object> ValidationParameters {\r
+            get {\r
+                return _validationParameters;\r
+            }\r
+        }\r
+\r
+        public string ValidationType {\r
+            get {\r
+                return _validationType ?? String.Empty;\r
+            }\r
+            set {\r
+                _validationType = value;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationStringLengthRule.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelClientValidationStringLengthRule.cs
new file mode 100644 (file)
index 0000000..92999ee
--- /dev/null
@@ -0,0 +1,22 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public class ModelClientValidationStringLengthRule : ModelClientValidationRule {\r
+        public ModelClientValidationStringLengthRule(string errorMessage, int minimumLength, int maximumLength) {\r
+            ErrorMessage = errorMessage;\r
+            ValidationType = "stringLength";\r
+            ValidationParameters["minimumLength"] = minimumLength;\r
+            ValidationParameters["maximumLength"] = maximumLength;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelError.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelError.cs
new file mode 100644 (file)
index 0000000..a6fb177
--- /dev/null
@@ -0,0 +1,46 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    [Serializable]\r
+    public class ModelError {\r
+\r
+        public ModelError(Exception exception)\r
+            : this(exception, null /* errorMessage */) {\r
+        }\r
+\r
+        public ModelError(Exception exception, string errorMessage)\r
+            : this(errorMessage) {\r
+            if (exception == null) {\r
+                throw new ArgumentNullException("exception");\r
+            }\r
+\r
+            Exception = exception;\r
+        }\r
+\r
+        public ModelError(string errorMessage) {\r
+            ErrorMessage = errorMessage ?? String.Empty;\r
+        }\r
+\r
+        public Exception Exception {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public string ErrorMessage {\r
+            get;\r
+            private set;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelErrorCollection.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelErrorCollection.cs
new file mode 100644 (file)
index 0000000..61898dd
--- /dev/null
@@ -0,0 +1,28 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.ObjectModel;\r
+\r
+    [Serializable]\r
+    public class ModelErrorCollection : Collection<ModelError> {\r
+\r
+        public void Add(Exception exception) {\r
+            Add(new ModelError(exception));\r
+        }\r
+\r
+        public void Add(string errorMessage) {\r
+            Add(new ModelError(errorMessage));\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelMetadata.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelMetadata.cs
new file mode 100644 (file)
index 0000000..54a56d6
--- /dev/null
@@ -0,0 +1,388 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Linq.Expressions;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.ExpressionUtil;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ModelMetadata {\r
+        // Explicit backing store for the things we want initialized by default, so don't have to call\r
+        // the protected virtual setters of an auto-generated property\r
+        private Dictionary<string, object> _additionalValues = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);\r
+        private readonly Type _containerType;\r
+        private bool _convertEmptyStringToNull = true;\r
+        private bool _isRequired;\r
+        private object _model;\r
+        private Func<object> _modelAccessor;\r
+        private readonly Type _modelType;\r
+        private IEnumerable<ModelMetadata> _properties;\r
+        private readonly string _propertyName;\r
+        private Type _realModelType;\r
+        private bool _showForDisplay = true;\r
+        private bool _showForEdit = true;\r
+        private string _simpleDisplayText;\r
+\r
+        public ModelMetadata(ModelMetadataProvider provider, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName) {\r
+            if (provider == null) {\r
+                throw new ArgumentNullException("provider");\r
+            }\r
+            if (modelType == null) {\r
+                throw new ArgumentNullException("modelType");\r
+            }\r
+\r
+            Provider = provider;\r
+\r
+            _containerType = containerType;\r
+            _isRequired = !TypeHelpers.TypeAllowsNullValue(modelType);\r
+            _modelAccessor = modelAccessor;\r
+            _modelType = modelType;\r
+            _propertyName = propertyName;\r
+        }\r
+\r
+        public virtual Dictionary<string, object> AdditionalValues {\r
+            get {\r
+                return _additionalValues;\r
+            }\r
+        }\r
+\r
+        public Type ContainerType {\r
+            get {\r
+                return _containerType;\r
+            }\r
+        }\r
+\r
+        public virtual bool ConvertEmptyStringToNull {\r
+            get {\r
+                return _convertEmptyStringToNull;\r
+            }\r
+            set {\r
+                _convertEmptyStringToNull = value;\r
+            }\r
+        }\r
+\r
+        public virtual string DataTypeName {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual string Description {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual string DisplayFormatString {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "The method is a delegating helper to choose among multiple property values")]\r
+        public virtual string DisplayName {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual string EditFormatString {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual bool HideSurroundingHtml {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual bool IsComplexType {\r
+            get {\r
+                return !(TypeDescriptor.GetConverter(ModelType).CanConvertFrom(typeof(string)));\r
+            }\r
+        }\r
+\r
+        public bool IsNullableValueType {\r
+            get {\r
+                return TypeHelpers.IsNullableValueType(ModelType);\r
+            }\r
+        }\r
+\r
+        public virtual bool IsReadOnly {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual bool IsRequired {\r
+            get {\r
+                return _isRequired;\r
+            }\r
+            set {\r
+                _isRequired = value;\r
+            }\r
+        }\r
+\r
+        public object Model {\r
+            get {\r
+                if (_modelAccessor != null) {\r
+                    _model = _modelAccessor();\r
+                    _modelAccessor = null;\r
+                }\r
+                return _model;\r
+            }\r
+            set {\r
+                _model = value;\r
+                _modelAccessor = null;\r
+            }\r
+        }\r
+\r
+        public Type ModelType {\r
+            get {\r
+                return _modelType;\r
+            }\r
+        }\r
+\r
+        public virtual string NullDisplayText { get; set; }\r
+\r
+        public virtual IEnumerable<ModelMetadata> Properties {\r
+            get {\r
+                if (_properties == null) {\r
+                    _properties = Provider.GetMetadataForProperties(Model, RealModelType);\r
+                }\r
+                return _properties;\r
+            }\r
+        }\r
+\r
+        public string PropertyName {\r
+            get {\r
+                return _propertyName;\r
+            }\r
+        }\r
+\r
+        protected ModelMetadataProvider Provider {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        internal Type RealModelType {\r
+            get {\r
+                if (_realModelType == null) {\r
+                    _realModelType = ModelType;\r
+\r
+                    // Don't call GetType() if the model is Nullable<T>, because it will\r
+                    // turn Nullable<T> into T for non-null values\r
+                    if (Model != null && !TypeHelpers.IsNullableValueType(ModelType)) {\r
+                        _realModelType = Model.GetType();\r
+                    }\r
+                }\r
+\r
+                return _realModelType;\r
+            }\r
+        }\r
+\r
+        public virtual string ShortDisplayName {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual bool ShowForDisplay {\r
+            get {\r
+                return _showForDisplay;\r
+            }\r
+            set {\r
+                _showForDisplay = value;\r
+            }\r
+        }\r
+\r
+        public virtual bool ShowForEdit {\r
+            get {\r
+                return _showForEdit;\r
+            }\r
+            set {\r
+                _showForEdit = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "This property delegates to the method when the user has not yet set a simple display text value.")]\r
+        public virtual string SimpleDisplayText {\r
+            get {\r
+                if (_simpleDisplayText == null) {\r
+                    _simpleDisplayText = GetSimpleDisplayText();\r
+                }\r
+                return _simpleDisplayText;\r
+            }\r
+            set {\r
+                _simpleDisplayText = value;\r
+            }\r
+        }\r
+\r
+        public virtual string TemplateHint {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual string Watermark {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]\r
+        public static ModelMetadata FromLambdaExpression<TParameter, TValue>(Expression<Func<TParameter, TValue>> expression,\r
+                                                                             ViewDataDictionary<TParameter> viewData) {\r
+            if (expression == null) {\r
+                throw new ArgumentNullException("expression");\r
+            }\r
+            if (viewData == null) {\r
+                throw new ArgumentNullException("viewData");\r
+            }\r
+\r
+            string propertyName = null;\r
+            Type containerType = null;\r
+            bool legalExpression = false;\r
+\r
+            // Need to verify the expression is valid; it needs to at least end in something\r
+            // that we can convert to a meaningful string for model binding purposes\r
+\r
+            switch (expression.Body.NodeType) {\r
+                // ArrayIndex always means a single-dimensional indexer; multi-dimensional indexer is a method call to Get()\r
+                case ExpressionType.ArrayIndex:\r
+                    legalExpression = true;\r
+                    break;\r
+\r
+                // Only legal method call is a single argument indexer/DefaultMember call\r
+                case ExpressionType.Call:\r
+                    legalExpression = ExpressionHelper.IsSingleArgumentIndexer(expression.Body);\r
+                    break;\r
+\r
+                // Property/field access is always legal\r
+                case ExpressionType.MemberAccess:\r
+                    MemberExpression memberExpression = (MemberExpression)expression.Body;\r
+                    propertyName = memberExpression.Member is PropertyInfo ? memberExpression.Member.Name : null;\r
+                    containerType = memberExpression.Member.DeclaringType;\r
+                    legalExpression = true;\r
+                    break;\r
+\r
+                // Parameter expression means "model => model", so we delegate to FromModel\r
+                case ExpressionType.Parameter:\r
+                    return FromModel(viewData);\r
+            }\r
+\r
+            if (!legalExpression) {\r
+                throw new InvalidOperationException(MvcResources.TemplateHelpers_TemplateLimitations);\r
+            }\r
+\r
+            TParameter container = viewData.Model;\r
+            Func<object> modelAccessor = () =>\r
+            {\r
+                try {\r
+                    return CachedExpressionCompiler.Process(expression)(container);\r
+                }\r
+                catch (NullReferenceException) {\r
+                    return null;\r
+                }\r
+            };\r
+\r
+            return GetMetadataFromProvider(modelAccessor, typeof(TValue), propertyName, containerType);\r
+        }\r
+\r
+        private static ModelMetadata FromModel(ViewDataDictionary viewData) {\r
+            return viewData.ModelMetadata ?? GetMetadataFromProvider(null, typeof(string), null, null);\r
+        }\r
+\r
+        public static ModelMetadata FromStringExpression(string expression, ViewDataDictionary viewData) {\r
+            if (expression == null) {\r
+                throw new ArgumentNullException("expression");\r
+            }\r
+            if (viewData == null) {\r
+                throw new ArgumentNullException("viewData");\r
+            }\r
+            if (expression.Length == 0) {    // Empty string really means "model metadata for the current model"\r
+                return FromModel(viewData);\r
+            }\r
+\r
+            ViewDataInfo vdi = viewData.GetViewDataInfo(expression);\r
+            Type containerType = null;\r
+            Type modelType = null;\r
+            Func<object> modelAccessor = null;\r
+            string propertyName = null;\r
+\r
+            if (vdi != null) {\r
+                if (vdi.Container != null) {\r
+                    containerType = vdi.Container.GetType();\r
+                }\r
+\r
+                modelAccessor = () => vdi.Value;\r
+\r
+                if (vdi.PropertyDescriptor != null) {\r
+                    propertyName = vdi.PropertyDescriptor.Name;\r
+                    modelType = vdi.PropertyDescriptor.PropertyType;\r
+                }\r
+                else if (vdi.Value != null) {  // We only need to delay accessing properties (for LINQ to SQL)\r
+                    modelType = vdi.Value.GetType();\r
+                }\r
+            }\r
+            //  Try getting a property from ModelMetadata if we couldn't find an answer in ViewData\r
+            else if (viewData.ModelMetadata != null) {\r
+                ModelMetadata propertyMetadata = viewData.ModelMetadata.Properties.Where(p => p.PropertyName == expression).FirstOrDefault();\r
+                if (propertyMetadata != null) {\r
+                    return propertyMetadata;\r
+                }\r
+            }\r
+\r
+\r
+            return GetMetadataFromProvider(modelAccessor, modelType ?? typeof(string), propertyName, containerType);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "The method is a delegating helper to choose among multiple property values")]\r
+        public string GetDisplayName() {\r
+            return DisplayName ?? PropertyName ?? ModelType.Name;\r
+        }\r
+\r
+        private static ModelMetadata GetMetadataFromProvider(Func<object> modelAccessor, Type modelType, string propertyName, Type containerType) {\r
+            if (containerType != null && !String.IsNullOrEmpty(propertyName)) {\r
+                return ModelMetadataProviders.Current.GetMetadataForProperty(modelAccessor, containerType, propertyName);\r
+            }\r
+            return ModelMetadataProviders.Current.GetMetadataForType(modelAccessor, modelType);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This method is used to resolve the simple display text when it was not explicitly set through other means.")]\r
+        protected virtual string GetSimpleDisplayText() {\r
+            if (Model == null) {\r
+                return NullDisplayText;\r
+            }\r
+\r
+            string toStringResult = Convert.ToString(Model, CultureInfo.CurrentCulture);\r
+            if (!toStringResult.Equals(Model.GetType().FullName, StringComparison.Ordinal)) {\r
+                return toStringResult;\r
+            }\r
+\r
+            ModelMetadata firstProperty = Properties.FirstOrDefault();\r
+            if (firstProperty == null) {\r
+                return String.Empty;\r
+            }\r
+\r
+            if (firstProperty.Model == null) {\r
+                return firstProperty.NullDisplayText;\r
+            }\r
+\r
+            return Convert.ToString(firstProperty.Model, CultureInfo.CurrentCulture);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This method may perform non-trivial work.")]\r
+        public virtual IEnumerable<ModelValidator> GetValidators(ControllerContext context) {\r
+            return ModelValidatorProviders.Providers.GetValidators(this, context);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelMetadataProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelMetadataProvider.cs
new file mode 100644 (file)
index 0000000..6e92367
--- /dev/null
@@ -0,0 +1,23 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+\r
+    public abstract class ModelMetadataProvider {\r
+        public abstract IEnumerable<ModelMetadata> GetMetadataForProperties(object container, Type containerType);\r
+\r
+        public abstract ModelMetadata GetMetadataForProperty(Func<object> modelAccessor, Type containerType, string propertyName);\r
+\r
+        public abstract ModelMetadata GetMetadataForType(Func<object> modelAccessor, Type modelType);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelMetadataProviders.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelMetadataProviders.cs
new file mode 100644 (file)
index 0000000..de948d1
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public static class ModelMetadataProviders {\r
+        private static ModelMetadataProvider _current = new DataAnnotationsModelMetadataProvider();\r
+\r
+        public static ModelMetadataProvider Current {\r
+            get {\r
+                return _current;\r
+            }\r
+            set {\r
+                _current = value ?? new EmptyModelMetadataProvider();\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelState.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelState.cs
new file mode 100644 (file)
index 0000000..38c5860
--- /dev/null
@@ -0,0 +1,31 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    [Serializable]\r
+    public class ModelState {\r
+\r
+        private ModelErrorCollection _errors = new ModelErrorCollection();\r
+\r
+        public ValueProviderResult Value {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public ModelErrorCollection Errors {\r
+            get {\r
+                return _errors;\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelStateDictionary.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelStateDictionary.cs
new file mode 100644 (file)
index 0000000..2510505
--- /dev/null
@@ -0,0 +1,170 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+\r
+    [Serializable]\r
+    public class ModelStateDictionary : IDictionary<string, ModelState> {\r
+\r
+        private readonly Dictionary<string, ModelState> _innerDictionary = new Dictionary<string, ModelState>(StringComparer.OrdinalIgnoreCase);\r
+\r
+        public ModelStateDictionary() {\r
+        }\r
+\r
+        public ModelStateDictionary(ModelStateDictionary dictionary) {\r
+            if (dictionary == null) {\r
+                throw new ArgumentNullException("dictionary");\r
+            }\r
+\r
+            foreach (var entry in dictionary) {\r
+                _innerDictionary.Add(entry.Key, entry.Value);\r
+            }\r
+        }\r
+\r
+        public int Count {\r
+            get {\r
+                return _innerDictionary.Count;\r
+            }\r
+        }\r
+\r
+        public bool IsReadOnly {\r
+            get {\r
+                return ((IDictionary<string, ModelState>)_innerDictionary).IsReadOnly;\r
+            }\r
+        }\r
+\r
+        public bool IsValid {\r
+            get {\r
+                return Values.All(modelState => modelState.Errors.Count == 0);\r
+            }\r
+        }\r
+\r
+        public ICollection<string> Keys {\r
+            get {\r
+                return _innerDictionary.Keys;\r
+            }\r
+        }\r
+\r
+        public ModelState this[string key] {\r
+            get {\r
+                ModelState value;\r
+                _innerDictionary.TryGetValue(key, out value);\r
+                return value;\r
+            }\r
+            set {\r
+                _innerDictionary[key] = value;\r
+            }\r
+        }\r
+\r
+        public ICollection<ModelState> Values {\r
+            get {\r
+                return _innerDictionary.Values;\r
+            }\r
+        }\r
+\r
+        public void Add(KeyValuePair<string, ModelState> item) {\r
+            ((IDictionary<string, ModelState>)_innerDictionary).Add(item);\r
+        }\r
+\r
+        public void Add(string key, ModelState value) {\r
+            _innerDictionary.Add(key, value);\r
+        }\r
+\r
+        public void AddModelError(string key, Exception exception) {\r
+            GetModelStateForKey(key).Errors.Add(exception);\r
+        }\r
+\r
+        public void AddModelError(string key, string errorMessage) {\r
+            GetModelStateForKey(key).Errors.Add(errorMessage);\r
+        }\r
+\r
+        public void Clear() {\r
+            _innerDictionary.Clear();\r
+        }\r
+\r
+        public bool Contains(KeyValuePair<string, ModelState> item) {\r
+            return ((IDictionary<string, ModelState>)_innerDictionary).Contains(item);\r
+        }\r
+\r
+        public bool ContainsKey(string key) {\r
+            return _innerDictionary.ContainsKey(key);\r
+        }\r
+\r
+        public void CopyTo(KeyValuePair<string, ModelState>[] array, int arrayIndex) {\r
+            ((IDictionary<string, ModelState>)_innerDictionary).CopyTo(array, arrayIndex);\r
+        }\r
+\r
+        public IEnumerator<KeyValuePair<string, ModelState>> GetEnumerator() {\r
+            return _innerDictionary.GetEnumerator();\r
+        }\r
+\r
+        private ModelState GetModelStateForKey(string key) {\r
+            if (key == null) {\r
+                throw new ArgumentNullException("key");\r
+            }\r
+\r
+            ModelState modelState;\r
+            if (!TryGetValue(key, out modelState)) {\r
+                modelState = new ModelState();\r
+                this[key] = modelState;\r
+            }\r
+\r
+            return modelState;\r
+        }\r
+\r
+        public bool IsValidField(string key) {\r
+            if (key == null) {\r
+                throw new ArgumentNullException("key");\r
+            }\r
+\r
+            // if the key is not found in the dictionary, we just say that it's valid (since there are no errors)\r
+            return DictionaryHelpers.FindKeysWithPrefix(this, key).All(entry => entry.Value.Errors.Count == 0);\r
+        }\r
+\r
+        public void Merge(ModelStateDictionary dictionary) {\r
+            if (dictionary == null) {\r
+                return;\r
+            }\r
+\r
+            foreach (var entry in dictionary) {\r
+                this[entry.Key] = entry.Value;\r
+            }\r
+        }\r
+\r
+        public bool Remove(KeyValuePair<string, ModelState> item) {\r
+            return ((IDictionary<string, ModelState>)_innerDictionary).Remove(item);\r
+        }\r
+\r
+        public bool Remove(string key) {\r
+            return _innerDictionary.Remove(key);\r
+        }\r
+\r
+        public void SetModelValue(string key, ValueProviderResult value) {\r
+            GetModelStateForKey(key).Value = value;\r
+        }\r
+\r
+        public bool TryGetValue(string key, out ModelState value) {\r
+            return _innerDictionary.TryGetValue(key, out value);\r
+        }\r
+\r
+        #region IEnumerable Members\r
+        IEnumerator IEnumerable.GetEnumerator() {\r
+            return ((IEnumerable)_innerDictionary).GetEnumerator();\r
+        }\r
+        #endregion\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidationResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidationResult.cs
new file mode 100644 (file)
index 0000000..dcb262e
--- /dev/null
@@ -0,0 +1,40 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public class ModelValidationResult {\r
+\r
+        private string _memberName;\r
+        private string _message;\r
+\r
+        public string MemberName {\r
+            get {\r
+                return _memberName ?? String.Empty;\r
+            }\r
+            set {\r
+                _memberName = value;\r
+            }\r
+        }\r
+\r
+        public string Message {\r
+            get {\r
+                return _message ?? String.Empty;\r
+            }\r
+            set {\r
+                _message = value;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidator.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidator.cs
new file mode 100644 (file)
index 0000000..0570bff
--- /dev/null
@@ -0,0 +1,83 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq;\r
+\r
+    public abstract class ModelValidator {\r
+        protected ModelValidator(ModelMetadata metadata, ControllerContext controllerContext) {\r
+            if (metadata == null) {\r
+                throw new ArgumentNullException("metadata");\r
+            }\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+\r
+            Metadata = metadata;\r
+            ControllerContext = controllerContext;\r
+        }\r
+\r
+        protected internal ControllerContext ControllerContext { get; private set; }\r
+\r
+        public virtual bool IsRequired {\r
+            get {\r
+                return false;\r
+            }\r
+        }\r
+\r
+        protected internal ModelMetadata Metadata { get; private set; }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This method may perform non-trivial work.")]\r
+        public virtual IEnumerable<ModelClientValidationRule> GetClientValidationRules() {\r
+            return Enumerable.Empty<ModelClientValidationRule>();\r
+        }\r
+\r
+        public static ModelValidator GetModelValidator(ModelMetadata metadata, ControllerContext context) {\r
+            return new CompositeModelValidator(metadata, context);\r
+        }\r
+\r
+        public abstract IEnumerable<ModelValidationResult> Validate(object container);\r
+\r
+        private class CompositeModelValidator : ModelValidator {\r
+            public CompositeModelValidator(ModelMetadata metadata, ControllerContext controllerContext)\r
+                : base(metadata, controllerContext) {\r
+            }\r
+\r
+            public override IEnumerable<ModelValidationResult> Validate(object container) {\r
+                bool propertiesValid = true;\r
+\r
+                foreach (ModelMetadata propertyMetadata in Metadata.Properties) {\r
+                    foreach (ModelValidator propertyValidator in propertyMetadata.GetValidators(ControllerContext)) {\r
+                        foreach (ModelValidationResult propertyResult in propertyValidator.Validate(Metadata.Model)) {\r
+                            propertiesValid = false;\r
+                            yield return new ModelValidationResult {\r
+                                MemberName = DefaultModelBinder.CreateSubPropertyName(propertyMetadata.PropertyName, propertyResult.MemberName),\r
+                                Message = propertyResult.Message\r
+                            };\r
+                        }\r
+                    }\r
+                }\r
+\r
+                if (propertiesValid) {\r
+                    foreach (ModelValidator typeValidator in Metadata.GetValidators(ControllerContext)) {\r
+                        foreach (ModelValidationResult typeResult in typeValidator.Validate(container)) {\r
+                            yield return typeResult;\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidatorProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidatorProvider.cs
new file mode 100644 (file)
index 0000000..88dc223
--- /dev/null
@@ -0,0 +1,19 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+\r
+    public abstract class ModelValidatorProvider {\r
+        public abstract IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidatorProviderCollection.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidatorProviderCollection.cs
new file mode 100644 (file)
index 0000000..ffc845b
--- /dev/null
@@ -0,0 +1,47 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.ObjectModel;\r
+    using System.Linq;\r
+\r
+    public class ModelValidatorProviderCollection : Collection<ModelValidatorProvider> {\r
+\r
+        public ModelValidatorProviderCollection() {\r
+        }\r
+\r
+        public ModelValidatorProviderCollection(IList<ModelValidatorProvider> list)\r
+            : base(list) {\r
+        }\r
+\r
+        protected override void InsertItem(int index, ModelValidatorProvider item) {\r
+            if (item == null) {\r
+                throw new ArgumentNullException("item");\r
+            }\r
+            base.InsertItem(index, item);\r
+        }\r
+\r
+        protected override void SetItem(int index, ModelValidatorProvider item) {\r
+            if (item == null) {\r
+                throw new ArgumentNullException("item");\r
+            }\r
+            base.SetItem(index, item);\r
+        }\r
+\r
+        public IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context) {\r
+            return this.SelectMany(provider => provider.GetValidators(metadata, context));\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidatorProviders.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ModelValidatorProviders.cs
new file mode 100644 (file)
index 0000000..563d495
--- /dev/null
@@ -0,0 +1,29 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public static class ModelValidatorProviders {\r
+\r
+        private static readonly ModelValidatorProviderCollection _providers = new ModelValidatorProviderCollection() {\r
+            new DataAnnotationsModelValidatorProvider(),\r
+            new DataErrorInfoModelValidatorProvider(),\r
+            new ClientDataTypeModelValidatorProvider()\r
+        };\r
+\r
+        public static ModelValidatorProviderCollection Providers {\r
+            get {\r
+                return _providers;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/MultiSelectList.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/MultiSelectList.cs
new file mode 100644 (file)
index 0000000..2f1776f
--- /dev/null
@@ -0,0 +1,126 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Web.UI;\r
+\r
+    [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]\r
+    [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi",\r
+        Justification = "Common shorthand for 'multiple'.")]\r
+    public class MultiSelectList : IEnumerable<SelectListItem> {\r
+\r
+        public MultiSelectList(IEnumerable items)\r
+            : this(items, null /* selectedValues */) {\r
+        }\r
+\r
+        public MultiSelectList(IEnumerable items, IEnumerable selectedValues)\r
+            : this(items, null /* dataValuefield */, null /* dataTextField */, selectedValues) {\r
+        }\r
+\r
+        public MultiSelectList(IEnumerable items, string dataValueField, string dataTextField)\r
+            : this(items, dataValueField, dataTextField, null /* selectedValues */) {\r
+        }\r
+\r
+        public MultiSelectList(IEnumerable items, string dataValueField, string dataTextField, IEnumerable selectedValues) {\r
+            if (items == null) {\r
+                throw new ArgumentNullException("items");\r
+            }\r
+\r
+            Items = items;\r
+            DataValueField = dataValueField;\r
+            DataTextField = dataTextField;\r
+            SelectedValues = selectedValues;\r
+        }\r
+\r
+        public string DataTextField {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public string DataValueField {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public IEnumerable Items {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public IEnumerable SelectedValues {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public virtual IEnumerator<SelectListItem> GetEnumerator() {\r
+            return GetListItems().GetEnumerator();\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",\r
+            Justification = "Operation performs conversions and returns a unique instance on each call.")]\r
+        internal IList<SelectListItem> GetListItems() {\r
+            return (!String.IsNullOrEmpty(DataValueField)) ?\r
+                GetListItemsWithValueField() :\r
+                GetListItemsWithoutValueField();\r
+        }\r
+\r
+        private IList<SelectListItem> GetListItemsWithValueField() {\r
+            HashSet<string> selectedValues = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\r
+            if (SelectedValues != null) {\r
+                selectedValues.UnionWith(from object value in SelectedValues select Convert.ToString(value, CultureInfo.CurrentCulture));\r
+            }\r
+\r
+            var listItems = from object item in Items\r
+                            let value = Eval(item, DataValueField)\r
+                            select new SelectListItem {\r
+                                Value = value,\r
+                                Text = Eval(item, DataTextField),\r
+                                Selected = selectedValues.Contains(value)\r
+                            };\r
+            return listItems.ToList();\r
+        }\r
+\r
+        private IList<SelectListItem> GetListItemsWithoutValueField() {\r
+            HashSet<object> selectedValues = new HashSet<object>();\r
+            if (SelectedValues != null) {\r
+                selectedValues.UnionWith(SelectedValues.Cast<object>());\r
+            }\r
+\r
+            var listItems = from object item in Items\r
+                            select new SelectListItem {\r
+                                Text = Eval(item, DataTextField),\r
+                                Selected = selectedValues.Contains(item)\r
+                            };\r
+            return listItems.ToList();\r
+        }\r
+\r
+        private static string Eval(object container, string expression) {\r
+            object value = container;\r
+            if (!String.IsNullOrEmpty(expression)) {\r
+                value = DataBinder.Eval(container, expression);\r
+            }\r
+            return Convert.ToString(value, CultureInfo.CurrentCulture);\r
+        }\r
+\r
+        #region IEnumerable Members\r
+        IEnumerator IEnumerable.GetEnumerator() {\r
+            return GetEnumerator();\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcHandler.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcHandler.cs
new file mode 100644 (file)
index 0000000..1f15ae7
--- /dev/null
@@ -0,0 +1,212 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Threading;\r
+    using System.Web;\r
+    using System.Web.Mvc.Async;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+    using System.Web.SessionState;\r
+\r
+    [SuppressMessage("Microsoft.Security", "CA2112:SecuredTypesShouldNotExposeFields", Justification = "There's nothing secret about the value of this field.")]\r
+    public class MvcHandler : IHttpAsyncHandler, IHttpHandler, IRequiresSessionState {\r
+        private static readonly object _processRequestTag = new object();\r
+        private ControllerBuilder _controllerBuilder;\r
+\r
+        internal static readonly string MvcVersion = GetMvcVersionString();\r
+        public static readonly string MvcVersionHeaderName = "X-AspNetMvc-Version";\r
+\r
+        public MvcHandler(RequestContext requestContext) {\r
+            if (requestContext == null) {\r
+                throw new ArgumentNullException("requestContext");\r
+            }\r
+\r
+            RequestContext = requestContext;\r
+        }\r
+\r
+        internal ControllerBuilder ControllerBuilder {\r
+            get {\r
+                if (_controllerBuilder == null) {\r
+                    _controllerBuilder = ControllerBuilder.Current;\r
+                }\r
+                return _controllerBuilder;\r
+            }\r
+            set {\r
+                _controllerBuilder = value;\r
+            }\r
+        }\r
+\r
+        public static bool DisableMvcResponseHeader {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        protected virtual bool IsReusable {\r
+            get {\r
+                return false;\r
+            }\r
+        }\r
+\r
+        public RequestContext RequestContext {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        protected internal virtual void AddVersionHeader(HttpContextBase httpContext) {\r
+            if (!DisableMvcResponseHeader) {\r
+                httpContext.Response.AppendHeader(MvcVersionHeaderName, MvcVersion);\r
+            }\r
+        }\r
+\r
+        protected virtual IAsyncResult BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, object state) {\r
+            HttpContextBase iHttpContext = new HttpContextWrapper(httpContext);\r
+            return BeginProcessRequest(iHttpContext, callback, state);\r
+        }\r
+\r
+        protected internal virtual IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object state) {\r
+            IController controller;\r
+            IControllerFactory factory;\r
+            ProcessRequestInit(httpContext, out controller, out factory);\r
+\r
+            IAsyncController asyncController = controller as IAsyncController;\r
+            if (asyncController != null) {\r
+                // asynchronous controller\r
+                BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) {\r
+                    try {\r
+                        return asyncController.BeginExecute(RequestContext, asyncCallback, asyncState);\r
+                    }\r
+                    catch {\r
+                        factory.ReleaseController(asyncController);\r
+                        throw;\r
+                    }\r
+                };\r
+\r
+                EndInvokeDelegate endDelegate = delegate(IAsyncResult asyncResult) {\r
+                    try {\r
+                        asyncController.EndExecute(asyncResult);\r
+                    }\r
+                    finally {\r
+                        factory.ReleaseController(asyncController);\r
+                    }\r
+                };\r
+\r
+                SynchronizationContext syncContext = SynchronizationContextUtil.GetSynchronizationContext();\r
+                AsyncCallback newCallback = AsyncUtil.WrapCallbackForSynchronizedExecution(callback, syncContext);\r
+                return AsyncResultWrapper.Begin(newCallback, state, beginDelegate, endDelegate, _processRequestTag);\r
+            }\r
+            else {\r
+                // synchronous controller\r
+                Action action = delegate {\r
+                    try {\r
+                        controller.Execute(RequestContext);\r
+                    }\r
+                    finally {\r
+                        factory.ReleaseController(controller);\r
+                    }\r
+                };\r
+\r
+                return AsyncResultWrapper.BeginSynchronous(callback, state, action, _processRequestTag);\r
+            }\r
+        }\r
+\r
+        protected internal virtual void EndProcessRequest(IAsyncResult asyncResult) {\r
+            AsyncResultWrapper.End(asyncResult, _processRequestTag);\r
+        }\r
+\r
+        private static string GetMvcVersionString() {\r
+            // DevDiv 216459:\r
+            // This code originally used Assembly.GetName(), but that requires FileIOPermission, which isn't granted in\r
+            // medium trust. However, Assembly.FullName *is* accessible in medium trust.\r
+            return new AssemblyName(typeof(MvcHandler).Assembly.FullName).Version.ToString(2);\r
+        }\r
+\r
+        protected virtual void ProcessRequest(HttpContext httpContext) {\r
+            HttpContextBase iHttpContext = new HttpContextWrapper(httpContext);\r
+            ProcessRequest(iHttpContext);\r
+        }\r
+\r
+        protected internal virtual void ProcessRequest(HttpContextBase httpContext) {\r
+            IController controller;\r
+            IControllerFactory factory;\r
+            ProcessRequestInit(httpContext, out controller, out factory);\r
+\r
+            try {\r
+                controller.Execute(RequestContext);\r
+            }\r
+            finally {\r
+                factory.ReleaseController(controller);\r
+            }\r
+        }\r
+\r
+        private void ProcessRequestInit(HttpContextBase httpContext, out IController controller, out IControllerFactory factory) {\r
+            AddVersionHeader(httpContext);\r
+            RemoveOptionalRoutingParameters();\r
+\r
+            // Get the controller type\r
+            string controllerName = RequestContext.RouteData.GetRequiredString("controller");\r
+\r
+            // Instantiate the controller and call Execute\r
+            factory = ControllerBuilder.GetControllerFactory();\r
+            controller = factory.CreateController(RequestContext, controllerName);\r
+            if (controller == null) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.ControllerBuilder_FactoryReturnedNull,\r
+                        factory.GetType(),\r
+                        controllerName));\r
+            }\r
+        }\r
+\r
+        private void RemoveOptionalRoutingParameters() {\r
+            RouteValueDictionary rvd = RequestContext.RouteData.Values;\r
+\r
+            // Get all keys for which the corresponding value is 'Optional'.\r
+            // ToArray() necessary so that we don't manipulate the dictionary while enumerating.\r
+            string[] matchingKeys = (from entry in rvd\r
+                                     where entry.Value == UrlParameter.Optional\r
+                                     select entry.Key).ToArray();\r
+\r
+            foreach (string key in matchingKeys) {\r
+                rvd.Remove(key);\r
+            }\r
+        }\r
+\r
+        #region IHttpHandler Members\r
+        bool IHttpHandler.IsReusable {\r
+            get {\r
+                return IsReusable;\r
+            }\r
+        }\r
+\r
+        void IHttpHandler.ProcessRequest(HttpContext httpContext) {\r
+            ProcessRequest(httpContext);\r
+        }\r
+        #endregion\r
+\r
+        #region IHttpAsyncHandler Members\r
+        IAsyncResult IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) {\r
+            return BeginProcessRequest(context, cb, extraData);\r
+        }\r
+\r
+        void IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) {\r
+            EndProcessRequest(result);\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcHtmlString.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcHtmlString.cs
new file mode 100644 (file)
index 0000000..a6674bf
--- /dev/null
@@ -0,0 +1,101 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.ComponentModel;\r
+    using System.Linq.Expressions;\r
+    using System.Web;\r
+\r
+    // In ASP.NET 4, a new syntax <%: %> is being introduced in WebForms pages, where <%: expression %> is equivalent to\r
+    // <%= HttpUtility.HtmlEncode(expression) %>. The intent of this is to reduce common causes of XSS vulnerabilities\r
+    // in WebForms pages (WebForms views in the case of MVC). This involves the addition of an interface\r
+    // System.Web.IHtmlString and a static method overload System.Web.HttpUtility::HtmlEncode(object).  The interface\r
+    // definition is roughly:\r
+    //   public interface IHtmlString {\r
+    //     string ToHtmlString();\r
+    //   }\r
+    // And the HtmlEncode(object) logic is roughly:\r
+    //   - If the input argument is an IHtmlString, return argument.ToHtmlString(),\r
+    //   - Otherwise, return HtmlEncode(Convert.ToString(argument)).\r
+    //\r
+    // Unfortunately this has the effect that calling <%: Html.SomeHelper() %> in an MVC application running on .NET 4\r
+    // will end up encoding output that is already HTML-safe. As a result, we're changing out HTML helpers to return\r
+    // MvcHtmlString where appropriate. <%= Html.SomeHelper() %> will continue to work in both .NET 3.5 and .NET 4, but\r
+    // changing the return types to MvcHtmlString has the added benefit that <%: Html.SomeHelper() %> will also work\r
+    // properly in .NET 4 rather than resulting in a double-encoded output. MVC developers in .NET 4 will then be able\r
+    // to use the <%: %> syntax almost everywhere instead of having to remember where to use <%= %> and where to use\r
+    // <%: %>. This should help developers craft more secure web applications by default.\r
+    //\r
+    // To create an MvcHtmlString, use the static Create() method instead of calling the protected constructor.\r
+\r
+    public class MvcHtmlString {\r
+\r
+        private delegate MvcHtmlString MvcHtmlStringCreator(string value);\r
+        private static readonly MvcHtmlStringCreator _creator = GetCreator();\r
+\r
+        // imporant: this declaration must occur after the _creator declaration\r
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",\r
+            Justification = "MvcHtmlString is immutable")]\r
+        public static readonly MvcHtmlString Empty = Create(String.Empty);\r
+\r
+        private readonly string _value;\r
+\r
+        // This constructor is only protected so that we can subclass it in a dynamic module. In practice,\r
+        // nobody should ever call this constructor, and it is likely to be removed in a future version\r
+        // of the framework. Use the static Create() method instead.\r
+        [EditorBrowsable(EditorBrowsableState.Never)]\r
+        [Obsolete("The recommended alternative is the static MvcHtmlString.Create(String value) method.")]\r
+        protected MvcHtmlString(string value) {\r
+            _value = value ?? String.Empty;\r
+        }\r
+\r
+        public static MvcHtmlString Create(string value) {\r
+            return _creator(value);\r
+        }\r
+\r
+        // in .NET 4, we dynamically create a type that subclasses MvcHtmlString and implements IHtmlString\r
+        private static MvcHtmlStringCreator GetCreator() {\r
+            Type iHtmlStringType = typeof(HttpContext).Assembly.GetType("System.Web.IHtmlString");\r
+            if (iHtmlStringType != null) {\r
+                // first, create the dynamic type\r
+                Type dynamicType = DynamicTypeGenerator.GenerateType("DynamicMvcHtmlString", typeof(MvcHtmlString), new Type[] { iHtmlStringType });\r
+\r
+                // then, create the delegate to instantiate the dynamic type\r
+                ParameterExpression valueParamExpr = Expression.Parameter(typeof(string), "value");\r
+                NewExpression newObjExpr = Expression.New(dynamicType.GetConstructor(new Type[] { typeof(string) }), valueParamExpr);\r
+                Expression<MvcHtmlStringCreator> lambdaExpr = Expression.Lambda<MvcHtmlStringCreator>(newObjExpr, valueParamExpr);\r
+                return lambdaExpr.Compile();\r
+            }\r
+            else {\r
+                // disabling 0618 allows us to call the MvcHtmlString() constructor\r
+#pragma warning disable 0618\r
+                return value => new MvcHtmlString(value);\r
+#pragma warning restore 0618\r
+            }\r
+        }\r
+\r
+        public static bool IsNullOrEmpty(MvcHtmlString value) {\r
+            return (value == null || value._value.Length == 0);\r
+        }\r
+\r
+        // IHtmlString.ToHtmlString()\r
+        public string ToHtmlString() {\r
+            return _value;\r
+        }\r
+\r
+        public override string ToString() {\r
+            return _value;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcHttpHandler.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcHttpHandler.cs
new file mode 100644 (file)
index 0000000..c9773d7
--- /dev/null
@@ -0,0 +1,101 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web;\r
+    using System.Web.Mvc.Async;\r
+    using System.Web.Routing;\r
+    using System.Web.SessionState;\r
+\r
+    public class MvcHttpHandler : UrlRoutingHandler, IHttpAsyncHandler, IRequiresSessionState {\r
+\r
+        private static readonly object _processRequestTag = new object();\r
+\r
+        protected virtual IAsyncResult BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, object state) {\r
+            HttpContextBase iHttpContext = new HttpContextWrapper(httpContext);\r
+            return BeginProcessRequest(iHttpContext, callback, state);\r
+        }\r
+\r
+        protected internal virtual IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object state) {\r
+            IHttpHandler httpHandler = GetHttpHandler(httpContext);\r
+            IHttpAsyncHandler httpAsyncHandler = httpHandler as IHttpAsyncHandler;\r
+\r
+            if (httpAsyncHandler != null) {\r
+                // asynchronous handler\r
+                BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) {\r
+                    return httpAsyncHandler.BeginProcessRequest(HttpContext.Current, asyncCallback, asyncState);\r
+                };\r
+                EndInvokeDelegate endDelegate = delegate(IAsyncResult asyncResult) {\r
+                    httpAsyncHandler.EndProcessRequest(asyncResult);\r
+                };\r
+                return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _processRequestTag);\r
+            }\r
+            else {\r
+                // synchronous handler\r
+                Action action = delegate {\r
+                    httpHandler.ProcessRequest(HttpContext.Current);\r
+                };\r
+                return AsyncResultWrapper.BeginSynchronous(callback, state, action, _processRequestTag);\r
+            }\r
+        }\r
+\r
+        protected internal virtual void EndProcessRequest(IAsyncResult asyncResult) {\r
+            AsyncResultWrapper.End(asyncResult, _processRequestTag);\r
+        }\r
+\r
+        private static IHttpHandler GetHttpHandler(HttpContextBase httpContext) {\r
+            DummyHttpHandler dummyHandler = new DummyHttpHandler();\r
+            dummyHandler.PublicProcessRequest(httpContext);\r
+            return dummyHandler.HttpHandler;\r
+        }\r
+\r
+        // synchronous code\r
+        protected override void VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) {\r
+            if (httpHandler == null) {\r
+                throw new ArgumentNullException("httpHandler");\r
+            }\r
+\r
+            httpHandler.ProcessRequest(HttpContext.Current);\r
+        }\r
+\r
+        #region IHttpAsyncHandler Members\r
+        IAsyncResult IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) {\r
+            return BeginProcessRequest(context, cb, extraData);\r
+        }\r
+\r
+        void IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) {\r
+            EndProcessRequest(result);\r
+        }\r
+        #endregion\r
+\r
+        // Since UrlRoutingHandler.ProcessRequest() does the heavy lifting of looking at the RouteCollection for\r
+        // a matching route, we need to call into it. However, that method is also responsible for kicking off\r
+        // the synchronous request, and we can't allow it to do that. The purpose of this dummy class is to run\r
+        // only the lookup portion of UrlRoutingHandler.ProcessRequest(), then intercept the handler it returns\r
+        // and execute it asynchronously.\r
+\r
+        private sealed class DummyHttpHandler : UrlRoutingHandler {\r
+            public IHttpHandler HttpHandler;\r
+\r
+            public void PublicProcessRequest(HttpContextBase httpContext) {\r
+                ProcessRequest(httpContext);\r
+            }\r
+\r
+            protected override void VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) {\r
+                // don't process the request, just store a reference to it\r
+                HttpHandler = httpHandler;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcRouteHandler.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/MvcRouteHandler.cs
new file mode 100644 (file)
index 0000000..5d2bbaa
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Web.Routing;\r
+\r
+    public class MvcRouteHandler : IRouteHandler {\r
+        protected virtual IHttpHandler GetHttpHandler(RequestContext requestContext) {\r
+            return new MvcHandler(requestContext);\r
+        }\r
+\r
+        #region IRouteHandler Members\r
+        IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext) {\r
+            return GetHttpHandler(requestContext);\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/NameValueCollectionExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/NameValueCollectionExtensions.cs
new file mode 100644 (file)
index 0000000..7faf9f0
--- /dev/null
@@ -0,0 +1,39 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.Specialized;\r
+\r
+    public static class NameValueCollectionExtensions {\r
+\r
+        public static void CopyTo(this NameValueCollection collection, IDictionary<string, object> destination) {\r
+            CopyTo(collection, destination, false /* replaceEntries */);\r
+        }\r
+\r
+        public static void CopyTo(this NameValueCollection collection, IDictionary<string, object> destination, bool replaceEntries) {\r
+            if (collection == null) {\r
+                throw new ArgumentNullException("collection");\r
+            }\r
+            if (destination == null) {\r
+                throw new ArgumentNullException("destination");\r
+            }\r
+\r
+            foreach (string key in collection.Keys) {\r
+                if (replaceEntries || !destination.ContainsKey(key)) {\r
+                    destination[key] = collection[key];\r
+                }\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/NameValueCollectionValueProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/NameValueCollectionValueProvider.cs
new file mode 100644 (file)
index 0000000..9bc990b
--- /dev/null
@@ -0,0 +1,68 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.Specialized;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+\r
+    public class NameValueCollectionValueProvider : IValueProvider {\r
+\r
+        private readonly HashSet<string> _prefixes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\r
+        private readonly Dictionary<string, ValueProviderResult> _values = new Dictionary<string, ValueProviderResult>(StringComparer.OrdinalIgnoreCase);\r
+\r
+        public NameValueCollectionValueProvider(NameValueCollection collection, CultureInfo culture) {\r
+            if (collection == null) {\r
+                throw new ArgumentNullException("collection");\r
+            }\r
+\r
+            AddValues(collection, culture);\r
+        }\r
+\r
+        private void AddValues(NameValueCollection collection, CultureInfo culture) {\r
+            if (collection.Count > 0) {\r
+                _prefixes.Add("");\r
+            }\r
+\r
+            foreach (string key in collection) {\r
+                if (key != null) {\r
+                    _prefixes.UnionWith(ValueProviderUtil.GetPrefixes(key));\r
+\r
+                    string[] rawValue = collection.GetValues(key);\r
+                    string attemptedValue = collection[key];\r
+                    _values[key] = new ValueProviderResult(rawValue, attemptedValue, culture);\r
+                }\r
+            }\r
+        }\r
+\r
+        public virtual bool ContainsPrefix(string prefix) {\r
+            if (prefix == null) {\r
+                throw new ArgumentNullException("prefix");\r
+            }\r
+\r
+            return _prefixes.Contains(prefix);\r
+        }\r
+\r
+        public virtual ValueProviderResult GetValue(string key) {\r
+            if (key == null) {\r
+                throw new ArgumentNullException("key");\r
+            }\r
+\r
+            ValueProviderResult vpResult;\r
+            _values.TryGetValue(key, out vpResult);\r
+            return vpResult;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/NoAsyncTimeoutAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/NoAsyncTimeoutAttribute.cs
new file mode 100644 (file)
index 0000000..b482dc8
--- /dev/null
@@ -0,0 +1,24 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Threading;\r
+\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]\r
+    public sealed class NoAsyncTimeoutAttribute : AsyncTimeoutAttribute {\r
+\r
+        public NoAsyncTimeoutAttribute()\r
+            : base(Timeout.Infinite) {\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/NonActionAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/NonActionAttribute.cs
new file mode 100644 (file)
index 0000000..c50ef63
--- /dev/null
@@ -0,0 +1,22 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Reflection;\r
+\r
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public sealed class NonActionAttribute : ActionMethodSelectorAttribute {\r
+        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) {\r
+            return false;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/NullViewLocationCache.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/NullViewLocationCache.cs
new file mode 100644 (file)
index 0000000..dbfc9ae
--- /dev/null
@@ -0,0 +1,30 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+    using System.Text;\r
+\r
+    internal sealed class NullViewLocationCache : IViewLocationCache {\r
+\r
+        #region IViewLocationCache Members\r
+        public string GetViewLocation(HttpContextBase httpContext, string key) {\r
+            return null;\r
+        }\r
+\r
+        public void InsertViewLocation(HttpContextBase httpContext, string key, string virtualPath) {\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/OutputCacheAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/OutputCacheAttribute.cs
new file mode 100644 (file)
index 0000000..a83a82b
--- /dev/null
@@ -0,0 +1,146 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Web;\r
+    using System.Web.UI;\r
+\r
+    [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes",\r
+        Justification = "Unsealed so that subclassed types can set properties in the default constructor.")]\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]\r
+    public class OutputCacheAttribute : ActionFilterAttribute {\r
+\r
+        private OutputCacheParameters _cacheSettings = new OutputCacheParameters();\r
+\r
+        public string CacheProfile {\r
+            get {\r
+                return _cacheSettings.CacheProfile ?? String.Empty;\r
+            }\r
+            set {\r
+                _cacheSettings.CacheProfile = value;\r
+            }\r
+        }\r
+\r
+        internal OutputCacheParameters CacheSettings {\r
+            get {\r
+                return _cacheSettings;\r
+            }\r
+        }\r
+\r
+        public int Duration {\r
+            get {\r
+                return _cacheSettings.Duration;\r
+            }\r
+            set {\r
+                _cacheSettings.Duration = value;\r
+            }\r
+        }\r
+\r
+        public OutputCacheLocation Location {\r
+            get {\r
+                return _cacheSettings.Location;\r
+            }\r
+            set {\r
+                _cacheSettings.Location = value;\r
+            }\r
+        }\r
+\r
+        public bool NoStore {\r
+            get {\r
+                return _cacheSettings.NoStore;\r
+            }\r
+            set {\r
+                _cacheSettings.NoStore = value;\r
+            }\r
+        }\r
+\r
+        public string SqlDependency {\r
+            get {\r
+                return _cacheSettings.SqlDependency ?? String.Empty;\r
+            }\r
+            set {\r
+                _cacheSettings.SqlDependency = value;\r
+            }\r
+        }\r
+\r
+        public string VaryByContentEncoding {\r
+            get {\r
+                return _cacheSettings.VaryByContentEncoding ?? String.Empty;\r
+            }\r
+            set {\r
+                _cacheSettings.VaryByContentEncoding = value;\r
+            }\r
+        }\r
+\r
+        public string VaryByCustom {\r
+            get {\r
+                return _cacheSettings.VaryByCustom ?? String.Empty;\r
+            }\r
+            set {\r
+                _cacheSettings.VaryByCustom = value;\r
+            }\r
+        }\r
+\r
+        public string VaryByHeader {\r
+            get {\r
+                return _cacheSettings.VaryByHeader ?? String.Empty;\r
+            }\r
+            set {\r
+                _cacheSettings.VaryByHeader = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Param",\r
+            Justification = "Matches the @ OutputCache page directive.")]\r
+        public string VaryByParam {\r
+            get {\r
+                return _cacheSettings.VaryByParam ?? String.Empty;\r
+            }\r
+            set {\r
+                _cacheSettings.VaryByParam = value;\r
+            }\r
+        }\r
+\r
+        public override void OnResultExecuting(ResultExecutingContext filterContext) {\r
+            if (filterContext == null) {\r
+                throw new ArgumentNullException("filterContext");\r
+            }\r
+\r
+            if (filterContext.IsChildAction) {\r
+                return;\r
+            }\r
+\r
+            // we need to call ProcessRequest() since there's no other way to set the Page.Response intrinsic\r
+            OutputCachedPage page = new OutputCachedPage(_cacheSettings);\r
+            page.ProcessRequest(HttpContext.Current);\r
+        }\r
+\r
+        private sealed class OutputCachedPage : Page {\r
+            private OutputCacheParameters _cacheSettings;\r
+\r
+            public OutputCachedPage(OutputCacheParameters cacheSettings) {\r
+                // Tracing requires Page IDs to be unique.\r
+                ID = Guid.NewGuid().ToString();\r
+                _cacheSettings = cacheSettings;\r
+            }\r
+\r
+            protected override void FrameworkInitialize() {\r
+                // when you put the <%@ OutputCache %> directive on a page, the generated code calls InitOutputCache() from here\r
+                base.FrameworkInitialize();\r
+                InitOutputCache(_cacheSettings);\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ParameterBindingInfo.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ParameterBindingInfo.cs
new file mode 100644 (file)
index 0000000..09334b8
--- /dev/null
@@ -0,0 +1,43 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+\r
+    public abstract class ParameterBindingInfo {\r
+\r
+        public virtual IModelBinder Binder {\r
+            get {\r
+                return null;\r
+            }\r
+        }\r
+\r
+        public virtual ICollection<string> Exclude {\r
+            get {\r
+                return new string[0];\r
+            }\r
+        }\r
+\r
+        public virtual ICollection<string> Include {\r
+            get {\r
+                return new string[0];\r
+            }\r
+        }\r
+\r
+        public virtual string Prefix {\r
+            get {\r
+                return null;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ParameterDescriptor.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ParameterDescriptor.cs
new file mode 100644 (file)
index 0000000..92ddce4
--- /dev/null
@@ -0,0 +1,69 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Reflection;\r
+\r
+    public abstract class ParameterDescriptor : ICustomAttributeProvider {\r
+\r
+        private static readonly EmptyParameterBindingInfo _emptyBindingInfo = new EmptyParameterBindingInfo();\r
+\r
+        public abstract ActionDescriptor ActionDescriptor {\r
+            get;\r
+        }\r
+\r
+        public virtual ParameterBindingInfo BindingInfo {\r
+            get {\r
+                return _emptyBindingInfo;\r
+            }\r
+        }\r
+\r
+        public virtual object DefaultValue {\r
+            get {\r
+                return null;\r
+            }\r
+        }\r
+\r
+        public abstract string ParameterName {\r
+            get;\r
+        }\r
+\r
+        public abstract Type ParameterType {\r
+            get;\r
+        }\r
+\r
+        public virtual object[] GetCustomAttributes(bool inherit) {\r
+            return GetCustomAttributes(typeof(object), inherit);\r
+        }\r
+\r
+        public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) {\r
+            if (attributeType == null) {\r
+                throw new ArgumentNullException("attributeType");\r
+            }\r
+\r
+            return (object[])Array.CreateInstance(attributeType, 0);\r
+        }\r
+\r
+        public virtual bool IsDefined(Type attributeType, bool inherit) {\r
+            if (attributeType == null) {\r
+                throw new ArgumentNullException("attributeType");\r
+            }\r
+\r
+            return false;\r
+        }\r
+\r
+        private sealed class EmptyParameterBindingInfo : ParameterBindingInfo {\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ParameterInfoUtil.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ParameterInfoUtil.cs
new file mode 100644 (file)
index 0000000..c538e14
--- /dev/null
@@ -0,0 +1,42 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.ComponentModel;\r
+    using System.Reflection;\r
+\r
+    internal static class ParameterInfoUtil {\r
+\r
+        public static bool TryGetDefaultValue(ParameterInfo parameterInfo, out object value) {\r
+            // this will get the default value as seen by the VB / C# compilers\r
+            // if no value was baked in, RawDefaultValue returns DBNull.Value\r
+            object rawDefaultValue = parameterInfo.RawDefaultValue;\r
+            if (rawDefaultValue != DBNull.Value) {\r
+                value = rawDefaultValue;\r
+                return true;\r
+            }\r
+\r
+            // if the compiler did not bake in a default value, check the [DefaultValue] attribute\r
+            DefaultValueAttribute[] attrs = (DefaultValueAttribute[])parameterInfo.GetCustomAttributes(typeof(DefaultValueAttribute), false);\r
+            if (attrs == null || attrs.Length == 0) {\r
+                value = default(object);\r
+                return false;\r
+            }\r
+            else {\r
+                value = attrs[0].Value;\r
+                return true;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/PartialViewResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/PartialViewResult.cs
new file mode 100644 (file)
index 0000000..86f9fb1
--- /dev/null
@@ -0,0 +1,37 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Globalization;\r
+    using System.Text;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class PartialViewResult : ViewResultBase {\r
+\r
+        protected override ViewEngineResult FindView(ControllerContext context) {\r
+            ViewEngineResult result = ViewEngineCollection.FindPartialView(context, ViewName);\r
+            if (result.View != null) {\r
+                return result;\r
+            }\r
+\r
+            // we need to generate an exception containing all the locations we searched\r
+            StringBuilder locationsText = new StringBuilder();\r
+            foreach (string location in result.SearchedLocations) {\r
+                locationsText.AppendLine();\r
+                locationsText.Append(location);\r
+            }\r
+            throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture,\r
+                MvcResources.Common_PartialViewNotFound, ViewName, locationsText));\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/PathHelpers.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/PathHelpers.cs
new file mode 100644 (file)
index 0000000..cb5be74
--- /dev/null
@@ -0,0 +1,97 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Specialized;\r
+    using System.Web;\r
+\r
+    internal static class PathHelpers {\r
+\r
+        private const string _urlRewriterServerVar = "HTTP_X_ORIGINAL_URL";\r
+\r
+        // this method can accept an app-relative path or an absolute path for contentPath\r
+        public static string GenerateClientUrl(HttpContextBase httpContext, string contentPath) {\r
+            if (String.IsNullOrEmpty(contentPath)) {\r
+                return contentPath;\r
+            }\r
+\r
+            // many of the methods we call internally can't handle query strings properly, so just strip it out for\r
+            // the time being\r
+            string query;\r
+            contentPath = StripQuery(contentPath, out query);\r
+\r
+            return GenerateClientUrlInternal(httpContext, contentPath) + query;\r
+        }\r
+\r
+        private static string GenerateClientUrlInternal(HttpContextBase httpContext, string contentPath) {\r
+            if (String.IsNullOrEmpty(contentPath)) {\r
+                return contentPath;\r
+            }\r
+\r
+            // can't call VirtualPathUtility.IsAppRelative since it throws on some inputs\r
+            bool isAppRelative = contentPath[0] == '~';\r
+            if (isAppRelative) {\r
+                string absoluteContentPath = VirtualPathUtility.ToAbsolute(contentPath, httpContext.Request.ApplicationPath);\r
+                string modifiedAbsoluteContentPath = httpContext.Response.ApplyAppPathModifier(absoluteContentPath);\r
+                return GenerateClientUrlInternal(httpContext, modifiedAbsoluteContentPath);\r
+            }\r
+\r
+            // we only want to manipulate the path if URL rewriting is active, else we risk breaking the generated URL\r
+            NameValueCollection serverVars = httpContext.Request.ServerVariables;\r
+            bool urlRewriterIsEnabled = (serverVars != null && serverVars[_urlRewriterServerVar] != null);\r
+            if (!urlRewriterIsEnabled) {\r
+                return contentPath;\r
+            }\r
+\r
+            // Since the rawUrl represents what the user sees in his browser, it is what we want to use as the base\r
+            // of our absolute paths. For example, consider mysite.example.com/foo, which is internally\r
+            // rewritten to content.example.com/mysite/foo. When we want to generate a link to ~/bar, we want to\r
+            // base it from / instead of /foo, otherwise the user ends up seeing mysite.example.com/foo/bar,\r
+            // which is incorrect.\r
+            string relativeUrlToDestination = MakeRelative(httpContext.Request.Path, contentPath);\r
+            string absoluteUrlToDestination = MakeAbsolute(httpContext.Request.RawUrl, relativeUrlToDestination);\r
+            return absoluteUrlToDestination;\r
+        }\r
+\r
+        public static string MakeAbsolute(string basePath, string relativePath) {\r
+            // The Combine() method can't handle query strings on the base path, so we trim it off.\r
+            string query;\r
+            basePath = StripQuery(basePath, out query);\r
+            return VirtualPathUtility.Combine(basePath, relativePath);\r
+        }\r
+\r
+        public static string MakeRelative(string fromPath, string toPath) {\r
+            string relativeUrl = VirtualPathUtility.MakeRelative(fromPath, toPath);\r
+            if (String.IsNullOrEmpty(relativeUrl) || relativeUrl[0] == '?') {\r
+                // Sometimes VirtualPathUtility.MakeRelative() will return an empty string when it meant to return '.',\r
+                // but links to {empty string} are browser dependent. We replace it with an explicit path to force\r
+                // consistency across browsers.\r
+                relativeUrl = "./" + relativeUrl;\r
+            }\r
+            return relativeUrl;\r
+        }\r
+\r
+        private static string StripQuery(string path, out string query) {\r
+            int queryIndex = path.IndexOf('?');\r
+            if (queryIndex >= 0) {\r
+                query = path.Substring(queryIndex);\r
+                return path.Substring(0, queryIndex);\r
+            }\r
+            else {\r
+                query = null;\r
+                return path;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/QueryStringValueProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/QueryStringValueProvider.cs
new file mode 100644 (file)
index 0000000..19f4c6e
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Specialized;\r
+    using System.Globalization;\r
+\r
+    public sealed class QueryStringValueProvider : NameValueCollectionValueProvider {\r
+\r
+        // QueryString should use the invariant culture since it's part of the URL, and the URL should be\r
+        // interpreted in a uniform fashion regardless of the origin of a particular request.\r
+        public QueryStringValueProvider(ControllerContext controllerContext)\r
+            : base(controllerContext.HttpContext.Request.QueryString, CultureInfo.InvariantCulture) {\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/QueryStringValueProviderFactory.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/QueryStringValueProviderFactory.cs
new file mode 100644 (file)
index 0000000..c12bb3b
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public sealed class QueryStringValueProviderFactory : ValueProviderFactory {\r
+\r
+        public override IValueProvider GetValueProvider(ControllerContext controllerContext) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+\r
+            return new QueryStringValueProvider(controllerContext);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RangeAttributeAdapter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RangeAttributeAdapter.cs
new file mode 100644 (file)
index 0000000..d789d98
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel.DataAnnotations;\r
+\r
+    public class RangeAttributeAdapter : DataAnnotationsModelValidator<RangeAttribute> {\r
+        public RangeAttributeAdapter(ModelMetadata metadata, ControllerContext context, RangeAttribute attribute)\r
+            : base(metadata, context, attribute) {\r
+        }\r
+\r
+        public override IEnumerable<ModelClientValidationRule> GetClientValidationRules() {\r
+            return new[] { new ModelClientValidationRangeRule(ErrorMessage, Attribute.Minimum, Attribute.Maximum) };\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReaderWriterCache`2.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReaderWriterCache`2.cs
new file mode 100644 (file)
index 0000000..63e2fd4
--- /dev/null
@@ -0,0 +1,72 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Threading;\r
+\r
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",\r
+        Justification = "Instances of this type are meant to be singletons.")]\r
+    internal abstract class ReaderWriterCache<TKey, TValue> {\r
+\r
+        private readonly Dictionary<TKey, TValue> _cache;\r
+        private readonly ReaderWriterLockSlim _rwLock = new ReaderWriterLockSlim();\r
+\r
+        protected ReaderWriterCache()\r
+            : this(null) {\r
+        }\r
+\r
+        protected ReaderWriterCache(IEqualityComparer<TKey> comparer) {\r
+            _cache = new Dictionary<TKey, TValue>(comparer);\r
+        }\r
+\r
+        protected Dictionary<TKey, TValue> Cache {\r
+            get {\r
+                return _cache;\r
+            }\r
+        }\r
+\r
+        protected TValue FetchOrCreateItem(TKey key, Func<TValue> creator) {\r
+            // first, see if the item already exists in the cache\r
+            _rwLock.EnterReadLock();\r
+            try {\r
+                TValue existingEntry;\r
+                if (_cache.TryGetValue(key, out existingEntry)) {\r
+                    return existingEntry;\r
+                }\r
+            }\r
+            finally {\r
+                _rwLock.ExitReadLock();\r
+            }\r
+\r
+            // insert the new item into the cache\r
+            TValue newEntry = creator();\r
+            _rwLock.EnterWriteLock();\r
+            try {\r
+                TValue existingEntry;\r
+                if (_cache.TryGetValue(key, out existingEntry)) {\r
+                    // another thread already inserted an item, so use that one\r
+                    return existingEntry;\r
+                }\r
+\r
+                _cache[key] = newEntry;\r
+                return newEntry;\r
+            }\r
+            finally {\r
+                _rwLock.ExitWriteLock();\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RedirectResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RedirectResult.cs
new file mode 100644 (file)
index 0000000..10abf15
--- /dev/null
@@ -0,0 +1,52 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    // represents a result that performs a redirection given some URI\r
+    public class RedirectResult : ActionResult {\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#",\r
+            Justification = "Response.Redirect() takes its URI as a string parameter.")]\r
+        public RedirectResult(string url) {\r
+            if (String.IsNullOrEmpty(url)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "url");\r
+            }\r
+\r
+            Url = url;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings",\r
+            Justification = "Response.Redirect() takes its URI as a string parameter.")]\r
+        public string Url {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public override void ExecuteResult(ControllerContext context) {\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+            if (context.IsChildAction) {\r
+                throw new InvalidOperationException(MvcResources.RedirectAction_CannotRedirectInChildAction);\r
+            }\r
+\r
+            string destinationUrl = UrlHelper.GenerateContentUrl(Url, context.HttpContext);\r
+            context.Controller.TempData.Keep();\r
+            context.HttpContext.Response.Redirect(destinationUrl, false /* endResponse */);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RedirectToRouteResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RedirectToRouteResult.cs
new file mode 100644 (file)
index 0000000..74b5ce5
--- /dev/null
@@ -0,0 +1,71 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    // represents a result that performs a redirection given some values dictionary\r
+    public class RedirectToRouteResult : ActionResult {\r
+\r
+        private RouteCollection _routes;\r
+\r
+        public RedirectToRouteResult(RouteValueDictionary routeValues) :\r
+            this(null, routeValues) {\r
+        }\r
+\r
+        public RedirectToRouteResult(string routeName, RouteValueDictionary routeValues) {\r
+            RouteName = routeName ?? String.Empty;\r
+            RouteValues = routeValues ?? new RouteValueDictionary();\r
+        }\r
+\r
+        public string RouteName {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public RouteValueDictionary RouteValues {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        internal RouteCollection Routes {\r
+            get {\r
+                if (_routes == null) {\r
+                    _routes = RouteTable.Routes;\r
+                }\r
+                return _routes;\r
+            }\r
+            set {\r
+                _routes = value;\r
+            }\r
+        }\r
+\r
+        public override void ExecuteResult(ControllerContext context) {\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+            if (context.IsChildAction) {\r
+                throw new InvalidOperationException(MvcResources.RedirectAction_CannotRedirectInChildAction);\r
+            }\r
+\r
+            string destinationUrl = UrlHelper.GenerateUrl(RouteName, null /* actionName */, null /* controllerName */, RouteValues, Routes, context.RequestContext, false /* includeImplicitMvcValues */);\r
+            if (String.IsNullOrEmpty(destinationUrl)) {\r
+                throw new InvalidOperationException(MvcResources.Common_NoRouteMatched);\r
+            }\r
+\r
+            context.Controller.TempData.Keep();\r
+            context.HttpContext.Response.Redirect(destinationUrl, false /* endResponse */);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedActionDescriptor.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedActionDescriptor.cs
new file mode 100644 (file)
index 0000000..c8ff6ba
--- /dev/null
@@ -0,0 +1,131 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ReflectedActionDescriptor : ActionDescriptor {\r
+\r
+        private readonly string _actionName;\r
+        private readonly ControllerDescriptor _controllerDescriptor;\r
+        private ParameterDescriptor[] _parametersCache;\r
+\r
+        public ReflectedActionDescriptor(MethodInfo methodInfo, string actionName, ControllerDescriptor controllerDescriptor)\r
+            : this(methodInfo, actionName, controllerDescriptor, true /* validateMethod */) {\r
+        }\r
+\r
+        internal ReflectedActionDescriptor(MethodInfo methodInfo, string actionName, ControllerDescriptor controllerDescriptor, bool validateMethod) {\r
+            if (methodInfo == null) {\r
+                throw new ArgumentNullException("methodInfo");\r
+            }\r
+            if (String.IsNullOrEmpty(actionName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName");\r
+            }\r
+            if (controllerDescriptor == null) {\r
+                throw new ArgumentNullException("controllerDescriptor");\r
+            }\r
+\r
+            if (validateMethod) {\r
+                string failedMessage = VerifyActionMethodIsCallable(methodInfo);\r
+                if (failedMessage != null) {\r
+                    throw new ArgumentException(failedMessage, "methodInfo");\r
+                }\r
+            }\r
+\r
+            MethodInfo = methodInfo;\r
+            _actionName = actionName;\r
+            _controllerDescriptor = controllerDescriptor;\r
+        }\r
+\r
+        public override string ActionName {\r
+            get {\r
+                return _actionName;\r
+            }\r
+        }\r
+\r
+        public override ControllerDescriptor ControllerDescriptor {\r
+            get {\r
+                return _controllerDescriptor;\r
+            }\r
+        }\r
+\r
+        public MethodInfo MethodInfo {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public override object Execute(ControllerContext controllerContext, IDictionary<string, object> parameters) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (parameters == null) {\r
+                throw new ArgumentNullException("parameters");\r
+            }\r
+\r
+            ParameterInfo[] parameterInfos = MethodInfo.GetParameters();\r
+            var rawParameterValues = from parameterInfo in parameterInfos\r
+                                     select ExtractParameterFromDictionary(parameterInfo, parameters, MethodInfo);\r
+            object[] parametersArray = rawParameterValues.ToArray();\r
+\r
+            ActionMethodDispatcher dispatcher = DispatcherCache.GetDispatcher(MethodInfo);\r
+            object actionReturnValue = dispatcher.Execute(controllerContext.Controller, parametersArray);\r
+            return actionReturnValue;\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(bool inherit) {\r
+            return MethodInfo.GetCustomAttributes(inherit);\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit) {\r
+            return MethodInfo.GetCustomAttributes(attributeType, inherit);\r
+        }\r
+\r
+        public override FilterInfo GetFilters() {\r
+            return GetFilters(MethodInfo);\r
+        }\r
+\r
+        public override ParameterDescriptor[] GetParameters() {\r
+            ParameterDescriptor[] parameters = LazilyFetchParametersCollection();\r
+\r
+            // need to clone array so that user modifications aren't accidentally stored\r
+            return (ParameterDescriptor[])parameters.Clone();\r
+        }\r
+\r
+        public override ICollection<ActionSelector> GetSelectors() {\r
+            ActionMethodSelectorAttribute[] attrs = (ActionMethodSelectorAttribute[])MethodInfo.GetCustomAttributes(typeof(ActionMethodSelectorAttribute), true /* inherit */);\r
+            ActionSelector[] selectors = Array.ConvertAll(attrs, attr => (ActionSelector)(controllerContext => attr.IsValidForRequest(controllerContext, MethodInfo)));\r
+            return selectors;\r
+        }\r
+\r
+        public override bool IsDefined(Type attributeType, bool inherit) {\r
+            return MethodInfo.IsDefined(attributeType, inherit);\r
+        }\r
+\r
+        private ParameterDescriptor[] LazilyFetchParametersCollection() {\r
+            return DescriptorUtil.LazilyFetchOrCreateDescriptors<ParameterInfo, ParameterDescriptor>(\r
+                ref _parametersCache /* cacheLocation */,\r
+                MethodInfo.GetParameters /* initializer */,\r
+                parameterInfo => new ReflectedParameterDescriptor(parameterInfo, this) /* converter */);\r
+        }\r
+\r
+        internal static ReflectedActionDescriptor TryCreateDescriptor(MethodInfo methodInfo, string name, ControllerDescriptor controllerDescriptor) {\r
+            ReflectedActionDescriptor descriptor = new ReflectedActionDescriptor(methodInfo, name, controllerDescriptor, false /* validateMethod */);\r
+            string failedMessage = VerifyActionMethodIsCallable(methodInfo);\r
+            return (failedMessage == null) ? descriptor : null;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedControllerDescriptor.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedControllerDescriptor.cs
new file mode 100644 (file)
index 0000000..990f136
--- /dev/null
@@ -0,0 +1,91 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ReflectedControllerDescriptor : ControllerDescriptor {\r
+\r
+        private ActionDescriptor[] _canonicalActionsCache;\r
+        private readonly Type _controllerType;\r
+        private readonly ActionMethodSelector _selector;\r
+\r
+        public ReflectedControllerDescriptor(Type controllerType) {\r
+            if (controllerType == null) {\r
+                throw new ArgumentNullException("controllerType");\r
+            }\r
+\r
+            _controllerType = controllerType;\r
+            _selector = new ActionMethodSelector(_controllerType);\r
+        }\r
+\r
+        public sealed override Type ControllerType {\r
+            get {\r
+                return _controllerType;\r
+            }\r
+        }\r
+\r
+        public override ActionDescriptor FindAction(ControllerContext controllerContext, string actionName) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (String.IsNullOrEmpty(actionName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName");\r
+            }\r
+\r
+            MethodInfo matched = _selector.FindActionMethod(controllerContext, actionName);\r
+            if (matched == null) {\r
+                return null;\r
+            }\r
+\r
+            return new ReflectedActionDescriptor(matched, actionName, this);\r
+        }\r
+\r
+        private MethodInfo[] GetAllActionMethodsFromSelector() {\r
+            List<MethodInfo> allValidMethods = new List<MethodInfo>();\r
+            allValidMethods.AddRange(_selector.AliasedMethods);\r
+            allValidMethods.AddRange(_selector.NonAliasedMethods.SelectMany(g => g));\r
+            return allValidMethods.ToArray();\r
+        }\r
+\r
+        public override ActionDescriptor[] GetCanonicalActions() {\r
+            ActionDescriptor[] actions = LazilyFetchCanonicalActionsCollection();\r
+\r
+            // need to clone array so that user modifications aren't accidentally stored\r
+            return (ActionDescriptor[])actions.Clone();\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(bool inherit) {\r
+            return ControllerType.GetCustomAttributes(inherit);\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit) {\r
+            return ControllerType.GetCustomAttributes(attributeType, inherit);\r
+        }\r
+\r
+        public override bool IsDefined(Type attributeType, bool inherit) {\r
+            return ControllerType.IsDefined(attributeType, inherit);\r
+        }\r
+\r
+        private ActionDescriptor[] LazilyFetchCanonicalActionsCollection() {\r
+            return DescriptorUtil.LazilyFetchOrCreateDescriptors<MethodInfo, ActionDescriptor>(\r
+                ref _canonicalActionsCache /* cacheLocation */,\r
+                GetAllActionMethodsFromSelector /* initializer */,\r
+                methodInfo => ReflectedActionDescriptor.TryCreateDescriptor(methodInfo, methodInfo.Name, this) /* converter */);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedParameterBindingInfo.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedParameterBindingInfo.cs
new file mode 100644 (file)
index 0000000..0281765
--- /dev/null
@@ -0,0 +1,73 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.ObjectModel;\r
+    using System.Globalization;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    internal class ReflectedParameterBindingInfo : ParameterBindingInfo {\r
+\r
+        private ICollection<string> _exclude = new string[0];\r
+        private ICollection<string> _include = new string[0];\r
+        private readonly ParameterInfo _parameterInfo;\r
+        private string _prefix;\r
+\r
+        public ReflectedParameterBindingInfo(ParameterInfo parameterInfo) {\r
+            _parameterInfo = parameterInfo;\r
+            ReadSettingsFromBindAttribute();\r
+        }\r
+\r
+        public override IModelBinder Binder {\r
+            get {\r
+                IModelBinder binder = ModelBinders.GetBinderFromAttributes(_parameterInfo,\r
+                    () => String.Format(CultureInfo.CurrentUICulture, MvcResources.ReflectedParameterBindingInfo_MultipleConverterAttributes,\r
+                        _parameterInfo.Name, _parameterInfo.Member));\r
+\r
+                return binder;\r
+            }\r
+        }\r
+\r
+        public override ICollection<string> Exclude {\r
+            get {\r
+                return _exclude;\r
+            }\r
+        }\r
+\r
+        public override ICollection<string> Include {\r
+            get {\r
+                return _include;\r
+            }\r
+        }\r
+\r
+        public override string Prefix {\r
+            get {\r
+                return _prefix;\r
+            }\r
+        }\r
+\r
+        private void ReadSettingsFromBindAttribute() {\r
+            BindAttribute attr = (BindAttribute)Attribute.GetCustomAttribute(_parameterInfo, typeof(BindAttribute));\r
+            if (attr == null) {\r
+                return;\r
+            }\r
+\r
+            _exclude = new ReadOnlyCollection<string>(AuthorizeAttribute.SplitString(attr.Exclude));\r
+            _include = new ReadOnlyCollection<string>(AuthorizeAttribute.SplitString(attr.Include));\r
+            _prefix = attr.Prefix;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedParameterDescriptor.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ReflectedParameterDescriptor.cs
new file mode 100644 (file)
index 0000000..357f45e
--- /dev/null
@@ -0,0 +1,90 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.ComponentModel;\r
+    using System.Reflection;\r
+\r
+    public class ReflectedParameterDescriptor : ParameterDescriptor {\r
+\r
+        private readonly ActionDescriptor _actionDescriptor;\r
+        private readonly ReflectedParameterBindingInfo _bindingInfo;\r
+\r
+        public ReflectedParameterDescriptor(ParameterInfo parameterInfo, ActionDescriptor actionDescriptor) {\r
+            if (parameterInfo == null) {\r
+                throw new ArgumentNullException("parameterInfo");\r
+            }\r
+            if (actionDescriptor == null) {\r
+                throw new ArgumentNullException("actionDescriptor");\r
+            }\r
+\r
+            ParameterInfo = parameterInfo;\r
+            _actionDescriptor = actionDescriptor;\r
+            _bindingInfo = new ReflectedParameterBindingInfo(parameterInfo);\r
+        }\r
+\r
+        public override ActionDescriptor ActionDescriptor {\r
+            get {\r
+                return _actionDescriptor;\r
+            }\r
+        }\r
+\r
+        public override ParameterBindingInfo BindingInfo {\r
+            get {\r
+                return _bindingInfo;\r
+            }\r
+        }\r
+\r
+        public override object DefaultValue {\r
+            get {\r
+                object value;\r
+                if (ParameterInfoUtil.TryGetDefaultValue(ParameterInfo, out value)) {\r
+                    return value;\r
+                }\r
+                else {\r
+                    return base.DefaultValue;\r
+                }\r
+            }\r
+        }\r
+\r
+        public ParameterInfo ParameterInfo {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public override string ParameterName {\r
+            get {\r
+                return ParameterInfo.Name;\r
+            }\r
+        }\r
+\r
+        public override Type ParameterType {\r
+            get {\r
+                return ParameterInfo.ParameterType;\r
+            }\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(bool inherit) {\r
+            return ParameterInfo.GetCustomAttributes(inherit);\r
+        }\r
+\r
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit) {\r
+            return ParameterInfo.GetCustomAttributes(attributeType, inherit);\r
+        }\r
+\r
+        public override bool IsDefined(Type attributeType, bool inherit) {\r
+            return ParameterInfo.IsDefined(attributeType, inherit);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RegularExpressionAttributeAdapter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RegularExpressionAttributeAdapter.cs
new file mode 100644 (file)
index 0000000..f175502
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel.DataAnnotations;\r
+\r
+    public class RegularExpressionAttributeAdapter : DataAnnotationsModelValidator<RegularExpressionAttribute> {\r
+        public RegularExpressionAttributeAdapter(ModelMetadata metadata, ControllerContext context, RegularExpressionAttribute attribute)\r
+            : base(metadata, context, attribute) {\r
+        }\r
+\r
+        public override IEnumerable<ModelClientValidationRule> GetClientValidationRules() {\r
+            return new[] { new ModelClientValidationRegexRule(ErrorMessage, Attribute.Pattern) };\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RequireHttpsAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RequireHttpsAttribute.cs
new file mode 100644 (file)
index 0000000..dff4c92
--- /dev/null
@@ -0,0 +1,47 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes",\r
+        Justification = "Unsealed because type contains virtual extensibility points.")]\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]\r
+    public class RequireHttpsAttribute : FilterAttribute, IAuthorizationFilter {\r
+\r
+        public virtual void OnAuthorization(AuthorizationContext filterContext) {\r
+            if (filterContext == null) {\r
+                throw new ArgumentNullException("filterContext");\r
+            }\r
+\r
+            if (!filterContext.HttpContext.Request.IsSecureConnection) {\r
+                HandleNonHttpsRequest(filterContext);\r
+            }\r
+        }\r
+\r
+        protected virtual void HandleNonHttpsRequest(AuthorizationContext filterContext) {\r
+            // only redirect for GET requests, otherwise the browser might not propagate the verb and request\r
+            // body correctly.\r
+\r
+            if (!String.Equals(filterContext.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase)) {\r
+                throw new InvalidOperationException(MvcResources.RequireHttpsAttribute_MustUseSsl);\r
+            }\r
+\r
+            // redirect to HTTPS version of page\r
+            string url = "https://" + filterContext.HttpContext.Request.Url.Host + filterContext.HttpContext.Request.RawUrl;\r
+            filterContext.Result = new RedirectResult(url);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RequiredAttributeAdapter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RequiredAttributeAdapter.cs
new file mode 100644 (file)
index 0000000..edb7dc3
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel.DataAnnotations;\r
+\r
+    public class RequiredAttributeAdapter : DataAnnotationsModelValidator<RequiredAttribute> {\r
+        public RequiredAttributeAdapter(ModelMetadata metadata, ControllerContext context, RequiredAttribute attribute)\r
+            : base(metadata, context, attribute) {\r
+        }\r
+\r
+        public override IEnumerable<ModelClientValidationRule> GetClientValidationRules() {\r
+            return new[] { new ModelClientValidationRequiredRule(ErrorMessage) };\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Resources/MvcResources.Designer.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Resources/MvcResources.Designer.cs
new file mode 100644 (file)
index 0000000..4be3e6b
--- /dev/null
@@ -0,0 +1,797 @@
+//------------------------------------------------------------------------------\r
+// <auto-generated>\r
+//     This code was generated by a tool.\r
+//     Runtime Version:2.0.50727.4200\r
+//\r
+//     Changes to this file may cause incorrect behavior and will be lost if\r
+//     the code is regenerated.\r
+// </auto-generated>\r
+//------------------------------------------------------------------------------\r
+\r
+namespace System.Web.Mvc.Resources {\r
+    using System;\r
+    \r
+    \r
+    /// <summary>\r
+    ///   A strongly-typed resource class, for looking up localized strings, etc.\r
+    /// </summary>\r
+    // This class was auto-generated by the StronglyTypedResourceBuilder\r
+    // class via a tool like ResGen or Visual Studio.\r
+    // To add or remove a member, edit your .ResX file then rerun ResGen\r
+    // with the /str option, or rebuild your VS project.\r
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]\r
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\r
+    internal class MvcResources {\r
+        \r
+        private static global::System.Resources.ResourceManager resourceMan;\r
+        \r
+        private static global::System.Globalization.CultureInfo resourceCulture;\r
+        \r
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]\r
+        internal MvcResources() {\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Returns the cached ResourceManager instance used by this class.\r
+        /// </summary>\r
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\r
+        internal static global::System.Resources.ResourceManager ResourceManager {\r
+            get {\r
+                if (object.ReferenceEquals(resourceMan, null)) {\r
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("System.Web.Mvc.Resources.MvcResources", typeof(MvcResources).Assembly);\r
+                    resourceMan = temp;\r
+                }\r
+                return resourceMan;\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Overrides the current thread's CurrentUICulture property for all\r
+        ///   resource lookups using this strongly typed resource class.\r
+        /// </summary>\r
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\r
+        internal static global::System.Globalization.CultureInfo Culture {\r
+            get {\r
+                return resourceCulture;\r
+            }\r
+            set {\r
+                resourceCulture = value;\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The current request for action &apos;{0}&apos; on controller type &apos;{1}&apos; is ambiguous between the following action methods:{2}.\r
+        /// </summary>\r
+        internal static string ActionMethodSelector_AmbiguousMatch {\r
+            get {\r
+                return ResourceManager.GetString("ActionMethodSelector_AmbiguousMatch", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to {0} on type {1}.\r
+        /// </summary>\r
+        internal static string ActionMethodSelector_AmbiguousMatchType {\r
+            get {\r
+                return ResourceManager.GetString("ActionMethodSelector_AmbiguousMatchType", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to A required anti-forgery token was not supplied or was invalid..\r
+        /// </summary>\r
+        internal static string AntiForgeryToken_ValidationFailed {\r
+            get {\r
+                return ResourceManager.GetString("AntiForgeryToken_ValidationFailed", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Lookup for method &apos;{0}&apos; on controller type &apos;{1}&apos; failed because of an ambiguity between the following methods:{2}.\r
+        /// </summary>\r
+        internal static string AsyncActionMethodSelector_AmbiguousMethodMatch {\r
+            get {\r
+                return ResourceManager.GetString("AsyncActionMethodSelector_AmbiguousMethodMatch", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Could not locate a method named &apos;{0}&apos; on controller type {1}..\r
+        /// </summary>\r
+        internal static string AsyncActionMethodSelector_CouldNotFindMethod {\r
+            get {\r
+                return ResourceManager.GetString("AsyncActionMethodSelector_CouldNotFindMethod", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The provided IAsyncResult has already been consumed..\r
+        /// </summary>\r
+        internal static string AsyncCommon_AsyncResultAlreadyConsumed {\r
+            get {\r
+                return ResourceManager.GetString("AsyncCommon_AsyncResultAlreadyConsumed", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The controller of type &apos;{0}&apos; must subclass AsyncController or implement the IAsyncManagerContainer interface..\r
+        /// </summary>\r
+        internal static string AsyncCommon_ControllerMustImplementIAsyncManagerContainer {\r
+            get {\r
+                return ResourceManager.GetString("AsyncCommon_ControllerMustImplementIAsyncManagerContainer", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The provided IAsyncResult is not valid for this method..\r
+        /// </summary>\r
+        internal static string AsyncCommon_InvalidAsyncResult {\r
+            get {\r
+                return ResourceManager.GetString("AsyncCommon_InvalidAsyncResult", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The timeout value must be non-negative or Timeout.Infinite..\r
+        /// </summary>\r
+        internal static string AsyncCommon_InvalidTimeout {\r
+            get {\r
+                return ResourceManager.GetString("AsyncCommon_InvalidTimeout", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The action &apos;{0}&apos; is accessible only by a child request..\r
+        /// </summary>\r
+        internal static string ChildActionOnlyAttribute_MustBeInChildRequest {\r
+            get {\r
+                return ResourceManager.GetString("ChildActionOnlyAttribute_MustBeInChildRequest", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The field {0} must be a number..\r
+        /// </summary>\r
+        internal static string ClientDataTypeModelValidatorProvider_FieldMustBeNumeric {\r
+            get {\r
+                return ResourceManager.GetString("ClientDataTypeModelValidatorProvider_FieldMustBeNumeric", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to No route in the route table matches the supplied values..\r
+        /// </summary>\r
+        internal static string Common_NoRouteMatched {\r
+            get {\r
+                return ResourceManager.GetString("Common_NoRouteMatched", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Value cannot be null or empty..\r
+        /// </summary>\r
+        internal static string Common_NullOrEmpty {\r
+            get {\r
+                return ResourceManager.GetString("Common_NullOrEmpty", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The partial view &apos;{0}&apos; was not found. The following locations were searched:{1}.\r
+        /// </summary>\r
+        internal static string Common_PartialViewNotFound {\r
+            get {\r
+                return ResourceManager.GetString("Common_PartialViewNotFound", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The property &apos;{0}&apos; cannot be null or empty..\r
+        /// </summary>\r
+        internal static string Common_PropertyCannotBeNullOrEmpty {\r
+            get {\r
+                return ResourceManager.GetString("Common_PropertyCannotBeNullOrEmpty", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The property {0}.{1} could not be found..\r
+        /// </summary>\r
+        internal static string Common_PropertyNotFound {\r
+            get {\r
+                return ResourceManager.GetString("Common_PropertyNotFound", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to False.\r
+        /// </summary>\r
+        internal static string Common_TriState_False {\r
+            get {\r
+                return ResourceManager.GetString("Common_TriState_False", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Not Set.\r
+        /// </summary>\r
+        internal static string Common_TriState_NotSet {\r
+            get {\r
+                return ResourceManager.GetString("Common_TriState_NotSet", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to True.\r
+        /// </summary>\r
+        internal static string Common_TriState_True {\r
+            get {\r
+                return ResourceManager.GetString("Common_TriState_True", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The type {0} must derive from {1}.\r
+        /// </summary>\r
+        internal static string Common_TypeMustDriveFromType {\r
+            get {\r
+                return ResourceManager.GetString("Common_TypeMustDriveFromType", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The value &apos;{0}&apos; is invalid..\r
+        /// </summary>\r
+        internal static string Common_ValueNotValidForProperty {\r
+            get {\r
+                return ResourceManager.GetString("Common_ValueNotValidForProperty", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The view &apos;{0}&apos; or its master was not found. The following locations were searched:{1}.\r
+        /// </summary>\r
+        internal static string Common_ViewNotFound {\r
+            get {\r
+                return ResourceManager.GetString("Common_ViewNotFound", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to A public action method &apos;{0}&apos; was not found on controller &apos;{1}&apos;..\r
+        /// </summary>\r
+        internal static string Controller_UnknownAction {\r
+            get {\r
+                return ResourceManager.GetString("Controller_UnknownAction", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The model of type &apos;{0}&apos; could not be updated..\r
+        /// </summary>\r
+        internal static string Controller_UpdateModel_UpdateUnsuccessful {\r
+            get {\r
+                return ResourceManager.GetString("Controller_UpdateModel_UpdateUnsuccessful", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The model of type &apos;{0}&apos; is not valid..\r
+        /// </summary>\r
+        internal static string Controller_Validate_ValidationFailed {\r
+            get {\r
+                return ResourceManager.GetString("Controller_Validate_ValidationFailed", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to A single instance of controller &apos;{0}&apos; cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of the controller for each request..\r
+        /// </summary>\r
+        internal static string ControllerBase_CannotHandleMultipleRequests {\r
+            get {\r
+                return ResourceManager.GetString("ControllerBase_CannotHandleMultipleRequests", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to An error occurred when trying to create the IControllerFactory &apos;{0}&apos;. Make sure that the controller factory has a public parameterless constructor..\r
+        /// </summary>\r
+        internal static string ControllerBuilder_ErrorCreatingControllerFactory {\r
+            get {\r
+                return ResourceManager.GetString("ControllerBuilder_ErrorCreatingControllerFactory", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The IControllerFactory &apos;{0}&apos; did not return a controller for the name &apos;{1}&apos;..\r
+        /// </summary>\r
+        internal static string ControllerBuilder_FactoryReturnedNull {\r
+            get {\r
+                return ResourceManager.GetString("ControllerBuilder_FactoryReturnedNull", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The controller factory type &apos;{0}&apos; must implement the IControllerFactory interface..\r
+        /// </summary>\r
+        internal static string ControllerBuilder_MissingIControllerFactory {\r
+            get {\r
+                return ResourceManager.GetString("ControllerBuilder_MissingIControllerFactory", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to {0} has a DisplayColumn attribute for {1}, but property {1} does not exist..\r
+        /// </summary>\r
+        internal static string DataAnnotationsModelMetadataProvider_UnknownProperty {\r
+            get {\r
+                return ResourceManager.GetString("DataAnnotationsModelMetadataProvider_UnknownProperty", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to {0} has a DisplayColumn attribute for {1}, but property {1} does not have a public getter..\r
+        /// </summary>\r
+        internal static string DataAnnotationsModelMetadataProvider_UnreadableProperty {\r
+            get {\r
+                return ResourceManager.GetString("DataAnnotationsModelMetadataProvider_UnreadableProperty", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The type {0} must have a public constructor which accepts three parameters of types {1}, {2}, and {3}.\r
+        /// </summary>\r
+        internal static string DataAnnotationsModelValidatorProvider_ConstructorRequirements {\r
+            get {\r
+                return ResourceManager.GetString("DataAnnotationsModelValidatorProvider_ConstructorRequirements", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Multiple types were found that match the controller named &apos;{0}&apos;. This can happen if the route that services this request does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the &apos;MapRoute&apos; method that takes a &apos;namespaces&apos; parameter.\r
+        ///\r
+        ///The request for &apos;{0}&apos; has found the following matching controllers:{1}.\r
+        /// </summary>\r
+        internal static string DefaultControllerFactory_ControllerNameAmbiguous_WithoutRouteUrl {\r
+            get {\r
+                return ResourceManager.GetString("DefaultControllerFactory_ControllerNameAmbiguous_WithoutRouteUrl", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Multiple types were found that match the controller named &apos;{0}&apos;. This can happen if the route that services this request (&apos;{1}&apos;) does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the &apos;MapRoute&apos; method that takes a &apos;namespaces&apos; parameter.\r
+        ///\r
+        ///The request for &apos;{0}&apos; has found the following matching controllers:{2}.\r
+        /// </summary>\r
+        internal static string DefaultControllerFactory_ControllerNameAmbiguous_WithRouteUrl {\r
+            get {\r
+                return ResourceManager.GetString("DefaultControllerFactory_ControllerNameAmbiguous_WithRouteUrl", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to An error occurred when trying to create a controller of type &apos;{0}&apos;. Make sure that the controller has a parameterless public constructor..\r
+        /// </summary>\r
+        internal static string DefaultControllerFactory_ErrorCreatingController {\r
+            get {\r
+                return ResourceManager.GetString("DefaultControllerFactory_ErrorCreatingController", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The controller for path &apos;{0}&apos; was not found or does not implement IController..\r
+        /// </summary>\r
+        internal static string DefaultControllerFactory_NoControllerFound {\r
+            get {\r
+                return ResourceManager.GetString("DefaultControllerFactory_NoControllerFound", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The controller type &apos;{0}&apos; must implement IController..\r
+        /// </summary>\r
+        internal static string DefaultControllerFactory_TypeDoesNotSubclassControllerBase {\r
+            get {\r
+                return ResourceManager.GetString("DefaultControllerFactory_TypeDoesNotSubclassControllerBase", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The value &apos;{0}&apos; is not valid for {1}..\r
+        /// </summary>\r
+        internal static string DefaultModelBinder_ValueInvalid {\r
+            get {\r
+                return ResourceManager.GetString("DefaultModelBinder_ValueInvalid", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to A value is required..\r
+        /// </summary>\r
+        internal static string DefaultModelBinder_ValueRequired {\r
+            get {\r
+                return ResourceManager.GetString("DefaultModelBinder_ValueRequired", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The number of ticks for the TimeSpan value must be greater than or equal to 0..\r
+        /// </summary>\r
+        internal static string DefaultViewLocationCache_NegativeTimeSpan {\r
+            get {\r
+                return ResourceManager.GetString("DefaultViewLocationCache_NegativeTimeSpan", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The type &apos;{0}&apos; does not inherit from Exception..\r
+        /// </summary>\r
+        internal static string ExceptionViewAttribute_NonExceptionType {\r
+            get {\r
+                return ResourceManager.GetString("ExceptionViewAttribute_NonExceptionType", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The expression compiler was unable to evaluate the indexer expression &apos;{0}&apos; because it references the model parameter &apos;{1}&apos; which is unavailable..\r
+        /// </summary>\r
+        internal static string ExpressionHelper_InvalidIndexerExpression {\r
+            get {\r
+                return ResourceManager.GetString("ExpressionHelper_InvalidIndexerExpression", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Order must be greater than or equal to -1..\r
+        /// </summary>\r
+        internal static string FilterAttribute_OrderOutOfRange {\r
+            get {\r
+                return ResourceManager.GetString("FilterAttribute_OrderOutOfRange", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The GET and POST HTTP methods are not supported..\r
+        /// </summary>\r
+        internal static string HtmlHelper_InvalidHttpMethod {\r
+            get {\r
+                return ResourceManager.GetString("HtmlHelper_InvalidHttpMethod", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The specified HttpVerbs value is not supported. The supported values are Delete, Head, and Put..\r
+        /// </summary>\r
+        internal static string HtmlHelper_InvalidHttpVerb {\r
+            get {\r
+                return ResourceManager.GetString("HtmlHelper_InvalidHttpVerb", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to There is no ViewData item of type &apos;{1}&apos; that has the key &apos;{0}&apos;..\r
+        /// </summary>\r
+        internal static string HtmlHelper_MissingSelectData {\r
+            get {\r
+                return ResourceManager.GetString("HtmlHelper_MissingSelectData", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The value must be greater than or equal to zero..\r
+        /// </summary>\r
+        internal static string HtmlHelper_TextAreaParameterOutOfRange {\r
+            get {\r
+                return ResourceManager.GetString("HtmlHelper_TextAreaParameterOutOfRange", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The ViewData item that has the key &apos;{0}&apos; is of type &apos;{1}&apos; but must be of type &apos;{2}&apos;..\r
+        /// </summary>\r
+        internal static string HtmlHelper_WrongSelectDataType {\r
+            get {\r
+                return ResourceManager.GetString("HtmlHelper_WrongSelectDataType", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet..\r
+        /// </summary>\r
+        internal static string JsonRequest_GetNotAllowed {\r
+            get {\r
+                return ResourceManager.GetString("JsonRequest_GetNotAllowed", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to An error occurred when trying to create the IModelBinder &apos;{0}&apos;. Make sure that the binder has a public parameterless constructor..\r
+        /// </summary>\r
+        internal static string ModelBinderAttribute_ErrorCreatingModelBinder {\r
+            get {\r
+                return ResourceManager.GetString("ModelBinderAttribute_ErrorCreatingModelBinder", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The type &apos;{0}&apos; does not implement the IModelBinder interface..\r
+        /// </summary>\r
+        internal static string ModelBinderAttribute_TypeNotIModelBinder {\r
+            get {\r
+                return ResourceManager.GetString("ModelBinderAttribute_TypeNotIModelBinder", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The type &apos;{0}&apos; contains multiple attributes that inherit from CustomModelBinderAttribute..\r
+        /// </summary>\r
+        internal static string ModelBinderDictionary_MultipleAttributes {\r
+            get {\r
+                return ResourceManager.GetString("ModelBinderDictionary_MultipleAttributes", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to This property setter is obsolete, because its value is derived from ModelMetadata.Model now..\r
+        /// </summary>\r
+        internal static string ModelMetadata_PropertyNotSettable {\r
+            get {\r
+                return ResourceManager.GetString("ModelMetadata_PropertyNotSettable", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The associated metadata type for type &apos;{0}&apos; contains the following unknown properties or fields: {1}. Please make sure that the names of these members match the names of the properties on the main type..\r
+        /// </summary>\r
+        internal static string PrivateAssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties {\r
+            get {\r
+                return ResourceManager.GetString("PrivateAssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties" +\r
+                        "", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Child actions are not allowed to perform redirect actions..\r
+        /// </summary>\r
+        internal static string RedirectAction_CannotRedirectInChildAction {\r
+            get {\r
+                return ResourceManager.GetString("RedirectAction_CannotRedirectInChildAction", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Cannot create a descriptor for instance method &apos;{0}&apos; on type &apos;{1}&apos; because the type does not derive from ControllerBase..\r
+        /// </summary>\r
+        internal static string ReflectedActionDescriptor_CannotCallInstanceMethodOnNonControllerType {\r
+            get {\r
+                return ResourceManager.GetString("ReflectedActionDescriptor_CannotCallInstanceMethodOnNonControllerType", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Cannot call action method &apos;{0}&apos; on controller &apos;{1}&apos; because the parameter &apos;{2}&apos; is passed by reference..\r
+        /// </summary>\r
+        internal static string ReflectedActionDescriptor_CannotCallMethodsWithOutOrRefParameters {\r
+            get {\r
+                return ResourceManager.GetString("ReflectedActionDescriptor_CannotCallMethodsWithOutOrRefParameters", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Cannot call action method &apos;{0}&apos; on controller &apos;{1}&apos; because the action method is a generic method..\r
+        /// </summary>\r
+        internal static string ReflectedActionDescriptor_CannotCallOpenGenericMethods {\r
+            get {\r
+                return ResourceManager.GetString("ReflectedActionDescriptor_CannotCallOpenGenericMethods", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The parameters dictionary contains a null entry for parameter &apos;{0}&apos; of non-nullable type &apos;{1}&apos; for method &apos;{2}&apos; in &apos;{3}&apos;. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter..\r
+        /// </summary>\r
+        internal static string ReflectedActionDescriptor_ParameterCannotBeNull {\r
+            get {\r
+                return ResourceManager.GetString("ReflectedActionDescriptor_ParameterCannotBeNull", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The parameters dictionary does not contain an entry for parameter &apos;{0}&apos; of type &apos;{1}&apos; for method &apos;{2}&apos; in &apos;{3}&apos;. The dictionary must contain an entry for each parameter, including parameters that have null values..\r
+        /// </summary>\r
+        internal static string ReflectedActionDescriptor_ParameterNotInDictionary {\r
+            get {\r
+                return ResourceManager.GetString("ReflectedActionDescriptor_ParameterNotInDictionary", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The parameters dictionary contains an invalid entry for parameter &apos;{0}&apos; for method &apos;{1}&apos; in &apos;{2}&apos;. The dictionary contains a value of type &apos;{3}&apos;, but the parameter requires a value of type &apos;{4}&apos;..\r
+        /// </summary>\r
+        internal static string ReflectedActionDescriptor_ParameterValueHasWrongType {\r
+            get {\r
+                return ResourceManager.GetString("ReflectedActionDescriptor_ParameterValueHasWrongType", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The asynchronous action method &apos;{0}&apos; cannot be executed synchronously..\r
+        /// </summary>\r
+        internal static string ReflectedAsyncActionDescriptor_CannotExecuteSynchronously {\r
+            get {\r
+                return ResourceManager.GetString("ReflectedAsyncActionDescriptor_CannotExecuteSynchronously", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The parameter &apos;{0}&apos; on method &apos;{1}&apos; contains multiple attributes that inherit from CustomModelBinderAttribute..\r
+        /// </summary>\r
+        internal static string ReflectedParameterBindingInfo_MultipleConverterAttributes {\r
+            get {\r
+                return ResourceManager.GetString("ReflectedParameterBindingInfo_MultipleConverterAttributes", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The requested resource can only be accessed via SSL..\r
+        /// </summary>\r
+        internal static string RequireHttpsAttribute_MustUseSsl {\r
+            get {\r
+                return ResourceManager.GetString("RequireHttpsAttribute_MustUseSsl", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The SessionStateTempDataProvider class requires session state to be enabled..\r
+        /// </summary>\r
+        internal static string SessionStateTempDataProvider_SessionStateDisabled {\r
+            get {\r
+                return ResourceManager.GetString("SessionStateTempDataProvider_SessionStateDisabled", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to An operation that crossed a synchronization context failed. See the inner exception for more information..\r
+        /// </summary>\r
+        internal static string SynchronizationContextUtil_ExceptionThrown {\r
+            get {\r
+                return ResourceManager.GetString("SynchronizationContextUtil_ExceptionThrown", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Unable to locate an appropriate template for type {0}..\r
+        /// </summary>\r
+        internal static string TemplateHelpers_NoTemplate {\r
+            get {\r
+                return ResourceManager.GetString("TemplateHelpers_NoTemplate", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions..\r
+        /// </summary>\r
+        internal static string TemplateHelpers_TemplateLimitations {\r
+            get {\r
+                return ResourceManager.GetString("TemplateHelpers_TemplateLimitations", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The Collection template was used with an object of type &apos;{0}&apos;, which does not implement System.IEnumerable..\r
+        /// </summary>\r
+        internal static string Templates_TypeMustImplementIEnumerable {\r
+            get {\r
+                return ResourceManager.GetString("Templates_TypeMustImplementIEnumerable", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to This file is automatically generated. Please do not modify the contents of this file..\r
+        /// </summary>\r
+        internal static string TypeCache_DoNotModify {\r
+            get {\r
+                return ResourceManager.GetString("TypeCache_DoNotModify", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The parameter conversion from type &apos;{0}&apos; to type &apos;{1}&apos; failed. See the inner exception for more information..\r
+        /// </summary>\r
+        internal static string ValueProviderResult_ConversionThrew {\r
+            get {\r
+                return ResourceManager.GetString("ValueProviderResult_ConversionThrew", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The parameter conversion from type &apos;{0}&apos; to type &apos;{1}&apos; failed because no type converter can convert between these types..\r
+        /// </summary>\r
+        internal static string ValueProviderResult_NoConverterExists {\r
+            get {\r
+                return ResourceManager.GetString("ValueProviderResult_NoConverterExists", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The model item passed into the dictionary is null, but this dictionary requires a non-null model item of type &apos;{0}&apos;..\r
+        /// </summary>\r
+        internal static string ViewDataDictionary_ModelCannotBeNull {\r
+            get {\r
+                return ResourceManager.GetString("ViewDataDictionary_ModelCannotBeNull", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The model item passed into the dictionary is of type &apos;{0}&apos;, but this dictionary requires a model item of type &apos;{1}&apos;..\r
+        /// </summary>\r
+        internal static string ViewDataDictionary_WrongTModelType {\r
+            get {\r
+                return ResourceManager.GetString("ViewDataDictionary_WrongTModelType", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to A ViewMasterPage can be used only with content pages that derive from ViewPage or ViewPage&lt;TViewItem&gt;..\r
+        /// </summary>\r
+        internal static string ViewMasterPage_RequiresViewPage {\r
+            get {\r
+                return ResourceManager.GetString("ViewMasterPage_RequiresViewPage", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Execution of the child request failed. Please examine the InnerException for more information..\r
+        /// </summary>\r
+        internal static string ViewPageHttpHandlerWrapper_ExceptionOccurred {\r
+            get {\r
+                return ResourceManager.GetString("ViewPageHttpHandlerWrapper_ExceptionOccurred", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The ViewUserControl &apos;{0}&apos; cannot find an IViewDataContainer object. The ViewUserControl must be inside a ViewPage, a ViewMasterPage, or another ViewUserControl..\r
+        /// </summary>\r
+        internal static string ViewUserControl_RequiresViewDataProvider {\r
+            get {\r
+                return ResourceManager.GetString("ViewUserControl_RequiresViewDataProvider", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to A ViewUserControl can be used only in pages that derive from ViewPage or ViewPage&lt;TViewItem&gt;..\r
+        /// </summary>\r
+        internal static string ViewUserControl_RequiresViewPage {\r
+            get {\r
+                return ResourceManager.GetString("ViewUserControl_RequiresViewPage", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to A master name cannot be specified when the view is a ViewUserControl..\r
+        /// </summary>\r
+        internal static string WebFormViewEngine_UserControlCannotHaveMaster {\r
+            get {\r
+                return ResourceManager.GetString("WebFormViewEngine_UserControlCannotHaveMaster", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The view found at &apos;{0}&apos; was not created..\r
+        /// </summary>\r
+        internal static string WebFormViewEngine_ViewCouldNotBeCreated {\r
+            get {\r
+                return ResourceManager.GetString("WebFormViewEngine_ViewCouldNotBeCreated", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The view at &apos;{0}&apos; must derive from ViewPage, ViewPage&lt;TViewData&gt;, ViewUserControl, or ViewUserControl&lt;TViewData&gt;..\r
+        /// </summary>\r
+        internal static string WebFormViewEngine_WrongViewBase {\r
+            get {\r
+                return ResourceManager.GetString("WebFormViewEngine_WrongViewBase", resourceCulture);\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Resources/MvcResources.resx b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Resources/MvcResources.resx
new file mode 100644 (file)
index 0000000..6e29c4d
--- /dev/null
@@ -0,0 +1,367 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <data name="ActionMethodSelector_AmbiguousMatch" xml:space="preserve">\r
+    <value>The current request for action '{0}' on controller type '{1}' is ambiguous between the following action methods:{2}</value>\r
+  </data>\r
+  <data name="Common_NoRouteMatched" xml:space="preserve">\r
+    <value>No route in the route table matches the supplied values.</value>\r
+  </data>\r
+  <data name="Common_NullOrEmpty" xml:space="preserve">\r
+    <value>Value cannot be null or empty.</value>\r
+  </data>\r
+  <data name="Common_PartialViewNotFound" xml:space="preserve">\r
+    <value>The partial view '{0}' was not found. The following locations were searched:{1}</value>\r
+  </data>\r
+  <data name="Common_PropertyCannotBeNullOrEmpty" xml:space="preserve">\r
+    <value>The property '{0}' cannot be null or empty.</value>\r
+  </data>\r
+  <data name="Common_ViewNotFound" xml:space="preserve">\r
+    <value>The view '{0}' or its master was not found. The following locations were searched:{1}</value>\r
+  </data>\r
+  <data name="ControllerBuilder_ErrorCreatingControllerFactory" xml:space="preserve">\r
+    <value>An error occurred when trying to create the IControllerFactory '{0}'. Make sure that the controller factory has a public parameterless constructor.</value>\r
+  </data>\r
+  <data name="ControllerBuilder_FactoryReturnedNull" xml:space="preserve">\r
+    <value>The IControllerFactory '{0}' did not return a controller for the name '{1}'.</value>\r
+  </data>\r
+  <data name="ControllerBuilder_MissingIControllerFactory" xml:space="preserve">\r
+    <value>The controller factory type '{0}' must implement the IControllerFactory interface.</value>\r
+  </data>\r
+  <data name="Controller_UnknownAction" xml:space="preserve">\r
+    <value>A public action method '{0}' was not found on controller '{1}'.</value>\r
+  </data>\r
+  <data name="DefaultControllerFactory_ErrorCreatingController" xml:space="preserve">\r
+    <value>An error occurred when trying to create a controller of type '{0}'. Make sure that the controller has a parameterless public constructor.</value>\r
+  </data>\r
+  <data name="DefaultControllerFactory_NoControllerFound" xml:space="preserve">\r
+    <value>The controller for path '{0}' was not found or does not implement IController.</value>\r
+  </data>\r
+  <data name="DefaultControllerFactory_TypeDoesNotSubclassControllerBase" xml:space="preserve">\r
+    <value>The controller type '{0}' must implement IController.</value>\r
+  </data>\r
+  <data name="ValueProviderResult_ConversionThrew" xml:space="preserve">\r
+    <value>The parameter conversion from type '{0}' to type '{1}' failed. See the inner exception for more information.</value>\r
+  </data>\r
+  <data name="ValueProviderResult_NoConverterExists" xml:space="preserve">\r
+    <value>The parameter conversion from type '{0}' to type '{1}' failed because no type converter can convert between these types.</value>\r
+  </data>\r
+  <data name="ExceptionViewAttribute_NonExceptionType" xml:space="preserve">\r
+    <value>The type '{0}' does not inherit from Exception.</value>\r
+  </data>\r
+  <data name="FilterAttribute_OrderOutOfRange" xml:space="preserve">\r
+    <value>Order must be greater than or equal to -1.</value>\r
+  </data>\r
+  <data name="HtmlHelper_MissingSelectData" xml:space="preserve">\r
+    <value>There is no ViewData item of type '{1}' that has the key '{0}'.</value>\r
+  </data>\r
+  <data name="HtmlHelper_TextAreaParameterOutOfRange" xml:space="preserve">\r
+    <value>The value must be greater than or equal to zero.</value>\r
+  </data>\r
+  <data name="HtmlHelper_WrongSelectDataType" xml:space="preserve">\r
+    <value>The ViewData item that has the key '{0}' is of type '{1}' but must be of type '{2}'.</value>\r
+  </data>\r
+  <data name="ModelBinderAttribute_ErrorCreatingModelBinder" xml:space="preserve">\r
+    <value>An error occurred when trying to create the IModelBinder '{0}'. Make sure that the binder has a public parameterless constructor.</value>\r
+  </data>\r
+  <data name="ModelBinderAttribute_TypeNotIModelBinder" xml:space="preserve">\r
+    <value>The type '{0}' does not implement the IModelBinder interface.</value>\r
+  </data>\r
+  <data name="ModelBinderDictionary_MultipleAttributes" xml:space="preserve">\r
+    <value>The type '{0}' contains multiple attributes that inherit from CustomModelBinderAttribute.</value>\r
+  </data>\r
+  <data name="SessionStateTempDataProvider_SessionStateDisabled" xml:space="preserve">\r
+    <value>The SessionStateTempDataProvider class requires session state to be enabled.</value>\r
+  </data>\r
+  <data name="ViewDataDictionary_WrongTModelType" xml:space="preserve">\r
+    <value>The model item passed into the dictionary is of type '{0}', but this dictionary requires a model item of type '{1}'.</value>\r
+  </data>\r
+  <data name="ViewMasterPage_RequiresViewPage" xml:space="preserve">\r
+    <value>A ViewMasterPage can be used only with content pages that derive from ViewPage or ViewPage&lt;TViewItem&gt;.</value>\r
+  </data>\r
+  <data name="ViewUserControl_RequiresViewDataProvider" xml:space="preserve">\r
+    <value>The ViewUserControl '{0}' cannot find an IViewDataContainer object. The ViewUserControl must be inside a ViewPage, a ViewMasterPage, or another ViewUserControl.</value>\r
+  </data>\r
+  <data name="ViewUserControl_RequiresViewPage" xml:space="preserve">\r
+    <value>A ViewUserControl can be used only in pages that derive from ViewPage or ViewPage&lt;TViewItem&gt;.</value>\r
+  </data>\r
+  <data name="WebFormViewEngine_UserControlCannotHaveMaster" xml:space="preserve">\r
+    <value>A master name cannot be specified when the view is a ViewUserControl.</value>\r
+  </data>\r
+  <data name="WebFormViewEngine_ViewCouldNotBeCreated" xml:space="preserve">\r
+    <value>The view found at '{0}' was not created.</value>\r
+  </data>\r
+  <data name="WebFormViewEngine_WrongViewBase" xml:space="preserve">\r
+    <value>The view at '{0}' must derive from ViewPage, ViewPage&lt;TViewData&gt;, ViewUserControl, or ViewUserControl&lt;TViewData&gt;.</value>\r
+  </data>\r
+  <data name="Common_ValueNotValidForProperty" xml:space="preserve">\r
+    <value>The value '{0}' is invalid.</value>\r
+  </data>\r
+  <data name="ActionMethodSelector_AmbiguousMatchType" xml:space="preserve">\r
+    <value>{0} on type {1}</value>\r
+  </data>\r
+  <data name="Controller_UpdateModel_UpdateUnsuccessful" xml:space="preserve">\r
+    <value>The model of type '{0}' could not be updated.</value>\r
+  </data>\r
+  <data name="DefaultModelBinder_ValueRequired" xml:space="preserve">\r
+    <value>A value is required.</value>\r
+  </data>\r
+  <data name="ReflectedActionDescriptor_ParameterCannotBeNull" xml:space="preserve">\r
+    <value>The parameters dictionary contains a null entry for parameter '{0}' of non-nullable type '{1}' for method '{2}' in '{3}'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.</value>\r
+  </data>\r
+  <data name="ReflectedActionDescriptor_ParameterNotInDictionary" xml:space="preserve">\r
+    <value>The parameters dictionary does not contain an entry for parameter '{0}' of type '{1}' for method '{2}' in '{3}'. The dictionary must contain an entry for each parameter, including parameters that have null values.</value>\r
+  </data>\r
+  <data name="ReflectedActionDescriptor_ParameterValueHasWrongType" xml:space="preserve">\r
+    <value>The parameters dictionary contains an invalid entry for parameter '{0}' for method '{1}' in '{2}'. The dictionary contains a value of type '{3}', but the parameter requires a value of type '{4}'.</value>\r
+  </data>\r
+  <data name="ReflectedParameterBindingInfo_MultipleConverterAttributes" xml:space="preserve">\r
+    <value>The parameter '{0}' on method '{1}' contains multiple attributes that inherit from CustomModelBinderAttribute.</value>\r
+  </data>\r
+  <data name="ReflectedActionDescriptor_CannotCallInstanceMethodOnNonControllerType" xml:space="preserve">\r
+    <value>Cannot create a descriptor for instance method '{0}' on type '{1}' because the type does not derive from ControllerBase.</value>\r
+  </data>\r
+  <data name="ReflectedActionDescriptor_CannotCallMethodsWithOutOrRefParameters" xml:space="preserve">\r
+    <value>Cannot call action method '{0}' on controller '{1}' because the parameter '{2}' is passed by reference.</value>\r
+  </data>\r
+  <data name="ReflectedActionDescriptor_CannotCallOpenGenericMethods" xml:space="preserve">\r
+    <value>Cannot call action method '{0}' on controller '{1}' because the action method is a generic method.</value>\r
+  </data>\r
+  <data name="DefaultViewLocationCache_NegativeTimeSpan" xml:space="preserve">\r
+    <value>The number of ticks for the TimeSpan value must be greater than or equal to 0.</value>\r
+  </data>\r
+  <data name="AntiForgeryToken_ValidationFailed" xml:space="preserve">\r
+    <value>A required anti-forgery token was not supplied or was invalid.</value>\r
+  </data>\r
+  <data name="DefaultModelBinder_ValueInvalid" xml:space="preserve">\r
+    <value>The value '{0}' is not valid for {1}.</value>\r
+  </data>\r
+  <data name="TemplateHelpers_TemplateLimitations" xml:space="preserve">\r
+    <value>Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.</value>\r
+  </data>\r
+  <data name="Common_TriState_False" xml:space="preserve">\r
+    <value>False</value>\r
+  </data>\r
+  <data name="Common_TriState_NotSet" xml:space="preserve">\r
+    <value>Not Set</value>\r
+  </data>\r
+  <data name="Common_TriState_True" xml:space="preserve">\r
+    <value>True</value>\r
+  </data>\r
+  <data name="ControllerBase_CannotHandleMultipleRequests" xml:space="preserve">\r
+    <value>A single instance of controller '{0}' cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of the controller for each request.</value>\r
+  </data>\r
+  <data name="Common_PropertyNotFound" xml:space="preserve">\r
+    <value>The property {0}.{1} could not be found.</value>\r
+  </data>\r
+  <data name="DataAnnotationsModelMetadataProvider_UnknownProperty" xml:space="preserve">\r
+    <value>{0} has a DisplayColumn attribute for {1}, but property {1} does not exist.</value>\r
+  </data>\r
+  <data name="DataAnnotationsModelMetadataProvider_UnreadableProperty" xml:space="preserve">\r
+    <value>{0} has a DisplayColumn attribute for {1}, but property {1} does not have a public getter.</value>\r
+  </data>\r
+  <data name="TemplateHelpers_NoTemplate" xml:space="preserve">\r
+    <value>Unable to locate an appropriate template for type {0}.</value>\r
+  </data>\r
+  <data name="RequireHttpsAttribute_MustUseSsl" xml:space="preserve">\r
+    <value>The requested resource can only be accessed via SSL.</value>\r
+  </data>\r
+  <data name="HtmlHelper_InvalidHttpVerb" xml:space="preserve">\r
+    <value>The specified HttpVerbs value is not supported. The supported values are Delete, Head, and Put.</value>\r
+  </data>\r
+  <data name="HtmlHelper_InvalidHttpMethod" xml:space="preserve">\r
+    <value>The GET and POST HTTP methods are not supported.</value>\r
+  </data>\r
+  <data name="JsonRequest_GetNotAllowed" xml:space="preserve">\r
+    <value>This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.</value>\r
+  </data>\r
+  <data name="ModelMetadata_PropertyNotSettable" xml:space="preserve">\r
+    <value>This property setter is obsolete, because its value is derived from ModelMetadata.Model now.</value>\r
+  </data>\r
+  <data name="ViewDataDictionary_ModelCannotBeNull" xml:space="preserve">\r
+    <value>The model item passed into the dictionary is null, but this dictionary requires a non-null model item of type '{0}'.</value>\r
+  </data>\r
+  <data name="Common_TypeMustDriveFromType" xml:space="preserve">\r
+    <value>The type {0} must derive from {1}</value>\r
+  </data>\r
+  <data name="DataAnnotationsModelValidatorProvider_ConstructorRequirements" xml:space="preserve">\r
+    <value>The type {0} must have a public constructor which accepts three parameters of types {1}, {2}, and {3}</value>\r
+  </data>\r
+  <data name="ViewPageHttpHandlerWrapper_ExceptionOccurred" xml:space="preserve">\r
+    <value>Execution of the child request failed. Please examine the InnerException for more information.</value>\r
+  </data>\r
+  <data name="RedirectAction_CannotRedirectInChildAction" xml:space="preserve">\r
+    <value>Child actions are not allowed to perform redirect actions.</value>\r
+  </data>\r
+  <data name="AsyncCommon_AsyncResultAlreadyConsumed" xml:space="preserve">\r
+    <value>The provided IAsyncResult has already been consumed.</value>\r
+  </data>\r
+  <data name="AsyncCommon_InvalidAsyncResult" xml:space="preserve">\r
+    <value>The provided IAsyncResult is not valid for this method.</value>\r
+  </data>\r
+  <data name="SynchronizationContextUtil_ExceptionThrown" xml:space="preserve">\r
+    <value>An operation that crossed a synchronization context failed. See the inner exception for more information.</value>\r
+  </data>\r
+  <data name="ReflectedAsyncActionDescriptor_CannotExecuteSynchronously" xml:space="preserve">\r
+    <value>The asynchronous action method '{0}' cannot be executed synchronously.</value>\r
+  </data>\r
+  <data name="AsyncCommon_ControllerMustImplementIAsyncManagerContainer" xml:space="preserve">\r
+    <value>The controller of type '{0}' must subclass AsyncController or implement the IAsyncManagerContainer interface.</value>\r
+  </data>\r
+  <data name="AsyncCommon_InvalidTimeout" xml:space="preserve">\r
+    <value>The timeout value must be non-negative or Timeout.Infinite.</value>\r
+  </data>\r
+  <data name="AsyncActionMethodSelector_AmbiguousMethodMatch" xml:space="preserve">\r
+    <value>Lookup for method '{0}' on controller type '{1}' failed because of an ambiguity between the following methods:{2}</value>\r
+  </data>\r
+  <data name="AsyncActionMethodSelector_CouldNotFindMethod" xml:space="preserve">\r
+    <value>Could not locate a method named '{0}' on controller type {1}.</value>\r
+  </data>\r
+  <data name="ChildActionOnlyAttribute_MustBeInChildRequest" xml:space="preserve">\r
+    <value>The action '{0}' is accessible only by a child request.</value>\r
+  </data>\r
+  <data name="Templates_TypeMustImplementIEnumerable" xml:space="preserve">\r
+    <value>The Collection template was used with an object of type '{0}', which does not implement System.IEnumerable.</value>\r
+  </data>\r
+  <data name="TypeCache_DoNotModify" xml:space="preserve">\r
+    <value>This file is automatically generated. Please do not modify the contents of this file.</value>\r
+  </data>\r
+  <data name="PrivateAssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties" xml:space="preserve">\r
+    <value>The associated metadata type for type '{0}' contains the following unknown properties or fields: {1}. Please make sure that the names of these members match the names of the properties on the main type.</value>\r
+  </data>\r
+  <data name="ClientDataTypeModelValidatorProvider_FieldMustBeNumeric" xml:space="preserve">\r
+    <value>The field {0} must be a number.</value>\r
+  </data>\r
+  <data name="ExpressionHelper_InvalidIndexerExpression" xml:space="preserve">\r
+    <value>The expression compiler was unable to evaluate the indexer expression '{0}' because it references the model parameter '{1}' which is unavailable.</value>\r
+  </data>\r
+  <data name="Controller_Validate_ValidationFailed" xml:space="preserve">\r
+    <value>The model of type '{0}' is not valid.</value>\r
+  </data>\r
+  <data name="DefaultControllerFactory_ControllerNameAmbiguous_WithoutRouteUrl" xml:space="preserve">\r
+    <value>Multiple types were found that match the controller named '{0}'. This can happen if the route that services this request does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.\r
+\r
+The request for '{0}' has found the following matching controllers:{1}</value>\r
+  </data>\r
+  <data name="DefaultControllerFactory_ControllerNameAmbiguous_WithRouteUrl" xml:space="preserve">\r
+    <value>Multiple types were found that match the controller named '{0}'. This can happen if the route that services this request ('{1}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.\r
+\r
+The request for '{0}' has found the following matching controllers:{2}</value>\r
+  </data>\r
+</root>
\ No newline at end of file
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ResultExecutedContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ResultExecutedContext.cs
new file mode 100644 (file)
index 0000000..aec1a1f
--- /dev/null
@@ -0,0 +1,57 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public class ResultExecutedContext : ControllerContext {\r
+\r
+        // parameterless constructor used for mocking\r
+        public ResultExecutedContext() {\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
+        public ResultExecutedContext(ControllerContext controllerContext, ActionResult result, bool canceled, Exception exception)\r
+            : base(controllerContext) {\r
+            if (result == null) {\r
+                throw new ArgumentNullException("result");\r
+            }\r
+\r
+            Result = result;\r
+            Canceled = canceled;\r
+            Exception = exception;\r
+        }\r
+\r
+        public virtual bool Canceled {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual Exception Exception {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public bool ExceptionHandled {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual ActionResult Result {\r
+            get;\r
+            set;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ResultExecutingContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ResultExecutingContext.cs
new file mode 100644 (file)
index 0000000..893bfd0
--- /dev/null
@@ -0,0 +1,45 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public class ResultExecutingContext : ControllerContext {\r
+\r
+        // parameterless constructor used for mocking\r
+        public ResultExecutingContext() {\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
+        public ResultExecutingContext(ControllerContext controllerContext, ActionResult result)\r
+            : base(controllerContext) {\r
+            if (result == null) {\r
+                throw new ArgumentNullException("result");\r
+            }\r
+\r
+            Result = result;\r
+        }\r
+\r
+        public bool Cancel {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual ActionResult Result {\r
+            get;\r
+            set;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteCollectionExtensions.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteCollectionExtensions.cs
new file mode 100644 (file)
index 0000000..a42b6f6
--- /dev/null
@@ -0,0 +1,181 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Web.Routing;\r
+\r
+    public static class RouteCollectionExtensions {\r
+\r
+        // This method returns a new RouteCollection containing only routes that matched a particular area.\r
+        // The Boolean out parameter is just a flag specifying whether any registered routes were area-aware.\r
+        private static RouteCollection FilterRouteCollectionByArea(RouteCollection routes, string areaName, out bool usingAreas) {\r
+            if (areaName == null) {\r
+                areaName = String.Empty;\r
+            }\r
+\r
+            usingAreas = false;\r
+            RouteCollection filteredRoutes = new RouteCollection();\r
+\r
+            using (routes.GetReadLock()) {\r
+                foreach (RouteBase route in routes) {\r
+                    string thisAreaName = AreaHelpers.GetAreaName(route) ?? String.Empty;\r
+                    usingAreas |= (thisAreaName.Length > 0);\r
+                    if (String.Equals(thisAreaName, areaName, StringComparison.OrdinalIgnoreCase)) {\r
+                        filteredRoutes.Add(route);\r
+                    }\r
+                }\r
+            }\r
+\r
+            // if areas are not in use, the filtered route collection might be incorrect\r
+            return (usingAreas) ? filteredRoutes : routes;\r
+        }\r
+\r
+        public static VirtualPathData GetVirtualPathForArea(this RouteCollection routes, RequestContext requestContext, RouteValueDictionary values) {\r
+            return GetVirtualPathForArea(routes, requestContext, null /* name */, values);\r
+        }\r
+\r
+        public static VirtualPathData GetVirtualPathForArea(this RouteCollection routes, RequestContext requestContext, string name, RouteValueDictionary values) {\r
+            bool usingAreas; // don't care about this value\r
+            return GetVirtualPathForArea(routes, requestContext, name, values, out usingAreas);\r
+        }\r
+\r
+        internal static VirtualPathData GetVirtualPathForArea(this RouteCollection routes, RequestContext requestContext, string name, RouteValueDictionary values, out bool usingAreas) {\r
+            if (routes == null) {\r
+                throw new ArgumentNullException("routes");\r
+            }\r
+\r
+            if (!String.IsNullOrEmpty(name)) {\r
+                // the route name is a stronger qualifier than the area name, so just pipe it through\r
+                usingAreas = false;\r
+                return routes.GetVirtualPath(requestContext, name, values);\r
+            }\r
+\r
+            string targetArea = null;\r
+            if (values != null) {\r
+                object targetAreaRawValue;\r
+                if (values.TryGetValue("area", out targetAreaRawValue)) {\r
+                    targetArea = targetAreaRawValue as string;\r
+                }\r
+                else {\r
+                    // set target area to current area\r
+                    if (requestContext != null) {\r
+                        targetArea = AreaHelpers.GetAreaName(requestContext.RouteData);\r
+                    }\r
+                }\r
+            }\r
+\r
+            // need to apply a correction to the RVD if areas are in use\r
+            RouteValueDictionary correctedValues = values;\r
+            RouteCollection filteredRoutes = FilterRouteCollectionByArea(routes, targetArea, out usingAreas);\r
+            if (usingAreas) {\r
+                correctedValues = new RouteValueDictionary(values);\r
+                correctedValues.Remove("area");\r
+            }\r
+\r
+            VirtualPathData vpd = filteredRoutes.GetVirtualPath(requestContext, correctedValues);\r
+            return vpd;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public static void IgnoreRoute(this RouteCollection routes, string url) {\r
+            IgnoreRoute(routes, url, null /* constraints */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public static void IgnoreRoute(this RouteCollection routes, string url, object constraints) {\r
+            if (routes == null) {\r
+                throw new ArgumentNullException("routes");\r
+            }\r
+            if (url == null) {\r
+                throw new ArgumentNullException("url");\r
+            }\r
+\r
+            IgnoreRouteInternal route = new IgnoreRouteInternal(url) {\r
+                Constraints = new RouteValueDictionary(constraints)\r
+            };\r
+\r
+            routes.Add(route);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public static Route MapRoute(this RouteCollection routes, string name, string url) {\r
+            return MapRoute(routes, name, url, null /* defaults */, (object)null /* constraints */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults) {\r
+            return MapRoute(routes, name, url, defaults, (object)null /* constraints */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints) {\r
+            return MapRoute(routes, name, url, defaults, constraints, null /* namespaces */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public static Route MapRoute(this RouteCollection routes, string name, string url, string[] namespaces) {\r
+            return MapRoute(routes, name, url, null /* defaults */, null /* constraints */, namespaces);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults, string[] namespaces) {\r
+            return MapRoute(routes, name, url, defaults, null /* constraints */, namespaces);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#",\r
+            Justification = "This is not a regular URL as it may contain special routing characters.")]\r
+        public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces) {\r
+            if (routes == null) {\r
+                throw new ArgumentNullException("routes");\r
+            }\r
+            if (url == null) {\r
+                throw new ArgumentNullException("url");\r
+            }\r
+\r
+            Route route = new Route(url, new MvcRouteHandler()) {\r
+                Defaults = new RouteValueDictionary(defaults),\r
+                Constraints = new RouteValueDictionary(constraints),\r
+                DataTokens = new RouteValueDictionary()\r
+            };\r
+\r
+            if ((namespaces != null) && (namespaces.Length > 0)) {\r
+                route.DataTokens["Namespaces"] = namespaces;\r
+            }\r
+\r
+            routes.Add(name, route);\r
+\r
+            return route;\r
+        }\r
+\r
+        private sealed class IgnoreRouteInternal : Route {\r
+            public IgnoreRouteInternal(string url)\r
+                : base(url, new StopRoutingHandler()) {\r
+            }\r
+\r
+            public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary routeValues) {\r
+                // Never match during route generation. This avoids the scenario where an IgnoreRoute with\r
+                // fairly relaxed constraints ends up eagerly matching all generated URLs.\r
+                return null;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteDataValueProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteDataValueProvider.cs
new file mode 100644 (file)
index 0000000..5ae1ee7
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Globalization;\r
+\r
+    public sealed class RouteDataValueProvider : DictionaryValueProvider<object> {\r
+\r
+        // RouteData should use the invariant culture since it's part of the URL, and the URL should be\r
+        // interpreted in a uniform fashion regardless of the origin of a particular request.\r
+        public RouteDataValueProvider(ControllerContext controllerContext)\r
+            : base(controllerContext.RouteData.Values, CultureInfo.InvariantCulture) {\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteDataValueProviderFactory.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteDataValueProviderFactory.cs
new file mode 100644 (file)
index 0000000..4efadbf
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public sealed class RouteDataValueProviderFactory : ValueProviderFactory {\r
+\r
+        public override IValueProvider GetValueProvider(ControllerContext controllerContext) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+\r
+            return new RouteDataValueProvider(controllerContext);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteValuesHelpers.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/RouteValuesHelpers.cs
new file mode 100644 (file)
index 0000000..d227cb4
--- /dev/null
@@ -0,0 +1,61 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+    using System.Web.Routing;\r
+\r
+    internal static class RouteValuesHelpers {\r
+        public static RouteValueDictionary GetRouteValues(RouteValueDictionary routeValues) {\r
+            return (routeValues != null) ? new RouteValueDictionary(routeValues) : new RouteValueDictionary();\r
+        }\r
+\r
+        public static RouteValueDictionary MergeRouteValues(string actionName, string controllerName, RouteValueDictionary implicitRouteValues, RouteValueDictionary routeValues, bool includeImplicitMvcValues) {\r
+            // Create a new dictionary containing implicit and auto-generated values\r
+            RouteValueDictionary mergedRouteValues = new RouteValueDictionary();\r
+\r
+            if (includeImplicitMvcValues) {\r
+                // We only include MVC-specific values like 'controller' and 'action' if we are generating an action link.\r
+                // If we are generating a route link [as to MapRoute("Foo", "any/url", new { controller = ... })], including\r
+                // the current controller name will cause the route match to fail if the current controller is not the same\r
+                // as the destination controller.\r
+\r
+                object implicitValue;\r
+                if (implicitRouteValues != null && implicitRouteValues.TryGetValue("action", out implicitValue)) {\r
+                    mergedRouteValues["action"] = implicitValue;\r
+                }\r
+\r
+                if (implicitRouteValues != null && implicitRouteValues.TryGetValue("controller", out implicitValue)) {\r
+                    mergedRouteValues["controller"] = implicitValue;\r
+                }\r
+            }\r
+\r
+            // Merge values from the user's dictionary/object\r
+            if (routeValues != null) {\r
+                foreach (KeyValuePair<string, object> routeElement in GetRouteValues(routeValues)) {\r
+                    mergedRouteValues[routeElement.Key] = routeElement.Value;\r
+                }\r
+            }\r
+\r
+            // Merge explicit parameters when not null\r
+            if (actionName != null) {\r
+                mergedRouteValues["action"] = actionName;\r
+            }\r
+\r
+            if (controllerName != null) {\r
+                mergedRouteValues["controller"] = controllerName;\r
+            }\r
+\r
+            return mergedRouteValues;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/SelectList.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/SelectList.cs
new file mode 100644 (file)
index 0000000..9c85624
--- /dev/null
@@ -0,0 +1,46 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections;\r
+    using System.Diagnostics.CodeAnalysis;    \r
+\r
+    [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]\r
+    public class SelectList : MultiSelectList {\r
+\r
+        public SelectList(IEnumerable items)\r
+            : this(items, null /* selectedValue */) {\r
+        }\r
+\r
+        public SelectList(IEnumerable items, object selectedValue)\r
+            : this(items, null /* dataValuefield */, null /* dataTextField */, selectedValue) {\r
+        }\r
+\r
+        public SelectList(IEnumerable items, string dataValueField, string dataTextField)\r
+            : this(items, dataValueField, dataTextField, null /* selectedValue */) {\r
+        }\r
+\r
+        public SelectList(IEnumerable items, string dataValueField, string dataTextField, object selectedValue)\r
+            : base(items, dataValueField, dataTextField, ToEnumerable(selectedValue)) {\r
+            SelectedValue = selectedValue;\r
+        }\r
+\r
+        public object SelectedValue {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        private static IEnumerable ToEnumerable(object selectedValue) {\r
+            return (selectedValue != null) ? new object[] { selectedValue } : null;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/SelectListItem.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/SelectListItem.cs
new file mode 100644 (file)
index 0000000..962bf36
--- /dev/null
@@ -0,0 +1,32 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public class SelectListItem {\r
+\r
+        public bool Selected {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public string Text {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public string Value {\r
+            get;\r
+            set;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/SessionStateTempDataProvider.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/SessionStateTempDataProvider.cs
new file mode 100644 (file)
index 0000000..1da67bd
--- /dev/null
@@ -0,0 +1,65 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class SessionStateTempDataProvider : ITempDataProvider {\r
+        internal const string TempDataSessionStateKey = "__ControllerTempData";\r
+\r
+        public virtual IDictionary<string, object> LoadTempData(ControllerContext controllerContext) {\r
+            HttpSessionStateBase session = controllerContext.HttpContext.Session;\r
+\r
+            if (session != null) {\r
+                Dictionary<string, object> tempDataDictionary = session[TempDataSessionStateKey] as Dictionary<string, object>;\r
+\r
+                if (tempDataDictionary != null) {\r
+                    // If we got it from Session, remove it so that no other request gets it\r
+                    session.Remove(TempDataSessionStateKey);\r
+                    return tempDataDictionary;\r
+                }\r
+            }\r
+\r
+            return new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);\r
+        }\r
+\r
+        public virtual void SaveTempData(ControllerContext controllerContext, IDictionary<string, object> values) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+\r
+            HttpSessionStateBase session = controllerContext.HttpContext.Session;\r
+            bool isDirty = (values != null && values.Count > 0);\r
+\r
+            if (session == null) {\r
+                if (isDirty) {\r
+                    throw new InvalidOperationException(MvcResources.SessionStateTempDataProvider_SessionStateDisabled);\r
+                }\r
+            }\r
+            else {\r
+                if (isDirty) {\r
+                    session[TempDataSessionStateKey] = values;\r
+                }\r
+                else {\r
+                    // Since the default implementation of Remove() (from SessionStateItemCollection) dirties the\r
+                    // collection, we shouldn't call it unless we really do need to remove the existing key.\r
+                    if (session[TempDataSessionStateKey] != null) {\r
+                        session.Remove(TempDataSessionStateKey);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/StringLengthAttributeAdapter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/StringLengthAttributeAdapter.cs
new file mode 100644 (file)
index 0000000..6e96be4
--- /dev/null
@@ -0,0 +1,26 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel.DataAnnotations;\r
+\r
+    public class StringLengthAttributeAdapter : DataAnnotationsModelValidator<StringLengthAttribute> {\r
+        public StringLengthAttributeAdapter(ModelMetadata metadata, ControllerContext context, StringLengthAttribute attribute)\r
+            : base(metadata, context, attribute) {\r
+        }\r
+\r
+        public override IEnumerable<ModelClientValidationRule> GetClientValidationRules() {\r
+            return new[] { new ModelClientValidationStringLengthRule(ErrorMessage, 0, Attribute.MaximumLength) };\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/TagBuilder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/TagBuilder.cs
new file mode 100644 (file)
index 0000000..d093204
--- /dev/null
@@ -0,0 +1,214 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Globalization;\r
+    using System.Text;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class TagBuilder {\r
+        private string _idAttributeDotReplacement;\r
+\r
+        private const string _attributeFormat = @" {0}=""{1}""";\r
+        private const string _elementFormatEndTag = "</{0}>";\r
+        private const string _elementFormatNormal = "<{0}{1}>{2}</{0}>";\r
+        private const string _elementFormatSelfClosing = "<{0}{1} />";\r
+        private const string _elementFormatStartTag = "<{0}{1}>";\r
+\r
+        private string _innerHtml;\r
+\r
+        public TagBuilder(string tagName) {\r
+            if (String.IsNullOrEmpty(tagName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "tagName");\r
+            }\r
+\r
+            TagName = tagName;\r
+            Attributes = new SortedDictionary<string, string>(StringComparer.Ordinal);\r
+        }\r
+\r
+        public IDictionary<string, string> Attributes {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public string IdAttributeDotReplacement {\r
+            get {\r
+                if (String.IsNullOrEmpty(_idAttributeDotReplacement)) {\r
+                    _idAttributeDotReplacement = HtmlHelper.IdAttributeDotReplacement;\r
+                }\r
+                return _idAttributeDotReplacement;\r
+            }\r
+            set {\r
+                _idAttributeDotReplacement = value;\r
+            }\r
+        }\r
+\r
+        public string InnerHtml {\r
+            get {\r
+                return _innerHtml ?? String.Empty;\r
+            }\r
+            set {\r
+                _innerHtml = value;\r
+            }\r
+        }\r
+\r
+        public string TagName {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public void AddCssClass(string value) {\r
+            string currentValue;\r
+\r
+            if (Attributes.TryGetValue("class", out currentValue)) {\r
+                Attributes["class"] = value + " " + currentValue;\r
+            }\r
+            else {\r
+                Attributes["class"] = value;\r
+            }\r
+        }\r
+\r
+        internal static string CreateSanitizedId(string originalId, string dotReplacement) {\r
+            if (String.IsNullOrEmpty(originalId)) {\r
+                return null;\r
+            }\r
+\r
+            char firstChar = originalId[0];\r
+            if (!Html401IdUtil.IsLetter(firstChar)) {\r
+                // the first character must be a letter\r
+                return null;\r
+            }\r
+\r
+            StringBuilder sb = new StringBuilder(originalId.Length);\r
+            sb.Append(firstChar);\r
+\r
+            for (int i = 1; i < originalId.Length; i++) {\r
+                char thisChar = originalId[i];\r
+                if (Html401IdUtil.IsValidIdCharacter(thisChar)) {\r
+                    sb.Append(thisChar);\r
+                }\r
+                else {\r
+                    sb.Append(dotReplacement);\r
+                }\r
+            }\r
+\r
+            return sb.ToString();\r
+        }\r
+\r
+        public void GenerateId(string name) {\r
+            if (!Attributes.ContainsKey("id")) {\r
+                string sanitizedId = CreateSanitizedId(name, IdAttributeDotReplacement);\r
+                if (!String.IsNullOrEmpty(sanitizedId)) {\r
+                    Attributes["id"] = sanitizedId;\r
+                }\r
+            }\r
+        }\r
+\r
+        private string GetAttributesString() {\r
+            StringBuilder sb = new StringBuilder();\r
+            foreach (var attribute in Attributes) {\r
+                string key = attribute.Key;\r
+                if (String.Equals(key, "id", StringComparison.Ordinal /* case-sensitive */) && String.IsNullOrEmpty(attribute.Value)) {\r
+                    continue; // DevDiv Bugs #227595: don't output empty IDs\r
+                }\r
+                string value = HttpUtility.HtmlAttributeEncode(attribute.Value);\r
+                sb.AppendFormat(CultureInfo.InvariantCulture, _attributeFormat, key, value);\r
+            }\r
+            return sb.ToString();\r
+        }\r
+\r
+        public void MergeAttribute(string key, string value) {\r
+            MergeAttribute(key, value, false /* replaceExisting */);\r
+        }\r
+\r
+        public void MergeAttribute(string key, string value, bool replaceExisting) {\r
+            if (String.IsNullOrEmpty(key)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "key");\r
+            }\r
+\r
+            if (replaceExisting || !Attributes.ContainsKey(key)) {\r
+                Attributes[key] = value;\r
+            }\r
+        }\r
+\r
+        public void MergeAttributes<TKey, TValue>(IDictionary<TKey, TValue> attributes) {\r
+            MergeAttributes(attributes, false /* replaceExisting */);\r
+        }\r
+\r
+        public void MergeAttributes<TKey, TValue>(IDictionary<TKey, TValue> attributes, bool replaceExisting) {\r
+            if (attributes != null) {\r
+                foreach (var entry in attributes) {\r
+                    string key = Convert.ToString(entry.Key, CultureInfo.InvariantCulture);\r
+                    string value = Convert.ToString(entry.Value, CultureInfo.InvariantCulture);\r
+                    MergeAttribute(key, value, replaceExisting);\r
+                }\r
+            }\r
+        }\r
+\r
+        public void SetInnerText(string innerText) {\r
+            InnerHtml = HttpUtility.HtmlEncode(innerText);\r
+        }\r
+\r
+        internal MvcHtmlString ToMvcHtmlString(TagRenderMode renderMode) {\r
+            return MvcHtmlString.Create(ToString(renderMode));\r
+        }\r
+\r
+        public override string ToString() {\r
+            return ToString(TagRenderMode.Normal);\r
+        }\r
+\r
+        public string ToString(TagRenderMode renderMode) {\r
+            switch (renderMode) {\r
+                case TagRenderMode.StartTag:\r
+                    return String.Format(CultureInfo.InvariantCulture, _elementFormatStartTag, TagName, GetAttributesString());\r
+                case TagRenderMode.EndTag:\r
+                    return String.Format(CultureInfo.InvariantCulture, _elementFormatEndTag, TagName);\r
+                case TagRenderMode.SelfClosing:\r
+                    return String.Format(CultureInfo.InvariantCulture, _elementFormatSelfClosing, TagName, GetAttributesString());\r
+                default:\r
+                    return String.Format(CultureInfo.InvariantCulture, _elementFormatNormal, TagName, GetAttributesString(), InnerHtml);\r
+            }\r
+        }\r
+\r
+        // Valid IDs are defined in http://www.w3.org/TR/html401/types.html#type-id\r
+        private static class Html401IdUtil {\r
+            private static bool IsAllowableSpecialCharacter(char c) {\r
+                switch (c) {\r
+                    case '-':\r
+                    case '_':\r
+                    case ':':\r
+                        // note that we're specifically excluding the '.' character\r
+                        return true;\r
+\r
+                    default:\r
+                        return false;\r
+                }\r
+            }\r
+\r
+            private static bool IsDigit(char c) {\r
+                return ('0' <= c && c <= '9');\r
+            }\r
+\r
+            public static bool IsLetter(char c) {\r
+                return (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z'));\r
+            }\r
+\r
+            public static bool IsValidIdCharacter(char c) {\r
+                return (IsLetter(c) || IsDigit(c) || IsAllowableSpecialCharacter(c));\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/TagRenderMode.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/TagRenderMode.cs
new file mode 100644 (file)
index 0000000..8f889e7
--- /dev/null
@@ -0,0 +1,20 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public enum TagRenderMode {\r
+        Normal,\r
+        StartTag,\r
+        EndTag,\r
+        SelfClosing\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/TempDataDictionary.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/TempDataDictionary.cs
new file mode 100644 (file)
index 0000000..b2aa489
--- /dev/null
@@ -0,0 +1,219 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Linq;\r
+    using System.Runtime.Serialization;\r
+\r
+    [Serializable]\r
+    public class TempDataDictionary : IDictionary<string, object>, ISerializable {\r
+        internal const string _tempDataSerializationKey = "__tempData";\r
+\r
+        private Dictionary<string, object> _data;\r
+        private HashSet<string> _initialKeys = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\r
+        private HashSet<string> _retainedKeys = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\r
+\r
+        public TempDataDictionary() {\r
+            _data = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);\r
+        }\r
+\r
+        protected TempDataDictionary(SerializationInfo info, StreamingContext context) {\r
+            _data = info.GetValue(_tempDataSerializationKey, typeof(Dictionary<string, object>)) as Dictionary<string, object>;\r
+        }\r
+\r
+        public int Count {\r
+            get {\r
+                return _data.Count;\r
+            }\r
+        }\r
+\r
+        public ICollection<string> Keys {\r
+            get {\r
+                return _data.Keys;\r
+            }\r
+        }\r
+\r
+        public void Keep() {\r
+            _retainedKeys.Clear();\r
+            _retainedKeys.UnionWith(_data.Keys);\r
+        }\r
+\r
+        public void Keep(string key) {\r
+            _retainedKeys.Add(key);\r
+        }\r
+\r
+        public void Load(ControllerContext controllerContext, ITempDataProvider tempDataProvider) {\r
+            IDictionary<string, object> providerDictionary = tempDataProvider.LoadTempData(controllerContext);\r
+            _data = (providerDictionary != null) ? new Dictionary<string, object>(providerDictionary, StringComparer.OrdinalIgnoreCase) :\r
+                new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);\r
+            _initialKeys = new HashSet<string>(_data.Keys, StringComparer.OrdinalIgnoreCase);\r
+            _retainedKeys.Clear();\r
+        }\r
+\r
+        public object Peek(string key) {\r
+            object value;\r
+            _data.TryGetValue(key, out value);\r
+            return value;\r
+        }\r
+\r
+        public void Save(ControllerContext controllerContext, ITempDataProvider tempDataProvider) {\r
+            string[] keysToKeep = _initialKeys.Union(_retainedKeys, StringComparer.OrdinalIgnoreCase).ToArray();\r
+            string[] keysToRemove = _data.Keys.Except(keysToKeep, StringComparer.OrdinalIgnoreCase).ToArray();\r
+            foreach (string key in keysToRemove) {\r
+                _data.Remove(key);\r
+            }\r
+            tempDataProvider.SaveTempData(controllerContext, _data);\r
+        }\r
+\r
+        public ICollection<object> Values {\r
+            get {\r
+                return _data.Values;\r
+            }\r
+        }\r
+\r
+        public object this[string key] {\r
+            get {\r
+                object value;\r
+                if (TryGetValue(key, out value)) {\r
+                    _initialKeys.Remove(key);\r
+                    return value;\r
+                }\r
+                return null;\r
+            }\r
+            set {\r
+                _data[key] = value;\r
+                _initialKeys.Add(key);\r
+            }\r
+        }\r
+\r
+        public void Add(string key, object value) {\r
+            _data.Add(key, value);\r
+            _initialKeys.Add(key);\r
+        }\r
+\r
+        public void Clear() {\r
+            _data.Clear();\r
+            _retainedKeys.Clear();\r
+            _initialKeys.Clear();\r
+        }\r
+\r
+        public bool ContainsKey(string key) {\r
+            return _data.ContainsKey(key);\r
+        }\r
+\r
+        public bool ContainsValue(object value) {\r
+            return _data.ContainsValue(value);\r
+        }\r
+\r
+        public IEnumerator<KeyValuePair<string, object>> GetEnumerator() {\r
+            return new TempDataDictionaryEnumerator(this);\r
+        }\r
+\r
+        protected virtual void GetObjectData(SerializationInfo info, StreamingContext context) {\r
+            info.AddValue(_tempDataSerializationKey, _data);\r
+        }\r
+\r
+        public bool Remove(string key) {\r
+            _retainedKeys.Remove(key);\r
+            _initialKeys.Remove(key);\r
+            return _data.Remove(key);\r
+        }\r
+\r
+        public bool TryGetValue(string key, out object value) {\r
+            _initialKeys.Remove(key);\r
+            return _data.TryGetValue(key, out value);\r
+        }\r
+\r
+        #region ICollection<KeyValuePair<string, object>> Implementation\r
+        bool ICollection<KeyValuePair<string, object>>.IsReadOnly {\r
+            get {\r
+                return ((ICollection<KeyValuePair<string, object>>)_data).IsReadOnly;\r
+            }\r
+        }\r
+\r
+        void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int index) {\r
+            ((ICollection<KeyValuePair<string, object>>)_data).CopyTo(array, index);\r
+        }\r
+\r
+        void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> keyValuePair) {\r
+            _initialKeys.Add(keyValuePair.Key);\r
+            ((ICollection<KeyValuePair<string, object>>)_data).Add(keyValuePair);\r
+        }\r
+\r
+        bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> keyValuePair) {\r
+            return ((ICollection<KeyValuePair<string, object>>)_data).Contains(keyValuePair);\r
+        }\r
+\r
+        bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> keyValuePair) {\r
+            _initialKeys.Remove(keyValuePair.Key);\r
+            return ((ICollection<KeyValuePair<string, object>>)_data).Remove(keyValuePair);\r
+        }\r
+        #endregion\r
+\r
+        #region IEnumerable Implementation\r
+        IEnumerator IEnumerable.GetEnumerator() {\r
+            return (IEnumerator)(new TempDataDictionaryEnumerator(this));\r
+        }\r
+        #endregion\r
+\r
+        #region ISerializable Members\r
+        [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]\r
+        void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) {\r
+            GetObjectData(info, context);\r
+        }\r
+        #endregion\r
+\r
+        private sealed class TempDataDictionaryEnumerator : IEnumerator<KeyValuePair<string, object>> {\r
+            private IEnumerator<KeyValuePair<string, object>> _enumerator;\r
+            private TempDataDictionary _tempData;\r
+\r
+            public TempDataDictionaryEnumerator(TempDataDictionary tempData) {\r
+                _tempData = tempData;\r
+                _enumerator = _tempData._data.GetEnumerator();\r
+            }\r
+\r
+            public KeyValuePair<string, object> Current {\r
+                get {\r
+                    KeyValuePair<string, object> kvp = _enumerator.Current;\r
+                    _tempData._initialKeys.Remove(kvp.Key);\r
+                    return kvp;\r
+                }\r
+            }\r
+\r
+            public bool MoveNext() {\r
+                return _enumerator.MoveNext();\r
+            }\r
+\r
+            public void Reset() {\r
+                _enumerator.Reset();\r
+            }\r
+\r
+            #region IEnumerator Implementation\r
+            object IEnumerator.Current {\r
+                get {\r
+                    return Current;\r
+                }\r
+            }\r
+            #endregion\r
+\r
+            #region IDisposable Implementation\r
+            void IDisposable.Dispose() {\r
+                _enumerator.Dispose();\r
+            }\r
+            #endregion\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/TemplateInfo.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/TemplateInfo.cs
new file mode 100644 (file)
index 0000000..5ca8280
--- /dev/null
@@ -0,0 +1,71 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+\r
+    public class TemplateInfo {\r
+        private string _htmlFieldPrefix;\r
+        private object _formattedModelValue;\r
+        private HashSet<object> _visitedObjects;\r
+\r
+        public object FormattedModelValue {\r
+            get {\r
+                return _formattedModelValue ?? String.Empty;\r
+            }\r
+            set {\r
+                _formattedModelValue = value;\r
+            }\r
+        }\r
+\r
+        public string HtmlFieldPrefix {\r
+            get {\r
+                return _htmlFieldPrefix ?? String.Empty;\r
+            }\r
+            set {\r
+                _htmlFieldPrefix = value;\r
+            }\r
+        }\r
+\r
+        public int TemplateDepth {\r
+            get {\r
+                return VisitedObjects.Count;\r
+            }\r
+        }\r
+\r
+        // DDB #224750 - Keep a collection of visited objects to prevent infinite recursion\r
+        internal HashSet<object> VisitedObjects {\r
+            get {\r
+                if (_visitedObjects == null) {\r
+                    _visitedObjects = new HashSet<object>();\r
+                }\r
+                return _visitedObjects;\r
+            }\r
+            set {\r
+                _visitedObjects = value;\r
+            }\r
+        }\r
+\r
+        public string GetFullHtmlFieldId(string partialFieldName) {\r
+            return HtmlHelper.GenerateIdFromName(GetFullHtmlFieldName(partialFieldName));\r
+        }\r
+\r
+        public string GetFullHtmlFieldName(string partialFieldName) {\r
+            // This uses "combine and trim" because either or both of these values might be empty\r
+            return (HtmlFieldPrefix + "." + (partialFieldName ?? String.Empty)).Trim('.');\r
+        }\r
+\r
+        public bool Visited(ModelMetadata metadata) {\r
+            return VisitedObjects.Contains(metadata.Model ?? metadata.ModelType);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/TryGetValueDelegate.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/TryGetValueDelegate.cs
new file mode 100644 (file)
index 0000000..66a1966
--- /dev/null
@@ -0,0 +1,17 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    internal delegate bool TryGetValueDelegate(object dictionary, string key, out object value);\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeCacheSerializer.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeCacheSerializer.cs
new file mode 100644 (file)
index 0000000..bec4f0b
--- /dev/null
@@ -0,0 +1,128 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.IO;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Xml;\r
+\r
+    // Processes files with this format:\r
+    //\r
+    // <typeCache lastModified=... mvcVersionId=...>\r
+    //   <assembly name=...>\r
+    //     <module versionId=...>\r
+    //       <type>...</type>\r
+    //     </module>\r
+    //   </assembly>\r
+    // </typeCache>\r
+    //\r
+    // This is used to store caches of files between AppDomain resets, leading to improved cold boot time\r
+    // and more efficient use of memory.\r
+\r
+    internal sealed class TypeCacheSerializer {\r
+\r
+        private static readonly Guid _mvcVersionId = typeof(TypeCacheSerializer).Module.ModuleVersionId;\r
+\r
+        // used for unit testing\r
+\r
+        private DateTime CurrentDate {\r
+            get {\r
+                return CurrentDateOverride ?? DateTime.Now;\r
+            }\r
+        }\r
+\r
+        internal DateTime? CurrentDateOverride {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "This is an instance method for consistency with the SerializeTypes() method.")]\r
+        public List<Type> DeserializeTypes(TextReader input) {\r
+            XmlDocument doc = new XmlDocument();\r
+            doc.Load(input);\r
+            XmlElement rootElement = doc.DocumentElement;\r
+\r
+            Guid readMvcVersionId = new Guid(rootElement.Attributes["mvcVersionId"].Value);\r
+            if (readMvcVersionId != _mvcVersionId) {\r
+                // The cache is outdated because the cache file was produced by a different version\r
+                // of MVC.\r
+                return null;\r
+            }\r
+\r
+            List<Type> deserializedTypes = new List<Type>();\r
+            foreach (XmlNode assemblyNode in rootElement.ChildNodes) {\r
+                string assemblyName = assemblyNode.Attributes["name"].Value;\r
+                Assembly assembly = Assembly.Load(assemblyName);\r
+\r
+                foreach (XmlNode moduleNode in assemblyNode.ChildNodes) {\r
+                    Guid moduleVersionId = new Guid(moduleNode.Attributes["versionId"].Value);\r
+\r
+                    foreach (XmlNode typeNode in moduleNode.ChildNodes) {\r
+                        string typeName = typeNode.InnerText;\r
+                        Type type = assembly.GetType(typeName);\r
+                        if (type == null || type.Module.ModuleVersionId != moduleVersionId) {\r
+                            // The cache is outdated because we couldn't find a previously recorded\r
+                            // type or the type's containing module was modified.\r
+                            return null;\r
+                        }\r
+                        else {\r
+                            deserializedTypes.Add(type);\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+\r
+            return deserializedTypes;\r
+        }\r
+\r
+        public void SerializeTypes(IEnumerable<Type> types, TextWriter output) {\r
+            var groupedByAssembly = from type in types\r
+                                    group type by type.Module into groupedByModule\r
+                                    group groupedByModule by groupedByModule.Key.Assembly;\r
+\r
+            XmlDocument doc = new XmlDocument();\r
+            doc.AppendChild(doc.CreateComment(MvcResources.TypeCache_DoNotModify));\r
+\r
+            XmlElement typeCacheElement = doc.CreateElement("typeCache");\r
+            doc.AppendChild(typeCacheElement);\r
+            typeCacheElement.SetAttribute("lastModified", CurrentDate.ToString());\r
+            typeCacheElement.SetAttribute("mvcVersionId", _mvcVersionId.ToString());\r
+\r
+            foreach (var assemblyGroup in groupedByAssembly) {\r
+                XmlElement assemblyElement = doc.CreateElement("assembly");\r
+                typeCacheElement.AppendChild(assemblyElement);\r
+                assemblyElement.SetAttribute("name", assemblyGroup.Key.FullName);\r
+\r
+                foreach (var moduleGroup in assemblyGroup) {\r
+                    XmlElement moduleElement = doc.CreateElement("module");\r
+                    assemblyElement.AppendChild(moduleElement);\r
+                    moduleElement.SetAttribute("versionId", moduleGroup.Key.ModuleVersionId.ToString());\r
+\r
+                    foreach (Type type in moduleGroup) {\r
+                        XmlElement typeElement = doc.CreateElement("type");\r
+                        moduleElement.AppendChild(typeElement);\r
+                        typeElement.AppendChild(doc.CreateTextNode(type.FullName));\r
+                    }\r
+                }\r
+            }\r
+\r
+            doc.Save(output);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeCacheUtil.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeCacheUtil.cs
new file mode 100644 (file)
index 0000000..b3366d1
--- /dev/null
@@ -0,0 +1,103 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.IO;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+\r
+    internal static class TypeCacheUtil {\r
+\r
+        private static IEnumerable<Type> FilterTypesInAssemblies(IBuildManager buildManager, Predicate<Type> predicate) {\r
+            // Go through all assemblies referenced by the application and search for types matching a predicate\r
+            IEnumerable<Type> typesSoFar = Type.EmptyTypes;\r
+\r
+            ICollection assemblies = buildManager.GetReferencedAssemblies();\r
+            foreach (Assembly assembly in assemblies) {\r
+                Type[] typesInAsm;\r
+                try {\r
+                    typesInAsm = assembly.GetTypes();\r
+                }\r
+                catch (ReflectionTypeLoadException ex) {\r
+                    typesInAsm = ex.Types;\r
+                }\r
+                typesSoFar = typesSoFar.Concat(typesInAsm);\r
+            }\r
+            return typesSoFar.Where(type => TypeIsPublicClass(type) && predicate(type));\r
+        }\r
+\r
+        public static List<Type> GetFilteredTypesFromAssemblies(string cacheName, Predicate<Type> predicate, IBuildManager buildManager) {\r
+            TypeCacheSerializer serializer = new TypeCacheSerializer();\r
+\r
+            // first, try reading from the cache on disk\r
+            List<Type> matchingTypes = ReadTypesFromCache(cacheName, predicate, buildManager, serializer);\r
+            if (matchingTypes != null) {\r
+                return matchingTypes;\r
+            }\r
+\r
+            // if reading from the cache failed, enumerate over every assembly looking for a matching type\r
+            matchingTypes = FilterTypesInAssemblies(buildManager, predicate).ToList();\r
+\r
+            // finally, save the cache back to disk\r
+            SaveTypesToCache(cacheName, matchingTypes, buildManager, serializer);\r
+\r
+            return matchingTypes;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",\r
+            Justification = "Cache failures are not fatal, and the code should continue executing normally.")]\r
+        internal static List<Type> ReadTypesFromCache(string cacheName, Predicate<Type> predicate, IBuildManager buildManager, TypeCacheSerializer serializer) {\r
+            try {\r
+                using (Stream stream = buildManager.ReadCachedFile(cacheName)) {\r
+                    if (stream != null) {\r
+                        using (StreamReader reader = new StreamReader(stream)) {\r
+                            List<Type> deserializedTypes = serializer.DeserializeTypes(reader);\r
+                            if (deserializedTypes != null && deserializedTypes.All(type => TypeIsPublicClass(type) && predicate(type))) {\r
+                                // If all read types still match the predicate, success!\r
+                                return deserializedTypes;\r
+                            }\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+            catch {\r
+            }\r
+\r
+            return null;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",\r
+            Justification = "Cache failures are not fatal, and the code should continue executing normally.")]\r
+        internal static void SaveTypesToCache(string cacheName, IList<Type> matchingTypes, IBuildManager buildManager, TypeCacheSerializer serializer) {\r
+            try {\r
+                using (Stream stream = buildManager.CreateCachedFile(cacheName)) {\r
+                    if (stream != null) {\r
+                        using (StreamWriter writer = new StreamWriter(stream)) {\r
+                            serializer.SerializeTypes(matchingTypes, writer);\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+            catch {\r
+            }\r
+        }\r
+\r
+        private static bool TypeIsPublicClass(Type type) {\r
+            return (type != null && type.IsPublic && type.IsClass && !type.IsAbstract);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeDescriptorHelper.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeDescriptorHelper.cs
new file mode 100644 (file)
index 0000000..48ccb8e
--- /dev/null
@@ -0,0 +1,282 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel;\r
+    using System.ComponentModel.DataAnnotations;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    // TODO: Remove this class in MVC 3\r
+    //\r
+    // We brought in a private copy of the AssociatedMetadataTypeTypeDescriptionProvider\r
+    // from .NET 4, because it provides several bug fixes and perf improvements. If we're\r
+    // running on .NET < 4, we'll use our private copy.\r
+\r
+    internal static class TypeDescriptorHelper {\r
+\r
+        private static Func<Type, ICustomTypeDescriptor> _typeDescriptorFactory = GetTypeDescriptorFactory();\r
+\r
+        private static Func<Type, ICustomTypeDescriptor> GetTypeDescriptorFactory() {\r
+            if (Environment.Version.Major < 4) {\r
+                return type => new _AssociatedMetadataTypeTypeDescriptionProvider(type).GetTypeDescriptor(type);\r
+            }\r
+\r
+            return type => new AssociatedMetadataTypeTypeDescriptionProvider(type).GetTypeDescriptor(type);\r
+        }\r
+\r
+        public static ICustomTypeDescriptor Get(Type type) {\r
+            return _typeDescriptorFactory(type);\r
+        }\r
+\r
+        // Private copies of the .NET 4 AssociatedMetadataType classes\r
+\r
+        private class _AssociatedMetadataTypeTypeDescriptionProvider : TypeDescriptionProvider {\r
+            public _AssociatedMetadataTypeTypeDescriptionProvider(Type type)\r
+                : base(TypeDescriptor.GetProvider(type)) {\r
+            }\r
+\r
+            public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) {\r
+                ICustomTypeDescriptor baseDescriptor = base.GetTypeDescriptor(objectType, instance);\r
+                return new _AssociatedMetadataTypeTypeDescriptor(baseDescriptor, objectType);\r
+            }\r
+        }\r
+\r
+        private class _AssociatedMetadataTypeTypeDescriptor : CustomTypeDescriptor {\r
+            private Type AssociatedMetadataType {\r
+                get;\r
+                set;\r
+            }\r
+\r
+            public _AssociatedMetadataTypeTypeDescriptor(ICustomTypeDescriptor parent, Type type)\r
+                : base(parent) {\r
+                AssociatedMetadataType = TypeDescriptorCache.GetAssociatedMetadataType(type);\r
+                if (AssociatedMetadataType != null) {\r
+                    TypeDescriptorCache.ValidateMetadataType(type, AssociatedMetadataType);\r
+                }\r
+            }\r
+\r
+            public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) {\r
+                return GetPropertiesWithMetadata(base.GetProperties(attributes));\r
+            }\r
+\r
+            public override PropertyDescriptorCollection GetProperties() {\r
+                return GetPropertiesWithMetadata(base.GetProperties());\r
+            }\r
+\r
+            private PropertyDescriptorCollection GetPropertiesWithMetadata(PropertyDescriptorCollection originalCollection) {\r
+                if (AssociatedMetadataType == null) {\r
+                    return originalCollection;\r
+                }\r
+\r
+                bool customDescriptorsCreated = false;\r
+                List<PropertyDescriptor> tempPropertyDescriptors = new List<PropertyDescriptor>();\r
+                foreach (PropertyDescriptor propDescriptor in originalCollection) {\r
+                    Attribute[] newMetadata = TypeDescriptorCache.GetAssociatedMetadata(AssociatedMetadataType, propDescriptor.Name);\r
+                    PropertyDescriptor descriptor = propDescriptor;\r
+                    if (newMetadata.Length > 0) {\r
+                        // Create a metadata descriptor that wraps the property descriptor\r
+                        descriptor = new _MetadataPropertyDescriptorWrapper(propDescriptor, newMetadata);\r
+                        customDescriptorsCreated = true;\r
+                    }\r
+\r
+                    tempPropertyDescriptors.Add(descriptor);\r
+                }\r
+\r
+                if (customDescriptorsCreated) {\r
+                    return new PropertyDescriptorCollection(tempPropertyDescriptors.ToArray(), true);\r
+                }\r
+                return originalCollection;\r
+            }\r
+\r
+            public override AttributeCollection GetAttributes() {\r
+                // Since normal TD behavior is to return cached attribute instances on subsequent\r
+                // calls to GetAttributes, we must be sure below to use the TD APIs to get both\r
+                // the base and associated attributes\r
+                AttributeCollection attributes = base.GetAttributes();\r
+                if (AssociatedMetadataType != null) {\r
+                    // Note that the use of TypeDescriptor.GetAttributes here opens up the possibility of\r
+                    // infinite recursion, in the corner case of two Types referencing each other as\r
+                    // metadata types (or a longer cycle)\r
+                    Attribute[] newAttributes = TypeDescriptor.GetAttributes(AssociatedMetadataType).OfType<Attribute>().ToArray();\r
+                    attributes = AttributeCollection.FromExisting(attributes, newAttributes);\r
+                }\r
+                return attributes;\r
+            }\r
+\r
+            private static class TypeDescriptorCache {\r
+                private static readonly Attribute[] emptyAttributes = new Attribute[0];\r
+\r
+                // Stores the associated metadata type for a type\r
+                private static readonly Dictionary<Type, Type> _metadataTypeCache = new Dictionary<Type, Type>();\r
+\r
+                // For a type and a property name stores the attributes for that property name.\r
+                private static readonly Dictionary<Tuple<Type, string>, Attribute[]> _typeMemberCache = new Dictionary<Tuple<Type, string>, Attribute[]>();\r
+\r
+                // Stores whether or not a type and associated metadata type has been checked for validity\r
+                private static readonly Dictionary<Tuple<Type, Type>, bool> _validatedMetadataTypeCache = new Dictionary<Tuple<Type, Type>, bool>();\r
+\r
+                public static void ValidateMetadataType(Type type, Type associatedType) {\r
+                    Tuple<Type, Type> typeTuple = new Tuple<Type, Type>(type, associatedType);\r
+\r
+                    lock (_validatedMetadataTypeCache) {\r
+                        if (!_validatedMetadataTypeCache.ContainsKey(typeTuple)) {\r
+                            CheckAssociatedMetadataType(type, associatedType);\r
+                            _validatedMetadataTypeCache.Add(typeTuple, true);\r
+                        }\r
+                    }\r
+                }\r
+\r
+                public static Type GetAssociatedMetadataType(Type type) {\r
+                    Type associatedMetadataType = null;\r
+                    lock (_metadataTypeCache) {\r
+                        if (_metadataTypeCache.TryGetValue(type, out associatedMetadataType)) {\r
+                            return associatedMetadataType;\r
+                        }\r
+                    }\r
+\r
+                    // Try association attribute\r
+                    MetadataTypeAttribute attribute = (MetadataTypeAttribute)Attribute.GetCustomAttribute(type, typeof(MetadataTypeAttribute));\r
+                    if (attribute != null) {\r
+                        associatedMetadataType = attribute.MetadataClassType;\r
+                    }\r
+\r
+                    lock (_metadataTypeCache) {\r
+                        _metadataTypeCache[type] = associatedMetadataType; \r
+                    }\r
+\r
+                    return associatedMetadataType;\r
+                }\r
+\r
+                private static void CheckAssociatedMetadataType(Type mainType, Type associatedMetadataType) {\r
+                    // Only properties from main type\r
+                    HashSet<string> mainTypeMemberNames = new HashSet<string>(mainType.GetProperties().Select(p => p.Name));\r
+\r
+                    // Properties and fields from buddy type\r
+                    var buddyFields = associatedMetadataType.GetFields().Select(f => f.Name);\r
+                    var buddyProperties = associatedMetadataType.GetProperties().Select(p => p.Name);\r
+                    HashSet<string> buddyTypeMembers = new HashSet<string>(buddyFields.Concat(buddyProperties), StringComparer.Ordinal);\r
+\r
+                    // Buddy members should be a subset of the main type's members\r
+                    if (!buddyTypeMembers.IsSubsetOf(mainTypeMemberNames)) {\r
+                        // Reduce the buddy members to the set not contained in the main members\r
+                        buddyTypeMembers.ExceptWith(mainTypeMemberNames);\r
+\r
+                        throw new InvalidOperationException(String.Format(\r
+                            CultureInfo.CurrentCulture,\r
+                            MvcResources.PrivateAssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties,\r
+                            mainType.FullName,\r
+                            String.Join(", ", buddyTypeMembers.ToArray())));\r
+                    }\r
+                }\r
+\r
+                public static Attribute[] GetAssociatedMetadata(Type type, string memberName) {\r
+                    var memberTuple = new Tuple<Type, string>(type, memberName);\r
+                    Attribute[] attributes;\r
+                    lock (_typeMemberCache) {\r
+                        if (_typeMemberCache.TryGetValue(memberTuple, out attributes)) {\r
+                            return attributes;\r
+                        }\r
+                    }\r
+\r
+                    // Allow fields and properties\r
+                    MemberTypes allowedMemberTypes = MemberTypes.Property | MemberTypes.Field;\r
+                    // Only public static/instance members\r
+                    BindingFlags searchFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static;\r
+                    // Try to find a matching member on type\r
+                    MemberInfo matchingMember = type.GetMember(memberName, allowedMemberTypes, searchFlags).FirstOrDefault();\r
+                    if (matchingMember != null) {\r
+                        attributes = Attribute.GetCustomAttributes(matchingMember, true /* inherit */);\r
+                    }\r
+                    else {\r
+                        attributes = emptyAttributes;\r
+                    }\r
+\r
+                    lock (_typeMemberCache) {\r
+                        _typeMemberCache[memberTuple] = attributes;\r
+                    }\r
+                    return attributes;\r
+                }\r
+\r
+                private class Tuple<T1, T2> {\r
+                    public T1 Item1 { get; set; }\r
+                    public T2 Item2 { get; set; }\r
+\r
+                    public Tuple(T1 item1, T2 item2) {\r
+                        Item1 = item1;\r
+                        Item2 = item2;\r
+                    }\r
+\r
+                    public override int GetHashCode() {\r
+                        int h1 = Item1.GetHashCode();\r
+                        int h2 = Item2.GetHashCode();\r
+                        return ((h1 << 5) + h1) ^ h2;\r
+                    }\r
+\r
+                    public override bool Equals(object obj) {\r
+                        var other = obj as Tuple<T1, T2>;\r
+                        if (other != null) {\r
+                            return other.Item1.Equals(Item1) && other.Item2.Equals(Item2);\r
+                        }\r
+                        return false;\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        private class _MetadataPropertyDescriptorWrapper : PropertyDescriptor {\r
+            private PropertyDescriptor _descriptor;\r
+            private bool _isReadOnly;\r
+\r
+            public _MetadataPropertyDescriptorWrapper(PropertyDescriptor descriptor, Attribute[] newAttributes)\r
+                : base(descriptor, newAttributes) {\r
+                _descriptor = descriptor;\r
+                var readOnlyAttribute = newAttributes.OfType<ReadOnlyAttribute>().FirstOrDefault();\r
+                _isReadOnly = (readOnlyAttribute != null ? readOnlyAttribute.IsReadOnly : false);\r
+            }\r
+\r
+            public override void AddValueChanged(object component, EventHandler handler) { _descriptor.AddValueChanged(component, handler); }\r
+\r
+            public override bool CanResetValue(object component) { return _descriptor.CanResetValue(component); }\r
+\r
+            public override Type ComponentType { get { return _descriptor.ComponentType; } }\r
+\r
+            public override object GetValue(object component) { return _descriptor.GetValue(component); }\r
+\r
+            public override bool IsReadOnly {\r
+                get {\r
+                    // Dev10 Bug 594083\r
+                    // It's not enough to call the wrapped _descriptor because it does not know anything about\r
+                    // new attributes passed into the constructor of this class.\r
+                    return _isReadOnly || _descriptor.IsReadOnly;\r
+                }\r
+            }\r
+\r
+            public override Type PropertyType { get { return _descriptor.PropertyType; } }\r
+\r
+            public override void RemoveValueChanged(object component, EventHandler handler) { _descriptor.RemoveValueChanged(component, handler); }\r
+\r
+            public override void ResetValue(object component) { _descriptor.ResetValue(component); }\r
+\r
+            public override void SetValue(object component, object value) { _descriptor.SetValue(component, value); }\r
+\r
+            public override bool ShouldSerializeValue(object component) { return _descriptor.ShouldSerializeValue(component); }\r
+\r
+            public override bool SupportsChangeEvents { get { return _descriptor.SupportsChangeEvents; } }\r
+        }\r
+    \r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeHelpers.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/TypeHelpers.cs
new file mode 100644 (file)
index 0000000..6a024bb
--- /dev/null
@@ -0,0 +1,138 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+    using System.Reflection;\r
+    using System.Threading;\r
+\r
+    internal static class TypeHelpers {\r
+\r
+        private static readonly Dictionary<Type, TryGetValueDelegate> _tryGetValueDelegateCache = new Dictionary<Type, TryGetValueDelegate>();\r
+        private static readonly ReaderWriterLockSlim _tryGetValueDelegateCacheLock = new ReaderWriterLockSlim();\r
+\r
+        private static readonly MethodInfo _strongTryGetValueImplInfo = typeof(TypeHelpers).GetMethod("StrongTryGetValueImpl", BindingFlags.NonPublic | BindingFlags.Static);\r
+\r
+        public static readonly Assembly MsCorLibAssembly = typeof(string).Assembly;\r
+        public static readonly Assembly MvcAssembly = typeof(Controller).Assembly;\r
+        public static readonly Assembly SystemWebAssembly = typeof(HttpContext).Assembly;\r
+\r
+        // method is used primarily for lighting up new .NET Framework features even if MVC targets the previous version\r
+        // thisParameter is the 'this' parameter if target method is instance method, should be null for static method\r
+        public static TDelegate CreateDelegate<TDelegate>(Assembly assembly, string typeName, string methodName, object thisParameter) where TDelegate : class {\r
+            // ensure target type exists\r
+            Type targetType = assembly.GetType(typeName, false /* throwOnError */);\r
+            if (targetType == null) {\r
+                return null;\r
+            }\r
+\r
+            return CreateDelegate<TDelegate>(targetType, methodName, thisParameter);\r
+        }\r
+\r
+        public static TDelegate CreateDelegate<TDelegate>(Type targetType, string methodName, object thisParameter) where TDelegate : class {\r
+            // ensure target method exists\r
+            ParameterInfo[] delegateParameters = typeof(TDelegate).GetMethod("Invoke").GetParameters();\r
+            Type[] argumentTypes = Array.ConvertAll(delegateParameters, pInfo => pInfo.ParameterType);\r
+            MethodInfo targetMethod = targetType.GetMethod(methodName, argumentTypes);\r
+            if (targetMethod == null) {\r
+                return null;\r
+            }\r
+\r
+            TDelegate d = Delegate.CreateDelegate(typeof(TDelegate), thisParameter, targetMethod, false /* throwOnBindFailure */) as TDelegate;\r
+            return d;\r
+        }\r
+\r
+        public static TryGetValueDelegate CreateTryGetValueDelegate(Type targetType) {\r
+            TryGetValueDelegate result;\r
+\r
+            _tryGetValueDelegateCacheLock.EnterReadLock();\r
+            try {\r
+                if (_tryGetValueDelegateCache.TryGetValue(targetType, out result)) {\r
+                    return result;\r
+                }\r
+            }\r
+            finally {\r
+                _tryGetValueDelegateCacheLock.ExitReadLock();\r
+            }\r
+\r
+            Type dictionaryType = ExtractGenericInterface(targetType, typeof(IDictionary<,>));\r
+\r
+            // just wrap a call to the underlying IDictionary<TKey, TValue>.TryGetValue() where string can be cast to TKey\r
+            if (dictionaryType != null) {\r
+                Type[] typeArguments = dictionaryType.GetGenericArguments();\r
+                Type keyType = typeArguments[0];\r
+                Type returnType = typeArguments[1];\r
+\r
+                if (keyType.IsAssignableFrom(typeof(string))) {\r
+                    MethodInfo strongImplInfo = _strongTryGetValueImplInfo.MakeGenericMethod(keyType, returnType);\r
+                    result = (TryGetValueDelegate)Delegate.CreateDelegate(typeof(TryGetValueDelegate), strongImplInfo);\r
+                }\r
+            }\r
+\r
+            // wrap a call to the underlying IDictionary.Item()\r
+            if (result == null && typeof(IDictionary).IsAssignableFrom(targetType)) {\r
+                result = TryGetValueFromNonGenericDictionary;\r
+            }\r
+\r
+            _tryGetValueDelegateCacheLock.EnterWriteLock();\r
+            try {\r
+                _tryGetValueDelegateCache[targetType] = result;\r
+            }\r
+            finally {\r
+                _tryGetValueDelegateCacheLock.ExitWriteLock();\r
+            }\r
+\r
+            return result;\r
+        }\r
+\r
+        public static Type ExtractGenericInterface(Type queryType, Type interfaceType) {\r
+            Func<Type, bool> matchesInterface = t => t.IsGenericType && t.GetGenericTypeDefinition() == interfaceType;\r
+            return (matchesInterface(queryType)) ? queryType : queryType.GetInterfaces().FirstOrDefault(matchesInterface);\r
+        }\r
+\r
+        public static object GetDefaultValue(Type type) {\r
+            return (TypeAllowsNullValue(type)) ? null : Activator.CreateInstance(type);\r
+        }\r
+\r
+        public static bool IsCompatibleObject<T>(object value) {\r
+            return (value is T || (value == null && TypeAllowsNullValue(typeof(T))));\r
+        }\r
+\r
+        public static bool IsNullableValueType(Type type) {\r
+            return Nullable.GetUnderlyingType(type) != null;\r
+        }\r
+\r
+        private static bool StrongTryGetValueImpl<TKey, TValue>(object dictionary, string key, out object value) {\r
+            IDictionary<TKey, TValue> strongDict = (IDictionary<TKey, TValue>)dictionary;\r
+\r
+            TValue strongValue;\r
+            bool retVal = strongDict.TryGetValue((TKey)(object)key, out strongValue);\r
+            value = strongValue;\r
+            return retVal;\r
+        }\r
+\r
+        private static bool TryGetValueFromNonGenericDictionary(object dictionary, string key, out object value) {\r
+            IDictionary weakDict = (IDictionary)dictionary;\r
+\r
+            bool containsKey = weakDict.Contains(key);\r
+            value = (containsKey) ? weakDict[key] : null;\r
+            return containsKey;\r
+        }\r
+\r
+        public static bool TypeAllowsNullValue(Type type) {\r
+            return (!type.IsValueType || IsNullableValueType(type));\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/UrlHelper.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/UrlHelper.cs
new file mode 100644 (file)
index 0000000..6b310c8
--- /dev/null
@@ -0,0 +1,209 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.Routing;\r
+\r
+    public class UrlHelper {\r
+        public UrlHelper(RequestContext requestContext)\r
+            : this(requestContext, RouteTable.Routes) {\r
+        }\r
+\r
+        public UrlHelper(RequestContext requestContext, RouteCollection routeCollection) {\r
+            if (requestContext == null) {\r
+                throw new ArgumentNullException("requestContext");\r
+            }\r
+            if (routeCollection == null) {\r
+                throw new ArgumentNullException("routeCollection");\r
+            }\r
+            RequestContext = requestContext;\r
+            RouteCollection = routeCollection;\r
+        }\r
+\r
+        public RequestContext RequestContext {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public RouteCollection RouteCollection {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public string Action(string actionName) {\r
+            return GenerateUrl(null /* routeName */, actionName, null, (RouteValueDictionary)null /* routeValues */);\r
+        }\r
+\r
+        public string Action(string actionName, object routeValues) {\r
+            return GenerateUrl(null /* routeName */, actionName, null /* controllerName */, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        public string Action(string actionName, RouteValueDictionary routeValues) {\r
+            return GenerateUrl(null /* routeName */, actionName, null /* controllerName */, routeValues);\r
+        }\r
+\r
+        public string Action(string actionName, string controllerName) {\r
+            return GenerateUrl(null /* routeName */, actionName, controllerName, (RouteValueDictionary)null /* routeValues */);\r
+        }\r
+\r
+        public string Action(string actionName, string controllerName, object routeValues) {\r
+            return GenerateUrl(null /* routeName */, actionName, controllerName, new RouteValueDictionary(routeValues));\r
+        }\r
+\r
+        public string Action(string actionName, string controllerName, RouteValueDictionary routeValues) {\r
+            return GenerateUrl(null /* routeName */, actionName, controllerName, routeValues);\r
+        }\r
+\r
+        public string Action(string actionName, string controllerName, object routeValues, string protocol) {\r
+            return GenerateUrl(null /* routeName */, actionName, controllerName, protocol, null /* hostName */, null /* fragment */, new RouteValueDictionary(routeValues), RouteCollection, RequestContext, true /* includeImplicitMvcValues */);\r
+        }\r
+\r
+        public string Action(string actionName, string controllerName, RouteValueDictionary routeValues, string protocol, string hostName) {\r
+            return GenerateUrl(null /* routeName */, actionName, controllerName, protocol, hostName, null /* fragment */, routeValues, RouteCollection, RequestContext, true /* includeImplicitMvcValues */);\r
+        }\r
+\r
+        public string Content(string contentPath) {\r
+            return GenerateContentUrl(contentPath, RequestContext.HttpContext);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public static string GenerateContentUrl(string contentPath, HttpContextBase httpContext) {\r
+            if (String.IsNullOrEmpty(contentPath)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "contentPath");\r
+            }\r
+\r
+            if (httpContext == null) {\r
+                throw new ArgumentNullException("httpContext");\r
+            }\r
+\r
+            if (contentPath[0] == '~') {\r
+                return PathHelpers.GenerateClientUrl(httpContext, contentPath);\r
+            }\r
+            else {\r
+                return contentPath;\r
+            }\r
+        }\r
+\r
+        //REVIEW: Should we have an overload that takes Uri?\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",\r
+            Justification = "Needs to take same parameters as HttpUtility.UrlEncode()")]\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "For consistency, all helpers are instance methods.")]\r
+        public string Encode(string url) {\r
+            return HttpUtility.UrlEncode(url);\r
+        }\r
+\r
+        private string GenerateUrl(string routeName, string actionName, string controllerName, RouteValueDictionary routeValues) {\r
+            return GenerateUrl(routeName, actionName, controllerName, routeValues, RouteCollection, RequestContext, true /* includeImplicitMvcValues */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public static string GenerateUrl(string routeName, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, bool includeImplicitMvcValues) {\r
+            string url = GenerateUrl(routeName, actionName, controllerName, routeValues, routeCollection, requestContext, includeImplicitMvcValues);\r
+\r
+            if (url != null) {\r
+                if (!String.IsNullOrEmpty(fragment)) {\r
+                    url = url + "#" + fragment;\r
+                }\r
+\r
+                if (!String.IsNullOrEmpty(protocol) || !String.IsNullOrEmpty(hostName)) {\r
+                    Uri requestUrl = requestContext.HttpContext.Request.Url;\r
+                    protocol = (!String.IsNullOrEmpty(protocol)) ? protocol : Uri.UriSchemeHttp;\r
+                    hostName = (!String.IsNullOrEmpty(hostName)) ? hostName : requestUrl.Host;\r
+\r
+                    string port = String.Empty;\r
+                    string requestProtocol = requestUrl.Scheme;\r
+\r
+                    if (String.Equals(protocol, requestProtocol, StringComparison.OrdinalIgnoreCase)) {\r
+                        port = requestUrl.IsDefaultPort ? String.Empty : (":" + Convert.ToString(requestUrl.Port, CultureInfo.InvariantCulture));\r
+                    }\r
+\r
+                    url = protocol + Uri.SchemeDelimiter + hostName + port + url;\r
+                }\r
+            }\r
+\r
+            return url;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public static string GenerateUrl(string routeName, string actionName, string controllerName, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, bool includeImplicitMvcValues) {\r
+            if (routeCollection == null) {\r
+                throw new ArgumentNullException("routeCollection");\r
+            }\r
+\r
+            if (requestContext == null) {\r
+                throw new ArgumentNullException("requestContext");\r
+            }\r
+\r
+            RouteValueDictionary mergedRouteValues = RouteValuesHelpers.MergeRouteValues(actionName, controllerName, requestContext.RouteData.Values, routeValues, includeImplicitMvcValues);\r
+\r
+            VirtualPathData vpd = routeCollection.GetVirtualPathForArea(requestContext, routeName, mergedRouteValues);\r
+            if (vpd == null) {\r
+                return null;\r
+            }\r
+\r
+            string modifiedUrl = PathHelpers.GenerateClientUrl(requestContext.HttpContext, vpd.VirtualPath);\r
+            return modifiedUrl;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public string RouteUrl(object routeValues) {\r
+            return RouteUrl(null /* routeName */, routeValues);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public string RouteUrl(RouteValueDictionary routeValues) {\r
+            return RouteUrl(null /* routeName */, routeValues);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public string RouteUrl(string routeName) {\r
+            return RouteUrl(routeName, (object)null /* routeValues */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public string RouteUrl(string routeName, object routeValues) {\r
+            return RouteUrl(routeName, routeValues, null /* protocol */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public string RouteUrl(string routeName, RouteValueDictionary routeValues) {\r
+            return RouteUrl(routeName, routeValues, null /* protocol */, null /* hostName */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public string RouteUrl(string routeName, object routeValues, string protocol) {\r
+            return GenerateUrl(routeName, null /* actionName */, null /* controllerName */, protocol, null /* hostName */, null /* fragment */, new RouteValueDictionary(routeValues), RouteCollection, RequestContext, false /* includeImplicitMvcValues */);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",\r
+            Justification = "As the return value will used only for rendering, string return value is more appropriate.")]\r
+        public string RouteUrl(string routeName, RouteValueDictionary routeValues, string protocol, string hostName) {\r
+            return GenerateUrl(routeName, null /* actionName */, null /* controllerName */, protocol, hostName, null /* fragment */, routeValues, RouteCollection, RequestContext, false /* includeImplicitMvcValues */);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/UrlParameter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/UrlParameter.cs
new file mode 100644 (file)
index 0000000..3d39c1e
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public sealed class UrlParameter {\r
+\r
+        [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",\r
+            Justification = "This type is immutable.")]\r
+        public static readonly UrlParameter Optional = new UrlParameter();\r
+\r
+        // singleton constructor\r
+        private UrlParameter() { }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValidateAntiForgeryTokenAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValidateAntiForgeryTokenAttribute.cs
new file mode 100644 (file)
index 0000000..0eedc81
--- /dev/null
@@ -0,0 +1,94 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Web;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]\r
+    public sealed class ValidateAntiForgeryTokenAttribute : FilterAttribute, IAuthorizationFilter {\r
+\r
+        private string _salt;\r
+        private AntiForgeryDataSerializer _serializer;\r
+\r
+        public string Salt {\r
+            get {\r
+                return _salt ?? String.Empty;\r
+            }\r
+            set {\r
+                _salt = value;\r
+            }\r
+        }\r
+\r
+        internal AntiForgeryDataSerializer Serializer {\r
+            get {\r
+                if (_serializer == null) {\r
+                    _serializer = new AntiForgeryDataSerializer();\r
+                }\r
+                return _serializer;\r
+            }\r
+            set {\r
+                _serializer = value;\r
+            }\r
+        }\r
+\r
+        private bool ValidateFormToken(AntiForgeryData token) {\r
+            return (String.Equals(Salt, token.Salt, StringComparison.Ordinal));\r
+        }\r
+\r
+        private static HttpAntiForgeryException CreateValidationException() {\r
+            return new HttpAntiForgeryException(MvcResources.AntiForgeryToken_ValidationFailed);\r
+        }\r
+\r
+        public void OnAuthorization(AuthorizationContext filterContext) {\r
+            if (filterContext == null) {\r
+                throw new ArgumentNullException("filterContext");\r
+            }\r
+\r
+            string fieldName = AntiForgeryData.GetAntiForgeryTokenName(null);\r
+            string cookieName = AntiForgeryData.GetAntiForgeryTokenName(filterContext.HttpContext.Request.ApplicationPath);\r
+\r
+            HttpCookie cookie = filterContext.HttpContext.Request.Cookies[cookieName];\r
+            if (cookie == null || String.IsNullOrEmpty(cookie.Value)) {\r
+                // error: cookie token is missing\r
+                throw CreateValidationException();\r
+            }\r
+            AntiForgeryData cookieToken = Serializer.Deserialize(cookie.Value);\r
+\r
+            string formValue = filterContext.HttpContext.Request.Form[fieldName];\r
+            if (String.IsNullOrEmpty(formValue)) {\r
+                // error: form token is missing\r
+                throw CreateValidationException();\r
+            }\r
+            AntiForgeryData formToken = Serializer.Deserialize(formValue);\r
+\r
+            if (!String.Equals(cookieToken.Value, formToken.Value, StringComparison.Ordinal)) {\r
+                // error: form token does not match cookie token\r
+                throw CreateValidationException();\r
+            }\r
+\r
+            string currentUsername = AntiForgeryData.GetUsername(filterContext.HttpContext.User);\r
+            if (!String.Equals(formToken.Username, currentUsername, StringComparison.OrdinalIgnoreCase)) {\r
+                // error: form token is not valid for this user\r
+                // (don't care about cookie token)\r
+                throw CreateValidationException();\r
+            }\r
+\r
+            if (!ValidateFormToken(formToken)) {\r
+                // error: custom validation failed\r
+                throw CreateValidationException();\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValidateInputAttribute.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValidateInputAttribute.cs
new file mode 100644 (file)
index 0000000..7e07f99
--- /dev/null
@@ -0,0 +1,40 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes",\r
+        Justification = "No compelling performance reason to seal this type.")]\r
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]\r
+    public class ValidateInputAttribute : FilterAttribute, IAuthorizationFilter {\r
+\r
+        public ValidateInputAttribute(bool enableValidation) {\r
+            EnableValidation = enableValidation;\r
+        }\r
+\r
+        public bool EnableValidation {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public virtual void OnAuthorization(AuthorizationContext filterContext) {\r
+            if (filterContext == null) {\r
+                throw new ArgumentNullException("filterContext");\r
+            }\r
+\r
+            filterContext.Controller.ValidateRequest = EnableValidation;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderCollection.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderCollection.cs
new file mode 100644 (file)
index 0000000..46ec5ae
--- /dev/null
@@ -0,0 +1,54 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.ObjectModel;\r
+    using System.Linq;\r
+\r
+    public class ValueProviderCollection : Collection<IValueProvider>, IValueProvider {\r
+\r
+        public ValueProviderCollection() {\r
+        }\r
+\r
+        public ValueProviderCollection(IList<IValueProvider> list)\r
+            : base(list) {\r
+        }\r
+\r
+        public virtual bool ContainsPrefix(string prefix) {\r
+            return this.Any(vp => vp.ContainsPrefix(prefix));\r
+        }\r
+\r
+        public virtual ValueProviderResult GetValue(string key) {\r
+            return (from provider in this\r
+                    let result = provider.GetValue(key)\r
+                    where result != null\r
+                    select result).FirstOrDefault();\r
+        }\r
+\r
+        protected override void InsertItem(int index, IValueProvider item) {\r
+            if (item == null) {\r
+                throw new ArgumentNullException("item");\r
+            }\r
+            base.InsertItem(index, item);\r
+        }\r
+\r
+        protected override void SetItem(int index, IValueProvider item) {\r
+            if (item == null) {\r
+                throw new ArgumentNullException("item");\r
+            }\r
+            base.SetItem(index, item);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderDictionary.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderDictionary.cs
new file mode 100644 (file)
index 0000000..a5ea7f0
--- /dev/null
@@ -0,0 +1,208 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.Collections.Specialized;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Web.Routing;\r
+\r
+    [Obsolete("The recommended alternative is to use one of the specific ValueProvider types, such as FormValueProvider.")]\r
+    public class ValueProviderDictionary : IDictionary<string, ValueProviderResult>, IValueProvider {\r
+\r
+        private readonly Dictionary<string, ValueProviderResult> _dictionary = new Dictionary<string, ValueProviderResult>(StringComparer.OrdinalIgnoreCase);\r
+\r
+        public ValueProviderDictionary(ControllerContext controllerContext) {\r
+            ControllerContext = controllerContext;\r
+            if (controllerContext != null) {\r
+                PopulateDictionary();\r
+            }\r
+        }\r
+\r
+        public ControllerContext ControllerContext {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public int Count {\r
+            get {\r
+                return ((ICollection<KeyValuePair<string, ValueProviderResult>>)Dictionary).Count;\r
+            }\r
+        }\r
+\r
+        internal Dictionary<string, ValueProviderResult> Dictionary {\r
+            get {\r
+                return _dictionary;\r
+            }\r
+        }\r
+\r
+        public bool IsReadOnly {\r
+            get {\r
+                return ((ICollection<KeyValuePair<string, ValueProviderResult>>)Dictionary).IsReadOnly;\r
+            }\r
+        }\r
+\r
+        public ICollection<string> Keys {\r
+            get {\r
+                return Dictionary.Keys;\r
+            }\r
+        }\r
+\r
+        public ValueProviderResult this[string key] {\r
+            get {\r
+                ValueProviderResult result;\r
+                Dictionary.TryGetValue(key, out result);\r
+                return result;\r
+            }\r
+            set {\r
+                Dictionary[key] = value;\r
+            }\r
+        }\r
+\r
+        public ICollection<ValueProviderResult> Values {\r
+            get {\r
+                return Dictionary.Values;\r
+            }\r
+        }\r
+\r
+        public void Add(KeyValuePair<string, ValueProviderResult> item) {\r
+            ((ICollection<KeyValuePair<string, ValueProviderResult>>)Dictionary).Add(item);\r
+        }\r
+\r
+        public void Add(string key, object value) {\r
+            string attemptedValue = Convert.ToString(value, CultureInfo.InvariantCulture);\r
+            ValueProviderResult vpResult = new ValueProviderResult(value, attemptedValue, CultureInfo.InvariantCulture);\r
+            Add(key, vpResult);\r
+        }\r
+\r
+        public void Add(string key, ValueProviderResult value) {\r
+            Dictionary.Add(key, value);\r
+        }\r
+\r
+        private void AddToDictionaryIfNotPresent(string key, ValueProviderResult result) {\r
+            if (!String.IsNullOrEmpty(key)) {\r
+                if (!Dictionary.ContainsKey(key)) {\r
+                    Dictionary.Add(key, result);\r
+                }\r
+            }\r
+        }\r
+\r
+        public void Clear() {\r
+            ((ICollection<KeyValuePair<string, ValueProviderResult>>)Dictionary).Clear();\r
+        }\r
+\r
+        public bool Contains(KeyValuePair<string, ValueProviderResult> item) {\r
+            return ((ICollection<KeyValuePair<string, ValueProviderResult>>)Dictionary).Contains(item);\r
+        }\r
+\r
+        public bool ContainsKey(string key) {\r
+            return Dictionary.ContainsKey(key);\r
+        }\r
+\r
+        public void CopyTo(KeyValuePair<string, ValueProviderResult>[] array, int arrayIndex) {\r
+            ((ICollection<KeyValuePair<string, ValueProviderResult>>)Dictionary).CopyTo(array, arrayIndex);\r
+        }\r
+\r
+        public IEnumerator<KeyValuePair<string, ValueProviderResult>> GetEnumerator() {\r
+            return ((IEnumerable<KeyValuePair<string, ValueProviderResult>>)Dictionary).GetEnumerator();\r
+        }\r
+\r
+        private void PopulateDictionary() {\r
+            CultureInfo currentCulture = CultureInfo.CurrentCulture;\r
+            CultureInfo invariantCulture = CultureInfo.InvariantCulture;\r
+\r
+            // We use this order of precedence to populate the dictionary:\r
+            // 1. Request form submission (should be culture-aware)\r
+            // 2. Values from the RouteData (could be from the typed-in URL or from the route's default values)\r
+            // 3. URI query string\r
+\r
+            NameValueCollection form = ControllerContext.HttpContext.Request.Form;\r
+            if (form != null) {\r
+                string[] keys = form.AllKeys;\r
+                foreach (string key in keys) {\r
+                    string[] rawValue = form.GetValues(key);\r
+                    string attemptedValue = form[key];\r
+                    ValueProviderResult result = new ValueProviderResult(rawValue, attemptedValue, currentCulture);\r
+                    AddToDictionaryIfNotPresent(key, result);\r
+                }\r
+            }\r
+\r
+            RouteValueDictionary routeValues = ControllerContext.RouteData.Values;\r
+            if (routeValues != null) {\r
+                foreach (var kvp in routeValues) {\r
+                    string key = kvp.Key;\r
+                    object rawValue = kvp.Value;\r
+                    string attemptedValue = Convert.ToString(rawValue, invariantCulture);\r
+                    ValueProviderResult result = new ValueProviderResult(rawValue, attemptedValue, invariantCulture);\r
+                    AddToDictionaryIfNotPresent(key, result);\r
+                }\r
+            }\r
+\r
+            NameValueCollection queryString = ControllerContext.HttpContext.Request.QueryString;\r
+            if (queryString != null) {\r
+                string[] keys = queryString.AllKeys;\r
+                foreach (string key in keys) {\r
+                    string[] rawValue = queryString.GetValues(key);\r
+                    string attemptedValue = queryString[key];\r
+                    ValueProviderResult result = new ValueProviderResult(rawValue, attemptedValue, invariantCulture);\r
+                    AddToDictionaryIfNotPresent(key, result);\r
+                }\r
+            }\r
+        }\r
+\r
+        public bool Remove(KeyValuePair<string, ValueProviderResult> item) {\r
+            return ((ICollection<KeyValuePair<string, ValueProviderResult>>)Dictionary).Remove(item);\r
+        }\r
+\r
+        public bool Remove(string key) {\r
+            return Dictionary.Remove(key);\r
+        }\r
+\r
+        public bool TryGetValue(string key, out ValueProviderResult value) {\r
+            return Dictionary.TryGetValue(key, out value);\r
+        }\r
+\r
+        #region IEnumerable Members\r
+        IEnumerator IEnumerable.GetEnumerator() {\r
+            return ((IEnumerable)Dictionary).GetEnumerator();\r
+        }\r
+        #endregion\r
+\r
+        #region IValueProvider Members\r
+        [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes",\r
+            Justification = "The declaring type is obsolete, so there is little benefit to exposing this as a virtual method.")]\r
+        bool IValueProvider.ContainsPrefix(string prefix) {\r
+            if (prefix == null) {\r
+                throw new ArgumentNullException("prefix");\r
+            }\r
+\r
+            return ValueProviderUtil.CollectionContainsPrefix(Keys, prefix);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes",\r
+            Justification = "The declaring type is obsolete, so there is little benefit to exposing this as a virtual method.")]\r
+        ValueProviderResult IValueProvider.GetValue(string key) {\r
+            if (key == null) {\r
+                throw new ArgumentNullException("key");\r
+            }\r
+\r
+            ValueProviderResult vpResult;\r
+            TryGetValue(key, out vpResult);\r
+            return vpResult;\r
+        }\r
+        #endregion\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderFactories.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderFactories.cs
new file mode 100644 (file)
index 0000000..f926e58
--- /dev/null
@@ -0,0 +1,32 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public static class ValueProviderFactories {\r
+\r
+        private static readonly ValueProviderFactoryCollection _factories = new ValueProviderFactoryCollection() {\r
+            new FormValueProviderFactory(),\r
+            new RouteDataValueProviderFactory(),\r
+            new QueryStringValueProviderFactory(),\r
+            new HttpFileCollectionValueProviderFactory()\r
+        };\r
+\r
+        public static ValueProviderFactoryCollection Factories {\r
+            get {\r
+                return _factories;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderFactory.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderFactory.cs
new file mode 100644 (file)
index 0000000..3d2e42a
--- /dev/null
@@ -0,0 +1,19 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public abstract class ValueProviderFactory {\r
+        public abstract IValueProvider GetValueProvider(ControllerContext controllerContext);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderFactoryCollection.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderFactoryCollection.cs
new file mode 100644 (file)
index 0000000..2d797e2
--- /dev/null
@@ -0,0 +1,53 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.ObjectModel;\r
+    using System.Linq;\r
+\r
+    public class ValueProviderFactoryCollection : Collection<ValueProviderFactory> {\r
+\r
+        public ValueProviderFactoryCollection() {\r
+        }\r
+\r
+        public ValueProviderFactoryCollection(IList<ValueProviderFactory> list)\r
+            : base(list) {\r
+        }\r
+\r
+        public IValueProvider GetValueProvider(ControllerContext controllerContext) {\r
+            var valueProviders = from factory in this\r
+                                 let valueProvider = factory.GetValueProvider(controllerContext)\r
+                                 where valueProvider != null\r
+                                 select valueProvider;\r
+\r
+            return new ValueProviderCollection(valueProviders.ToList());\r
+        }\r
+\r
+\r
+        protected override void InsertItem(int index, ValueProviderFactory item) {\r
+            if (item == null) {\r
+                throw new ArgumentNullException("item");\r
+            }\r
+            base.InsertItem(index, item);\r
+        }\r
+\r
+        protected override void SetItem(int index, ValueProviderFactory item) {\r
+            if (item == null) {\r
+                throw new ArgumentNullException("item");\r
+            }\r
+            base.SetItem(index, item);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderResult.cs
new file mode 100644 (file)
index 0000000..790a04a
--- /dev/null
@@ -0,0 +1,147 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.ComponentModel;\r
+    using System.Globalization;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    [Serializable]\r
+    public class ValueProviderResult {\r
+\r
+        private static readonly CultureInfo _staticCulture = CultureInfo.InvariantCulture;\r
+        private CultureInfo _instanceCulture;\r
+\r
+        // default constructor so that subclassed types can set the properties themselves\r
+        protected ValueProviderResult() {\r
+        }\r
+\r
+        public ValueProviderResult(object rawValue, string attemptedValue, CultureInfo culture) {\r
+            RawValue = rawValue;\r
+            AttemptedValue = attemptedValue;\r
+            Culture = culture;\r
+        }\r
+\r
+        public string AttemptedValue {\r
+            get;\r
+            protected set;\r
+        }\r
+\r
+        public CultureInfo Culture {\r
+            get {\r
+                if (_instanceCulture == null) {\r
+                    _instanceCulture = _staticCulture;\r
+                }\r
+                return _instanceCulture;\r
+            }\r
+            protected set {\r
+                _instanceCulture = value;\r
+            }\r
+        }\r
+\r
+        public object RawValue {\r
+            get;\r
+            protected set;\r
+        }\r
+\r
+        private static object ConvertSimpleType(CultureInfo culture, object value, Type destinationType) {\r
+            if (value == null || destinationType.IsInstanceOfType(value)) {\r
+                return value;\r
+            }\r
+\r
+            // if this is a user-input value but the user didn't type anything, return no value\r
+            string valueAsString = value as string;\r
+            if (valueAsString != null && valueAsString.Trim().Length == 0) {\r
+                return null;\r
+            }\r
+\r
+            TypeConverter converter = TypeDescriptor.GetConverter(destinationType);\r
+            bool canConvertFrom = converter.CanConvertFrom(value.GetType());\r
+            if (!canConvertFrom) {\r
+                converter = TypeDescriptor.GetConverter(value.GetType());\r
+            }\r
+            if (!(canConvertFrom || converter.CanConvertTo(destinationType))) {\r
+                string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ValueProviderResult_NoConverterExists,\r
+                    value.GetType().FullName, destinationType.FullName);\r
+                throw new InvalidOperationException(message);\r
+            }\r
+\r
+            try {\r
+                object convertedValue = (canConvertFrom) ?\r
+                     converter.ConvertFrom(null /* context */, culture, value) :\r
+                     converter.ConvertTo(null /* context */, culture, value, destinationType);\r
+                return convertedValue;\r
+            }\r
+            catch (Exception ex) {\r
+                string message = String.Format(CultureInfo.CurrentUICulture, MvcResources.ValueProviderResult_ConversionThrew,\r
+                    value.GetType().FullName, destinationType.FullName);\r
+                throw new InvalidOperationException(message, ex);\r
+            }\r
+        }\r
+\r
+        public object ConvertTo(Type type) {\r
+            return ConvertTo(type, null /* culture */);\r
+        }\r
+\r
+        public virtual object ConvertTo(Type type, CultureInfo culture) {\r
+            if (type == null) {\r
+                throw new ArgumentNullException("type");\r
+            }\r
+\r
+            CultureInfo cultureToUse = culture ?? Culture;\r
+            return UnwrapPossibleArrayType(cultureToUse, RawValue, type);\r
+        }\r
+\r
+        private static object UnwrapPossibleArrayType(CultureInfo culture, object value, Type destinationType) {\r
+            if (value == null || destinationType.IsInstanceOfType(value)) {\r
+                return value;\r
+            }\r
+\r
+            // array conversion results in four cases, as below\r
+            Array valueAsArray = value as Array;\r
+            if (destinationType.IsArray) {\r
+                Type destinationElementType = destinationType.GetElementType();\r
+                if (valueAsArray != null) {\r
+                    // case 1: both destination + source type are arrays, so convert each element\r
+                    IList converted = Array.CreateInstance(destinationElementType, valueAsArray.Length);\r
+                    for (int i = 0; i < valueAsArray.Length; i++) {\r
+                        converted[i] = ConvertSimpleType(culture, valueAsArray.GetValue(i), destinationElementType);\r
+                    }\r
+                    return converted;\r
+                }\r
+                else {\r
+                    // case 2: destination type is array but source is single element, so wrap element in array + convert\r
+                    object element = ConvertSimpleType(culture, value, destinationElementType);\r
+                    IList converted = Array.CreateInstance(destinationElementType, 1);\r
+                    converted[0] = element;\r
+                    return converted;\r
+                }\r
+            }\r
+            else if (valueAsArray != null) {\r
+                // case 3: destination type is single element but source is array, so extract first element + convert\r
+                if (valueAsArray.Length > 0) {\r
+                    value = valueAsArray.GetValue(0);\r
+                    return ConvertSimpleType(culture, value, destinationType);\r
+                }\r
+                else {\r
+                    // case 3(a): source is empty array, so can't perform conversion\r
+                    return null;\r
+                }\r
+            }\r
+            // case 4: both destination + source type are single elements, so convert\r
+            return ConvertSimpleType(culture, value, destinationType);\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderUtil.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ValueProviderUtil.cs
new file mode 100644 (file)
index 0000000..4bbad40
--- /dev/null
@@ -0,0 +1,63 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Linq;\r
+\r
+    internal static class ValueProviderUtil {\r
+\r
+        // Given "foo.bar[baz].quux", this method will return:\r
+        // - "foo.bar[baz].quux"\r
+        // - "foo.bar[baz]"\r
+        // - "foo.bar"\r
+        // - "foo"\r
+        public static IEnumerable<string> GetPrefixes(string key) {\r
+            yield return key;\r
+            for (int i = key.Length - 1; i >= 0; i--) {\r
+                switch (key[i]) {\r
+                    case '.':\r
+                    case '[':\r
+                        yield return key.Substring(0, i);\r
+                        break;\r
+                }\r
+            }\r
+        }\r
+\r
+        public static bool CollectionContainsPrefix(IEnumerable<string> collection, string prefix) {\r
+            foreach (string key in collection) {\r
+                if (key != null) {\r
+                    if (prefix.Length == 0) {\r
+                        return true; // shortcut - non-null key matches empty prefix\r
+                    }\r
+\r
+                    if (key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) {\r
+                        if (key.Length == prefix.Length) {\r
+                            return true; // exact match\r
+                        }\r
+                        else {\r
+                            switch (key[prefix.Length]) {\r
+                                case '.': // known separator characters\r
+                                case '[':\r
+                                    return true;\r
+                            }\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+\r
+            return false; // nothing found\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewContext.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewContext.cs
new file mode 100644 (file)
index 0000000..882c6df
--- /dev/null
@@ -0,0 +1,153 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.IO;\r
+    using System.Web.Script.Serialization;\r
+\r
+    public class ViewContext : ControllerContext {\r
+\r
+        private const string _clientValidationScript = @"<script type=""text/javascript"">\r
+//<![CDATA[\r
+if (!window.mvcClientValidationMetadata) {{ window.mvcClientValidationMetadata = []; }}\r
+window.mvcClientValidationMetadata.push({0});\r
+//]]>\r
+</script>";\r
+\r
+        // Some values have to be stored in HttpContext.Items in order to be propagated between calls\r
+        // to RenderPartial(), RenderAction(), etc.\r
+        private static readonly object _clientValidationEnabledKey = new object();\r
+        private static readonly object _formContextKey = new object();\r
+        private static readonly object _lastFormNumKey = new object();\r
+\r
+        private Func<string> _formIdGenerator;\r
+\r
+        // parameterless constructor used for mocking\r
+        public ViewContext() {\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
+        public ViewContext(ControllerContext controllerContext, IView view, ViewDataDictionary viewData, TempDataDictionary tempData, TextWriter writer)\r
+            : base(controllerContext) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (view == null) {\r
+                throw new ArgumentNullException("view");\r
+            }\r
+            if (viewData == null) {\r
+                throw new ArgumentNullException("viewData");\r
+            }\r
+            if (tempData == null) {\r
+                throw new ArgumentNullException("tempData");\r
+            }\r
+            if (writer == null) {\r
+                throw new ArgumentNullException("writer");\r
+            }\r
+\r
+            View = view;\r
+            ViewData = viewData;\r
+            Writer = writer;\r
+            TempData = tempData;\r
+        }\r
+\r
+        public virtual bool ClientValidationEnabled {\r
+            get {\r
+                return (HttpContext.Items[_clientValidationEnabledKey] as bool?).GetValueOrDefault();\r
+            }\r
+            set {\r
+                HttpContext.Items[_clientValidationEnabledKey] = value;\r
+            }\r
+        }\r
+\r
+        public virtual FormContext FormContext {\r
+            get {\r
+                return HttpContext.Items[_formContextKey] as FormContext;\r
+            }\r
+            set {\r
+                HttpContext.Items[_formContextKey] = value;\r
+            }\r
+        }\r
+\r
+        internal Func<string> FormIdGenerator {\r
+            get {\r
+                if (_formIdGenerator == null) {\r
+                    _formIdGenerator = DefaultFormIdGenerator;\r
+                }\r
+                return _formIdGenerator;\r
+            }\r
+            set {\r
+                _formIdGenerator = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "The property setter is only here to support mocking this type and should not be called at runtime.")]\r
+        public virtual TempDataDictionary TempData {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual IView View {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "The property setter is only here to support mocking this type and should not be called at runtime.")]\r
+        public virtual ViewDataDictionary ViewData {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public virtual TextWriter Writer {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        private string DefaultFormIdGenerator() {\r
+            int formNum = IncrementFormCount(HttpContext.Items);\r
+            return String.Format(CultureInfo.InvariantCulture, "form{0}", formNum);\r
+        }\r
+\r
+        internal FormContext GetFormContextForClientValidation() {\r
+            return (ClientValidationEnabled) ? FormContext : null;\r
+        }\r
+\r
+        private static int IncrementFormCount(IDictionary items) {\r
+            object lastFormNum = items[_lastFormNumKey];\r
+            int newFormNum = (lastFormNum != null) ? ((int)lastFormNum) + 1 : 0;\r
+            items[_lastFormNumKey] = newFormNum;\r
+            return newFormNum;\r
+        }\r
+\r
+        public void OutputClientValidation() {\r
+            FormContext formContext = GetFormContextForClientValidation();\r
+            if (formContext == null) {\r
+                return; // do nothing\r
+            }\r
+                        \r
+            string scriptWithCorrectNewLines = _clientValidationScript.Replace("\r\n", Environment.NewLine);\r
+            string validationJson = formContext.GetJsonValidationMetadata();\r
+            string formatted = String.Format(CultureInfo.InvariantCulture, scriptWithCorrectNewLines, validationJson);\r
+\r
+            Writer.Write(formatted);\r
+            FormContext = null;\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewDataDictionary.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewDataDictionary.cs
new file mode 100644 (file)
index 0000000..28b25dd
--- /dev/null
@@ -0,0 +1,356 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Collections.Generic;\r
+    using System.ComponentModel;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Reflection;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    // TODO: Unit test ModelState interaction with VDD\r
+\r
+    public class ViewDataDictionary : IDictionary<string, object> {\r
+\r
+        private readonly Dictionary<string, object> _innerDictionary = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);\r
+        private object _model;\r
+        private ModelMetadata _modelMetadata;\r
+        private readonly ModelStateDictionary _modelState = new ModelStateDictionary();\r
+        private TemplateInfo _templateMetadata;\r
+\r
+        public ViewDataDictionary()\r
+            : this((object)null) {\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "See note on SetModel() method.")]\r
+        public ViewDataDictionary(object model) {\r
+            Model = model;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
+            Justification = "See note on SetModel() method.")]\r
+        public ViewDataDictionary(ViewDataDictionary dictionary) {\r
+            if (dictionary == null) {\r
+                throw new ArgumentNullException("dictionary");\r
+            }\r
+\r
+            foreach (var entry in dictionary) {\r
+                _innerDictionary.Add(entry.Key, entry.Value);\r
+            }\r
+            foreach (var entry in dictionary.ModelState) {\r
+                ModelState.Add(entry.Key, entry.Value);\r
+            }\r
+\r
+            Model = dictionary.Model;\r
+            TemplateInfo = dictionary.TemplateInfo;\r
+\r
+            // PERF: Don't unnecessarily instantiate the model metadata\r
+            _modelMetadata = dictionary._modelMetadata;\r
+        }\r
+\r
+        public int Count {\r
+            get {\r
+                return _innerDictionary.Count;\r
+            }\r
+        }\r
+\r
+        public bool IsReadOnly {\r
+            get {\r
+                return ((IDictionary<string, object>)_innerDictionary).IsReadOnly;\r
+            }\r
+        }\r
+\r
+        public ICollection<string> Keys {\r
+            get {\r
+                return _innerDictionary.Keys;\r
+            }\r
+        }\r
+\r
+        public object Model {\r
+            get {\r
+                return _model;\r
+            }\r
+            set {\r
+                _modelMetadata = null;\r
+                SetModel(value);\r
+            }\r
+        }\r
+\r
+        public virtual ModelMetadata ModelMetadata {\r
+            get {\r
+                if (_modelMetadata == null && _model != null) {\r
+                    _modelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => _model, _model.GetType());\r
+                }\r
+                return _modelMetadata;\r
+            }\r
+            set {\r
+                _modelMetadata = value;\r
+            }\r
+        }\r
+\r
+        public ModelStateDictionary ModelState {\r
+            get {\r
+                return _modelState;\r
+            }\r
+        }\r
+\r
+        public object this[string key] {\r
+            get {\r
+                object value;\r
+                _innerDictionary.TryGetValue(key, out value);\r
+                return value;\r
+            }\r
+            set {\r
+                _innerDictionary[key] = value;\r
+            }\r
+        }\r
+\r
+        public TemplateInfo TemplateInfo {\r
+            get {\r
+                if (_templateMetadata == null) {\r
+                    _templateMetadata = new TemplateInfo();\r
+                }\r
+                return _templateMetadata;\r
+            }\r
+            set {\r
+                _templateMetadata = value;\r
+            }\r
+        }\r
+\r
+        public ICollection<object> Values {\r
+            get {\r
+                return _innerDictionary.Values;\r
+            }\r
+        }\r
+\r
+        public void Add(KeyValuePair<string, object> item) {\r
+            ((IDictionary<string, object>)_innerDictionary).Add(item);\r
+        }\r
+\r
+        public void Add(string key, object value) {\r
+            _innerDictionary.Add(key, value);\r
+        }\r
+\r
+        public void Clear() {\r
+            _innerDictionary.Clear();\r
+        }\r
+\r
+        public bool Contains(KeyValuePair<string, object> item) {\r
+            return ((IDictionary<string, object>)_innerDictionary).Contains(item);\r
+        }\r
+\r
+        public bool ContainsKey(string key) {\r
+            return _innerDictionary.ContainsKey(key);\r
+        }\r
+\r
+        public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex) {\r
+            ((IDictionary<string, object>)_innerDictionary).CopyTo(array, arrayIndex);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Eval",\r
+            Justification = "Commonly used shorthand for Evaluate.")]\r
+        public object Eval(string expression) {\r
+            ViewDataInfo info = GetViewDataInfo(expression);\r
+            return (info != null) ? info.Value : null;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Eval",\r
+            Justification = "Commonly used shorthand for Evaluate.")]\r
+        public string Eval(string expression, string format) {\r
+            object value = Eval(expression);\r
+\r
+            if (value == null) {\r
+                return String.Empty;\r
+            }\r
+\r
+            if (String.IsNullOrEmpty(format)) {\r
+                return Convert.ToString(value, CultureInfo.CurrentCulture);\r
+            }\r
+            else {\r
+                return String.Format(CultureInfo.CurrentCulture, format, value);\r
+            }\r
+        }\r
+\r
+        public IEnumerator<KeyValuePair<string, object>> GetEnumerator() {\r
+            return _innerDictionary.GetEnumerator();\r
+        }\r
+\r
+        public ViewDataInfo GetViewDataInfo(string expression) {\r
+            if (String.IsNullOrEmpty(expression)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "expression");\r
+            }\r
+\r
+            return ViewDataEvaluator.Eval(this, expression);\r
+        }\r
+\r
+        public bool Remove(KeyValuePair<string, object> item) {\r
+            return ((IDictionary<string, object>)_innerDictionary).Remove(item);\r
+        }\r
+\r
+        public bool Remove(string key) {\r
+            return _innerDictionary.Remove(key);\r
+        }\r
+\r
+        // This method will execute before the derived type's instance constructor executes. Derived types must\r
+        // be aware of this and should plan accordingly. For example, the logic in SetModel() should be simple\r
+        // enough so as not to depend on the "this" pointer referencing a fully constructed object.\r
+        protected virtual void SetModel(object value) {\r
+            _model = value;\r
+        }\r
+\r
+        public bool TryGetValue(string key, out object value) {\r
+            return _innerDictionary.TryGetValue(key, out value);\r
+        }\r
+\r
+        internal static class ViewDataEvaluator {\r
+\r
+            public static ViewDataInfo Eval(ViewDataDictionary vdd, string expression) {\r
+                //Given an expression "foo.bar.baz" we look up the following (pseudocode):\r
+                //  this["foo.bar.baz.quux"]\r
+                //  this["foo.bar.baz"]["quux"]\r
+                //  this["foo.bar"]["baz.quux]\r
+                //  this["foo.bar"]["baz"]["quux"]\r
+                //  this["foo"]["bar.baz.quux"]\r
+                //  this["foo"]["bar.baz"]["quux"]\r
+                //  this["foo"]["bar"]["baz.quux"]\r
+                //  this["foo"]["bar"]["baz"]["quux"]\r
+\r
+                ViewDataInfo evaluated = EvalComplexExpression(vdd, expression);\r
+                return evaluated;\r
+            }\r
+\r
+            private static ViewDataInfo EvalComplexExpression(object indexableObject, string expression) {\r
+                foreach (ExpressionPair expressionPair in GetRightToLeftExpressions(expression)) {\r
+                    string subExpression = expressionPair.Left;\r
+                    string postExpression = expressionPair.Right;\r
+\r
+                    ViewDataInfo subTargetInfo = GetPropertyValue(indexableObject, subExpression);\r
+                    if (subTargetInfo != null) {\r
+                        if (String.IsNullOrEmpty(postExpression)) {\r
+                            return subTargetInfo;\r
+                        }\r
+\r
+                        if (subTargetInfo.Value != null) {\r
+                            ViewDataInfo potential = EvalComplexExpression(subTargetInfo.Value, postExpression);\r
+                            if (potential != null) {\r
+                                return potential;\r
+                            }\r
+                        }\r
+                    }\r
+                }\r
+                return null;\r
+            }\r
+\r
+            private static IEnumerable<ExpressionPair> GetRightToLeftExpressions(string expression) {\r
+                // Produces an enumeration of all the combinations of complex property names\r
+                // given a complex expression. See the list above for an example of the result\r
+                // of the enumeration.\r
+\r
+                yield return new ExpressionPair(expression, String.Empty);\r
+\r
+                int lastDot = expression.LastIndexOf('.');\r
+\r
+                string subExpression = expression;\r
+                string postExpression = string.Empty;\r
+\r
+                while (lastDot > -1) {\r
+                    subExpression = expression.Substring(0, lastDot);\r
+                    postExpression = expression.Substring(lastDot + 1);\r
+                    yield return new ExpressionPair(subExpression, postExpression);\r
+\r
+                    lastDot = subExpression.LastIndexOf('.');\r
+                }\r
+            }\r
+\r
+            private static ViewDataInfo GetIndexedPropertyValue(object indexableObject, string key) {\r
+                IDictionary<string, object> dict = indexableObject as IDictionary<string, object>;\r
+                object value = null;\r
+                bool success = false;\r
+                \r
+                if (dict != null) {\r
+                    success = dict.TryGetValue(key, out value);\r
+                }\r
+                else {\r
+                    TryGetValueDelegate tgvDel = TypeHelpers.CreateTryGetValueDelegate(indexableObject.GetType());\r
+                    if (tgvDel != null) {\r
+                        success = tgvDel(indexableObject, key, out value);\r
+                    }\r
+                }\r
+                \r
+                if (success) {\r
+                    return new ViewDataInfo() {\r
+                        Container = indexableObject,\r
+                        Value = value\r
+                    };\r
+                }\r
+\r
+                return null;\r
+            }\r
+\r
+            private static ViewDataInfo GetPropertyValue(object container, string propertyName) {\r
+                // This method handles one "segment" of a complex property expression\r
+\r
+                // First, we try to evaluate the property based on its indexer\r
+                ViewDataInfo value = GetIndexedPropertyValue(container, propertyName);\r
+                if (value != null) {\r
+                    return value;\r
+                }\r
+\r
+                // If the indexer didn't return anything useful, continue...\r
+\r
+                // If the container is a ViewDataDictionary then treat its Model property\r
+                // as the container instead of the ViewDataDictionary itself.\r
+                ViewDataDictionary vdd = container as ViewDataDictionary;\r
+                if (vdd != null) {\r
+                    container = vdd.Model;\r
+                }\r
+\r
+                // If the container is null, we're out of options\r
+                if (container == null) {\r
+                    return null;\r
+                }\r
+\r
+                // Second, we try to use PropertyDescriptors and treat the expression as a property name\r
+                PropertyDescriptor descriptor = TypeDescriptor.GetProperties(container).Find(propertyName, true);\r
+                if (descriptor == null) {\r
+                    return null;\r
+                }\r
+\r
+                return new ViewDataInfo(() => descriptor.GetValue(container)) {\r
+                    Container = container,\r
+                    PropertyDescriptor = descriptor\r
+                };\r
+            }\r
+\r
+            private struct ExpressionPair {\r
+                public readonly string Left;\r
+                public readonly string Right;\r
+\r
+                public ExpressionPair(string left, string right) {\r
+                    Left = left;\r
+                    Right = right;\r
+                }\r
+            }\r
+        }\r
+\r
+        #region IEnumerable Members\r
+        IEnumerator IEnumerable.GetEnumerator() {\r
+            return ((IEnumerable)_innerDictionary).GetEnumerator();\r
+        }\r
+        #endregion\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewDataDictionary`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewDataDictionary`1.cs
new file mode 100644 (file)
index 0000000..a0d09f2
--- /dev/null
@@ -0,0 +1,66 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+\r
+    public class ViewDataDictionary<TModel> : ViewDataDictionary {\r
+        public ViewDataDictionary() :\r
+            base(default(TModel)) {\r
+        }\r
+\r
+        public ViewDataDictionary(TModel model) :\r
+            base(model) {\r
+        }\r
+\r
+        public ViewDataDictionary(ViewDataDictionary viewDataDictionary) :\r
+            base(viewDataDictionary) {\r
+        }\r
+\r
+        public new TModel Model {\r
+            get {\r
+                return (TModel)base.Model;\r
+            }\r
+            set {\r
+                SetModel(value);\r
+            }\r
+        }\r
+\r
+        public override ModelMetadata ModelMetadata {\r
+            get {\r
+                ModelMetadata result = base.ModelMetadata;\r
+                if (result == null) {\r
+                    result = base.ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(TModel));\r
+                }\r
+                return result;\r
+            }\r
+            set {\r
+                base.ModelMetadata = value;\r
+            }\r
+        }\r
+\r
+        protected override void SetModel(object value) {\r
+            bool castWillSucceed = TypeHelpers.IsCompatibleObject<TModel>(value);\r
+\r
+            if (castWillSucceed) {\r
+                base.SetModel((TModel)value);\r
+            }\r
+            else {\r
+                InvalidOperationException exception = (value != null)\r
+                    ? Error.ViewDataDictionary_WrongTModelType(value.GetType(), typeof(TModel))\r
+                    : Error.ViewDataDictionary_ModelCannotBeNull(typeof(TModel));\r
+                throw exception;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewDataInfo.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewDataInfo.cs
new file mode 100644 (file)
index 0000000..8cc480b
--- /dev/null
@@ -0,0 +1,55 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.ComponentModel;\r
+\r
+    public class ViewDataInfo {\r
+\r
+        private object _value;\r
+        private Func<object> _valueAccessor;\r
+\r
+        public ViewDataInfo() {\r
+        }\r
+\r
+        public ViewDataInfo(Func<object> valueAccessor) {\r
+            _valueAccessor = valueAccessor;\r
+        }\r
+\r
+        public object Container {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public PropertyDescriptor PropertyDescriptor {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public object Value {\r
+            get {\r
+                if (_valueAccessor != null) {\r
+                    _value = _valueAccessor();\r
+                    _valueAccessor = null;\r
+                }\r
+\r
+                return _value;\r
+            }\r
+            set {\r
+                _value = value;\r
+                _valueAccessor = null;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewEngineCollection.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewEngineCollection.cs
new file mode 100644 (file)
index 0000000..1fce965
--- /dev/null
@@ -0,0 +1,95 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Collections.Generic;\r
+    using System.Collections.ObjectModel;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ViewEngineCollection : Collection<IViewEngine> {\r
+\r
+        public ViewEngineCollection() {\r
+        }\r
+\r
+        public ViewEngineCollection(IList<IViewEngine> list)\r
+            : base(list) {\r
+        }\r
+\r
+        protected override void InsertItem(int index, IViewEngine item) {\r
+            if (item == null) {\r
+                throw new ArgumentNullException("item");\r
+            }\r
+            base.InsertItem(index, item);\r
+        }\r
+\r
+        protected override void SetItem(int index, IViewEngine item) {\r
+            if (item == null) {\r
+                throw new ArgumentNullException("item");\r
+            }\r
+            base.SetItem(index, item);\r
+        }\r
+\r
+        private ViewEngineResult Find(Func<IViewEngine, ViewEngineResult> cacheLocator, Func<IViewEngine, ViewEngineResult> locator) {\r
+            ViewEngineResult result;\r
+\r
+            foreach (IViewEngine engine in Items) {\r
+                if (engine != null) {\r
+                    result = cacheLocator(engine);\r
+\r
+                    if (result.View != null) {\r
+                        return result;\r
+                    }\r
+                }\r
+            }\r
+\r
+            List<string> searched = new List<string>();\r
+\r
+            foreach (IViewEngine engine in Items) {\r
+                if (engine != null) {\r
+                    result = locator(engine);\r
+\r
+                    if (result.View != null) {\r
+                        return result;\r
+                    }\r
+\r
+                    searched.AddRange(result.SearchedLocations);\r
+                }\r
+            }\r
+\r
+            return new ViewEngineResult(searched);\r
+        }\r
+\r
+        public virtual ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (string.IsNullOrEmpty(partialViewName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "partialViewName");\r
+            }\r
+            Func<IViewEngine, ViewEngineResult> cacheLocator = e => e.FindPartialView(controllerContext, partialViewName, true);\r
+            Func<IViewEngine, ViewEngineResult> locator = e => e.FindPartialView(controllerContext, partialViewName, false);\r
+            return Find(cacheLocator, locator);\r
+        }\r
+\r
+        public virtual ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (string.IsNullOrEmpty(viewName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "viewName");\r
+            }\r
+            Func<IViewEngine, ViewEngineResult> cacheLocator = e => e.FindView(controllerContext, viewName, masterName, true);\r
+            Func<IViewEngine, ViewEngineResult> locator = e => e.FindView(controllerContext, viewName, masterName, false);\r
+            return Find(cacheLocator, locator);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewEngineResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewEngineResult.cs
new file mode 100644 (file)
index 0000000..97a1b31
--- /dev/null
@@ -0,0 +1,54 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+\r
+    public class ViewEngineResult {\r
+\r
+        public ViewEngineResult(IEnumerable<string> searchedLocations) {\r
+            if (searchedLocations == null) {\r
+                throw new ArgumentNullException("searchedLocations");\r
+            }\r
+\r
+            SearchedLocations = searchedLocations;\r
+        }\r
+\r
+        public ViewEngineResult(IView view, IViewEngine viewEngine) {\r
+            if (view == null) {\r
+                throw new ArgumentNullException("view");\r
+            }\r
+            if (viewEngine == null) {\r
+                throw new ArgumentNullException("viewEngine");\r
+            }\r
+\r
+            View = view;\r
+            ViewEngine = viewEngine;\r
+        }\r
+\r
+        public IEnumerable<string> SearchedLocations {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public IView View {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public IViewEngine ViewEngine {\r
+            get;\r
+            private set;\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewEngines.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewEngines.cs
new file mode 100644 (file)
index 0000000..af4c016
--- /dev/null
@@ -0,0 +1,27 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public static class ViewEngines {\r
+\r
+        private readonly static ViewEngineCollection _engines = new ViewEngineCollection {\r
+            new WebFormViewEngine() \r
+        };\r
+\r
+        public static ViewEngineCollection Engines {\r
+            get {\r
+                return _engines;\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewMasterPage.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewMasterPage.cs
new file mode 100644 (file)
index 0000000..837dabf
--- /dev/null
@@ -0,0 +1,77 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Globalization;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.UI;\r
+\r
+    public class ViewMasterPage : MasterPage {\r
+        public AjaxHelper<object> Ajax {\r
+            get {\r
+                return ViewPage.Ajax;\r
+            }\r
+        }\r
+\r
+        public HtmlHelper<object> Html {\r
+            get {\r
+                return ViewPage.Html;\r
+            }\r
+        }\r
+\r
+        public object Model {\r
+            get {\r
+                return ViewData.Model;\r
+            }\r
+        }\r
+\r
+        public TempDataDictionary TempData {\r
+            get {\r
+                return ViewPage.TempData;\r
+            }\r
+        }\r
+\r
+        public UrlHelper Url {\r
+            get {\r
+                return ViewPage.Url;\r
+            }\r
+        }\r
+\r
+        public ViewContext ViewContext {\r
+            get {\r
+                return ViewPage.ViewContext;\r
+            }\r
+        }\r
+\r
+        public ViewDataDictionary ViewData {\r
+            get {\r
+                return ViewPage.ViewData;\r
+            }\r
+        }\r
+\r
+        internal ViewPage ViewPage {\r
+            get {\r
+                ViewPage viewPage = Page as ViewPage;\r
+                if (viewPage == null) {\r
+                    throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, MvcResources.ViewMasterPage_RequiresViewPage));\r
+                }\r
+                return viewPage;\r
+            }\r
+        }\r
+\r
+        public HtmlTextWriter Writer {\r
+            get {\r
+                return ViewPage.Writer;\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewMasterPage`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewMasterPage`1.cs
new file mode 100644 (file)
index 0000000..c3c95d1
--- /dev/null
@@ -0,0 +1,53 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+\r
+    public class ViewMasterPage<TModel> : ViewMasterPage {\r
+        private AjaxHelper<TModel> _ajaxHelper;\r
+        private HtmlHelper<TModel> _htmlHelper;\r
+        private ViewDataDictionary<TModel> _viewData;\r
+\r
+        public new AjaxHelper<TModel> Ajax {\r
+            get {\r
+                if (_ajaxHelper == null) {\r
+                    _ajaxHelper = new AjaxHelper<TModel>(ViewContext, ViewPage);\r
+                }\r
+                return _ajaxHelper;\r
+            }\r
+        }\r
+\r
+        public new HtmlHelper<TModel> Html {\r
+            get {\r
+                if (_htmlHelper == null) {\r
+                    _htmlHelper = new HtmlHelper<TModel>(ViewContext, ViewPage);\r
+                }\r
+                return _htmlHelper;\r
+            }\r
+        }\r
+\r
+        public new TModel Model {\r
+            get {\r
+                return ViewData.Model;\r
+            }\r
+        }\r
+\r
+        public new ViewDataDictionary<TModel> ViewData {\r
+            get {\r
+                if (_viewData == null) {\r
+                    _viewData = new ViewDataDictionary<TModel>(ViewPage.ViewData);\r
+                }\r
+                return _viewData;\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewPage.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewPage.cs
new file mode 100644 (file)
index 0000000..6e1891c
--- /dev/null
@@ -0,0 +1,378 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.IO;\r
+    using System.Text;\r
+    using System.Web;\r
+    using System.Web.UI;\r
+\r
+    [FileLevelControlBuilder(typeof(ViewPageControlBuilder))]\r
+    public class ViewPage : Page, IViewDataContainer {\r
+\r
+        private string _masterLocation;\r
+        [ThreadStatic]\r
+        private static int _nextId;\r
+        private ViewDataDictionary _viewData;\r
+\r
+        public AjaxHelper<object> Ajax {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public HtmlHelper<object> Html {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public string MasterLocation {\r
+            get {\r
+                return _masterLocation ?? String.Empty;\r
+            }\r
+            set {\r
+                _masterLocation = value;\r
+            }\r
+        }\r
+\r
+        public object Model {\r
+            get {\r
+                return ViewData.Model;\r
+            }\r
+        }\r
+\r
+        public TempDataDictionary TempData {\r
+            get {\r
+                return ViewContext.TempData;\r
+            }\r
+        }\r
+\r
+        public UrlHelper Url {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public ViewContext ViewContext {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "This is the mechanism by which the ViewPage gets its ViewDataDictionary object.")]\r
+        public ViewDataDictionary ViewData {\r
+            get {\r
+                if (_viewData == null) {\r
+                    SetViewData(new ViewDataDictionary());\r
+                }\r
+                return _viewData;\r
+            }\r
+            set {\r
+                SetViewData(value);\r
+            }\r
+        }\r
+\r
+        public HtmlTextWriter Writer {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public virtual void InitHelpers() {\r
+            Ajax = new AjaxHelper<object>(ViewContext, this);\r
+            Html = new HtmlHelper<object>(ViewContext, this);\r
+            Url = new UrlHelper(ViewContext.RequestContext);\r
+        }\r
+\r
+        internal static string NextId() {\r
+            return (++_nextId).ToString(CultureInfo.InvariantCulture);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")]\r
+        protected override void OnPreInit(EventArgs e) {\r
+            base.OnPreInit(e);\r
+\r
+            if (!String.IsNullOrEmpty(MasterLocation)) {\r
+                MasterPageFile = MasterLocation;\r
+            }\r
+        }\r
+\r
+        public override void ProcessRequest(HttpContext context) {\r
+            // Tracing requires IDs to be unique.\r
+            ID = NextId();\r
+\r
+            base.ProcessRequest(context);\r
+        }\r
+\r
+        protected override void Render(HtmlTextWriter writer) {\r
+            Writer = writer;\r
+            try {\r
+                base.Render(writer);\r
+            }\r
+            finally {\r
+                Writer = null;\r
+            }\r
+        }\r
+\r
+        public virtual void RenderView(ViewContext viewContext) {\r
+            ViewContext = viewContext;\r
+            InitHelpers();\r
+\r
+            bool needServerExecute = false;\r
+\r
+            SwitchWriter switchWriter = viewContext.HttpContext.Response.Output as SwitchWriter;\r
+            if (switchWriter == null) {\r
+                switchWriter = new SwitchWriter();\r
+                needServerExecute = true;\r
+            }\r
+\r
+            using (switchWriter.Scope(viewContext.Writer)) {\r
+                if (needServerExecute) {\r
+                    // It's safe to reset the _nextId within a Server.Execute() since it pushes a new TraceContext onto\r
+                    // the stack, so there won't be an ID conflict.\r
+                    int originalNextId = _nextId;\r
+                    try {\r
+                        _nextId = 0;\r
+                        viewContext.HttpContext.Server.Execute(HttpHandlerUtil.WrapForServerExecute(this), switchWriter, true /* preserveForm */);\r
+                    }\r
+                    finally {\r
+                        // Restore the original _nextId in case this isn't actually the outermost view, since resetting\r
+                        // the _nextId may now cause trace ID conflicts in the outer view.\r
+                        _nextId = originalNextId;\r
+                    }\r
+                }\r
+                else {\r
+                    ProcessRequest(HttpContext.Current);\r
+                }\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "textWriter",\r
+            Justification = "This method existed in MVC 1.0 and has been deprecated.")]\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "This method existed in MVC 1.0 and has been deprecated.")]\r
+        [Obsolete("The TextWriter is now provided by the ViewContext object passed to the RenderView method.", true /* error */)]\r
+        public void SetTextWriter(TextWriter textWriter) {\r
+            // this is now a no-op\r
+        }\r
+\r
+        protected virtual void SetViewData(ViewDataDictionary viewData) {\r
+            _viewData = viewData;\r
+        }\r
+\r
+        internal class SwitchWriter : TextWriter {\r
+            public SwitchWriter()\r
+                : base(CultureInfo.CurrentCulture) {\r
+            }\r
+\r
+            public override Encoding Encoding {\r
+                get {\r
+                    return InnerWriter.Encoding;\r
+                }\r
+            }\r
+\r
+            public override IFormatProvider FormatProvider {\r
+                get {\r
+                    return InnerWriter.FormatProvider;\r
+                }\r
+            }\r
+\r
+            internal TextWriter InnerWriter {\r
+                get;\r
+                set;\r
+            }\r
+\r
+            public override string NewLine {\r
+                get {\r
+                    return InnerWriter.NewLine;\r
+                }\r
+                set {\r
+                    InnerWriter.NewLine = value;\r
+                }\r
+            }\r
+\r
+            public override void Close() {\r
+                InnerWriter.Close();\r
+            }\r
+\r
+            public override void Flush() {\r
+                InnerWriter.Flush();\r
+            }\r
+\r
+            public IDisposable Scope(TextWriter writer) {\r
+                WriterScope scope = new WriterScope(this, InnerWriter);\r
+\r
+                if (writer != this) {\r
+                    InnerWriter = writer;\r
+                }\r
+\r
+                return scope;\r
+            }\r
+\r
+            public override void Write(bool value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(char value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(char[] buffer) {\r
+                InnerWriter.Write(buffer);\r
+            }\r
+\r
+            public override void Write(char[] buffer, int index, int count) {\r
+                InnerWriter.Write(buffer, index, count);\r
+            }\r
+\r
+            public override void Write(decimal value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(double value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(float value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(int value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(long value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(object value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(string format, object arg0) {\r
+                InnerWriter.Write(format, arg0);\r
+            }\r
+\r
+            public override void Write(string format, object arg0, object arg1) {\r
+                InnerWriter.Write(format, arg0, arg1);\r
+            }\r
+\r
+            public override void Write(string format, object arg0, object arg1, object arg2) {\r
+                InnerWriter.Write(format, arg0, arg1, arg2);\r
+            }\r
+\r
+            public override void Write(string format, params object[] arg) {\r
+                InnerWriter.Write(format, arg);\r
+            }\r
+\r
+            public override void Write(string value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(uint value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void Write(ulong value) {\r
+                InnerWriter.Write(value);\r
+            }\r
+\r
+            public override void WriteLine() {\r
+                InnerWriter.WriteLine();\r
+            }\r
+\r
+            public override void WriteLine(bool value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(char value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(char[] buffer) {\r
+                InnerWriter.WriteLine(buffer);\r
+            }\r
+\r
+            public override void WriteLine(char[] buffer, int index, int count) {\r
+                InnerWriter.WriteLine(buffer, index, count);\r
+            }\r
+\r
+            public override void WriteLine(decimal value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(double value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(float value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(int value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(long value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(object value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(string format, object arg0) {\r
+                InnerWriter.WriteLine(format, arg0);\r
+            }\r
+\r
+            public override void WriteLine(string format, object arg0, object arg1) {\r
+                InnerWriter.WriteLine(format, arg0, arg1);\r
+            }\r
+\r
+            public override void WriteLine(string format, object arg0, object arg1, object arg2) {\r
+                InnerWriter.WriteLine(format, arg0, arg1, arg2);\r
+            }\r
+\r
+            public override void WriteLine(string format, params object[] arg) {\r
+                InnerWriter.WriteLine(format, arg);\r
+            }\r
+\r
+            public override void WriteLine(string value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(uint value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            public override void WriteLine(ulong value) {\r
+                InnerWriter.WriteLine(value);\r
+            }\r
+\r
+            private sealed class WriterScope : IDisposable {\r
+                private SwitchWriter _switchWriter;\r
+                private TextWriter _writerToRestore;\r
+\r
+                public WriterScope(SwitchWriter switchWriter, TextWriter writerToRestore) {\r
+                    _switchWriter = switchWriter;\r
+                    _writerToRestore = writerToRestore;\r
+                }\r
+\r
+                public void Dispose() {\r
+                    _switchWriter.InnerWriter = _writerToRestore;\r
+                }\r
+            }\r
+\r
+        }\r
+\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewPageControlBuilder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewPageControlBuilder.cs
new file mode 100644 (file)
index 0000000..cf494c2
--- /dev/null
@@ -0,0 +1,36 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.CodeDom;\r
+    using System.Web.UI;\r
+\r
+    internal sealed class ViewPageControlBuilder : FileLevelPageControlBuilder {\r
+        public string PageBaseType {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public override void ProcessGeneratedCode(\r
+            CodeCompileUnit codeCompileUnit,\r
+            CodeTypeDeclaration baseType,\r
+            CodeTypeDeclaration derivedType,\r
+            CodeMemberMethod buildMethod,\r
+            CodeMemberMethod dataBindingMethod) {\r
+\r
+            // If we find got a base class string, use it\r
+            if (PageBaseType != null) {\r
+                derivedType.BaseTypes[0] = new CodeTypeReference(PageBaseType);\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewPage`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewPage`1.cs
new file mode 100644 (file)
index 0000000..3f55539
--- /dev/null
@@ -0,0 +1,62 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public class ViewPage<TModel> : ViewPage {\r
+\r
+        private ViewDataDictionary<TModel> _viewData;\r
+\r
+        public new AjaxHelper<TModel> Ajax {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public new HtmlHelper<TModel> Html {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public new TModel Model {\r
+            get {\r
+                return ViewData.Model;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]\r
+        public new ViewDataDictionary<TModel> ViewData {\r
+            get {\r
+                if (_viewData == null) {\r
+                    SetViewData(new ViewDataDictionary<TModel>());\r
+                }\r
+                return _viewData;\r
+            }\r
+            set {\r
+                SetViewData(value);\r
+            }\r
+        }\r
+\r
+        public override void InitHelpers() {\r
+            base.InitHelpers();\r
+\r
+            Ajax = new AjaxHelper<TModel>(ViewContext, this);\r
+            Html = new HtmlHelper<TModel>(ViewContext, this);\r
+        }\r
+\r
+        protected override void SetViewData(ViewDataDictionary viewData) {\r
+            _viewData = new ViewDataDictionary<TModel>(viewData);\r
+\r
+            base.SetViewData(_viewData);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewResult.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewResult.cs
new file mode 100644 (file)
index 0000000..49b8a85
--- /dev/null
@@ -0,0 +1,47 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Globalization;\r
+    using System.Text;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class ViewResult : ViewResultBase {\r
+        private string _masterName;\r
+\r
+        public string MasterName {\r
+            get {\r
+                return _masterName ?? String.Empty;\r
+            }\r
+            set {\r
+                _masterName = value;\r
+            }\r
+        }\r
+\r
+        protected override ViewEngineResult FindView(ControllerContext context) {\r
+            ViewEngineResult result = ViewEngineCollection.FindView(context, ViewName, MasterName);\r
+            if (result.View != null) {\r
+                return result;\r
+            }\r
+\r
+            // we need to generate an exception containing all the locations we searched\r
+            StringBuilder locationsText = new StringBuilder();\r
+            foreach (string location in result.SearchedLocations) {\r
+                locationsText.AppendLine();\r
+                locationsText.Append(location);\r
+            }\r
+            throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture,\r
+                MvcResources.Common_ViewNotFound, ViewName, locationsText));\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewResultBase.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewResultBase.cs
new file mode 100644 (file)
index 0000000..c4fc2cc
--- /dev/null
@@ -0,0 +1,103 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.IO;\r
+\r
+    public abstract class ViewResultBase : ActionResult {\r
+        private TempDataDictionary _tempData;\r
+        private ViewDataDictionary _viewData;\r
+        private ViewEngineCollection _viewEngineCollection;\r
+        private string _viewName;\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "This entire type is meant to be mutable.")]\r
+        public TempDataDictionary TempData {\r
+            get {\r
+                if (_tempData == null) {\r
+                    _tempData = new TempDataDictionary();\r
+                }\r
+                return _tempData;\r
+            }\r
+            set {\r
+                _tempData = value;\r
+            }\r
+        }\r
+\r
+        public IView View {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "This entire type is meant to be mutable.")]\r
+        public ViewDataDictionary ViewData {\r
+            get {\r
+                if (_viewData == null) {\r
+                    _viewData = new ViewDataDictionary();\r
+                }\r
+                return _viewData;\r
+            }\r
+            set {\r
+                _viewData = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "This entire type is meant to be mutable.")]\r
+        public ViewEngineCollection ViewEngineCollection {\r
+            get {\r
+                return _viewEngineCollection ?? ViewEngines.Engines;\r
+            }\r
+            set {\r
+                _viewEngineCollection = value;\r
+            }\r
+        }\r
+\r
+        public string ViewName {\r
+            get {\r
+                return _viewName ?? String.Empty;\r
+            }\r
+            set {\r
+                _viewName = value;\r
+            }\r
+        }\r
+\r
+        public override void ExecuteResult(ControllerContext context) {\r
+            if (context == null) {\r
+                throw new ArgumentNullException("context");\r
+            }\r
+            if (String.IsNullOrEmpty(ViewName)) {\r
+                ViewName = context.RouteData.GetRequiredString("action");\r
+            }\r
+\r
+            ViewEngineResult result = null;\r
+\r
+            if (View == null) {\r
+                result = FindView(context);\r
+                View = result.View;\r
+            }\r
+\r
+            TextWriter writer = context.HttpContext.Response.Output;\r
+            ViewContext viewContext = new ViewContext(context, View, ViewData, TempData, writer);\r
+            View.Render(viewContext, writer);\r
+\r
+            if (result != null) {\r
+                result.ViewEngine.ReleaseView(context, View);\r
+            }\r
+        }\r
+\r
+        protected abstract ViewEngineResult FindView(ControllerContext context);\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTemplateUserControl.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTemplateUserControl.cs
new file mode 100644 (file)
index 0000000..3ccc4fb
--- /dev/null
@@ -0,0 +1,15 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public class ViewTemplateUserControl : ViewTemplateUserControl<object> { }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTemplateUserControl`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTemplateUserControl`1.cs
new file mode 100644 (file)
index 0000000..f2ae5db
--- /dev/null
@@ -0,0 +1,19 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    public class ViewTemplateUserControl<TModel> : ViewUserControl<TModel> {\r
+        protected string FormattedModelValue {\r
+            get { return ViewData.TemplateInfo.FormattedModelValue.ToString(); }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewType.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewType.cs
new file mode 100644 (file)
index 0000000..39afcc9
--- /dev/null
@@ -0,0 +1,32 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.ComponentModel;\r
+    using System.Web.UI;\r
+\r
+    [ControlBuilder(typeof(ViewTypeControlBuilder))]\r
+    [NonVisualControl]\r
+    public class ViewType : Control {\r
+        private string _typeName;\r
+\r
+        [DefaultValue("")]\r
+        public string TypeName {\r
+            get {\r
+                return _typeName ?? String.Empty;\r
+            }\r
+            set {\r
+                _typeName = value;\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTypeControlBuilder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTypeControlBuilder.cs
new file mode 100644 (file)
index 0000000..0a30653
--- /dev/null
@@ -0,0 +1,39 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.CodeDom;\r
+    using System.Collections;\r
+    using System.Web.UI;\r
+\r
+    internal sealed class ViewTypeControlBuilder : ControlBuilder {\r
+        private string _typeName;\r
+\r
+        public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attribs) {\r
+            base.Init(parser, parentBuilder, type, tagName, id, attribs);\r
+\r
+            _typeName = (string)attribs["typename"];\r
+        }\r
+\r
+        public override void ProcessGeneratedCode(\r
+            CodeCompileUnit codeCompileUnit,\r
+            CodeTypeDeclaration baseType,\r
+            CodeTypeDeclaration derivedType,\r
+            CodeMemberMethod buildMethod,\r
+            CodeMemberMethod dataBindingMethod) {\r
+\r
+            // Override the view's base type with the explicit base type\r
+            derivedType.BaseTypes[0] = new CodeTypeReference(_typeName);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTypeParserFilter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewTypeParserFilter.cs
new file mode 100644 (file)
index 0000000..4fb159a
--- /dev/null
@@ -0,0 +1,156 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections;\r
+    using System.Web.UI;\r
+\r
+    internal class ViewTypeParserFilter : PageParserFilter {\r
+\r
+        private string _viewBaseType;\r
+        private DirectiveType _directiveType = DirectiveType.Unknown;\r
+        private bool _viewTypeControlAdded;\r
+\r
+        public override void PreprocessDirective(string directiveName, IDictionary attributes) {\r
+            base.PreprocessDirective(directiveName, attributes);\r
+\r
+            string defaultBaseType = null;\r
+\r
+            // If we recognize the directive, keep track of what it was. If we don't recognize\r
+            // the directive then just stop.\r
+            switch (directiveName) {\r
+                case "page":\r
+                    _directiveType = DirectiveType.Page;\r
+                    defaultBaseType = typeof(ViewPage).FullName;\r
+                    break;\r
+                case "control":\r
+                    _directiveType = DirectiveType.UserControl;\r
+                    defaultBaseType = typeof(ViewUserControl).FullName;\r
+                    break;\r
+                case "master":\r
+                    _directiveType = DirectiveType.Master;\r
+                    defaultBaseType = typeof(ViewMasterPage).FullName;\r
+                    break;\r
+            }\r
+\r
+            if (_directiveType == DirectiveType.Unknown) {\r
+                // If we're processing an unknown directive (e.g. a register directive), stop processing\r
+                return;\r
+            }\r
+\r
+            // Look for an inherit attribute\r
+            string inherits = (string)attributes["inherits"];\r
+            if (!String.IsNullOrEmpty(inherits)) {\r
+                // If it doesn't look like a generic type, don't do anything special,\r
+                // and let the parser do its normal processing\r
+                if (IsGenericTypeString(inherits)) {\r
+                    // Remove the inherits attribute so the parser doesn't blow up\r
+                    attributes["inherits"] = defaultBaseType;\r
+\r
+                    // Remember the full type string so we can later give it to the ControlBuilder\r
+                    _viewBaseType = inherits;\r
+                }\r
+            }\r
+        }\r
+\r
+        private static bool IsGenericTypeString(string typeName) {\r
+            // Detect C# and VB generic syntax\r
+            // REVIEW: what about other languages?\r
+            return typeName.IndexOfAny(new char[] { '<', '(' }) >= 0;\r
+        }\r
+\r
+        public override void ParseComplete(ControlBuilder rootBuilder) {\r
+            base.ParseComplete(rootBuilder);\r
+\r
+            // If it's our page ControlBuilder, give it the base type string\r
+            ViewPageControlBuilder pageBuilder = rootBuilder as ViewPageControlBuilder;\r
+            if (pageBuilder != null) {\r
+                pageBuilder.PageBaseType = _viewBaseType;\r
+            }\r
+            ViewUserControlControlBuilder userControlBuilder = rootBuilder as ViewUserControlControlBuilder;\r
+            if (userControlBuilder != null) {\r
+                userControlBuilder.UserControlBaseType = _viewBaseType;\r
+            }\r
+        }\r
+\r
+        public override bool ProcessCodeConstruct(CodeConstructType codeType, string code) {\r
+            if (!_viewTypeControlAdded &&\r
+                _viewBaseType != null &&\r
+                _directiveType == DirectiveType.Master) {\r
+\r
+                // If we're dealing with a master page that needs to have its base type set, do it here.\r
+                // It's done by adding the ViewType control, which has a builder that sets the base type.\r
+\r
+                // The code currently assumes that the file in question contains a code snippet, since\r
+                // that's the item we key off of in order to know when to add the ViewType control.\r
+\r
+                Hashtable attribs = new Hashtable();\r
+                attribs["typename"] = _viewBaseType;\r
+                AddControl(typeof(ViewType), attribs);\r
+                _viewTypeControlAdded = true;\r
+            }\r
+\r
+            return base.ProcessCodeConstruct(codeType, code);\r
+        }\r
+\r
+        // Everything else in this class is unrelated to our 'inherits' handling.\r
+        // Since PageParserFilter blocks everything by default, we need to unblock it\r
+\r
+        public override bool AllowCode {\r
+            get {\r
+                return true;\r
+            }\r
+        }\r
+\r
+        public override bool AllowBaseType(Type baseType) {\r
+            return true;\r
+        }\r
+\r
+        public override bool AllowControl(Type controlType, ControlBuilder builder) {\r
+            return true;\r
+        }\r
+\r
+        public override bool AllowVirtualReference(string referenceVirtualPath, VirtualReferenceType referenceType) {\r
+            return true;\r
+        }\r
+\r
+        public override bool AllowServerSideInclude(string includeVirtualPath) {\r
+            return true;\r
+        }\r
+\r
+        public override int NumberOfControlsAllowed {\r
+            get {\r
+                return -1;\r
+            }\r
+        }\r
+\r
+        public override int NumberOfDirectDependenciesAllowed {\r
+            get {\r
+                return -1;\r
+            }\r
+        }\r
+\r
+        public override int TotalNumberOfDependenciesAllowed {\r
+            get {\r
+                return -1;\r
+            }\r
+        }\r
+\r
+        private enum DirectiveType {\r
+            Unknown,\r
+            Page,\r
+            UserControl,\r
+            Master,\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewUserControl.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewUserControl.cs
new file mode 100644 (file)
index 0000000..d1ec1e1
--- /dev/null
@@ -0,0 +1,200 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.ComponentModel;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.IO;\r
+    using System.Web.Mvc.Resources;\r
+    using System.Web.UI;\r
+\r
+    [FileLevelControlBuilder(typeof(ViewUserControlControlBuilder))]\r
+    public class ViewUserControl : UserControl, IViewDataContainer {\r
+        private AjaxHelper<object> _ajaxHelper;\r
+        private HtmlHelper<object> _htmlHelper;\r
+        private ViewContext _viewContext;\r
+        private ViewDataDictionary _viewData;\r
+        private string _viewDataKey;\r
+\r
+        public AjaxHelper<object> Ajax {\r
+            get {\r
+                if (_ajaxHelper == null) {\r
+                    _ajaxHelper = new AjaxHelper<object>(ViewContext, this);\r
+                }\r
+                return _ajaxHelper;\r
+            }\r
+        }\r
+\r
+        public HtmlHelper<object> Html {\r
+            get {\r
+                if (_htmlHelper == null) {\r
+                    _htmlHelper = new HtmlHelper<object>(ViewContext, this);\r
+                }\r
+                return _htmlHelper;\r
+            }\r
+        }\r
+\r
+        public object Model {\r
+            get {\r
+                return ViewData.Model;\r
+            }\r
+        }\r
+\r
+        public TempDataDictionary TempData {\r
+            get {\r
+                return ViewPage.TempData;\r
+            }\r
+        }\r
+\r
+        public UrlHelper Url {\r
+            get {\r
+                return ViewPage.Url;\r
+            }\r
+        }\r
+\r
+        [Browsable(false)]\r
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\r
+        public ViewContext ViewContext {\r
+            get {\r
+                return _viewContext ?? ViewPage.ViewContext;\r
+            }\r
+            set {\r
+                _viewContext = value;\r
+            }\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",\r
+            Justification = "This is the mechanism by which the ViewUserControl gets its ViewDataDictionary object.")]\r
+        [Browsable(false)]\r
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\r
+        public ViewDataDictionary ViewData {\r
+            get {\r
+                EnsureViewData();\r
+                return _viewData;\r
+            }\r
+            set {\r
+                SetViewData(value);\r
+            }\r
+        }\r
+\r
+        [DefaultValue("")]\r
+        public string ViewDataKey {\r
+            get {\r
+                return _viewDataKey ?? String.Empty;\r
+            }\r
+            set {\r
+                _viewDataKey = value;\r
+            }\r
+        }\r
+\r
+        internal ViewPage ViewPage {\r
+            get {\r
+                ViewPage viewPage = Page as ViewPage;\r
+                if (viewPage == null) {\r
+                    throw new InvalidOperationException(MvcResources.ViewUserControl_RequiresViewPage);\r
+                }\r
+                return viewPage;\r
+            }\r
+        }\r
+\r
+        public HtmlTextWriter Writer {\r
+            get {\r
+                return ViewPage.Writer;\r
+            }\r
+        }\r
+\r
+        protected virtual void SetViewData(ViewDataDictionary viewData) {\r
+            _viewData = viewData;\r
+        }\r
+\r
+        protected void EnsureViewData() {\r
+            if (_viewData != null) {\r
+                return;\r
+            }\r
+\r
+            // Get the ViewData for this ViewUserControl, optionally using the specified ViewDataKey\r
+            IViewDataContainer vdc = GetViewDataContainer(this);\r
+            if (vdc == null) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.ViewUserControl_RequiresViewDataProvider,\r
+                        AppRelativeVirtualPath));\r
+            }\r
+\r
+            ViewDataDictionary myViewData = vdc.ViewData;\r
+\r
+            // If we have a ViewDataKey, try to extract the ViewData from the dictionary, otherwise\r
+            // return the container's ViewData.\r
+            if (!String.IsNullOrEmpty(ViewDataKey)) {\r
+                object target = myViewData.Eval(ViewDataKey);\r
+                myViewData = target as ViewDataDictionary ?? new ViewDataDictionary(myViewData) { Model = target };\r
+            }\r
+\r
+            SetViewData(myViewData);\r
+        }\r
+\r
+        private static IViewDataContainer GetViewDataContainer(Control control) {\r
+            // Walk up the control hierarchy until we find someone that implements IViewDataContainer\r
+            while (control != null) {\r
+                control = control.Parent;\r
+                IViewDataContainer vdc = control as IViewDataContainer;\r
+                if (vdc != null) {\r
+                    return vdc;\r
+                }\r
+            }\r
+            return null;\r
+        }\r
+\r
+        public virtual void RenderView(ViewContext viewContext) {\r
+            ViewUserControlContainerPage containerPage = new ViewUserControlContainerPage(this);\r
+\r
+            RenderViewAndRestoreContentType(containerPage, viewContext);\r
+        }\r
+\r
+        internal static void RenderViewAndRestoreContentType(ViewPage containerPage, ViewContext viewContext) {\r
+            // We need to restore the Content-Type since Page.SetIntrinsics() will reset it. It's not possible\r
+            // to work around the call to SetIntrinsics() since the control's render method requires the\r
+            // containing page's Response property to be non-null, and SetIntrinsics() is the only way to set\r
+            // this.\r
+            string savedContentType = viewContext.HttpContext.Response.ContentType;\r
+            containerPage.RenderView(viewContext);\r
+            viewContext.HttpContext.Response.ContentType = savedContentType;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "textWriter",\r
+            Justification = "This method existed in MVC 1.0 and has been deprecated.")]\r
+        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic",\r
+            Justification = "This method existed in MVC 1.0 and has been deprecated.")]\r
+        [Obsolete("The TextWriter is now provided by the ViewContext object passed to the RenderView method.", true /* error */)]\r
+        public void SetTextWriter(TextWriter textWriter) {\r
+            // this is now a no-op\r
+        }\r
+\r
+        private sealed class ViewUserControlContainerPage : ViewPage {\r
+            private readonly ViewUserControl _userControl;\r
+\r
+            public ViewUserControlContainerPage(ViewUserControl userControl) {\r
+                _userControl = userControl;\r
+            }\r
+\r
+            public override void ProcessRequest(HttpContext context) {\r
+                _userControl.ID = ViewPage.NextId();\r
+                Controls.Add(_userControl);\r
+\r
+                base.ProcessRequest(context);\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewUserControlControlBuilder.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewUserControlControlBuilder.cs
new file mode 100644 (file)
index 0000000..8bd473a
--- /dev/null
@@ -0,0 +1,36 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.CodeDom;\r
+    using System.Web.UI;\r
+\r
+    internal sealed class ViewUserControlControlBuilder : FileLevelUserControlBuilder {\r
+        internal string UserControlBaseType {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public override void ProcessGeneratedCode(\r
+            CodeCompileUnit codeCompileUnit,\r
+            CodeTypeDeclaration baseType,\r
+            CodeTypeDeclaration derivedType,\r
+            CodeMemberMethod buildMethod,\r
+            CodeMemberMethod dataBindingMethod) {\r
+\r
+            // If we find got a base class string, use it\r
+            if (UserControlBaseType != null) {\r
+                derivedType.BaseTypes[0] = new CodeTypeReference(UserControlBaseType);\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewUserControl`1.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/ViewUserControl`1.cs
new file mode 100644 (file)
index 0000000..1a36f68
--- /dev/null
@@ -0,0 +1,62 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Diagnostics.CodeAnalysis;\r
+\r
+    public class ViewUserControl<TModel> : ViewUserControl {\r
+        private AjaxHelper<TModel> _ajaxHelper;\r
+        private HtmlHelper<TModel> _htmlHelper;\r
+        private ViewDataDictionary<TModel> _viewData;\r
+\r
+        public new AjaxHelper<TModel> Ajax {\r
+            get {\r
+                if (_ajaxHelper == null) {\r
+                    _ajaxHelper = new AjaxHelper<TModel>(ViewContext, this);\r
+                }\r
+                return _ajaxHelper;\r
+            }\r
+        }\r
+\r
+        public new HtmlHelper<TModel> Html {\r
+            get {\r
+                if (_htmlHelper == null) {\r
+                    _htmlHelper = new HtmlHelper<TModel>(ViewContext, this);\r
+                }\r
+                return _htmlHelper;\r
+            }\r
+        }\r
+\r
+        public new TModel Model {\r
+            get {\r
+                return ViewData.Model;\r
+            }            \r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]\r
+        public new ViewDataDictionary<TModel> ViewData {\r
+            get {\r
+                EnsureViewData();\r
+                return _viewData;\r
+            }\r
+            set {\r
+                SetViewData(value);\r
+            }\r
+        }\r
+\r
+        protected override void SetViewData(ViewDataDictionary viewData) {\r
+            _viewData = new ViewDataDictionary<TModel>(viewData);\r
+\r
+            base.SetViewData(_viewData);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/VirtualPathProviderViewEngine.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/VirtualPathProviderViewEngine.cs
new file mode 100644 (file)
index 0000000..5dd74ba
--- /dev/null
@@ -0,0 +1,266 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Globalization;\r
+    using System.Linq;\r
+    using System.Web;\r
+    using System.Web.Hosting;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public abstract class VirtualPathProviderViewEngine : IViewEngine {\r
+        // format is ":ViewCacheEntry:{cacheType}:{prefix}:{name}:{controllerName}:{areaName}:"\r
+        private const string _cacheKeyFormat = ":ViewCacheEntry:{0}:{1}:{2}:{3}:{4}:";\r
+        private const string _cacheKeyPrefix_Master = "Master";\r
+        private const string _cacheKeyPrefix_Partial = "Partial";\r
+        private const string _cacheKeyPrefix_View = "View";\r
+        private static readonly string[] _emptyLocations = new string[0];\r
+\r
+        private VirtualPathProvider _vpp;\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]\r
+        public string[] AreaMasterLocationFormats {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]\r
+        public string[] AreaPartialViewLocationFormats {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]\r
+        public string[] AreaViewLocationFormats {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]\r
+        public string[] MasterLocationFormats {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]\r
+        public string[] PartialViewLocationFormats {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public IViewLocationCache ViewLocationCache {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]\r
+        public string[] ViewLocationFormats {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        protected VirtualPathProvider VirtualPathProvider {\r
+            get {\r
+                if (_vpp == null) {\r
+                    _vpp = HostingEnvironment.VirtualPathProvider;\r
+                }\r
+                return _vpp;\r
+            }\r
+            set {\r
+                _vpp = value;\r
+            }\r
+        }\r
+\r
+        protected VirtualPathProviderViewEngine() {\r
+            if (HttpContext.Current == null || HttpContext.Current.IsDebuggingEnabled) {\r
+                ViewLocationCache = DefaultViewLocationCache.Null;\r
+            }\r
+            else {\r
+                ViewLocationCache = new DefaultViewLocationCache();\r
+            }\r
+        }\r
+\r
+        private string CreateCacheKey(string prefix, string name, string controllerName, string areaName) {\r
+            return String.Format(CultureInfo.InvariantCulture, _cacheKeyFormat,\r
+                GetType().AssemblyQualifiedName, prefix, name, controllerName, areaName);\r
+        }\r
+\r
+        protected abstract IView CreatePartialView(ControllerContext controllerContext, string partialPath);\r
+\r
+        protected abstract IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath);\r
+\r
+        protected virtual bool FileExists(ControllerContext controllerContext, string virtualPath) {\r
+            return VirtualPathProvider.FileExists(virtualPath);\r
+        }\r
+\r
+        public virtual ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (String.IsNullOrEmpty(partialViewName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "partialViewName");\r
+            }\r
+\r
+            string[] searched;\r
+            string controllerName = controllerContext.RouteData.GetRequiredString("controller");\r
+            string partialPath = GetPath(controllerContext, PartialViewLocationFormats, AreaPartialViewLocationFormats, "PartialViewLocationFormats", partialViewName, controllerName, _cacheKeyPrefix_Partial, useCache, out searched);\r
+\r
+            if (String.IsNullOrEmpty(partialPath)) {\r
+                return new ViewEngineResult(searched);\r
+            }\r
+\r
+            return new ViewEngineResult(CreatePartialView(controllerContext, partialPath), this);\r
+        }\r
+\r
+        public virtual ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) {\r
+            if (controllerContext == null) {\r
+                throw new ArgumentNullException("controllerContext");\r
+            }\r
+            if (String.IsNullOrEmpty(viewName)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "viewName");\r
+            }\r
+\r
+            string[] viewLocationsSearched;\r
+            string[] masterLocationsSearched;\r
+\r
+            string controllerName = controllerContext.RouteData.GetRequiredString("controller");\r
+            string viewPath = GetPath(controllerContext, ViewLocationFormats, AreaViewLocationFormats, "ViewLocationFormats", viewName, controllerName, _cacheKeyPrefix_View, useCache, out viewLocationsSearched);\r
+            string masterPath = GetPath(controllerContext, MasterLocationFormats, AreaMasterLocationFormats, "MasterLocationFormats", masterName, controllerName, _cacheKeyPrefix_Master, useCache, out masterLocationsSearched);\r
+\r
+            if (String.IsNullOrEmpty(viewPath) || (String.IsNullOrEmpty(masterPath) && !String.IsNullOrEmpty(masterName))) {\r
+                return new ViewEngineResult(viewLocationsSearched.Union(masterLocationsSearched));\r
+            }\r
+\r
+            return new ViewEngineResult(CreateView(controllerContext, viewPath, masterPath), this);\r
+        }\r
+\r
+        private string GetPath(ControllerContext controllerContext, string[] locations, string[] areaLocations, string locationsPropertyName, string name, string controllerName, string cacheKeyPrefix, bool useCache, out string[] searchedLocations) {\r
+            searchedLocations = _emptyLocations;\r
+\r
+            if (String.IsNullOrEmpty(name)) {\r
+                return String.Empty;\r
+            }\r
+\r
+            string areaName = AreaHelpers.GetAreaName(controllerContext.RouteData);\r
+            bool usingAreas = !String.IsNullOrEmpty(areaName);\r
+            List<ViewLocation> viewLocations = GetViewLocations(locations, (usingAreas) ? areaLocations : null);\r
+\r
+            if (viewLocations.Count == 0) {\r
+                throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture,\r
+                    MvcResources.Common_PropertyCannotBeNullOrEmpty, locationsPropertyName));\r
+            }\r
+\r
+            bool nameRepresentsPath = IsSpecificPath(name);\r
+            string cacheKey = CreateCacheKey(cacheKeyPrefix, name, (nameRepresentsPath) ? String.Empty : controllerName, areaName);\r
+\r
+            if (useCache) {\r
+                return ViewLocationCache.GetViewLocation(controllerContext.HttpContext, cacheKey);\r
+            }\r
+\r
+            return (nameRepresentsPath) ?\r
+                GetPathFromSpecificName(controllerContext, name, cacheKey, ref searchedLocations) :\r
+                GetPathFromGeneralName(controllerContext, viewLocations, name, controllerName, areaName, cacheKey, ref searchedLocations);\r
+        }\r
+\r
+        private string GetPathFromGeneralName(ControllerContext controllerContext, List<ViewLocation> locations, string name, string controllerName, string areaName, string cacheKey, ref string[] searchedLocations) {\r
+            string result = String.Empty;\r
+            searchedLocations = new string[locations.Count];\r
+\r
+            for (int i = 0; i < locations.Count; i++) {\r
+                ViewLocation location = locations[i];\r
+                string virtualPath = location.Format(name, controllerName, areaName);\r
+\r
+                if (FileExists(controllerContext, virtualPath)) {\r
+                    searchedLocations = _emptyLocations;\r
+                    result = virtualPath;\r
+                    ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, result);\r
+                    break;\r
+                }\r
+\r
+                searchedLocations[i] = virtualPath;\r
+            }\r
+\r
+            return result;\r
+        }\r
+\r
+        private string GetPathFromSpecificName(ControllerContext controllerContext, string name, string cacheKey, ref string[] searchedLocations) {\r
+            string result = name;\r
+\r
+            if (!FileExists(controllerContext, name)) {\r
+                result = String.Empty;\r
+                searchedLocations = new[] { name };\r
+            }\r
+\r
+            ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, result);\r
+            return result;\r
+        }\r
+\r
+        private static List<ViewLocation> GetViewLocations(string[] viewLocationFormats, string[] areaViewLocationFormats) {\r
+            List<ViewLocation> allLocations = new List<ViewLocation>();\r
+\r
+            if (areaViewLocationFormats != null) {\r
+                foreach (string areaViewLocationFormat in areaViewLocationFormats) {\r
+                    allLocations.Add(new AreaAwareViewLocation(areaViewLocationFormat));\r
+                }\r
+            }\r
+\r
+            if (viewLocationFormats != null) {\r
+                foreach (string viewLocationFormat in viewLocationFormats) {\r
+                    allLocations.Add(new ViewLocation(viewLocationFormat));\r
+                }\r
+            }\r
+\r
+            return allLocations;\r
+        }\r
+\r
+        private static bool IsSpecificPath(string name) {\r
+            char c = name[0];\r
+            return (c == '~' || c == '/');\r
+        }\r
+\r
+        public virtual void ReleaseView(ControllerContext controllerContext, IView view) {\r
+            IDisposable disposable = view as IDisposable;\r
+            if (disposable != null) {\r
+                disposable.Dispose();\r
+            }\r
+        }\r
+\r
+        private class ViewLocation {\r
+\r
+            protected string _virtualPathFormatString;\r
+\r
+            public ViewLocation(string virtualPathFormatString) {\r
+                _virtualPathFormatString = virtualPathFormatString;\r
+            }\r
+\r
+            public virtual string Format(string viewName, string controllerName, string areaName) {\r
+                return String.Format(CultureInfo.InvariantCulture, _virtualPathFormatString, viewName, controllerName);\r
+            }\r
+\r
+        }\r
+\r
+        private class AreaAwareViewLocation : ViewLocation {\r
+\r
+            public AreaAwareViewLocation(string virtualPathFormatString)\r
+                : base(virtualPathFormatString) {\r
+            }\r
+\r
+            public override string Format(string viewName, string controllerName, string areaName) {\r
+                return String.Format(CultureInfo.InvariantCulture, _virtualPathFormatString, viewName, controllerName, areaName);\r
+            }\r
+\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/WebFormView.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/WebFormView.cs
new file mode 100644 (file)
index 0000000..7167d8c
--- /dev/null
@@ -0,0 +1,109 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System;\r
+    using System.Globalization;\r
+    using System.IO;\r
+    using System.Web.Mvc.Resources;\r
+\r
+    public class WebFormView : IView {\r
+\r
+        private IBuildManager _buildManager;\r
+\r
+        public WebFormView(string viewPath)\r
+            : this(viewPath, null) {\r
+        }\r
+\r
+        public WebFormView(string viewPath, string masterPath) {\r
+            if (String.IsNullOrEmpty(viewPath)) {\r
+                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "viewPath");\r
+            }\r
+\r
+            ViewPath = viewPath;\r
+            MasterPath = masterPath ?? String.Empty;\r
+        }\r
+\r
+        internal IBuildManager BuildManager {\r
+            get {\r
+                if (_buildManager == null) {\r
+                    _buildManager = new BuildManagerWrapper();\r
+                }\r
+                return _buildManager;\r
+            }\r
+            set {\r
+                _buildManager = value;\r
+            }\r
+        }\r
+\r
+        public string MasterPath {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public string ViewPath {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public virtual void Render(ViewContext viewContext, TextWriter writer) {\r
+            if (viewContext == null) {\r
+                throw new ArgumentNullException("viewContext");\r
+            }\r
+\r
+            object viewInstance = BuildManager.CreateInstanceFromVirtualPath(ViewPath, typeof(object));\r
+            if (viewInstance == null) {\r
+                throw new InvalidOperationException(\r
+                    String.Format(\r
+                        CultureInfo.CurrentUICulture,\r
+                        MvcResources.WebFormViewEngine_ViewCouldNotBeCreated,\r
+                        ViewPath));\r
+            }\r
+\r
+            ViewPage viewPage = viewInstance as ViewPage;\r
+            if (viewPage != null) {\r
+                RenderViewPage(viewContext, viewPage);\r
+                return;\r
+            }\r
+\r
+            ViewUserControl viewUserControl = viewInstance as ViewUserControl;\r
+            if (viewUserControl != null) {\r
+                RenderViewUserControl(viewContext, viewUserControl);\r
+                return;\r
+            }\r
+\r
+            throw new InvalidOperationException(\r
+                String.Format(\r
+                    CultureInfo.CurrentUICulture,\r
+                    MvcResources.WebFormViewEngine_WrongViewBase,\r
+                    ViewPath));\r
+        }\r
+\r
+        private void RenderViewPage(ViewContext context, ViewPage page) {\r
+            if (!String.IsNullOrEmpty(MasterPath)) {\r
+                page.MasterLocation = MasterPath;\r
+            }\r
+\r
+            page.ViewData = context.ViewData;\r
+            page.RenderView(context);\r
+        }\r
+\r
+        private void RenderViewUserControl(ViewContext context, ViewUserControl control) {\r
+            if (!String.IsNullOrEmpty(MasterPath)) {\r
+                throw new InvalidOperationException(MvcResources.WebFormViewEngine_UserControlCannotHaveMaster);\r
+            }\r
+\r
+            control.ViewData = context.ViewData;\r
+            control.RenderView(context);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/WebFormViewEngine.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/WebFormViewEngine.cs
new file mode 100644 (file)
index 0000000..9f2d080
--- /dev/null
@@ -0,0 +1,98 @@
+/* ****************************************************************************\r
+ *\r
+ * Copyright (c) Microsoft Corporation. All rights reserved.\r
+ *\r
+ * This software is subject to the Microsoft Public License (Ms-PL). \r
+ * A copy of the license can be found in the license.htm file included \r
+ * in this distribution.\r
+ *\r
+ * You must not remove this notice, or any other, from this software.\r
+ *\r
+ * ***************************************************************************/\r
+\r
+namespace System.Web.Mvc {\r
+    using System.Diagnostics.CodeAnalysis;\r
+    using System.Net;\r
+    using System.Web;\r
+\r
+    public class WebFormViewEngine : VirtualPathProviderViewEngine {\r
+\r
+        private IBuildManager _buildManager;\r
+\r
+        public WebFormViewEngine() {\r
+            MasterLocationFormats = new[] {\r
+                "~/Views/{1}/{0}.master",\r
+                "~/Views/Shared/{0}.master"\r
+            };\r
+\r
+            AreaMasterLocationFormats = new[] {\r
+                "~/Areas/{2}/Views/{1}/{0}.master",\r
+                "~/Areas/{2}/Views/Shared/{0}.master",\r
+            };\r
+\r
+            ViewLocationFormats = new[] {\r
+                "~/Views/{1}/{0}.aspx",\r
+                "~/Views/{1}/{0}.ascx",\r
+                "~/Views/Shared/{0}.aspx",\r
+                "~/Views/Shared/{0}.ascx"\r
+            };\r
+\r
+            AreaViewLocationFormats = new[] {\r
+                "~/Areas/{2}/Views/{1}/{0}.aspx",\r
+                "~/Areas/{2}/Views/{1}/{0}.ascx",\r
+                "~/Areas/{2}/Views/Shared/{0}.aspx",\r
+                "~/Areas/{2}/Views/Shared/{0}.ascx",\r
+            };\r
+\r
+            PartialViewLocationFormats = ViewLocationFormats;\r
+            AreaPartialViewLocationFormats = AreaViewLocationFormats;\r
+        }\r
+\r
+        internal IBuildManager BuildManager {\r
+            get {\r
+                if (_buildManager == null) {\r
+                    _buildManager = new BuildManagerWrapper();\r
+                }\r
+                return _buildManager;\r
+            }\r
+            set {\r
+                _buildManager = value;\r
+            }\r
+        }\r
+\r
+        protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath) {\r
+            return new WebFormView(partialPath, null);\r
+        }\r
+\r
+        protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath) {\r
+            return new WebFormView(viewPath, masterPath);\r
+        }\r
+\r
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",\r
+            Justification = "Exceptions are interpreted as indicating that the file does not exist.")]\r
+        protected override bool FileExists(ControllerContext controllerContext, string virtualPath) {\r
+            try {\r
+                object viewInstance = BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(object));\r
+                return viewInstance != null;\r
+            }\r
+            catch (HttpException he) {\r
+                if (he is HttpParseException) {\r
+                    // The build manager found something, but instantiation failed due to a runtime lookup failure\r
+                    throw;\r
+                }\r
+\r
+                if (he.GetHttpCode() == (int)HttpStatusCode.NotFound) {\r
+                    // If BuildManager returns a 404 (Not Found) that means that a file did not exist.\r
+                    // If the view itself doesn't exist, then this method should report that rather than throw an exception.\r
+                    if (!base.FileExists(controllerContext, virtualPath)) {\r
+                        return false;\r
+                    }\r
+                }\r
+\r
+                // All other error codes imply other errors such as compilation or parsing errors\r
+                throw;\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
index 12433d7341e5eaeaed4ac334c1fc13cd1966890e..372b03b8a29ac83f4218b0dd2983833c3a099cea 100644 (file)
@@ -884,9 +884,14 @@ namespace System.Web.Compilation
                        if (tparser != null)
                                tparser.Location = location;
 
-                       if (text.Length != 0)
-                               FlushText (lastTag == TagType.CodeRender);
-
+                       if (text.Length != 0) {
+                               bool ignoreEmptyString = lastTag == TagType.CodeRender;
+#if NET_4_0
+                               ignoreEmptyString |= lastTag == TagType.CodeRenderEncode;
+#endif
+                               FlushText (ignoreEmptyString);
+                       }
+                       
                        if (0 == String.Compare (tagid, "script", true, Helpers.InvariantCulture)) {
                                bool in_script = (inScript || ignore_text);
                                if (in_script) {
@@ -941,10 +946,11 @@ namespace System.Web.Compilation
                                }
                                break;
                        case TagType.DataBinding:
-                               goto case TagType.CodeRender;
                        case TagType.CodeRenderExpression:
-                               goto case TagType.CodeRender;
                        case TagType.CodeRender:
+#if NET_4_0
+                       case TagType.CodeRenderEncode:
+#endif
                                if (isApplication)
                                        throw new ParseException (location, "Invalid content for application file.");
                        
@@ -1442,6 +1448,9 @@ namespace System.Web.Compilation
                                        return CodeConstructType.ExpressionSnippet;
 
                                case TagType.CodeRender:
+#if NET_4_0
+                               case TagType.CodeRenderEncode:
+#endif
                                        return CodeConstructType.CodeSnippet;
 
                                case TagType.DataBinding:
@@ -1474,6 +1483,10 @@ namespace System.Web.Compilation
                                b = new CodeRenderBuilder (code, true, location);
                        else if (tagtype == TagType.DataBinding)
                                b = new DataBindingBuilder (code, location);
+#if NET_4_0
+                       else if (tagtype == TagType.CodeRenderEncode)
+                               b = new CodeRenderBuilder (code, true, location, true);
+#endif
                        else
                                throw new HttpException ("Should never happen");
 
@@ -1578,7 +1591,11 @@ namespace System.Web.Compilation
                                        case TagType.CodeRenderExpression:
                                                builder.AppendSubBuilder (new CodeRenderBuilder (tagid, true, location));
                                                break;
-                                               
+#if NET_4_0
+                                       case TagType.CodeRenderEncode:
+                                               builder.AppendSubBuilder (new CodeRenderBuilder (tagid, true, location, true));
+                                               break;
+#endif
                                        case TagType.DataBinding:
                                                builder.AppendSubBuilder (new DataBindingBuilder (tagid, location));
                                                break;
index d0e08f8fcb962dad5b18719f7e73de213d7678ff..af8cc7b9b65e0460b827f3e5e775540d9bca0283 100644 (file)
@@ -597,8 +597,14 @@ namespace System.Web.Compilation
                        tokenizer.ExpectAttrValue = old;
                        bool varname;
                        bool databinding;
+#if NET_4_0
+                       bool codeRenderEncode;
+#endif
                        varname = Eat ('=');
                        databinding = !varname && Eat ('#');
+#if NET_4_0
+                       codeRenderEncode = !databinding && !varname && Eat (':');
+#endif
                        string odds = tokenizer.Odds;
                        
                        tokenizer.Verbatim = true;
@@ -614,8 +620,16 @@ namespace System.Web.Compilation
                        tokenizer.Verbatim = false;
                        id = inside_tags;
                        attributes = null;
-                       tagtype = (databinding ? TagType.DataBinding :
-                                 (varname ? TagType.CodeRenderExpression : TagType.CodeRender));
+                       if (databinding)
+                               tagtype = TagType.DataBinding;
+                       else if (varname)
+                               tagtype = TagType.CodeRenderExpression;
+#if NET_4_0
+                       else if (codeRenderEncode)
+                               tagtype = TagType.CodeRenderEncode;
+#endif
+                       else
+                               tagtype = TagType.CodeRender;
                }
 
                public override string ToString ()
index d9d49b1bd9ba03cef91860563b25083626f271d0..5cfee1313d655eb45277e71a34a3aa838c2f99e6 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-17  Marek Habersack  <mhabersack@novell.com>
+
+       * AspGenerator.cs, AspParser.cs, TemplateControlCompiler.cs, TagType.cs, CodeRenderBuilder.cs: implemented the new <%: %> 4.0 html-encoded code render expression.
+
 2010-03-06  Marek Habersack  <mhabersack@novell.com>
 
        * TemplateControlCompiler.cs: AssignPropertyForResources localizes
index af38a4124b34e04091977b4f378f825b99de9470..9d3b879599bab250d2e6ac917e654a2ebd294e9b 100644 (file)
@@ -40,7 +40,10 @@ namespace System.Web.Compilation
                DataBinding,
                CodeRender,
                CodeRenderExpression,
-               Include
+               Include,
+#if NET_4_0
+               CodeRenderEncode
+#endif
        }
 }
 
index 1d2a5365524ed863b96760df774ab129ccbac14a..4b01ccd67853f2ae263f23f390a1cc351188cde5 100644 (file)
@@ -1262,9 +1262,21 @@ namespace System.Web.Compilation
                                                        new CodeArgumentReferenceExpression ("__output"),
                                                        "Write");
 
-                       expr.Parameters.Add (new CodeSnippetExpression (cr.Code));
+                       expr.Parameters.Add (GetWrappedCodeExpression (cr));
                        parent.RenderMethod.Statements.Add (AddLinePragma (expr, cr));
                }
+
+               CodeExpression GetWrappedCodeExpression (CodeRenderBuilder cr)
+               {
+                       var ret = new CodeSnippetExpression (cr.Code);
+#if NET_4_0
+                       if (cr.HtmlEncode) {
+                               var encodeRef = new CodeMethodReferenceExpression (new CodeTypeReferenceExpression (typeof (HttpUtility)), "HtmlEncode");
+                               return new CodeMethodInvokeExpression (encodeRef, new CodeExpression[] { ret });
+                       } else
+#endif
+                               return ret;
+               }
                
                static Type GetContainerType (ControlBuilder builder)
                {
index 3721ff584b8418135aad2922f9aebf252098502c..e6230b1ad3ecc8abd5dc5cdffccd1826f7a5da0c 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-19 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * TreeView.cs: use enums instead of strings for attributes.
+
 2010-03-06  Marek Habersack  <mhabersack@novell.com>
 
        * XmlDataSource.cs: reload document when one of Data, DataFile,
index b3c005d0c8f4782cc64eb4d29e87fc8b69d2de1b..1716ee8709def23989c4045eda8fd6bcb8e18599 100644 (file)
@@ -1375,9 +1375,9 @@ namespace System.Web.UI.WebControls
                        else
                                hasChildNodes = (node.PopulateOnDemand && !node.Populated) || node.ChildNodes.Count > 0;
                                
-                       writer.AddAttribute ("cellpadding", "0", false);
-                       writer.AddAttribute ("cellspacing", "0", false);
-                       writer.AddStyleAttribute ("border-width", "0");
+                       writer.AddAttribute (HtmlTextWriterAttribute.Cellpadding, "0", false);
+                       writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0", false);
+                       writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0");
                        writer.RenderBeginTag (HtmlTextWriterTag.Table);
 
                        Unit nodeSpacing = GetNodeSpacing (node);
@@ -1392,11 +1392,11 @@ namespace System.Web.UI.WebControls
                        nodeImage = GetNodeImageUrl ("i", imageStyle);
                        for (int n=0; n<level; n++) {
                                writer.RenderBeginTag (HtmlTextWriterTag.Td);
-                               writer.AddStyleAttribute ("width", NodeIndent + "px");
-                               writer.AddStyleAttribute ("height", "1px");
+                               writer.AddStyleAttribute (HtmlTextWriterStyle.Width, NodeIndent + "px");
+                               writer.AddStyleAttribute (HtmlTextWriterStyle.Height, "1px");
                                writer.RenderBeginTag (HtmlTextWriterTag.Div);
                                if (ShowLines && levelLines [n] != null) {
-                                       writer.AddAttribute ("src", nodeImage);
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Src, nodeImage);
                                        writer.AddAttribute (HtmlTextWriterAttribute.Alt, String.Empty, false);
                                        writer.RenderBeginTag (HtmlTextWriterTag.Img);
                                        writer.RenderEndTag ();
@@ -1442,18 +1442,18 @@ namespace System.Web.UI.WebControls
                                        
                                        if (buttonImage) {
                                                if (!clientExpand || (!PopulateNodesFromClient && node.PopulateOnDemand && !node.Populated))
-                                                       writer.AddAttribute ("href", GetClientEvent (node, "ec"));
+                                                       writer.AddAttribute (HtmlTextWriterAttribute.Href, GetClientEvent (node, "ec"));
                                                else
-                                                       writer.AddAttribute ("href", GetClientExpandEvent(node));
+                                                       writer.AddAttribute (HtmlTextWriterAttribute.Href, GetClientExpandEvent(node));
                                                writer.RenderBeginTag (HtmlTextWriterTag.A);    // Anchor
                                        }
 
                                        // tooltip is 'HtmlAttributeEncoded'
-                                       writer.AddAttribute ("alt", tooltip);
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Alt, tooltip);
 
                                        if (buttonImage && clientExpand)
-                                               writer.AddAttribute ("id", GetNodeClientId (node, "img"));
-                                       writer.AddAttribute ("src", nodeImage);
+                                               writer.AddAttribute (HtmlTextWriterAttribute.Id, GetNodeClientId (node, "img"));
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Src, nodeImage);
                                        if (buttonImage)
                                                writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0");
                                        writer.RenderBeginTag (HtmlTextWriterTag.Img);
@@ -1484,9 +1484,9 @@ namespace System.Web.UI.WebControls
                        if (!String.IsNullOrEmpty (imageUrl)) {
                                writer.RenderBeginTag (HtmlTextWriterTag.Td);   // TD
                                BeginNodeTag (writer, node, clientExpand);
-                               writer.AddAttribute ("src", imageUrl);
+                               writer.AddAttribute (HtmlTextWriterAttribute.Src, imageUrl);
                                writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0");
-                               writer.AddAttribute ("alt", node.ImageToolTip);
+                               writer.AddAttribute (HtmlTextWriterAttribute.Alt, node.ImageToolTip);
                                writer.RenderBeginTag (HtmlTextWriterTag.Img);
                                writer.RenderEndTag (); // IMG
                                writer.RenderEndTag (); // style tag
@@ -1494,7 +1494,7 @@ namespace System.Web.UI.WebControls
                        }
 
                        if (!NodeWrap)
-                               writer.AddStyleAttribute ("white-space", "nowrap");
+                               writer.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
 
                        bool nodeIsSelected = node == SelectedNode && selectedNodeStyle != null;
                        if (!nodeIsSelected && selectedNodeStyle != null) {
@@ -1512,10 +1512,10 @@ namespace System.Web.UI.WebControls
                        // Checkbox
                        
                        if (node.ShowCheckBoxInternal) {
-                               writer.AddAttribute ("name", ClientID + "_cs_" + node.Path);
-                               writer.AddAttribute ("type", "checkbox", false);
-                               writer.AddAttribute ("title", node.Text);
-                               if (node.Checked) writer.AddAttribute ("checked", "checked", false);
+                               writer.AddAttribute (HtmlTextWriterAttribute.Name, ClientID + "_cs_" + node.Path);
+                               writer.AddAttribute (HtmlTextWriterAttribute.Type, "checkbox", false);
+                               writer.AddAttribute (HtmlTextWriterAttribute.Title, node.Text);
+                               if (node.Checked) writer.AddAttribute (HtmlTextWriterAttribute.Checked, "checked", false);
                                writer.RenderBeginTag (HtmlTextWriterTag.Input);        // INPUT
                                writer.RenderEndTag (); // INPUT
                        }
@@ -1525,7 +1525,7 @@ namespace System.Web.UI.WebControls
                        node.BeginRenderText (writer);
                        
                        if (clientExpand)
-                               writer.AddAttribute ("id", GetNodeClientId (node, "txt"));
+                               writer.AddAttribute (HtmlTextWriterAttribute.Id, GetNodeClientId (node, "txt"));
                        AddNodeLinkStyle (writer, node, level, nodeIsSelected);
                        BeginNodeTag (writer, node, clientExpand);
                        writer.Write (node.Text);
@@ -1559,10 +1559,10 @@ namespace System.Web.UI.WebControls
                                
                                if (clientExpand) {
                                        if (!(node.Expanded.HasValue && node.Expanded.Value))
-                                               writer.AddStyleAttribute ("display", "none");
+                                               writer.AddStyleAttribute (HtmlTextWriterStyle.Display, "none");
                                        else
-                                               writer.AddStyleAttribute ("display", "block");
-                                       writer.AddAttribute ("id", GetNodeClientId (node, null));
+                                               writer.AddStyleAttribute (HtmlTextWriterStyle.Display, "block");
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Id, GetNodeClientId (node, null));
                                        writer.RenderBeginTag (HtmlTextWriterTag.Span);
                                        
                                        if (renderChildNodes) {
@@ -1600,7 +1600,7 @@ namespace System.Web.UI.WebControls
                                return;
 
                        writer.RenderBeginTag (HtmlTextWriterTag.Table);
-                       writer.AddAttribute ("height", ((int) value).ToString (), false);
+                       writer.AddAttribute (HtmlTextWriterAttribute.Height, ((int) value).ToString (), false);
                        writer.RenderBeginTag (HtmlTextWriterTag.Tr);
                        writer.RenderBeginTag (HtmlTextWriterTag.Td);
                        writer.RenderEndTag (); // td
@@ -1610,7 +1610,7 @@ namespace System.Web.UI.WebControls
                
                void RenderMenuItemSpacing (HtmlTextWriter writer, Unit itemSpacing)
                {
-                       writer.AddStyleAttribute ("height", itemSpacing.ToString ());
+                       writer.AddStyleAttribute (HtmlTextWriterStyle.Height, itemSpacing.ToString ());
                        writer.RenderBeginTag (HtmlTextWriterTag.Tr);
                        writer.RenderBeginTag (HtmlTextWriterTag.Td);
                        writer.RenderEndTag ();
@@ -1774,7 +1774,7 @@ namespace System.Web.UI.WebControls
                void BeginNodeTag (HtmlTextWriter writer, TreeNode node, bool clientExpand)
                {
                        if(node.ToolTip.Length>0)
-                               writer.AddAttribute ("title", node.ToolTip);
+                               writer.AddAttribute (HtmlTextWriterAttribute.Title, node.ToolTip);
 
                        string navigateUrl = node.NavigateUrl;
                        if (!String.IsNullOrEmpty (navigateUrl)) {
@@ -1784,15 +1784,15 @@ namespace System.Web.UI.WebControls
 #else
                                string navUrl = ResolveClientUrl (navigateUrl);
 #endif
-                               writer.AddAttribute ("href", navUrl);
+                               writer.AddAttribute (HtmlTextWriterAttribute.Href, navUrl);
                                if (target.Length > 0)
-                                       writer.AddAttribute ("target", target);
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Target, target);
                                writer.RenderBeginTag (HtmlTextWriterTag.A);
                        } else if (node.SelectAction != TreeNodeSelectAction.None) {
                                if (node.SelectAction == TreeNodeSelectAction.Expand && clientExpand)
-                                       writer.AddAttribute ("href", GetClientExpandEvent (node));
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Href, GetClientExpandEvent (node));
                                else
-                                       writer.AddAttribute ("href", GetClientEvent (node, "sel"));
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Href, GetClientEvent (node, "sel"));
                                writer.RenderBeginTag (HtmlTextWriterTag.A);
                        } else
                                writer.RenderBeginTag (HtmlTextWriterTag.Span);
index 5997bc55a144d7d927579b6090d0239d732a9db1..c3b23b4a6bd0f8a7ef82558c43bb747d0661c40d 100644 (file)
@@ -34,6 +34,18 @@ namespace System.Web.UI
 {
        sealed class CodeRenderBuilder : CodeBuilder
        {
+#if NET_4_0
+               public bool HtmlEncode {
+                       get; private set;
+               }
+
+               public CodeRenderBuilder (string code, bool isAssign, ILocation location, bool doHtmlEncode)
+                       : base (code, isAssign, location)
+               {
+                       this.HtmlEncode = doHtmlEncode;
+               }
+#endif
+               
                public CodeRenderBuilder (string code, bool isAssign, ILocation location)
                        : base (code, isAssign, location)
                {
index d7f305d0cc460ae33fa3b1fc4950675edb862d04..3962a92d2a0ac8bba2faba41e7e1ce4876f3a0b1 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-20  Marek Habersack  <mhabersack@novell.com>
+
+       * SiteMapNode.cs: avoid calling ChildNodes twice in HasChildNodes.
+       Cache child nodes in the ChildNodes property.
+
 2010-03-06  Marek Habersack  <mhabersack@novell.com>
 
        * HttpRequest.cs: cache RawUrl value.
index ec30ded240ad5495cf4ae2549867a08a03d9939e..e1fb52011f9f6017f96a3eb4f6ee86fbda1e9d2f 100644 (file)
@@ -91,7 +91,10 @@ namespace System.Web {
                }
 
                public virtual bool HasChildNodes {
-                       get { return ChildNodes != null && ChildNodes.Count != 0; }
+                       get {
+                               SiteMapNodeCollection childNodes = ChildNodes;
+                               return childNodes != null && childNodes.Count > 0;
+                       }
                }
 
                public SiteMapNodeCollection GetAllNodes ()
@@ -172,18 +175,11 @@ namespace System.Web {
                        }
                }
 
-               internal SiteMapNodeCollection ChildNodesInternal {
+               public virtual SiteMapNodeCollection ChildNodes {
                        get {
                                if (childNodes == null)
-                                       childNodes = new SiteMapNodeCollection ();
+                                       childNodes = provider.GetChildNodes (this);
                                return childNodes;
-                       }
-               }
-
-               public virtual SiteMapNodeCollection ChildNodes {
-                       get {
-                               if (childNodes != null) return childNodes;
-                               return provider.GetChildNodes (this);
                        } 
                        set {
                                CheckWritable ();
index 2f640577a411e9e31ceac5eae41d5fab17700a30..d2dcf223779108a6263d88b30600d8c37f7eb864 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-20  Marek Habersack  <mhabersack@novell.com>
+
+       * XmlSiteMapProviderTest.cs: AreEqual should have expected result first
+       and actual next - swapped parameters in RootNode_2_OnLoad
+
 2009-11-16  Marek Habersack  <mhabersack@novell.com>
 
        * HttpContext.cs: added some tests for RewritePath
index 60f384a4824c2902c28ae1f6ae960f4d538db86e..0eae9bc5a9ab725ecc90605ca3eac7faa7a35ae5 100644 (file)
@@ -249,8 +249,8 @@ namespace MonoTests.System.Web
                        Assert.AreEqual (provider.RootNode.Provider, provider, "#A2");
                        Assert.IsNotNull (provider.CallTrace, "#A3");
                        Assert.Greater (provider.CallTrace.Length, 1, "#A3-1");
-                       Assert.AreEqual (provider.CallTrace[0].Name, "BuildSiteMap", "#A3-2");
-                       Assert.AreEqual (provider.CallTrace[1].Name, "get_RootNode", "#A3-3");
+                       Assert.AreEqual ("BuildSiteMap", provider.CallTrace[0].Name, "#A3-2");
+                       Assert.AreEqual ("get_RootNode", provider.CallTrace[1].Name, "#A3-3");
                }
 
                [Test]
index cc6b0faa22c221dbbed81f916ee43b3cf154e7d7..366c0dd5810943b685507aa015dae25fca7cbdba 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: rename the net_2_1 profile to moonlight.
+       * net_2_1_*.dll.sources: rename to moonlight_*.dll.sources.
+
 2009-11-30  Jonathan Pryor  <jpryor@novell.com>
 
        * monotouch_System.Xml.dll.sources: Add System.Xml/NamespaceHandling.cs 
index 6dd6a391add1155c4a23c643b98aeb1c048e8145..ff68bdcee1ae80717741b01cabed6212b9571190 100644 (file)
@@ -94,7 +94,7 @@ Mono.Xml.Xsl/PatternTokenizer.cs: System.Xml.XPath/Tokenizer.cs
        echo "#define XSLT_PATTERN" > $@
        cat $< >>$@
 
-ifneq (net_2_1_raw, $(PROFILE))
+ifneq (moonlight_raw, $(PROFILE))
 BUILT_SOURCES = System.Xml.XPath/Parser.cs \
        Mono.Xml.Xsl/PatternParser.cs \
        Mono.Xml.Xsl/PatternTokenizer.cs
index c2edf583dca9db9540c7d9f1883997a44cf5a1b9..fc5f9a2936f83c8e454638f976befc81965daca6 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSchemaComplexType.cs : quick fix for bug #584664. Fill base
+         content type particles in prior to filling its own.
+
 2010-02-16  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlSchemaComplexType.cs : in modern .NET, xs:anyType has the
index 2fc6e0db289c623806230790f9ebb7c66eb19993..9ee6609a6a0dc141e06d0c3a22236ff6d2f8c270 100644 (file)
@@ -414,6 +414,14 @@ namespace System.Xml.Schema
 
                void FillContentTypeParticle (ValidationEventHandler h, XmlSchema schema)
                {
+                       if (CollectProcessId == schema.CompilationId)
+                               return;
+                       CollectProcessId = schema.CompilationId;
+
+                       var ct = BaseXmlSchemaType as XmlSchemaComplexType;
+                       if (ct != null)
+                               ct.FillContentTypeParticle (h, schema);
+
                        // {content type} => ContentType and ContentTypeParticle (later)
                        if (ContentModel != null) {
                                CollectContentTypeFromContentModel (h, schema);
@@ -423,8 +431,6 @@ namespace System.Xml.Schema
                        contentTypeParticle = validatableParticle.GetOptimizedParticle (true);
                        if (contentTypeParticle == XmlSchemaParticle.Empty && resolvedContentType == XmlSchemaContentType.ElementOnly)
                                resolvedContentType = XmlSchemaContentType.Empty;
-
-                       CollectProcessId = schema.CompilationId;
                }
 
                #region {content type}
@@ -480,7 +486,7 @@ namespace System.Xml.Schema
                        if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
                                baseComplexType = XmlSchemaComplexType.AnyType;
 
-                       // On error case, it simple reject any contents
+                       // On error case, it simply rejects any contents
                        if (baseComplexType == null) {
                                validatableParticle = XmlSchemaParticle.Empty;
                                resolvedContentType = XmlSchemaContentType.Empty;
@@ -488,6 +494,7 @@ namespace System.Xml.Schema
                        }
 
                        // 3.4.2 complex content {content type}
+                       // FIXME: this part is looking different than the spec. sections.
                        if (cce.Particle == null || cce.Particle == XmlSchemaParticle.Empty) {
                                // - 2.1
                                if (baseComplexType == null) {
index c32317932accccc1a92b8606f7e3a14d3f1dd434..92a699ce1127a97f6ee6fcf82edb772e771430f3 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * SerializationSource.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2010-03-10  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlAnyElementAttribute.cs : add internal IsNullableSpecified
index 9df5c844067ff0899f522907b87c774013014a56..0ecac0ee0bc7bac7924ca4a55acc274d7fcd8cec 100644 (file)
@@ -34,7 +34,7 @@ using System.Text;
 
 namespace System.Xml.Serialization 
 {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
        internal abstract class SerializationSource 
        {
                Type[] includedTypes;
index 844607641ce7c5bdd66c8f079fc92b2316dea787..de6c30d51e99194dd1472c6460237352d42c7d49 100644 (file)
@@ -1,3 +1,28 @@
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlReader.cs, XmlQualifiedName.cs : ReadElementContentAs() when
+         used for qname, treats non-prefixed name as in default namespace.
+
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlTextWriter2.cs : fix cosmetic 2.0 compatibility issue in 
+         WriteStartAttribute() which allows "" for prefixed xmlns and brings
+         incompatibility with XmlTextWriter class.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * XmlNodeReader2.cs
+       * DTDValidatingReader2.cs
+       * XmlReader.cs
+       * XmlTextReader.cs
+       * XmlWriter.cs
+       * XmlResolver.cs
+       * XmlNodeReaderImpl.cs
+       * XmlInputStream.cs
+       * XmlReaderSettings.cs
+       * XmlWriterSettings.cs:
+               Use MOONLIGHT symbol to disambiguate MonoTouch and Moonlight code.
+
 2010-02-20  Geoff Norton  <gnorton@novell.com>
 
        * XmlInputStream.cs: Disable this codepath on monotouch.  Fixes
index 65c8b19e756783316938476aa5482bc8ad08a45c..bfc183beb7d5fe7b10e0e678c7ce3ca213df04d7 100644 (file)
@@ -966,7 +966,7 @@ namespace Mono.Xml
                        }
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                internal
 #else
                public
@@ -988,7 +988,7 @@ namespace Mono.Xml
                                return reader.ReadAttributeValue ();
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                internal
 #else
                public
@@ -1031,7 +1031,7 @@ namespace Mono.Xml
                        get { return reader.EOF; }
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                internal
 #else
                public
index 75a3f806b9859f2ddca3fd52096fbf6173e19c2a..44932ebeb40beca10c54f34e1d8876a676ed99c6 100644 (file)
@@ -361,7 +361,7 @@ namespace System.Xml
 
                static string GetStringFromBytes (byte [] bytes, int index, int count)
                {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        char [] chars = new char [count];
                        for (int i = index; i < count; i++)
                                chars [i] = (char) bytes [i];
index ce4f47a7963e869428b41b8f33a499f6eb8c1e8a..4c58656206c0631b2efe20965c4403144beee22e 100644 (file)
@@ -126,7 +126,7 @@ namespace System.Xml
                        get { return Current.HasAttributes; }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public override bool HasValue {
                        get { return Current.HasValue; }
                }
@@ -436,7 +436,7 @@ namespace System.Xml
                        return base.ReadString ();
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public override void ResolveEntity ()
                {
                        if (entity != null)
index 34f104346829e9707bfceb6b5a7e9d4f244ce297..35ce8963f93a13db75a87437598bbfa54d8fb84b 100644 (file)
@@ -161,7 +161,7 @@ namespace System.Xml
                        }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public override bool HasValue {
                        get {
                                if (current == null)
@@ -816,7 +816,7 @@ namespace System.Xml
                        return base.ReadString ();
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public override void ResolveEntity ()
                {
                        throw new NotSupportedException ("Should not happen.");
index 58b962205d508b04857f4015299b8293a47478f6..ea32cbacb86782c73aac3210127c85732082b6c8 100644 (file)
@@ -127,14 +127,19 @@ namespace System.Xml
                }
 
                internal static XmlQualifiedName Parse (string name, XmlReader reader)
+               {
+                       return Parse (name, reader, false);
+               }
+
+               internal static XmlQualifiedName Parse (string name, XmlReader reader, bool considerDefaultNamespace)
                {
                        int index = name.IndexOf (':');
-                       if (index < 0)
+                       if (index < 0 && !considerDefaultNamespace)
                                return new XmlQualifiedName (name);
-                       string ns = reader.LookupNamespace (name.Substring (0, index));
+                       string ns = reader.LookupNamespace (index < 0 ? String.Empty : name.Substring (0, index));
                        if (ns == null)
                                throw new ArgumentException ("Invalid qualified name.");
-                       return new XmlQualifiedName (name.Substring (index + 1), ns);
+                       return new XmlQualifiedName (index < 0 ? name : name.Substring (index + 1), ns);
                }
 
                // Operators
index f100bfa800e3f8eb2109ff14929c0649ada5c6c6..bf36030b03bfda5ab3bbf73cfe37c9fd70f7e11c 100644 (file)
@@ -35,7 +35,7 @@ using System.Collections;
 using System.Diagnostics;
 using System.IO;
 using System.Text;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using System.Xml.Schema; // only required for NET_2_0 (SchemaInfo)
 using System.Xml.Serialization; // only required for NET_2_0 (SchemaInfo)
 using Mono.Xml.Schema; // only required for NET_2_0
@@ -186,7 +186,7 @@ namespace System.Xml
                public abstract ReadState ReadState { get; }
 
 #if NET_2_0
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public virtual IXmlSchemaInfo SchemaInfo {
                        get { return null; }
                }
@@ -414,7 +414,7 @@ namespace System.Xml
 
                private static XmlReader CreateValidatingXmlReader (XmlReader reader, XmlReaderSettings settings)
                {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        return reader;
 #else
                        XmlValidatingReader xvr = null;
@@ -989,9 +989,9 @@ namespace System.Xml
                                        return text;
                                if (type == typeof (XmlQualifiedName)) {
                                        if (resolver != null)
-                                               return XmlQualifiedName.Parse (text, resolver);
+                                               return XmlQualifiedName.Parse (text, resolver, true);
                                        else
-                                               return XmlQualifiedName.Parse (text, this);
+                                               return XmlQualifiedName.Parse (text, this, true);
                                }
                                if (type == typeof (DateTimeOffset))
                                        return XmlConvert.ToDateTimeOffset (text);
index 4e9bb846c4b8bbc1294879dc62cb7499a353289e..444ec804691546844618bd3b0ded907058f5bb1f 100644 (file)
@@ -35,7 +35,7 @@ using System.IO;
 using System.Net;
 using System.Xml.Schema;
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using XsValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags;
 #endif
 
@@ -53,14 +53,14 @@ namespace System.Xml
                private int linePositionOffset;
                private bool prohibitDtd;
                private XmlNameTable nameTable;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                private XmlSchemaSet schemas;
                private bool schemasNeedsInitialization;
                private XsValidationFlags validationFlags;
                private ValidationType validationType;
 #endif
                private XmlResolver xmlResolver;
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                private DtdProcessing dtdProcessing;
                private long maxCharactersFromEntities;
                private long maxCharactersInDocument;
@@ -71,7 +71,7 @@ namespace System.Xml
                        Reset ();
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public event ValidationEventHandler ValidationEventHandler;
 #endif
 
@@ -91,7 +91,7 @@ namespace System.Xml
                        lineNumberOffset = 0;
                        linePositionOffset = 0;
                        prohibitDtd = true;
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        xmlResolver = new XmlXapResolver ();
 #else
                        schemas = null;
@@ -118,7 +118,7 @@ namespace System.Xml
                        get { return conformance; }
                        set { conformance = value; }
                }
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                public DtdProcessing DtdProcessing {
                        get { return dtdProcessing; }
                        set {
@@ -177,7 +177,7 @@ namespace System.Xml
                        set { nameTable = value; }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public XmlSchemaSet Schemas {
                        get {
                                if (schemasNeedsInitialization) {
index 6c0829f44211120ab822ce0bfd1310ac8c8475f3..0cf9f3172593eaead0697d0b073cef54db557841 100644 (file)
@@ -38,7 +38,7 @@ namespace System.Xml
 {
        public abstract class XmlResolver
        {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public abstract ICredentials Credentials { set; }
 #endif
 
@@ -53,7 +53,7 @@ namespace System.Xml
                        if (baseUri == null) {
                                if (relativeUri == null)
                                        throw new ArgumentNullException ("Either baseUri or relativeUri are required.");
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                return new Uri (relativeUri, UriKind.RelativeOrAbsolute);
 #else
                                // Don't ignore such case that relativeUri is in fact absolute uri (e.g. ResolveUri (null, "http://foo.com")).
@@ -82,7 +82,7 @@ namespace System.Xml
                                .Replace ("%", "%25")
                                .Replace ("\"", "%22");
                }
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                public virtual bool SupportsType (Uri absoluteUri, Type type)
                {
                        if (absoluteUri == null)
index 106ae5a35e98e765482c0951cf47830ceba7bbf9..c43f2d594e6d0bf56bf1434a7506298356335df6 100644 (file)
@@ -130,7 +130,7 @@ namespace System.Xml
                internal XmlTextReader (bool dummy, XmlResolver resolver, string url, XmlNodeType fragType, XmlParserContext context)
                {
                        if (resolver == null) {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                resolver = new XmlXapResolver ();
 #else
                                resolver = new XmlUrlResolver ();
@@ -958,7 +958,7 @@ namespace System.Xml
                // These values are never re-initialized.
                private bool namespaces = true;
                private WhitespaceHandling whitespaceHandling = WhitespaceHandling.All;
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                private XmlResolver resolver = new XmlXapResolver ();
 #else
                private XmlResolver resolver = new XmlUrlResolver ();
index edb537a3982f1d648c730e89b92ed5d7bd57cc83..a47d0edc80b5fb13c25696cb5891d83240d5f2d2 100644 (file)
@@ -841,7 +841,7 @@ namespace Mono.Xml
                                if (prefix == "xml")
                                        namespaceUri = XmlNamespace;
                                // infer namespace URI.
-                               else if ((object) namespaceUri == null) {
+                               else if ((object) namespaceUri == null || (v2 && namespaceUri.Length == 0)) {
                                        if (isNSDecl)
                                                namespaceUri = XmlnsNamespace;
                                        else
index 4fc3c44024fe12eb765d9054e850fc99ddba8172..58fc211b86645a33dff2cf15f4f97902ecaf7a35 100644 (file)
@@ -35,17 +35,13 @@ using System;
 using System.Collections;
 using System.IO;
 using System.Text;
-#if NET_2_0 && (!NET_2_1 || MONOTOUCH)
+#if !MOONLIGHT
 using System.Xml.XPath;
 #endif
 
 namespace System.Xml
 {
-#if NET_2_0
        public abstract class XmlWriter : IDisposable
-#else
-       public abstract class XmlWriter
-#endif
        {
 #if NET_2_0
                XmlWriterSettings settings;
@@ -179,7 +175,7 @@ namespace System.Xml
                                return;
 
                        WriteStartAttribute (reader.Prefix, reader.LocalName, reader.NamespaceURI);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // no ReadAttributeValue() in 2.1 profile.
                        WriteString (reader.Value);
 #else
@@ -392,7 +388,7 @@ namespace System.Xml
                                WriteString (localName);
                }
 
-#if NET_2_0 && (!NET_2_1 || MONOTOUCH)
+#if !MOONLIGHT
                public virtual void WriteNode (XPathNavigator navigator, bool defattr)
                {
                        if (navigator == null)
index 90d66534fae5a1fd9f57aa28b68c1e60da8879fd..8cfb78d3e5850987010b667d71a4455b41d09a71 100644 (file)
@@ -146,7 +146,7 @@ namespace System.Xml
                        //set { outputMethod = value; }
                }
 
-#if (NET_2_1 || NET_4_0) && !MONOTOUCH
+#if MOONLIGHT || NET_4_0
                public
 #else
                internal
index 39c4dec4398601b2408b5f10cf02daa95759330d..b5a4f30dc55a0b43e106d60babdf5c5dbdb2b3fd 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSchemaValidatorTests.cs : added test for bug #584664.
+
 2010-01-27  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlSchemaValidatorTests.cs : added test for bug #557452, by
index 853a3f4f117378a82ee4f41dcd18df76b1ff9794..e58e24c359077077d5b0215f3ac8f418cc9c587a 100644 (file)
@@ -290,6 +290,13 @@ namespace MonoTests.System.Xml
                        doc.Schemas.Add (XmlSchema.Read (XmlReader.Create (new StringReader (xsd)), null));
                        doc.Validate (null);
                }
+
+               [Test]
+               public void Bug584664 ()
+               {
+                       Validate (File.ReadAllText ("Test/XmlFiles/xsd/584664a.xml"), File.ReadAllText ("Test/XmlFiles/xsd/584664a.xsd"));
+                       Validate (File.ReadAllText ("Test/XmlFiles/xsd/584664b.xml"), File.ReadAllText ("Test/XmlFiles/xsd/584664b.xsd"));
+               }
        }
 }
 
index f4ea90a545dee2e3246595c63c37ef712279feae..6582a26e1e85d59e718539960fb32169387e91c3 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlReaderCommonTests.cs : added test for ReadElementContentAs() for
+         qname, with default namespace.
+
 2010-01-28  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlReaderCommonTests.cs : added test for bug #543332.
index 7495ebaee1d6fd54641796c0ab15219a8c4f5f7c..1f6ee9bb39a8fc5c061b77b491600d4c0cd7290b 100644 (file)
@@ -2203,6 +2203,21 @@ namespace MonoTests.System.Xml
                        Assert.AreEqual (0, bytesRead, "#3");\r
                        Assert.AreEqual (XmlNodeType.EndElement, reader.NodeType, "#4");\r
                }\r
+\r
+               [Test]\r
+               public void ReadElementContentAsQNameDefaultNS ()\r
+               {\r
+                       var sw = new StringWriter ();\r
+                       var xw = XmlWriter.Create (sw);\r
+                       xw.WriteStartElement ("", "foo", "urn:foo");\r
+                       xw.WriteValue (new XmlQualifiedName ("x", "urn:foo"));\r
+                       xw.WriteEndElement ();\r
+                       xw.Close ();\r
+                       var xr = XmlReader.Create (new StringReader (sw.ToString ()));\r
+                       xr.MoveToContent ();\r
+                       var q = (XmlQualifiedName) xr.ReadElementContentAs (typeof (XmlQualifiedName), xr as IXmlNamespaceResolver);\r
+                       Assert.AreEqual ("urn:foo", q.Namespace, "#1");\r
+               }\r
 #endif\r
        }\r
 }\r
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/584664a.xml b/mcs/class/System.XML/Test/XmlFiles/xsd/584664a.xml
new file mode 100644 (file)
index 0000000..50db974
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<root xmlns="http://a">
+  <leaf/>
+</root>
\ No newline at end of file
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/584664a.xsd b/mcs/class/System.XML/Test/XmlFiles/xsd/584664a.xsd
new file mode 100644 (file)
index 0000000..7260c0c
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://a" xmlns="http://a" elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+<xs:complexType name="base">
+  <xs:sequence>
+    <xs:element name="leaf" type="xs:string"/>
+    <xs:element name="nested" type="derived" minOccurs="0" maxOccurs="unbounded"/>
+  </xs:sequence>
+</xs:complexType>
+
+<xs:complexType name="derived">
+  <xs:complexContent>
+    <xs:extension base="base"/>
+  </xs:complexContent>
+</xs:complexType>
+
+<xs:element name="root" type="derived"/>
+
+</xs:schema>
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/584664b.xml b/mcs/class/System.XML/Test/XmlFiles/xsd/584664b.xml
new file mode 100644 (file)
index 0000000..58c5907
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<root xmlns="http://b">
+  <leaf/>
+</root>
\ No newline at end of file
diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/584664b.xsd b/mcs/class/System.XML/Test/XmlFiles/xsd/584664b.xsd
new file mode 100644 (file)
index 0000000..da5e5ca
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://b" xmlns="http://b" elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+<xs:complexType name="base">
+  <xs:sequence>
+    <xs:element name="leaf" type="xs:string"/>
+  </xs:sequence>
+</xs:complexType>
+
+<xs:complexType name="derived">
+  <xs:complexContent>
+    <xs:extension base="base"/>
+  </xs:complexContent>
+</xs:complexType>
+
+<xs:element name="root" type="derived"/>
+
+</xs:schema>
\ No newline at end of file
index 64bdb6c1fa629c35fad58f1ea97c31ccdd8b21dd..1ee824d36c558d742b32aa1c53793746151d25b1 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * 584664b.xsd, 584664a.xml, 584664b.xml, 584664a.xsd: new test files
+         by Florian Haag.
+
 2009-05-21  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * extension-attr-redefine-*.xsd: new test files.
diff --git a/mcs/class/System.XML/moonlight_raw_System.Xml.dll.sources b/mcs/class/System.XML/moonlight_raw_System.Xml.dll.sources
new file mode 100644 (file)
index 0000000..867f13f
--- /dev/null
@@ -0,0 +1,70 @@
+Assembly/AssemblyInfo.cs
+Mono.Xml/IHasXmlParserContext.cs
+Mono.Xml/SubtreeXmlReader.cs
+Mono.Xml/XmlFilterReader.cs
+System.Xml.Schema/XmlSeverityType.cs
+System.Xml.Schema/XmlSchemaForm.cs
+System.Xml.Schema/XmlTypeCode.cs
+System.Xml/ConformanceLevel.cs
+System.Xml/DtdProcessing.cs
+System.Xml/DTDAutomata.cs
+System.Xml/DTDObjectModel.cs
+System.Xml/DTDReader.cs
+System.Xml/EntityHandling.cs
+System.Xml/EntityResolvingXmlReader.cs
+System.Xml/Formatting.cs
+System.Xml/IXmlLineInfo.cs
+System.Xml/IXmlNamespaceResolver.cs
+System.Xml/NamespaceHandling.cs
+System.Xml/NameTable.cs
+System.Xml/NewLineHandling.cs
+System.Xml/ReadState.cs
+System.Xml/WhitespaceHandling.cs
+System.Xml/WriteState.cs
+System.Xml/XQueryConvert.cs
+System.Xml/XmlChar.cs
+System.Xml/XmlConvert.cs
+System.Xml/XmlDateTimeSerializationMode.cs
+System.Xml/XmlException.cs
+System.Xml/XmlInputStream.cs
+System.Xml/XmlNameTable.cs
+System.Xml/XmlNamespaceManager.cs
+System.Xml/XmlNamespaceScope.cs
+System.Xml/XmlNodeType.cs
+System.Xml/XmlOutputMethod.cs
+System.Xml/XmlParserContext.cs
+System.Xml/XmlParserInput.cs
+System.Xml/XmlQualifiedName.cs
+System.Xml/XmlReader.cs
+System.Xml/XmlReaderBinarySupport.cs
+System.Xml/XmlReaderSettings.cs
+System.Xml/XmlResolver.cs
+System.Xml/XmlSpace.cs
+System.Xml/XmlTextReader.cs
+System.Xml/XmlTextReader2.cs
+System.Xml/XmlTextWriter2.cs
+System.Xml/XmlTokenizedType.cs
+System.Xml/XmlWriter.cs
+System.Xml/XmlWriterSettings.cs
+System.Xml/XmlXapResolver.cs
+System.Xml.Schema/XmlSchemaDatatype_2_1.cs
+System.Xml.Schema/XmlSchema_2_1.cs
+System.Xml.Schema/XmlSchemaObject_2_1.cs
+System.Xml.Schema/XmlSchemaSet_2_1.cs
+System.Xml.Serialization/IXmlSerializable.cs
+System.Xml.Serialization/KeyHelper.cs
+System.Xml.Serialization/SerializationSource.cs
+System.Xml.Serialization/XmlAnyElementAttribute.cs
+System.Xml.Serialization/XmlArrayAttribute.cs
+System.Xml.Serialization/XmlArrayItemAttribute.cs
+System.Xml.Serialization/XmlAttributeAttribute.cs
+System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs
+System.Xml.Serialization/XmlElementAttribute.cs
+System.Xml.Serialization/XmlEnumAttribute.cs
+System.Xml.Serialization/XmlIgnoreAttribute.cs
+System.Xml.Serialization/XmlIncludeAttribute.cs
+System.Xml.Serialization/XmlNamespaceDeclarationsAttribute.cs
+System.Xml.Serialization/XmlRootAttribute.cs
+System.Xml.Serialization/XmlSchemaProviderAttribute.cs
+System.Xml.Serialization/XmlTextAttribute.cs
+System.Xml.Serialization/XmlTypeAttribute.cs
diff --git a/mcs/class/System.XML/net_2_1_raw_System.Xml.dll.sources b/mcs/class/System.XML/net_2_1_raw_System.Xml.dll.sources
deleted file mode 100644 (file)
index 867f13f..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-Assembly/AssemblyInfo.cs
-Mono.Xml/IHasXmlParserContext.cs
-Mono.Xml/SubtreeXmlReader.cs
-Mono.Xml/XmlFilterReader.cs
-System.Xml.Schema/XmlSeverityType.cs
-System.Xml.Schema/XmlSchemaForm.cs
-System.Xml.Schema/XmlTypeCode.cs
-System.Xml/ConformanceLevel.cs
-System.Xml/DtdProcessing.cs
-System.Xml/DTDAutomata.cs
-System.Xml/DTDObjectModel.cs
-System.Xml/DTDReader.cs
-System.Xml/EntityHandling.cs
-System.Xml/EntityResolvingXmlReader.cs
-System.Xml/Formatting.cs
-System.Xml/IXmlLineInfo.cs
-System.Xml/IXmlNamespaceResolver.cs
-System.Xml/NamespaceHandling.cs
-System.Xml/NameTable.cs
-System.Xml/NewLineHandling.cs
-System.Xml/ReadState.cs
-System.Xml/WhitespaceHandling.cs
-System.Xml/WriteState.cs
-System.Xml/XQueryConvert.cs
-System.Xml/XmlChar.cs
-System.Xml/XmlConvert.cs
-System.Xml/XmlDateTimeSerializationMode.cs
-System.Xml/XmlException.cs
-System.Xml/XmlInputStream.cs
-System.Xml/XmlNameTable.cs
-System.Xml/XmlNamespaceManager.cs
-System.Xml/XmlNamespaceScope.cs
-System.Xml/XmlNodeType.cs
-System.Xml/XmlOutputMethod.cs
-System.Xml/XmlParserContext.cs
-System.Xml/XmlParserInput.cs
-System.Xml/XmlQualifiedName.cs
-System.Xml/XmlReader.cs
-System.Xml/XmlReaderBinarySupport.cs
-System.Xml/XmlReaderSettings.cs
-System.Xml/XmlResolver.cs
-System.Xml/XmlSpace.cs
-System.Xml/XmlTextReader.cs
-System.Xml/XmlTextReader2.cs
-System.Xml/XmlTextWriter2.cs
-System.Xml/XmlTokenizedType.cs
-System.Xml/XmlWriter.cs
-System.Xml/XmlWriterSettings.cs
-System.Xml/XmlXapResolver.cs
-System.Xml.Schema/XmlSchemaDatatype_2_1.cs
-System.Xml.Schema/XmlSchema_2_1.cs
-System.Xml.Schema/XmlSchemaObject_2_1.cs
-System.Xml.Schema/XmlSchemaSet_2_1.cs
-System.Xml.Serialization/IXmlSerializable.cs
-System.Xml.Serialization/KeyHelper.cs
-System.Xml.Serialization/SerializationSource.cs
-System.Xml.Serialization/XmlAnyElementAttribute.cs
-System.Xml.Serialization/XmlArrayAttribute.cs
-System.Xml.Serialization/XmlArrayItemAttribute.cs
-System.Xml.Serialization/XmlAttributeAttribute.cs
-System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs
-System.Xml.Serialization/XmlElementAttribute.cs
-System.Xml.Serialization/XmlEnumAttribute.cs
-System.Xml.Serialization/XmlIgnoreAttribute.cs
-System.Xml.Serialization/XmlIncludeAttribute.cs
-System.Xml.Serialization/XmlNamespaceDeclarationsAttribute.cs
-System.Xml.Serialization/XmlRootAttribute.cs
-System.Xml.Serialization/XmlSchemaProviderAttribute.cs
-System.Xml.Serialization/XmlTextAttribute.cs
-System.Xml.Serialization/XmlTypeAttribute.cs
index 15210973344b65fe0bc7e77d518bca67464ce49b..65cf2210f97c00b11d6d3ee275aaae111e5c0d21 100644 (file)
@@ -1,3 +1,17 @@
+2010-03-16  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * XElement.cs:
+       * SaveOptions.cs: Add more 4.0 api to Moonlight.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * XElement.cs, XNodeNavigator.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
+2010-03-15  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * XElement.cs: Added two new Load overloads for NET 4.0 and Moonlight.
+
 2010-02-12  Miguel de Icaza  <miguel@novell.com>
 
        * XStreamingElement.cs: Avoid an extra indirect call, by calling
        * XAttribute.cs, XIterators.cs, XName.cs, XElementSequence.cs,
          System.Xml.XLinq.cs :
          Minimum implementation to run ms XLinqIntro.
-
index f2753fc07cf201243b7a75c148b98d40fc4773ad..f0a4d4efeef9250c54f69827ac80c70981b1cf5b 100644 (file)
@@ -33,7 +33,7 @@ namespace System.Xml.Linq
        {
                None = 0,
                DisableFormatting = 1,
-#if NET_4_0
+#if NET_4_0 || MOONLIGHT
                OmitDuplicateNamespaces = 2
 #endif
        }
index 92c6e7f84555fc9ded3c29785b7e22b950adaee9..16c969c332aaf5a2d89e334b1327b2b5d45a4dc1 100644 (file)
@@ -394,7 +394,7 @@ namespace System.Xml.Linq
 
                static void DefineDefaultSettings (XmlReaderSettings settings, LoadOptions options)
                {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // 2.1 has a DtdProcessing property which defaults to DtdProcessing.Prohibit
                        settings.DtdProcessing = DtdProcessing.Parse;
 #else
@@ -454,6 +454,23 @@ namespace System.Xml.Linq
                        }
                }
 
+#if MOONLIGHT || NET_4_0
+               public static XElement Load (Stream stream)
+               {
+                       return Load (stream, LoadOptions.None);
+               }
+
+               public static XElement Load (Stream stream, LoadOptions options)
+               {
+                       XmlReaderSettings s = new XmlReaderSettings ();
+                       DefineDefaultSettings (s, options);
+
+                       using (XmlReader r = XmlReader.Create (stream, s)) {
+                               return LoadCore (r, options);
+                       }
+               }
+#endif
+
                internal static XElement LoadCore (XmlReader r, LoadOptions options)
                {
                        r.MoveToContent ();
@@ -519,7 +536,7 @@ namespace System.Xml.Linq
 
                        if ((options & SaveOptions.DisableFormatting) == SaveOptions.None)
                                s.Indent = true;
-#if NET_4_0
+#if NET_4_0 || MOONLIGHT
                        if ((options & SaveOptions.OmitDuplicateNamespaces) == SaveOptions.OmitDuplicateNamespaces)
                                s.NamespaceHandling |= NamespaceHandling.OmitDuplicates;
 #endif
@@ -539,7 +556,7 @@ namespace System.Xml.Linq
                        
                        if ((options & SaveOptions.DisableFormatting) == SaveOptions.None)
                                s.Indent = true;
-#if NET_4_0
+#if NET_4_0 || MOONLIGHT
                        if ((options & SaveOptions.OmitDuplicateNamespaces) == SaveOptions.OmitDuplicateNamespaces)
                                s.NamespaceHandling |= NamespaceHandling.OmitDuplicates;
 #endif
@@ -553,7 +570,7 @@ namespace System.Xml.Linq
                        WriteTo (w);
                }
 
-#if NET_4_0
+#if NET_4_0 || MOONLIGHT
                public void Save (Stream stream)
                {
                        Save (stream, SaveOptions.None);
index 429954cb8dfac7fab121765bb2307a05d720a8c8..a64ca7e882172c7fc07cdcc65ca39c7f9afd1528 100644 (file)
@@ -24,7 +24,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System;
 using System.IO;
index c403ee2420da2fd859c565e5c551460d786b81e7..f4641d77fa98274f4a5afc5161851591d6ae5f6e 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Extensions.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2009-07-20  Jb Evain  <jbevain@novell.com>
 
        * Extensions.cs: do not compile for a NET_2_1 profile.
index 86c0beb6039f473dca3e8173f208420e9d6fc736..cc3f448733aefca7b56c973270c3eb919e2b6fb3 100644 (file)
@@ -24,7 +24,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System;
 using System.Collections.Generic;
diff --git a/mcs/class/System.Xml.Serialization/Assembly/AssemblyInfo.cs b/mcs/class/System.Xml.Serialization/Assembly/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..b86fa22
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+//   Rolf Bjarne Kvinge  (RKvinge@novell.com)
+//
+// Copyright (c) 2010 Novell, Inc. (http://www.novell.com)
+//
+//
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the System.Xml.Serialization assembly
+
+[assembly: AssemblyTitle ("System.Xml.Serialization.dll")]
+[assembly: AssemblyDescription ("System.Xml.Serialization.dll")]
+[assembly: AssemblyDefaultAlias ("System.Xml.Serialization.dll")]
+
+[assembly: AssemblyCompany (Consts.MonoCompany)]
+[assembly: AssemblyProduct (Consts.MonoProduct)]
+[assembly: AssemblyCopyright (Consts.MonoCopyright)]
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
+
+[assembly: NeutralResourcesLanguage ("en-US")]
+
+[assembly: ComVisible (false)]
+
+[assembly: CLSCompliant (true)]
+[assembly: AssemblyDelaySign (true)]
+[assembly: AssemblyKeyFile ("../silverlight.pub")]
+[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
+[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
+[assembly: Debuggable (DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
+[assembly: RuntimeCompatibility (WrapNonExceptionThrows = true)]
diff --git a/mcs/class/System.Xml.Serialization/Assembly/ChangeLog b/mcs/class/System.Xml.Serialization/Assembly/ChangeLog
new file mode 100644 (file)
index 0000000..872b6a8
--- /dev/null
@@ -0,0 +1,4 @@
+2010-03-16  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * AssemblyInfo.cs: Added.
+
diff --git a/mcs/class/System.Xml.Serialization/ChangeLog b/mcs/class/System.Xml.Serialization/ChangeLog
new file mode 100644 (file)
index 0000000..8038f0a
--- /dev/null
@@ -0,0 +1,6 @@
+2010-03-16  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * Makefile: 
+       * System.Xml.Serialization.dll.sources:
+       * moonlight_raw_System.Xml.Serialization.dll.sources: Added.
+
diff --git a/mcs/class/System.Xml.Serialization/Makefile b/mcs/class/System.Xml.Serialization/Makefile
new file mode 100644 (file)
index 0000000..ee8337a
--- /dev/null
@@ -0,0 +1,24 @@
+thisdir = class/System.Xml.Serialization
+SUBDIRS = 
+include ../../build/rules.make
+
+LIBRARY = System.Xml.Serialization.dll
+LIB_MCS_FLAGS =  -unsafe -r:System.dll -r:System.Core.dll -r:System.Xml.dll -d:NET_2_1 -d:NET_2_0 -d:NET_1_1
+
+ifneq (2.1, $(FRAMEWORK_VERSION))
+LIB_MCS_FLAGS += -d:NET_3_5 -nowarn:1720
+endif
+
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
+
+EXTRA_DISTFILES =
+
+VALID_PROFILE := $(filter 2.1, $(FRAMEWORK_VERSION))
+ifndef VALID_PROFILE
+LIBRARY_NAME = dummy-System.Xml.Serialization.dll
+NO_INSTALL = yes
+NO_SIGN_ASSEMBLY = yes
+NO_TEST = yes
+endif
+
+include ../../build/library.make
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization.dll.sources b/mcs/class/System.Xml.Serialization/System.Xml.Serialization.dll.sources
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/ChangeLog b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/ChangeLog
new file mode 100644 (file)
index 0000000..10fa384
--- /dev/null
@@ -0,0 +1,14 @@
+2010-03-16  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * XmlMapping.cs:
+       * XmlAttributes.cs:
+       * XmlSerializer.cs:
+       * XmlTypeMapping.cs:
+       * XmlAttributeOverrides.cs:
+       * XmlSerializationWriter.cs:
+       * XmlSerializationReader.cs:
+       * XmlSerializerNamespaces.cs:
+       * XmlSerializationGeneratedCode.cs: Added a partially stubbed out version of
+       System.Xml.Serialization.dll, required for the Silverlight test suite to
+       compile. A real implementation based on the same classes in System.Xml should
+       eventually be done.
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlAttributeOverrides.cs b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlAttributeOverrides.cs
new file mode 100644 (file)
index 0000000..3f7a66c
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// XmlAttributeOverrides.cs
+//
+// Authors:
+//   Rolf Bjarne Kvinge (RKvinge@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+//
+// This class is just a stub of the same class in System.Xml/System.Xml.Serialization
+//
+
+namespace System.Xml.Serialization {
+       public class XmlAttributeOverrides {
+               public XmlAttributeOverrides ()
+               {
+                       throw new NotImplementedException ();
+               }
+               public void Add (Type type, XmlAttributes attributes)
+               {
+                       throw new NotImplementedException ();
+               }
+               public void Add (Type type, string member, XmlAttributes attributes)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlAttributes this [Type type, string member] {
+                       get {
+                               throw new NotImplementedException ();
+                       }
+               }
+               public XmlAttributes this [Type type] {
+                       get {
+                               throw new NotImplementedException ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlAttributes.cs b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlAttributes.cs
new file mode 100644 (file)
index 0000000..903b463
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// XmlAttributes.cs
+//
+// Authors:
+//   Rolf Bjarne Kvinge (RKvinge@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+//
+// This class is just a stub of the same class in System.Xml/System.Xml.Serialization
+//
+
+namespace System.Xml.Serialization {
+       public class XmlAttributes {
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlMapping.cs b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlMapping.cs
new file mode 100644 (file)
index 0000000..e5e9600
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// XmlMapping.cs
+//
+// Authors:
+//   Rolf Bjarne Kvinge (RKvinge@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+//
+// This class is just a stub of the same class in System.Xml/System.Xml.Serialization
+//
+
+namespace System.Xml.Serialization {
+       public abstract class XmlMapping {
+               public void SetKey (string key)
+               {
+                       throw new NotImplementedException ();
+               }
+               public string ElementName { get; private set; }
+               public string Namespace { get; private set; }
+               public string XsdElementName { get; private set; }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializationGeneratedCode.cs b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializationGeneratedCode.cs
new file mode 100644 (file)
index 0000000..04a2a8d
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// XmlSerializationGeneratedCode.cs
+//
+// Authors:
+//   Rolf Bjarne Kvinge (RKvinge@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+//
+// This class is just a stub of the same class in System.Xml/System.Xml.Serialization
+//
+
+namespace System.Xml.Serialization {
+       public abstract class XmlSerializationGeneratedCode {
+               protected XmlSerializationGeneratedCode ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializationReader.cs b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializationReader.cs
new file mode 100644 (file)
index 0000000..1b5f1f1
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// XmlSerializationReader.cs
+//
+// Authors:
+//   Rolf Bjarne Kvinge (RKvinge@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+//
+// This class is just a stub of the same class in System.Xml/System.Xml.Serialization
+//
+
+namespace System.Xml.Serialization {
+       public abstract class XmlSerializationReader : XmlSerializationGeneratedCode {
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializationWriter.cs b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializationWriter.cs
new file mode 100644 (file)
index 0000000..97acb4a
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// XmlSerializationWriter.cs
+//
+// Authors:
+//   Rolf Bjarne Kvinge (RKvinge@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+//
+// This class is just a stub of the same class in System.Xml/System.Xml.Serialization
+//
+
+namespace System.Xml.Serialization {
+       public abstract class XmlSerializationWriter : XmlSerializationGeneratedCode {
+               
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializer.cs b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializer.cs
new file mode 100644 (file)
index 0000000..bda6b9c
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// XmlSerializer.cs
+//
+// Authors:
+//   Rolf Bjarne Kvinge (RKvinge@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+//
+// This class is just a stub of the same class in System.Xml/System.Xml.Serialization
+//
+
+using System;
+using System.IO;
+namespace System.Xml.Serialization {
+       public class XmlSerializer {
+               public XmlSerializer ()
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer (Type type)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer (XmlTypeMapping xmlTYpeMapping)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer (Type type, Type [] extraTypes)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer (Type type, string defaultNamespace)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer (Type type, XmlAttributeOverrides overrides)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer (Type type, XmlRootAttribute root)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer (Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer (Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, object location, object evidence)
+               {
+                       throw new NotImplementedException ();
+               }
+               public bool CanDeserializer (XmlReader xmlReader)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializationReader CreateReader ()
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializationWriter CreateWriter ()
+               {
+                       throw new NotImplementedException ();
+               }
+               public object Deserialize (Stream stream)
+               {
+                       throw new NotImplementedException ();
+               }
+               public object Deserialize (XmlSerializationReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+               public object Deserialize (TextReader textReader)
+               {
+                       throw new NotImplementedException ();
+               }
+               public object Deserialize (XmlReader xmlReader)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer [] FromMappings (XmlMapping [] mappings)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer [] FromMappings (XmlMapping [] mappings, Type type)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializer [] FromTypes (Type [] types)
+               {
+                       throw new NotImplementedException ();
+               }
+               protected virtual void Serialize (object o, XmlSerializationWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+               public void Serialize (Stream stream, object o)
+               {
+                       throw new NotImplementedException ();
+               }
+               public void Serialize (TextWriter textWriter, object o)
+               {
+                       throw new NotImplementedException ();
+               }
+               public void Serialize (XmlWriter xmlWriter, object o)
+               {
+                       throw new NotImplementedException ();
+               }
+               public void Serialize (TextWriter textWriter, object o, XmlSerializerNamespaces namespaces)
+               {
+                       throw new NotImplementedException ();
+               }
+               public void Serialize (XmlWriter xmlWriter, object o, XmlSerializerNamespaces namespaces)
+               {
+                       throw new NotImplementedException ();
+               }
+               public void Serialize (Stream stream, object o, XmlSerializerNamespaces namespaces)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializerNamespaces.cs b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlSerializerNamespaces.cs
new file mode 100644 (file)
index 0000000..4dcb738
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// XmlSerializerNamespaces.cs
+//
+// Authors:
+//   Rolf Bjarne Kvinge (RKvinge@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+//
+// This class is just a stub of the same class in System.Xml/System.Xml.Serialization
+//
+
+namespace System.Xml.Serialization {
+       public class XmlSerializerNamespaces {
+               public XmlSerializerNamespaces ()
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializerNamespaces (XmlSerializerNamespaces namespaces)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlSerializerNamespaces (XmlQualifiedName [] namespaces)
+               {
+                       throw new NotImplementedException ();
+               }
+               public void Add (string prefix, string ns)
+               {
+                       throw new NotImplementedException ();
+               }
+               public XmlQualifiedName [] ToArray ()
+               {
+                       throw new NotImplementedException ();
+               }
+               public int Count { get; private set; }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlTypeMapping.cs b/mcs/class/System.Xml.Serialization/System.Xml.Serialization/XmlTypeMapping.cs
new file mode 100644 (file)
index 0000000..d789df6
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// XmlTypeMapping.cs
+//
+// Authors:
+//   Rolf Bjarne Kvinge (RKvinge@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+//
+// This class is just a stub of the same class in System.Xml/System.Xml.Serialization
+//
+
+namespace System.Xml.Serialization {
+       public class XmlTypeMapping : XmlMapping {
+               public string TypeFullName { get; private set; }
+               public string TypeName { get; private set; }
+               public string XsdTypeName { get; private set; }
+               public string XsdTypeNamespace { get; private set; }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.Xml.Serialization/moonlight_raw_System.Xml.Serialization.dll.sources b/mcs/class/System.Xml.Serialization/moonlight_raw_System.Xml.Serialization.dll.sources
new file mode 100644 (file)
index 0000000..1e0ecb0
--- /dev/null
@@ -0,0 +1,13 @@
+Assembly/AssemblyInfo.cs
+../System.XML/../../build/common/Consts.cs
+../System.XML/../../build/common/Locale.cs
+../System.XML/../../build/common/MonoTODOAttribute.cs
+System.Xml.Serialization/XmlAttributeOverrides.cs
+System.Xml.Serialization/XmlAttributes.cs
+System.Xml.Serialization/XmlMapping.cs
+System.Xml.Serialization/XmlSerializationGeneratedCode.cs
+System.Xml.Serialization/XmlSerializationReader.cs
+System.Xml.Serialization/XmlSerializationWriter.cs
+System.Xml.Serialization/XmlSerializer.cs
+System.Xml.Serialization/XmlSerializerNamespaces.cs
+System.Xml.Serialization/XmlTypeMapping.cs
index e3474f10dc6b04e1a780b18e4a5de69d606cca1e..4619fa2a0a8c4e38e1209e7a261bc85188dba1dc 100644 (file)
@@ -1,3 +1,22 @@
+2010-03-20  Miguel de Icaza  <miguel@novell.com>
+
+       * Eliminate warnings in a bunch of places.
+
+2010-03-19  Miguel de Icaza  <miguel@novell.com>
+
+       * Eliminate warnings in a bunch of places.
+
+2010-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * moonlight_*_System.dll.sources: Bring extra types so we can
+       build a full, managed, internal HTTP stack to be reused for SL3+
+       * Makefile: Add a INSIDE_SYSTEM define when compiling System.dll
+       to makes it possible to rebuild the same types in System.Net.dll
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * net_2_1_*.dll.sources: rename to moonlight_*.dll.sources.
+
 2010-03-11  Sebastien Pouliot  <sebastien@ximian.com>
 
        * net_2_1_raw_System.dll.sources: Add existing files that are 
index 1a408b072551750e0be210ef74c92fc16557b88c..0e2a75541b4aa3dce8db4388eb7d613ef4eda0ad 100644 (file)
@@ -29,6 +29,9 @@ TEST_MCS_FLAGS += -r:System.Configuration
 PROFILE_2_OR_4 := $(filter net_2_0 net_4_0, $(PROFILE))
 NOT_SL := $(filter net_2_0 net_4_0 monotouch, $(PROFILE))
 endif
+ifeq (2.1, $(FRAMEWORK_VERSION))
+LIB_MCS_FLAGS += -d:INSIDE_SYSTEM
+endif
 
 EXTRA_DISTFILES = \
        System.Text.RegularExpressions/notes.txt        \
index 0f98a1d85781d09e6483b33c6c8b976d8ded7387..9ef0707f18dd7671def762cf4dc66d7679aed05e 100644 (file)
@@ -45,11 +45,9 @@ namespace System.CodeDom
                private CodeTypeReference returnType;
                private CodeStatementCollection statements;
                private CodeAttributeDeclarationCollection returnAttributes;
-               int populated;
+               //int populated;
 
-#if NET_2_0
                CodeTypeParameterCollection typeParameters;
-#endif
                //
                // Constructors
                //
@@ -122,7 +120,6 @@ namespace System.CodeDom
                        }
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public CodeTypeParameterCollection TypeParameters {
                        get {
@@ -131,7 +128,6 @@ namespace System.CodeDom
                                return typeParameters;
                        }
                }
-#endif
 
                //
                // Events
index 22e05cb7ba88a7f9b5a847cf612042faf51ea6c5..8a709865b4149519aa388fe7ba56963d8346188e 100644 (file)
@@ -40,10 +40,10 @@ namespace System.CodeDom
        {
                private CodeCommentStatementCollection comments;
                private CodeNamespaceImportCollection imports;
-               private CodeNamespaceCollection namespaces;
+               //private CodeNamespaceCollection namespaces;
                private CodeTypeDeclarationCollection classes;
                private string name;
-               int populated;
+               //int populated;
 
                //
                // Constructors
index ed75aeea9174019db90dfa04a5005a310f14c431..ea6551a4af6026561f81fa56bf3a942150c4b417 100644 (file)
@@ -46,7 +46,7 @@ namespace System.CodeDom
                private TypeAttributes attributes = TypeAttributes.Public;
                private bool isEnum;
                private bool isStruct;
-               int populated;
+               //int populated;
 
 #if NET_2_0
                bool isPartial;
index cffd919fe40142b82d09fb775798250a018d0824..a61df458f7393e363d4053106b299a7d58780265 100644 (file)
@@ -43,7 +43,7 @@ namespace System.CodeDom
                private CodeTypeReference arrayElementType;
                private int arrayRank;
                private bool isInterface;
-               bool needsFixup;
+               //bool needsFixup;
 
 #if NET_2_0
                CodeTypeReferenceCollection typeArguments;
index 650521244b9de5d54939a01d250ea83f727ded4d..8b6cc9664cbd875f937b280958c5f2a430839fcd 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-03  Miguel de Icaza  <miguel@novell.com>
+
+       * RBTree.cs: Make these serializable, should fix the serialization
+       across appdomains of SortedDictionaries
+
 2010-03-11  Sebastien Pouliot  <sebastien@ximian.com>
 
        * ISet.cs: Add NET_2_1 since this is part of SL4
index 6325f32ff2e75df60cb886c22ff08fa1d2d33d24..51430bf1f02393f8e77be47c4023f86dcbaaea2f 100644 (file)
@@ -36,6 +36,7 @@ using System.Collections;
 
 namespace System.Collections.Generic
 {
+       [Serializable]
        internal class RBTree : IEnumerable, IEnumerable<RBTree.Node> {
                public interface INodeHelper<T> {
                        int Compare (T key, Node node);
@@ -576,6 +577,7 @@ namespace System.Collections.Generic
                        }
                }
 
+               [Serializable]
                public struct NodeEnumerator : IEnumerator, IEnumerator<Node> {
                        RBTree tree;
                        uint version;
index e4e61199c69b9acef0b525e3906d97230ddb267f..8e68d59004f1aaaa1590ac2584798dd452e71f65 100644 (file)
@@ -1,3 +1,13 @@
+2010-03-20  Miguel de Icaza  <miguel@novell.com>
+
+       * TypeDescriptor.cs: Remove warning.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * TypeConverter_2_1.cs, ComponentCollection.cs,
+       PropertyDescriptor.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2010-02-05  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * MaskedTextProvider.cs: In ToString() if we are a password, use the
index d09bc22bfae8e14bc4beb19f9013aaee10c0d3a8..cb34124823f9a1d8c71fa6c30fdae213af38187c 100644 (file)
@@ -38,7 +38,7 @@ using System.Reflection;
 
 namespace System.ComponentModel {
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
        public class ComponentCollection
        {
        }
index f636f59878482d8ad03d56a09108e52bcf00f4b8..74940e0787d9f660fcbd8a582e76ef16e121d14c 100644 (file)
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices;
 
 namespace System.ComponentModel
 {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
        public abstract class PropertyDescriptor
        {
        }
index ad4dd816db3c58b46dad6372bfc599e7d626b0b1..f27107bb010e25cfd1aa02ccea92c611c9d77a92 100644 (file)
@@ -23,7 +23,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
 
 using System;
 using System.Globalization;
index 614ede271fc479e93171733a0db92f6644e3d390..35df4f0410e2b3420fa350183039717c37bd10b0 100644 (file)
@@ -863,14 +863,14 @@ public sealed class TypeDescriptor
                if (instance == null)
                        throw new ArgumentNullException ("instance");
 
-               bool removed = false;
+               //bool removed = false;
                lock (componentDescriptionProvidersLock) {
                        LinkedList <TypeDescriptionProvider> plist;
                        WeakObjectWrapper instanceWrapper = new WeakObjectWrapper (instance);
 
                        if (componentDescriptionProviders.TryGetValue (instanceWrapper, out plist) && plist.Count > 0) {
                                RemoveProvider (provider, plist);
-                               removed = true;
+                               //removed = true;
                        }
                        
                        instanceWrapper = null;
@@ -889,13 +889,11 @@ public sealed class TypeDescriptor
                if (type == null)
                        throw new ArgumentNullException ("type");
 
-               bool removed = false;
                lock (typeDescriptionProvidersLock) {
                        LinkedList <TypeDescriptionProvider> plist;
 
                        if (typeDescriptionProviders.TryGetValue (type, out plist) && plist.Count > 0) {
                                RemoveProvider (provider, plist);
-                               removed = true;
                        }
                }
 
index 199d83fe7bb383121660fd6e0dc5199d262e4321..551a263b7316ce891b72c5af8a2bbc6c23084f0b 100644 (file)
@@ -240,7 +240,9 @@ namespace System.Configuration
                public readonly string TypeName;
                public readonly bool AllowLocation;
                public readonly AllowDefinition AllowDefinition;
+#if XML_DEP
                public string FileName;
+#endif
                public readonly bool RequirePermission;
 
                public SectionData (string sectionName, string typeName,
index 347bcf82747b7e7017691f15bb5c0597d5b58c14..8fe2b6ae83df9d688041155c05132b316e178951 100644 (file)
@@ -140,6 +140,9 @@ namespace System.Net.Mail {
                                if (cfg.From != null)
                                        defaultFrom = new MailAddress (cfg.From);
                        }
+#else
+                       // Just to eliminate the warning, this codepath does not end up in production.
+                       defaultFrom = null;
 #endif
 
                        if (!String.IsNullOrEmpty (host))
index 4a6c38b3579723979af332880a0a052ba9659434..6c0f25c8a7e50e18250df5321fbd1e6fb1f5c5d5 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-25  Marek Safar  <marek.safar@gmail.com>
+
+       * IPGlobalProperties.cs: Made Win32_IN6_ADDR verifiable.
+
 2009-12-07 Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * Ping.cs: Try to detect the path to the bin command, since different
index 74928fb763f37ba1b32934cadee7a3495fe2457d..d3be931cbb03bcaa45d7fb5be6a47c17f8a1d0c1 100644 (file)
@@ -26,7 +26,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0
+
 using System.Collections.Generic;
 using System.Collections.Specialized;
 using System.Globalization;
@@ -585,12 +585,6 @@ namespace System.Net.NetworkInformation {
                        [FieldOffset (0)]
                        [MarshalAs ((short) UnmanagedType.U1, SizeConst = 16)]
                        public byte [] Bytes;
-                       [FieldOffset (0)]
-                       [MarshalAs ((short) UnmanagedType.U2, SizeConst = 8)]
-                       public byte [] UInt16Array;
-                       [FieldOffset (0)]
-                       [MarshalAs ((short) UnmanagedType.U4, SizeConst = 4)]
-                       public byte [] UInt32Array;
                }
 
                [StructLayout (LayoutKind.Sequential)]
@@ -663,5 +657,3 @@ namespace System.Net.NetworkInformation {
                }
        }
 }
-#endif
-
index 4f5ac86d7e468df11a5d06773803f0a3438089af..d017319290834e409f659b9303c2c75df04e9d03 100644 (file)
@@ -80,7 +80,6 @@ namespace System.Net.NetworkInformation {
                        try {
                                gateways = new IPAddressCollection ();
                                using (StreamReader reader = new StreamReader ("/proc/net/route")) {
-                                       string str;
                                        string line;
                                        reader.ReadLine (); // Ignore first line
                                        while ((line = reader.ReadLine ()) != null) {
index d3b32c9ffc0dc5c10b33d8bc9ab8bd2be7addc1d..79b9e37ff1ad5749afba520641ae32ad8a5364f7 100644 (file)
@@ -206,11 +206,11 @@ namespace System.Net.NetworkInformation {
        // dummy class
        class MacOsIPv4InterfaceStatistics : IPv4InterfaceStatistics
        {
-               MacOsNetworkInterface macos;
+               //MacOsNetworkInterface macos;
                
                public MacOsIPv4InterfaceStatistics (MacOsNetworkInterface parent)
                {
-                       macos = parent;
+                       //macos = parent;
                }
 
                public override long BytesReceived {
index 5eefd797ed02c54efa9a4587ef2d9453df40fc7e..0dea7a9d19764f73c5f54ecaebfe8c64b3f585e7 100644 (file)
@@ -135,7 +135,7 @@ namespace System.Net.NetworkInformation {
                protected IPInterfaceProperties ipproperties;
                
                string               name;
-               int                  index;
+               //int                  index;
                protected List <IPAddress> addresses;
                byte[]               macAddress;
                NetworkInterfaceType type;
@@ -158,7 +158,7 @@ namespace System.Net.NetworkInformation {
 
                internal void SetLinkLayerInfo (int index, byte[] macAddress, NetworkInterfaceType type)
                {
-                       this.index = index;
+                       //this.index = index;
                        this.macAddress = macAddress;
                        this.type = type;
                }
@@ -233,7 +233,7 @@ namespace System.Net.NetworkInformation {
                const int AF_INET6  = 10;
                const int AF_PACKET = 17;
                
-               NetworkInterfaceType type;
+               //NetworkInterfaceType type;
                string               iface_path;
                string               iface_operstate_path;
                string               iface_flags_path;          
index 19bde8f1259da67627eee8b13990267936eb0b6e..4f7f7b7b998d1dec0ccc58a39c56a97efa6156ef 100644 (file)
@@ -288,7 +288,6 @@ namespace System.Net.NetworkInformation {
                        ping.StartInfo.RedirectStandardOutput = true;
                        ping.StartInfo.RedirectStandardError = true;
 
-                       DateTime start = DateTime.UtcNow;
                        try {
                                ping.Start ();
 
index d09d844a91859d44952034b0e7bdde46435a2c9c..9702cb7ef2c6f43ebcc5b02c171dc3c0b4682242 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 using System.Security.Cryptography.X509Certificates;
 
 namespace System.Net.Security 
 {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
        public
 #endif
        delegate bool RemoteCertificateValidationCallback (
                object sender,
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                X509Certificate certificate,
                X509Chain chain,
 #else
@@ -49,6 +47,3 @@ namespace System.Net.Security
 #endif
                SslPolicyErrors sslPolicyErrors);
 }
-
-#endif
-
index 92eb11b778aca1875fd913b93860a9bc61fcc2d2..49d8d4f046ddf2a67239469f1c74962a0f7d76b4 100644 (file)
@@ -1,3 +1,22 @@
+2010-03-23 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * Socket.cs: error handling was totally broken in the synchronous
+       Connect() call.  Fixes bug #590488.
+
+2010-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Socket.cs: Remove some NET_2_0 defines (using) and add a few
+       MOONLIGHT defines needed to reuse Socket in the client http stack
+       * Socket_2_1.cs: Remove some MOONLIGHT defines
+       * SocketAsyncEventArgs.cs: For Moonlight check policy if outside
+       System.dll (the client stack use sockets with it's own web 
+       xdomain policy)
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Socket_2_1.cs, SocketAsyncEventArgs.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2010-03-10  Sebastien Pouliot  <sebastien@ximian.com>
 
        * SocketAsyncEventArgs.cs: Remove the use of reflection to check
index 0d5d30baa3f3a2dd69aa3de4a6c8ee6824974ef1..35492a91aaa010b9c40ef8ed4c365206e70a0975 100644 (file)
@@ -36,6 +36,7 @@
 using System;
 using System.Net;
 using System.Collections;
+using System.Collections.Generic;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Threading;
@@ -43,11 +44,9 @@ using System.Reflection;
 using System.IO;
 using System.Net.Configuration;
 using System.Text;
-
-#if NET_2_0
-using System.Collections.Generic;
-using System.Net.NetworkInformation;
 using System.Timers;
+#if !MOONLIGHT
+using System.Net.NetworkInformation;
 #endif
 
 namespace System.Net.Sockets 
@@ -664,7 +663,6 @@ namespace System.Net.Sockets
                        IList currentList = checkRead;
                        int currentIdx = 0;
                        for (int i = 0; i < count; i++) {
-                               Socket cur_sock;
                                Socket sock = sockets [i];
                                if (sock == null) { // separator
                                        if (currentList != null) {
@@ -685,8 +683,8 @@ namespace System.Net.Sockets
                                }
 
                                // Remove non-signaled sockets before the current one
-                               int max = currentList.Count;
-                               while ((cur_sock = (Socket) currentList [currentIdx]) != sock) {
+                               //int max = currentList.Count;
+                               while (((Socket) currentList [currentIdx]) != sock) {
                                        currentList.RemoveAt (currentIdx);
                                }
                                currentIdx++;
@@ -1793,7 +1791,7 @@ namespace System.Net.Sockets
                        seed_endpoint = local_end;
                }
 
-#if NET_2_0
+#if !MOONLIGHT
                public bool ConnectAsync (SocketAsyncEventArgs e)
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
@@ -1836,11 +1834,10 @@ namespace System.Net.Sockets
                                throw new InvalidOperationException ();
 
                        /* FIXME: do non-blocking sockets Poll here? */
+                       int error = 0;
                        foreach (IPAddress address in addresses) {
-                               IPEndPoint iep = new IPEndPoint (address,
-                                                                port);
+                               IPEndPoint iep = new IPEndPoint (address, port);
                                SocketAddress serial = iep.Serialize ();
-                               int error = 0;
                                
                                Connect_internal (socket, serial, out error);
                                if (error == 0) {
@@ -1854,14 +1851,16 @@ namespace System.Net.Sockets
                                
                                if (!blocking) {
                                        Poll (-1, SelectMode.SelectWrite);
-                                       int success = (int)GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
-                                       if (success == 0) {
+                                       error = (int)GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
+                                       if (error == 0) {
                                                connected = true;
                                                seed_endpoint = iep;
                                                return;
                                        }
                                }
                        }
+                       if (error != 0)
+                               throw new SocketException (error);
                }
 
                public void Connect (string host, int port)
index 3f015e43e58a675292d7adf0371563c797ca8e63..bf427c83a52d82987c8bab82f743027e265cccda 100644 (file)
@@ -32,7 +32,7 @@ using System.Collections.Generic;
 using System.Reflection;
 using System.Security;
 using System.Threading;
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT && !INSIDE_SYSTEM
 using System.Net.Policy;
 #endif
 
@@ -40,7 +40,7 @@ namespace System.Net.Sockets
 {
        public class SocketAsyncEventArgs : EventArgs, IDisposable
        {
-#if (NET_2_1 || NET_4_0) && !MONOTOUCH
+#if MOONLIGHT || NET_4_0
                public Exception ConnectByNameError { get; internal set; }
 #endif
 
@@ -206,7 +206,7 @@ namespace System.Net.Sockets
                        LastOperation = SocketAsyncOperation.Connect;
                        SocketError error = SocketError.AccessDenied;
                        try {
-#if (NET_2_1 || NET_4_0) && !MONOTOUCH
+#if MOONLIGHT || NET_4_0
                                // Connect to the first address that match the host name, like:
                                // http://blogs.msdn.com/ncl/archive/2009/07/20/new-ncl-features-in-net-4-0-beta-2.aspx
                                // while skipping entries that do not match the address family
@@ -245,7 +245,7 @@ namespace System.Net.Sockets
                {
                        curSocket.Connected = false;
                        SocketError error = SocketError.Success;
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT && !INSIDE_SYSTEM
                        // if we're not downloading a socket policy then check the policy
                        if (!PolicyRestricted) {
                                error = SocketError.AccessDenied;
index 540c9815a8f78d2337d624aacc51f1ff65ee25a6..af54044c3d50f2039abc56e331ebfc96c0462583 100644 (file)
@@ -227,7 +227,7 @@ namespace System.Net.Sockets {
                                                             bool block,
                                                             out int error);
 #endif
-#if !NET_2_1 || MONOTOUCH
+
                public bool Blocking {
                        get {
                                return(blocking);
@@ -246,7 +246,7 @@ namespace System.Net.Sockets {
                                blocking=value;
                        }
                }
-#endif
+
                public bool Connected {
                        get { return connected; }
                        internal set { connected = value; }
@@ -489,7 +489,7 @@ namespace System.Net.Sockets {
                                if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any))
                                        throw new SocketException ((int) SocketError.AddressNotAvailable);
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        if (protocol_type != ProtocolType.Tcp)
                                throw new SocketException ((int) SocketError.AccessDenied);
 #elif NET_2_0
@@ -565,7 +565,6 @@ namespace System.Net.Sockets {
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                extern static bool Poll_internal (IntPtr socket, SelectMode mode, int timeout, out int error);
 
-#if !NET_2_1 || MONOTOUCH
                /* This overload is needed as the async Connect method
                 * also needs to check the socket error status, but
                 * getsockopt(..., SO_ERROR) clears the error.
@@ -600,7 +599,7 @@ namespace System.Net.Sockets {
                        
                        return result;
                }
-#endif
+
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private extern static int Receive_internal(IntPtr sock,
                                                           byte[] buffer,
@@ -726,7 +725,7 @@ namespace System.Net.Sockets {
 #endif
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                static void CheckConnect (SocketAsyncEventArgs e)
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
index 798448f1e6252703b9d7569bacf14e6c2c2f300a..876418bbc6f7f61fa17f2f0ed2949971330227c6 100644 (file)
 //
 
 using System.Collections;
+using System.Collections.Specialized;
 using System.Configuration;
-#if NET_2_0
 using System.Net.Configuration;
-using System.Collections.Specialized;
-#endif
 
 namespace System.Net
 {
-       public class AuthenticationManager
-       {
+#if MOONLIGHT
+       internal class AuthenticationManager {
+#else
+       public class AuthenticationManager {
+#endif
                static ArrayList modules;
                static object locker = new object ();
 
@@ -54,12 +55,11 @@ namespace System.Net
                                        return;
                                
                                modules = new ArrayList ();
-#if MONOTOUCH
+#if NET_2_1
                                modules.Add (new BasicClient ());
                                modules.Add (new DigestClient ());
                                modules.Add (new NtlmClient ());
-#else
-#if NET_2_0 && CONFIGURATION_DEP
+#elif NET_2_0 && CONFIGURATION_DEP
                                object cfg = ConfigurationManager.GetSection ("system.net/authenticationModules");
                                AuthenticationModulesSection s = cfg as AuthenticationModulesSection;
                                if (s != null) {
@@ -74,12 +74,10 @@ namespace System.Net
                                }
 #else
                                ConfigurationSettings.GetConfig ("system.net/authenticationModules");
-#endif
 #endif
                        }
                }
                
-#if NET_2_0
                static ICredentialPolicy credential_policy = null;
                
                public static ICredentialPolicy CredentialPolicy
@@ -104,7 +102,6 @@ namespace System.Net
                                throw GetMustImplement ();
                        }
                }
-#endif
 
                public static IEnumerator RegisteredModules {
                        get {
index 6c227732843b788a340f4c697639fa4a84a0452f..399ac00aebc2ec596ea99299585b3035ae996851 100644 (file)
@@ -1,3 +1,64 @@
+2010-03-21 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * WebClient.cs: fix handling of query string, whether it comes from
+       the address used or is part of the QueryString.
+
+2010-03-20  Miguel de Icaza  <miguel@novell.com>
+
+       * WebConnection.cs: Drop pre-2.0 and pre-1.1 support, and remove
+       warnings. 
+
+       * WebClient.cs: Drop the pre-2.0 support
+
+2010-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * AuthenticationManager.cs: Internal type for Moonlight.
+       Add BasicClient, DigestClient, NtlmClient for NET_2_1 since
+       this applies to both monotouch and moonlight (client stack).
+       Removed unneeded NET_2_0 defines
+       * CookieContainer.cs: For Moonlight it needs to be internal in 
+       System.dll and public in System.Net.dll. Removed unneeded NET_2_0
+       defines
+       * HttpContinueDelegate.cs: Internal type for Moonlight.
+       * HttpRequestCreator.cs: Remove a MOONLIGHT define
+       * HttpStatusCode.cs: For Moonlight it needs to be internal in 
+       System.dll and public in System.Net.dll
+       * HttpWebRequest.cs: Internal type for Moonlight. Change S.Config
+       to NET_2_1 defines (applies to both monotouch and moonlight).
+       Removed unneeded NET_2_0 and NET_1_1 defines
+       * HttpWebResponse.cs: Internal type for Moonlight. Removed 
+       unneeded NET_2_0 defines
+       * IAuthenticationModule.cs: Internal type for Moonlight.
+       * ICertificatePolicy.cs: Internal type for Moonlight.
+       * ICredentialPolicy.cs: Internal type for Moonlight. Removed 
+       unneeded NET_2_0 defines
+       * IWebRequestCreate.cs: For Moonlight it needs to be internal in 
+       System.dll and public in System.Net.dll
+       * ServicePoint.cs: Internal type for Moonlight. Change S.Config
+       to NET_2_1 defines (applies to both monotouch and moonlight)
+       * ServicePointManager.cs: Remove a MOONLIGHT define
+       * WebException.cs: For Moonlight it needs to be internal in 
+       System.dll and public in System.Net.dll. Removed unneeded NET_2_0
+       defines
+       * WebHeaderCollection.cs: Internal type for Moonlight. Removed 
+       unneeded NET_2_0 defines
+       * WebRequest.cs: Internal type for Moonlight. Change S.Config
+       to NET_2_1 defines (applies to both monotouch and moonlight)
+       * WebResponse.cs: Internal type for Moonlight. Removed unneeded
+       NET_2_0 defines
+
+2010-03-18 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * FtpWebResponse.cs:
+       * FtpWebRequest.cs: for non-data operations, make sure we send the
+       QUIT command upon completion when KeepAlive is false.
+       Fixes bug #589305.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Dns.cs, HttpRequestCreator.cs, ServicePoint.cs: use MOONLIGHT
+       symbol to disambiguate MonoTouch and Moonlight code.
+
 2010-03-11 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * ServicePointManager.cs: perform the entire chain validation here.
index 0068d5fca23e94c6bf82c97fae6c4774be2bf7db..84e507de60fd0e8c339cba5d5318eb2c10050c63 100644 (file)
@@ -41,8 +41,12 @@ using System.Text.RegularExpressions;
 namespace System.Net 
 {
        [Serializable]
-#if NET_2_1
+#if MOONLIGHT
+       #if INSIDE_SYSTEM
+       internal sealed class CookieContainer {
+       #else 
        public sealed class CookieContainer {
+       #endif
 #else
        public class CookieContainer {
 #endif
@@ -63,11 +67,7 @@ namespace System.Net
                public CookieContainer (int capacity)
                {
                        if (capacity <= 0)
-#if NET_2_0
                                throw new ArgumentException ("Must be greater than zero", "Capacity");
-#else
-                               throw new ArgumentException ("Capacity");
-#endif
 
                        this.capacity = capacity;
                }
@@ -76,21 +76,13 @@ namespace System.Net
                        : this (capacity)
                {
                        if (perDomainCapacity != Int32.MaxValue && (perDomainCapacity <= 0 || perDomainCapacity > capacity))
-#if NET_2_0
                                throw new ArgumentOutOfRangeException ("perDomainCapacity",
                                        string.Format ("PerDomainCapacity must be " +
                                        "greater than {0} and less than {1}.", 0,
                                        capacity));
-#else
-                               throw new ArgumentException ("PerDomainCapacity");
-#endif
 
                        if (maxCookieSize <= 0)
-#if NET_2_0
                                throw new ArgumentException ("Must be greater than zero", "MaxCookieSize");
-#else
-                               throw new ArgumentException ("MaxCookieSize");
-#endif
 
                        this.perDomainCapacity = perDomainCapacity;
                        this.maxCookieSize = maxCookieSize;
@@ -138,11 +130,7 @@ namespace System.Net
                                throw new ArgumentNullException ("cookie");
 
                        if (cookie.Domain.Length == 0)
-#if NET_2_0
                                throw new ArgumentException ("Cookie domain not set.", "cookie.Domain");
-#else
-                               throw new ArgumentException ("cookie.Domain");
-#endif
 
                        if (cookie.Value.Length > maxCookieSize)
                                throw new CookieException ("value is larger than MaxCookieSize.");
index 42e0d47a55ab3978e3d254b78ad37db1853a427e..15a17be550041196a7c988ed5845394c24d3ca08 100644 (file)
@@ -48,7 +48,7 @@ namespace System.Net {
                        System.Net.Sockets.Socket.CheckProtocolSupport();
                }
 
-#if !NET_2_1 || MONOTOUCH // global remove of async methods
+#if !MOONLIGHT // global remove of async methods
 
                private delegate IPHostEntry GetHostByNameCallback (string hostName);
                private delegate IPHostEntry ResolveCallback (string hostName);
@@ -177,7 +177,7 @@ namespace System.Net {
                }
 #endif
                
-#endif // !NET_2_1: global remove of async methods
+#endif // !MOONLIGHT: global remove of async methods
 
 #if !TARGET_JVM
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
index 32ae9a1b26325eeea03e13a82c7daabb2fc933c6..bb765dd660c494f9c6f25fad8cfc33a129e2ae32 100644 (file)
@@ -204,13 +204,14 @@ namespace System.Net
                        }
                }
 
+               [MonoTODO ("We don't support KeepAlive = true")]
                public bool KeepAlive {
                        get {
                                return keepAlive;
                        }
                        set {
                                CheckRequestStarted ();
-                               keepAlive = value;
+                               //keepAlive = value;
                        }
                }
 
@@ -366,7 +367,7 @@ namespace System.Net
 
                                if (!InFinalState ()) {
                                        State = RequestState.Aborted;
-                                       ftpResponse = new FtpWebResponse (requestUri, method, FtpStatusCode.FileActionAborted, "Aborted by request");
+                                       ftpResponse = new FtpWebResponse (this, requestUri, method, FtpStatusCode.FileActionAborted, "Aborted by request");
                                }
                        }
                }
@@ -500,7 +501,7 @@ namespace System.Net
                void ProcessRequest () {
 
                        if (State == RequestState.Scheduled) {
-                               ftpResponse = new FtpWebResponse (requestUri, method, keepAlive);
+                               ftpResponse = new FtpWebResponse (this, requestUri, method, keepAlive);
 
                                try {
                                        ProcessMethod ();
@@ -642,7 +643,7 @@ namespace System.Net
                        
                        status = SendCommand (method, file_name);
 
-                       ftpResponse.Stream = new EmptyStream ();
+                       ftpResponse.Stream = Stream.Null;
                        
                        string desc = status.StatusDescription;
 
@@ -855,7 +856,7 @@ namespace System.Net
 
                Exception CreateExceptionFromResponse (FtpStatus status)
                {
-                       FtpWebResponse ftpResponse = new FtpWebResponse (requestUri, method, status);
+                       FtpWebResponse ftpResponse = new FtpWebResponse (this, requestUri, method, status);
                        
                        WebException exc = new WebException ("Server returned an error: " + status.StatusDescription, 
                                null, WebExceptionStatus.ProtocolError, ftpResponse);
@@ -875,6 +876,12 @@ namespace System.Net
                                CloseConnection ();
                }
 
+               internal void OperationCompleted ()
+               {
+                       if(!keepAlive)
+                               CloseConnection ();
+               }
+
                void SetCompleteWithError (Exception exc)
                {
                        if (asyncResult != null) {
@@ -1133,13 +1140,6 @@ namespace System.Net
                        if (InFinalState ())
                                throw new InvalidOperationException ("Cannot change final state");
                }
-
-               class EmptyStream : MemoryStream
-               {
-                       internal EmptyStream ()
-                               : base (new byte [0], false) {
-                       }
-               }
        }
 }
 
index fe715922bc3de636afa99893d1f0e6706dda0dac..e42156efcb053c482a3fa7e92b87a62958a4cfe9 100644 (file)
@@ -29,24 +29,28 @@ namespace System.Net
                string method;
                //bool keepAlive;
                bool disposed;
+               FtpWebRequest request;
                internal long contentLength = -1;
                
-               internal FtpWebResponse (Uri uri, string method, bool keepAlive)
+               internal FtpWebResponse (FtpWebRequest request, Uri uri, string method, bool keepAlive)
                {
+                       this.request = request;
                        this.uri = uri;
                        this.method = method;
                        //this.keepAlive = keepAlive;
                }
 
-               internal FtpWebResponse (Uri uri, string method, FtpStatusCode statusCode, string statusDescription) {
+               internal FtpWebResponse (FtpWebRequest request, Uri uri, string method, FtpStatusCode statusCode, string statusDescription)
+               {
+                       this.request = request;
                        this.uri = uri;
                        this.method = method;
                        this.statusCode = statusCode;
                        this.statusDescription = statusDescription;
                }
 
-               internal FtpWebResponse (Uri uri, string method, FtpStatus status) :
-                       this (uri, method, status.StatusCode, status.StatusDescription)
+               internal FtpWebResponse (FtpWebRequest request, Uri uri, string method, FtpStatus status) :
+                       this (request, uri, method, status.StatusCode, status.StatusDescription)
                {
                }
                
@@ -128,8 +132,11 @@ namespace System.Net
                                return;
                        
                        disposed = true;
-                       if (stream != null)
+                       if (stream != null) {
                                stream.Close ();
+                               if (stream == Stream.Null)
+                                       request.OperationCompleted ();
+                       }
                        stream = null;
                }
 
index 482c7f916e259fcc27d05dcdfc3e5bf268c168ea..02283c62b6667eb32293eb7006db1f317da8445f 100644 (file)
@@ -26,7 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 && SECURITY_DEP
+#if SECURITY_DEP
 
 using System.IO;
 using System.Net.Sockets;
@@ -65,13 +65,9 @@ namespace System.Net {
                        if (secure == false) {
                                stream = new NetworkStream (sock, false);
                        } else {
-#if EMBEDDED_IN_1_0
-                               throw new NotImplementedException ();
-#else
                                SslServerStream ssl_stream = new SslServerStream (new NetworkStream (sock, false), cert, false, false);
                                ssl_stream.PrivateKeyCertSelectionDelegate += OnPVKSelection;
                                stream = ssl_stream;
-#endif
                        }
                        Init ();
                }
@@ -229,7 +225,7 @@ namespace System.Net {
                        try {
                                line = ReadLine (buffer, position, len - position, ref used);
                                position += used;
-                       } catch (Exception e) {
+                       } catch {
                                context.ErrorMessage = "Bad request";
                                context.ErrorStatus = 400;
                                return true;
@@ -267,7 +263,7 @@ namespace System.Net {
                                try {
                                        line = ReadLine (buffer, position, len - position, ref used);
                                        position += used;
-                               } catch (Exception e) {
+                               } catch {
                                        context.ErrorMessage = "Bad request";
                                        context.ErrorStatus = 400;
                                        return true;
index d71b746e630f192ff790f7af07eb8b488eff7e25..21bfee19119e9ff4d70174aee5b6f21907849924 100644 (file)
 \r
 namespace System.Net\r
 {\r
-       public delegate void HttpContinueDelegate (\r
+#if MOONLIGHT\r
+       internal\r
+#else\r
+       public\r
+#endif\r
+       delegate void HttpContinueDelegate (\r
                int StatusCode,\r
                WebHeaderCollection httpHeaders);\r
 }\r
index dc75c568ff498411f07b518b4b0add9c107dc540..cabc9db1f29a4aabec32fd4ad2b867d2dc8b5180 100644 (file)
@@ -38,11 +38,7 @@ namespace System.Net
 
                public WebRequest Create (Uri uri)
                {
-#if NET_2_1 && !MONOTOUCH
-                       throw new NotImplementedException ();
-#else
                        return new HttpWebRequest (uri);
-#endif
                }
        }
 }
index f6b72e03253d00caa337cf1bd4920209f2ff0089..123b7c37a2511e82864fb626ee619a8705ab4347 100644 (file)
 
 
 namespace System.Net {
+#if MOONLIGHT && INSIDE_SYSTEM
+       internal enum HttpStatusCode {
+#else
        public enum HttpStatusCode {
+#endif
                Continue = 100,
                SwitchingProtocols = 101,
                OK = 200,
index f35109c70005a248200efed867b2d08ade2aacf1..2be45f15b1fbfa8bf33e2603f49efdac53ac5248 100644 (file)
@@ -35,6 +35,7 @@ using System;
 using System.Collections;
 using System.Configuration;
 using System.IO;
+using System.Net.Cache;
 using System.Net.Sockets;
 using System.Runtime.Remoting.Messaging;
 using System.Runtime.Serialization;
@@ -42,15 +43,14 @@ using System.Security.Cryptography.X509Certificates;
 using System.Text;
 using System.Threading;
 
-#if NET_2_0
-using System.Net.Cache;
-#endif
-
 namespace System.Net 
 {
+#if MOONLIGHT
+       internal class HttpWebRequest : WebRequest, ISerializable {
+#else
        [Serializable]
-       public class HttpWebRequest : WebRequest, ISerializable
-       {
+       public class HttpWebRequest : WebRequest, ISerializable {
+#endif
                Uri requestUri;
                Uri actualUri;
                bool hostChanged;
@@ -99,10 +99,7 @@ namespace System.Net
                bool is_ntlm_auth;
                bool finished_reading;
                internal WebConnection WebConnection;
-#if NET_2_0
                DecompressionMethods auto_decomp;
-#endif
-#if NET_1_1
                int maxResponseHeadersLength;
                static int defaultMaxResponseHeadersLength;
                int readWriteTimeout = 300000; // ms
@@ -111,7 +108,7 @@ namespace System.Net
                static HttpWebRequest ()
                {
                        defaultMaxResponseHeadersLength = 64 * 1024;
-#if !MONOTOUCH
+#if !NET_2_1
                        NetConfig config = ConfigurationSettings.GetConfig ("system.net/settings") as NetConfig;
                        if (config != null) {
                                int x = config.MaxResponseHeadersLength;
@@ -122,7 +119,6 @@ namespace System.Net
                        }
 #endif
                }
-#endif
 
 #if NET_2_1
                public
@@ -136,9 +132,7 @@ namespace System.Net
                        this.proxy = GlobalProxySelection.Select;
                }               
                
-#if NET_2_0
                [Obsolete ("Serialization is obsoleted for this type", false)]
-#endif
                protected HttpWebRequest (SerializationInfo serializationInfo, StreamingContext streamingContext) 
                {
                        SerializationInfo info = serializationInfo;
@@ -192,7 +186,6 @@ namespace System.Net
                        set { allowBuffering = value; }
                }
 
-#if NET_2_0
                static Exception GetMustImplement ()
                {
                        return new NotImplementedException ();
@@ -208,7 +201,6 @@ namespace System.Net
                                auto_decomp = value;
                        }
                }
-#endif
                
                internal bool InternalAllowBuffering {
                        get {
@@ -225,12 +217,10 @@ namespace System.Net
 
                                return certificates;
                        }
-#if NET_2_0
                        [MonoTODO]
                        set {
                                throw GetMustImplement ();
                        }
-#endif
                }
                
                public string Connection {
@@ -302,7 +292,6 @@ namespace System.Net
                        set { credentials = value; }
                }
 
-#if NET_2_0
                [MonoTODO]
                public static new RequestCachePolicy DefaultCachePolicy
                {
@@ -324,7 +313,6 @@ namespace System.Net
                                throw GetMustImplement ();
                        }
                }
-#endif
                
                public string Expect {
                        get { return webHeaders ["Expect"]; }
@@ -402,7 +390,6 @@ namespace System.Net
                        }                       
                }
 
-#if NET_1_1
                [MonoTODO ("Use this")]
                public int MaximumResponseHeadersLength {
                        get { return maxResponseHeadersLength; }
@@ -415,11 +402,7 @@ namespace System.Net
                        set { defaultMaxResponseHeadersLength = value; }
                }
 
-               public
-#else
-               internal
-#endif
-               int ReadWriteTimeout {
+               public  int ReadWriteTimeout {
                        get { return readWriteTimeout; }
                        set {
                                if (requestSent)
@@ -473,11 +456,6 @@ namespace System.Net
                        get { return proxy; }
                        set { 
                                CheckRequestStarted ();
-#if ONLY_1_1
-                               if (value == null)
-                                       throw new ArgumentNullException ("value");
-#endif
-
                                proxy = value;
                                servicePoint = null; // we may need a new one
                        }
@@ -544,27 +522,23 @@ namespace System.Net
                        }
                }
 
-#if NET_2_0
                public override bool UseDefaultCredentials
                {
                        get { return CredentialCache.DefaultCredentials == Credentials; }
                        set { Credentials = value ? CredentialCache.DefaultCredentials : null; }
                }
-#endif
                
                public string UserAgent {
                        get { return webHeaders ["User-Agent"]; }
                        set { webHeaders.SetInternal ("User-Agent", value); }
                }
 
-#if NET_1_1
                bool unsafe_auth_blah;
                public bool UnsafeAuthenticatedConnectionSharing
                {
                        get { return unsafe_auth_blah; }
                        set { unsafe_auth_blah = value; }
                }
-#endif
 
                internal bool GotRequestStream {
                        get { return gotRequestStream; }
@@ -636,12 +610,6 @@ namespace System.Net
                                throw new InvalidOperationException ("rangeSpecifier");
                        webHeaders.RemoveAndAdd ("Range", value + from + "-" + to);     
                }
-#if !NET_2_0
-               public override int GetHashCode ()
-               {
-                       return base.GetHashCode ();
-               }
-#endif
                
                public override IAsyncResult BeginGetRequestStream (AsyncCallback callback, object state) 
                {
@@ -743,16 +711,6 @@ namespace System.Net
                        if (method == null)
                                throw new ProtocolViolationException ("Method is null.");
 
-#if !NET_2_0
-                       bool send = !(method == "GET" || method == "CONNECT" || method == "HEAD" ||
-                                               method == "TRACE" || method == "DELETE");
-                       if (send && contentLength < 0 && !sendChunked && !allowBuffering && KeepAlive)
-                               throw new ProtocolViolationException ("Buffering is disabled, ContentLength is negative and SendChunked is disabled.");
-
-                       if (!send && (contentLength > -1 || sendChunked))
-                               throw new ProtocolViolationException ("ContentLength can't be set for non-write operations.");
-#endif
-
                        string transferEncoding = TransferEncoding;
                        if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "")
                                throw new ProtocolViolationException ("SendChunked should be true.");
@@ -895,11 +853,8 @@ namespace System.Net
                        GetObjectData (serializationInfo, streamingContext);
                }
 
-#if NET_2_0
-               protected override
-#endif
-               void GetObjectData (SerializationInfo serializationInfo,
-                                   StreamingContext streamingContext)
+               protected override void GetObjectData (SerializationInfo serializationInfo,
+                       StreamingContext streamingContext)
                {
                        SerializationInfo info = serializationInfo;
 
@@ -1038,7 +993,6 @@ namespace System.Net
                                        webHeaders.SetInternal ("Cookie", cookieHeader);
                        }
 
-#if NET_2_0
                        string accept_encoding = null;
                        if ((auto_decomp & DecompressionMethods.GZip) != 0)
                                accept_encoding = "gzip";
@@ -1046,7 +1000,7 @@ namespace System.Net
                                accept_encoding = accept_encoding != null ? "gzip, deflate" : "deflate";
                        if (accept_encoding != null)
                                webHeaders.RemoveAndAdd ("Accept-Encoding", accept_encoding);
-#endif
+
                        if (!usedPreAuth && preAuthenticate)
                                DoPreAuthenticate ();
 
@@ -1226,9 +1180,7 @@ namespace System.Net
                                ICredentials creds = (!isProxy) ? credentials : proxy.Credentials;
                                if (creds != null) {
                                        cnc.NtlmCredential = creds.GetCredential (requestUri, "NTLM");
-#if NET_1_1
                                        cnc.UnsafeAuthenticatedConnectionSharing = unsafe_auth_blah;
-#endif
                                }
                        }
                        r.Reset ();
index 8eb5b7f84ee646a3d8e8d45fe216c030a3fc2a07..83eef98ca697bca3ce61fcc93f523814d81b2a12 100644 (file)
@@ -36,18 +36,19 @@ using System;
 using System.Collections;
 using System.Globalization;
 using System.IO;
+using System.IO.Compression;
 using System.Net.Sockets;
 using System.Runtime.Serialization;
 using System.Text;
-#if NET_2_0
-using System.IO.Compression;
-#endif
 
 namespace System.Net 
 {
+#if MOONLIGHT
+       internal class HttpWebResponse : WebResponse, ISerializable, IDisposable {
+#else
        [Serializable]
-       public class HttpWebResponse : WebResponse, ISerializable, IDisposable
-       {
+       public class HttpWebResponse : WebResponse, ISerializable, IDisposable {
+#endif
                Uri uri;
                WebHeaderCollection webHeaders;
                CookieCollection cookieCollection;
@@ -77,13 +78,8 @@ namespace System.Net
 
                        try {
                                string cl = webHeaders ["Content-Length"];
-#if NET_2_0
                                if (String.IsNullOrEmpty (cl) || !Int64.TryParse (cl, out contentLength))
                                        contentLength = -1;
-#else
-                               if (cl != null && cl != String.Empty)
-                                       contentLength = (long) UInt64.Parse (cl);
-#endif
                        } catch (Exception) {
                                contentLength = -1;
                        }
@@ -92,18 +88,15 @@ namespace System.Net
                                this.cookie_container = container;      
                                FillCookies ();
                        }
-#if NET_2_0
+
                        string content_encoding = webHeaders ["Content-Encoding"];
                        if (content_encoding == "gzip" && (data.request.AutomaticDecompression & DecompressionMethods.GZip) != 0)
                                stream = new GZipStream (stream, CompressionMode.Decompress);
                        else if (content_encoding == "deflate" && (data.request.AutomaticDecompression & DecompressionMethods.Deflate) != 0)
                                stream = new DeflateStream (stream, CompressionMode.Decompress);
-#endif
                }
 
-#if NET_2_0
                [Obsolete ("Serialization is obsoleted for this type", false)]
-#endif
                protected HttpWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext)
                {
                        SerializationInfo info = serializationInfo;
@@ -181,14 +174,10 @@ namespace System.Net
                
                public override WebHeaderCollection Headers {           
                        get {
-#if ONLY_1_1
-                               CheckDisposed ();
-#endif
                                return webHeaders; 
                        }
                }
 
-#if NET_2_0
                static Exception GetMustImplement ()
                {
                        return new NotImplementedException ();
@@ -201,7 +190,6 @@ namespace System.Net
                                throw GetMustImplement ();
                        }
                }
-#endif
                
                public DateTime LastModified {
                        get {
@@ -257,12 +245,6 @@ namespace System.Net
                }
 
                // Methods
-#if !NET_2_0
-               public override int GetHashCode ()
-               {
-                       return base.GetHashCode ();
-               }
-#endif
                
                public string GetResponseHeader (string headerName)
                {
@@ -299,11 +281,8 @@ namespace System.Net
                        GetObjectData (serializationInfo, streamingContext);
                }
 
-#if NET_2_0
-               protected override
-#endif
-               void GetObjectData (SerializationInfo serializationInfo,
-                                   StreamingContext streamingContext)
+               protected override void GetObjectData (SerializationInfo serializationInfo,
+                       StreamingContext streamingContext)
                {
                        SerializationInfo info = serializationInfo;
 
@@ -330,9 +309,6 @@ namespace System.Net
                        GC.SuppressFinalize (this);  
                }
 
-#if !NET_2_0
-               protected virtual
-#endif
                void Dispose (bool disposing) 
                {
                        if (this.disposed)
@@ -342,9 +318,6 @@ namespace System.Net
                        if (disposing) {
                                // release managed resources
                                uri = null;
-#if !NET_2_0
-                               webHeaders = null;
-#endif
                                cookieCollection = null;
                                method = null;
                                version = null;
@@ -414,11 +387,9 @@ namespace System.Net
                                        if (cookie.Domain == "")
                                                cookie.Domain = val;
                                        break;
-#if NET_2_0
                                case "HTTPONLY":
                                        cookie.HttpOnly = true;
                                        break;
-#endif
                                case "MAX-AGE": // RFC Style Set-Cookie2
                                        if (cookie.Expires == DateTime.MinValue) {
                                                try {
@@ -485,14 +456,8 @@ namespace System.Net
                                        DateTime cookieExpiresUtc = DateTime.ParseExact (value, cookieExpiresFormats [i], CultureInfo.InvariantCulture);
 
                                        //convert UTC/GMT time to local time
-#if NET_2_0
                                        cookieExpiresUtc = DateTime.SpecifyKind (cookieExpiresUtc, DateTimeKind.Utc);
                                        return TimeZone.CurrentTimeZone.ToLocalTime (cookieExpiresUtc);
-#else
-                                       //DateTime.Kind is only available on .NET 2.0, so do some calculation
-                                       TimeSpan localOffset = TimeZone.CurrentTimeZone.GetUtcOffset (cookieExpiresUtc.Date);
-                                       return cookieExpiresUtc.Add (localOffset);
-#endif
                                } catch {}
                        }
 
index b48e5d5ff85f45fdbba261908e517452db3339ca..76076c03ef3b39df829e0e3d847be530f5a69bb4 100644 (file)
@@ -33,8 +33,11 @@ namespace System.Net {
        // <remarks>
        //   Authentication interface for Web client authentication modules.
        // </remarks>
-       public interface IAuthenticationModule
-       {
+#if MOONLIGHT
+       internal interface IAuthenticationModule {
+#else
+       public interface IAuthenticationModule {
+#endif
                Authorization Authenticate (string challenge, WebRequest request, ICredentials credentials);
                Authorization PreAuthenticate (WebRequest request, ICredentials credentials);
                string AuthenticationType { get; }
index 43cfa91b20d3d77ce6035466e9863f6db844602a..98d8081af14d1e98f6a598d8b4e6acd416fa3f9d 100644 (file)
@@ -30,9 +30,11 @@ using System.Security.Cryptography.X509Certificates;
 
 namespace System.Net {
 
-       // <remarks>
-       // </remarks>
+#if MOONLIGHT
+       internal interface ICertificatePolicy {
+#else
        public interface ICertificatePolicy {
+#endif
                bool CheckValidationResult (
                                ServicePoint srvPoint,
                                X509Certificate certificate,
index 1b1d0070f43d10387276bd80e29d3a0cacad0fa5..a8d37e7d0183a0bd4dccdae0ba1c56b52fd7c30c 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 namespace System.Net {
 
+#if MOONLIGHT
+       internal interface ICredentialPolicy {
+#else
        public interface ICredentialPolicy {
-
+#endif
                bool ShouldSendCredential (Uri challengeUri,
                        WebRequest request,
                        NetworkCredential credential,
@@ -40,4 +41,3 @@ namespace System.Net {
        }
 }
 
-#endif
index af6a24ddf5ba1c4fa600c489042b866f754310fa..d6cd6f493bc7d32b29ab42d25adbb6dff46fcf9e 100644 (file)
 
 namespace System.Net {
 
-       // <remarks>
-       // </remarks>
+#if MOONLIGHT && INSIDE_SYSTEM
+       internal interface IWebRequestCreate {
+#else
        public interface IWebRequestCreate {
+#endif
                WebRequest Create (Uri uri);            
        }
 }
index f50d774ca0e78e23fbd908c96036bbe7a8abe5d7..ea4fecdfedf05af0f805834ae2bc8ef873282de9 100644 (file)
@@ -43,6 +43,8 @@ namespace System.Net
                {
 #if SECURITY_DEP
                        authObject = new Mono.Http.NtlmClient ();
+#else
+                       authObject = null;
 #endif
                }
        
index 740b8402a6b57c8c84cbf5f163049f754fd23bba..c93f36d1bba52b5c28f89ab5f537dc4b602af70c 100644 (file)
@@ -270,7 +270,8 @@ namespace System.Net
                {
                        protocolVersion = version;
                }
-#if MONOTOUCH || (!TARGET_JVM && !NET_2_1)
+
+#if !TARGET_JVM
                WebConnectionGroup GetConnectionGroup (string name)
                {
                        if (name == null)
index 016eee02bb341ce88bad04a6297cf2b682d601d4..d22ba5cc9013ba0b046da1734435a2d8a1f24be5 100644 (file)
@@ -69,8 +69,11 @@ using MSX = Mono.Security.X509;
 
 namespace System.Net 
 {
-       public class ServicePointManager
-       {
+#if MOONLIGHT
+       internal class ServicePointManager {
+#else
+       public class ServicePointManager {
+#endif
                class SPKey {
                        Uri uri; // schema/host/port
                        bool use_connect;
@@ -130,14 +133,14 @@ namespace System.Net
                public const int DefaultNonPersistentConnectionLimit = 4;
                public const int DefaultPersistentConnectionLimit = 2;
 
-#if !MONOTOUCH
+#if !NET_2_1
                const string configKey = "system.net/connectionManagement";
                static ConnectionManagementData manager;
 #endif
                
                static ServicePointManager ()
                {
-#if !MONOTOUCH
+#if !NET_2_1
 #if NET_2_0 && CONFIGURATION_DEP
                        object cfg = ConfigurationManager.GetSection (configKey);
                        ConnectionManagementSection s = cfg as ConnectionManagementSection;
@@ -326,7 +329,7 @@ namespace System.Net
                                        throw new InvalidOperationException ("maximum number of service points reached");
 
                                string addr = address.ToString ();
-#if MONOTOUCH
+#if NET_2_1
                                int limit = defaultConnectionLimit;
 #else
                                int limit = (int) manager.GetMaxConnections (addr);
@@ -384,6 +387,7 @@ namespace System.Net
                internal class ChainValidationHelper {
                        object sender;
                        string host;
+                       static bool is_macosx = System.IO.File.Exists (MSX.OSX509Certificates.SecurityLibrary);
 
                        public ChainValidationHelper (object sender)
                        {
@@ -435,9 +439,8 @@ namespace System.Net
 
                                bool result = false;
                                // No certificate root found means no mozroots or monotouch
-                               if (Environment.OSVersion.Platform == PlatformID.MacOSX) {
 #if !MONOTOUCH
-                               if (System.IO.File.Exists (MSX.OSX509Certificates.SecurityLibrary)) {
+                               if (is_macosx) {
 #endif
                                        // Attempt to use OSX certificates
                                        // Ideally we should return the SecTrustResult
@@ -460,7 +463,6 @@ namespace System.Net
 #if !MONOTOUCH
                                }
 #endif
-                               }
 
                                if (policy != null && (!(policy is DefaultCertificatePolicy) || cb == null)) {
                                        ServicePoint sp = null;
index 8ada916e77a263bb35464a71e50effc0dd154068..598c586b08287a7d5e0768b923178d7d96e42b91 100644 (file)
@@ -66,18 +66,12 @@ using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
 using System.Text;
 using System.Threading;
-#if NET_2_0
 using System.Net.Cache;
-#endif
 
 namespace System.Net 
 {
        [ComVisible(true)]
-       public
-#if !NET_2_0
-       sealed
-#endif
-       class WebClient : Component
+       public class WebClient : Component
        {
                static readonly string urlEncodedCType = "application/x-www-form-urlencoded";
                static byte [] hexBytes;
@@ -88,12 +82,10 @@ namespace System.Net
                string baseString;
                NameValueCollection queryString;
                bool is_busy;
-#if NET_2_0
                bool async;
                Thread async_thread;
                Encoding encoding = Encoding.Default;
                IWebProxy proxy;
-#endif
 
                // Constructors
                static WebClient ()
@@ -133,7 +125,6 @@ namespace System.Net
                        }
                }
 
-#if NET_2_0
                static Exception GetMustImplement ()
                {
                        return new NotImplementedException ();
@@ -160,7 +151,6 @@ namespace System.Net
                                throw GetMustImplement ();
                        }
                }
-#endif
                
                public ICredentials Credentials {
                        get { return credentials; }
@@ -191,7 +181,6 @@ namespace System.Net
                        get { return responseHeaders; }
                }
 
-#if NET_2_0
                public Encoding Encoding {
                        get { return encoding; }
                        set {
@@ -205,18 +194,10 @@ namespace System.Net
                        get { return proxy; }
                        set { proxy = value; }
                }
-#endif
 
-#if NET_2_0
                public bool IsBusy {
                        get { return is_busy; } 
                }
-#else
-               bool IsBusy {
-                       get { return is_busy; }
-               }
-#endif
-
                // Methods
 
                void CheckBusy ()
@@ -237,29 +218,20 @@ namespace System.Net
 
                public byte [] DownloadData (string address)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        return DownloadData (CreateUri (address));
                }
 
-#if NET_2_0
-               public
-#endif
-               byte [] DownloadData (Uri address)
+               public byte [] DownloadData (Uri address)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        try {
                                SetBusy ();
-#if NET_2_0                            
                                async = false;
-#endif                         
                                return DownloadDataCore (address, null);
                        } finally {
                                is_busy = false;
@@ -279,7 +251,7 @@ namespace System.Net
                                if (request != null)
                                        request.Abort ();
                                throw;
-                       } catch (WebException wexc) {
+                       } catch (WebException) {
                                throw;
                        } catch (Exception ex) {
                                throw new WebException ("An error occurred " +
@@ -291,33 +263,24 @@ namespace System.Net
 
                public void DownloadFile (string address, string fileName)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        DownloadFile (CreateUri (address), fileName);
                }
 
-#if NET_2_0
-               public
-#endif
-               void DownloadFile (Uri address, string fileName)
+               public void DownloadFile (Uri address, string fileName)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
                        if (fileName == null)
                                throw new ArgumentNullException ("fileName");
-#endif
 
                        try {
                                SetBusy ();
-#if NET_2_0                            
                                async = false;
-#endif                         
                                DownloadFileCore (address, fileName, null);
-                       } catch (WebException wexc) {
+                       } catch (WebException) {
                                throw;
                        } catch (Exception ex) {
                                throw new WebException ("An error occurred " +
@@ -342,18 +305,14 @@ namespace System.Net
                                        byte [] buffer = new byte [length];
                                        
                                        int nread = 0;
-#if NET_2_0
                                        long notify_total = 0;
-#endif                                 
                                        while ((nread = st.Read (buffer, 0, length)) != 0){
-#if NET_2_0
                                                if (async){
                                                        notify_total += nread;
                                                        OnDownloadProgressChanged (
                                                                new DownloadProgressChangedEventArgs (notify_total, response.ContentLength, userToken));
                                                                                                      
                                                }
-#endif
                                                f.Write (buffer, 0, nread);
                                        }
                                } catch (ThreadInterruptedException){
@@ -368,34 +327,24 @@ namespace System.Net
 
                public Stream OpenRead (string address)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
-
                        return OpenRead (CreateUri (address));
                }
 
-#if NET_2_0
-               public
-#endif
-               Stream OpenRead (Uri address)
+               public Stream OpenRead (Uri address)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        WebRequest request = null;
                        try {
                                SetBusy ();
-#if NET_2_0                            
                                async = false;
-#endif                         
                                request = SetupRequest (address);
                                WebResponse response = GetWebResponse (request);
                                return response.GetResponseStream ();
-                       } catch (WebException wexc) {
+                       } catch (WebException) {
                                throw;
                        } catch (Exception ex) {
                                throw new WebException ("An error occurred " +
@@ -409,50 +358,36 @@ namespace System.Net
 
                public Stream OpenWrite (string address)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        return OpenWrite (CreateUri (address));
                }
                
                public Stream OpenWrite (string address, string method)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        return OpenWrite (CreateUri (address), method);
                }
 
-#if NET_2_0
-               public
-#endif
-               Stream OpenWrite (Uri address)
+               public Stream OpenWrite (Uri address)
                {
                        return OpenWrite (address, (string) null);
                }
 
-#if NET_2_0
-               public
-#endif
-               Stream OpenWrite (Uri address, string method)
+               public Stream OpenWrite (Uri address, string method)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        try {
                                SetBusy ();
-#if NET_2_0                            
                                async = false;
-#endif                         
                                WebRequest request = SetupRequest (address, method, true);
                                return request.GetRequestStream ();
-                       } catch (WebException wexc) {
+                       } catch (WebException) {
                                throw;
                        } catch (Exception ex) {
                                throw new WebException ("An error occurred " +
@@ -467,10 +402,9 @@ namespace System.Net
                        if (method != null)
                                return method;
 
-#if NET_2_0
                        if (address.Scheme == Uri.UriSchemeFtp)
                                return (is_upload) ? "STOR" : "RETR";
-#endif
+
                        return (is_upload) ? "POST" : "GET";
                }
 
@@ -478,49 +412,35 @@ namespace System.Net
 
                public byte [] UploadData (string address, byte [] data)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        return UploadData (CreateUri (address), data);
                }
                
                public byte [] UploadData (string address, string method, byte [] data)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        return UploadData (CreateUri (address), method, data);
                }
 
-#if NET_2_0
-               public
-#endif
-               byte [] UploadData (Uri address, byte [] data)
+               public byte [] UploadData (Uri address, byte [] data)
                {
                        return UploadData (address, (string) null, data);
                }
 
-#if NET_2_0
-               public
-#endif
-               byte [] UploadData (Uri address, string method, byte [] data)
+               public byte [] UploadData (Uri address, string method, byte [] data)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
                        if (data == null)
                                throw new ArgumentNullException ("data");
-#endif
 
                        try {
                                SetBusy ();
-#if NET_2_0                            
                                async = false;
-#endif                         
                                return UploadDataCore (address, method, data, null);
                        } catch (WebException) {
                                throw;
@@ -534,13 +454,6 @@ namespace System.Net
 
                byte [] UploadDataCore (Uri address, string method, byte [] data, object userToken)
                {
-#if ONLY_1_1
-                       if (address == null)
-                               throw new ArgumentNullException ("address");
-                       if (data == null)
-                               throw new ArgumentNullException ("data");
-#endif
-
                        WebRequest request = SetupRequest (address, method, true);
                        try {
                                int contentLength = data.Length;
@@ -563,18 +476,13 @@ namespace System.Net
 
                public byte [] UploadFile (string address, string fileName)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        return UploadFile (CreateUri (address), fileName);
                }
 
-#if NET_2_0
-               public
-#endif
-               byte [] UploadFile (Uri address, string fileName)
+               public byte [] UploadFile (Uri address, string fileName)
                {
                        return UploadFile (address, (string) null, fileName);
                }
@@ -584,25 +492,18 @@ namespace System.Net
                        return UploadFile (CreateUri (address), method, fileName);
                }
 
-#if NET_2_0
-               public
-#endif
-               byte [] UploadFile (Uri address, string method, string fileName)
+               public byte [] UploadFile (Uri address, string method, string fileName)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
                        if (fileName == null)
                                throw new ArgumentNullException ("fileName");
-#endif
 
                        try {
                                SetBusy ();
-#if NET_2_0                            
                                async = false;
-#endif                         
                                return UploadFileCore (address, method, fileName, null);
-                       } catch (WebException wexc) {
+                       } catch (WebException) {
                                throw;
                        } catch (Exception ex) {
                                throw new WebException ("An error occurred " +
@@ -614,11 +515,6 @@ namespace System.Net
 
                byte [] UploadFileCore (Uri address, string method, string fileName, object userToken)
                {
-#if ONLY_1_1
-                       if (address == null)
-                               throw new ArgumentNullException ("address");
-#endif
-
                        string fileCType = Headers ["Content-Type"];
                        if (fileCType != null) {
                                string lower = fileCType.ToLower ();
@@ -681,51 +577,36 @@ namespace System.Net
                
                public byte[] UploadValues (string address, NameValueCollection data)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
 
                        return UploadValues (CreateUri (address), data);
                }
                
                public byte[] UploadValues (string address, string method, NameValueCollection data)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
-#endif
-
                        return UploadValues (CreateUri (address), method, data);
                }
 
-#if NET_2_0
-               public
-#endif
-               byte[] UploadValues (Uri address, NameValueCollection data)
+               public byte[] UploadValues (Uri address, NameValueCollection data)
                {
                        return UploadValues (address, (string) null, data);
                }
 
-#if NET_2_0
-               public
-#endif
-               byte[] UploadValues (Uri address, string method, NameValueCollection data)
+               public byte[] UploadValues (Uri address, string method, NameValueCollection data)
                {
-#if NET_2_0
                        if (address == null)
                                throw new ArgumentNullException ("address");
                        if (data == null)
                                throw new ArgumentNullException ("data");
-#endif
 
                        try {
                                SetBusy ();
-#if NET_2_0                            
                                async = false;
-#endif                         
                                return UploadValuesCore (address, method, data, null);
-                       } catch (WebException wexc) {
+                       } catch (WebException) {
                                throw;
                        } catch (Exception ex) {
                                throw new WebException ("An error occurred " +
@@ -737,11 +618,6 @@ namespace System.Net
 
                byte[] UploadValuesCore (Uri uri, string method, NameValueCollection data, object userToken)
                {
-#if ONLY_1_1
-                       if (data == null)
-                               throw new ArgumentNullException ("data");
-#endif
-
                        string cType = Headers ["Content-Type"];
                        if (cType != null && String.Compare (cType, urlEncodedCType, true) != 0)
                                throw new WebException ("Content-Type header cannot be changed from its default " +
@@ -780,7 +656,6 @@ namespace System.Net
                        }
                }
 
-#if NET_2_0
                public string DownloadString (string address)
                {
                        if (address == null)
@@ -852,42 +727,40 @@ namespace System.Net
                public event UploadProgressChangedEventHandler UploadProgressChanged;
                public event UploadStringCompletedEventHandler UploadStringCompleted;
                public event UploadValuesCompletedEventHandler UploadValuesCompleted;
-#endif
 
                Uri CreateUri (string address)
                {
-#if ONLY_1_1
+                       Uri uri;
                        try {
-                               return MakeUri (address);
-                       } catch (Exception ex) {
-                               throw new WebException ("An error occurred " +
-                                       "performing a WebClient request.", ex);
+                               if (baseAddress == null)
+                                       uri = new Uri (address);
+                               else
+                                       uri = new Uri (baseAddress, address);
+                               return CreateUri (uri);
+                       } catch {
                        }
-#else
-                       return MakeUri (address);
-#endif
+                       return new Uri (Path.GetFullPath (address));
                }
 
-#if NET_2_0
                Uri CreateUri (Uri address)
                {
-                       string query = address.Query;
+                       Uri result = address;
+                       if (baseAddress != null && !result.IsAbsoluteUri) {
+                               try {
+                                       result = new Uri (baseAddress, result.OriginalString);
+                               } catch {
+                                       return result; // Not much we can do here.
+                               }
+                       }
+
+                       string query = result.Query;
                        if (String.IsNullOrEmpty (query))
                                query = GetQueryString (true);
-
-                       if (baseAddress == null && query == null)
-                               return address;
-
-                       if (baseAddress == null)
-                               return new Uri (address.ToString () + query, (query != null));
-
-                       if (query == null)
-                               return new Uri (baseAddress, address.ToString ());
-
-                       return new Uri (baseAddress, address.ToString () + query, (query != null));
-
+                       UriBuilder builder = new UriBuilder (address);
+                       if (!String.IsNullOrEmpty (query))
+                               builder.Query = query.Substring (1);
+                       return builder.Uri;
                }
-#endif
 
                string GetQueryString (bool add_qmark)
                {
@@ -910,39 +783,11 @@ namespace System.Net
                        return sb.ToString ();
                }
 
-               Uri MakeUri (string path)
-               {
-                       string query = GetQueryString (true);
-                       if (baseAddress == null && query == null) {
-                               try {
-                                       return new Uri (path);
-#if NET_2_0
-                               } catch (ArgumentNullException) {
-                                       path = Path.GetFullPath (path);
-                                       return new Uri ("file://" + path);
-#endif
-                               } catch (UriFormatException) {
-                                       path = Path.GetFullPath (path);
-                                       return new Uri ("file://" + path);
-                               }
-                       }
-
-                       if (baseAddress == null)
-                               return new Uri (path + query, (query != null));
-
-                       if (query == null)
-                               return new Uri (baseAddress, path);
-
-                       return new Uri (baseAddress, path + query, (query != null));
-               }
-               
                WebRequest SetupRequest (Uri uri)
                {
                        WebRequest request = GetWebRequest (uri);
-#if NET_2_0
                        if (Proxy != null)
                                request.Proxy = Proxy;
-#endif
                        request.Credentials = credentials;
 
                        // Special headers. These are properties of HttpWebRequest.
@@ -1013,12 +858,10 @@ namespace System.Net
                                        offset += nread;
                                        size -= nread;
                                }
-#if NET_2_0
                                if (async){
 //                                     total += nread;
                                        OnDownloadProgressChanged (new DownloadProgressChangedEventArgs (nread, length, userToken));
                                }
-#endif
                        }
 
                        if (nolength)
@@ -1081,7 +924,6 @@ namespace System.Net
                        }
                }
 
-#if NET_2_0
                public void CancelAsync ()
                {
                        lock (this){
@@ -1546,20 +1388,13 @@ namespace System.Net
                        responseHeaders = response.Headers;
                        return response;
                }
-#endif
 
-#if NET_2_0
-               protected virtual
-#endif
-               WebRequest GetWebRequest (Uri address)
+               protected virtual WebRequest GetWebRequest (Uri address)
                {
                        return WebRequest.Create (address);
                }
 
-#if NET_2_0
-               protected virtual
-#endif
-               WebResponse GetWebResponse (WebRequest request)
+               protected virtual WebResponse GetWebResponse (WebRequest request)
                {
                        WebResponse response = request.GetResponse ();
                        responseHeaders = response.Headers;
index 5bb638c6a18876906ef85d743501206015c030ac..d197f837de4194afe12b5230902308c9fd7426e7 100644 (file)
@@ -35,7 +35,7 @@ using System.Reflection;
 using System.Security.Cryptography.X509Certificates;
 using System.Text;
 using System.Threading;
-#if (NET_2_0 || MONOTOUCH) && SECURITY_DEP
+#if SECURITY_DEP
 using Mono.Security.Protocol.Tls;
 #endif
 
@@ -73,9 +73,7 @@ namespace System.Net
                HttpWebRequest priority_request;
                NetworkCredential ntlm_credentials;
                bool ntlm_authenticated;
-#if NET_1_1
                bool unsafe_sharing;
-#endif
 
                bool ssl;
                bool certsAvailable;
@@ -164,21 +162,17 @@ namespace System.Net
 #endif
                                }
 
-                               WebConnectionData data = Data;
+                               //WebConnectionData data = Data;
                                foreach (IPAddress address in hostEntry.AddressList) {
                                        socket = new Socket (address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                                        IPEndPoint remote = new IPEndPoint (address, sPoint.Address.Port);
-#if NET_1_1
                                        socket.SetSocketOption (SocketOptionLevel.Tcp, SocketOptionName.NoDelay, sPoint.UseNagleAlgorithm ? 0 : 1);
-#endif
-#if NET_2_0
                                        socket.NoDelay = !sPoint.UseNagleAlgorithm;
                                        if (!sPoint.CallEndPointDelegate (socket, remote)) {
                                                socket.Close ();
                                                socket = null;
                                                status = WebExceptionStatus.ConnectFailure;
                                        } else {
-#endif
                                                try {
                                                        if (request.Aborted)
                                                                return;
@@ -192,7 +186,7 @@ namespace System.Net
                                                        if (s != null)
                                                                s.Close ();
                                                        return;
-                                               } catch (ObjectDisposedException exc) {
+                                               } catch (ObjectDisposedException) {
                                                        // socket closed from another thread
                                                        return;
                                                } catch (Exception exc) {
@@ -204,9 +198,7 @@ namespace System.Net
                                                                status = WebExceptionStatus.ConnectFailure;
                                                        connect_exception = exc;
                                                }
-#if NET_2_0
                                        }
-#endif
                                }
                        }
                }
@@ -355,7 +347,7 @@ namespace System.Net
                                                                                request.ClientCertificates,
                                                                                request, buffer};
                                                nstream = (Stream) Activator.CreateInstance (sslStream, args);
-#if (NET_2_0 || MONOTOUCH) && SECURITY_DEP
+#if SECURITY_DEP
                                                SslClientStream scs = (SslClientStream) nstream;
                                                var helper = new ServicePointManager.ChainValidationHelper (request);
                                                scs.ServerCertValidation2 += new CertificateValidationCallback2 (helper.ValidateChain);
@@ -1123,12 +1115,10 @@ namespace System.Net
                        set { ntlm_credentials = value; }
                }
 
-#if NET_1_1
                internal bool UnsafeAuthenticatedConnectionSharing {
                        get { return unsafe_sharing; }
                        set { unsafe_sharing = value; }
                }
-#endif
                // -
        }
 }
index f98144db88f122fd0bd1c491ba58be3ee48d4c74..8f0c5aa19499aadb47b382771922ee0012e76940 100644 (file)
@@ -59,7 +59,7 @@ namespace System.Net
                                WeakReference cncRef = null;
 
                                int end = connections.Count;
-                               ArrayList removed = null;
+                               // ArrayList removed = null;
                                for (int i = 0; i < end; i++) {
                                        cncRef = (WeakReference) connections [i];
                                        WebConnection cnc = cncRef.Target as WebConnection;
index be4446b7a0cb7fd971c461aa2559a81e2aca25d5..1e401660db60d6919439cd45b3ab6450e1c4dcde 100644 (file)
@@ -30,9 +30,12 @@ using System.Runtime.Serialization;
 \r
 namespace System.Net \r
 {\r
+#if MOONLIGHT && INSIDE_SYSTEM\r
+       internal class WebException : InvalidOperationException, ISerializable {\r
+#else\r
        [Serializable]\r
-       public class WebException : InvalidOperationException, ISerializable\r
-       {\r
+       public class WebException : InvalidOperationException, ISerializable {\r
+#endif\r
                private WebResponse response;\r
                private WebExceptionStatus status = WebExceptionStatus.UnknownError;\r
 \r
@@ -97,12 +100,10 @@ namespace System.Net
                }\r
 #endif \r
 \r
-#if NET_2_0\r
                public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
                {\r
                        base.GetObjectData (serializationInfo,\r
                                            streamingContext);\r
                }\r
-#endif\r
        }\r
 }\r
index ae4598f0383525b608981a9868baba5c4c2fac75..16f77533a40dfc0c95c8c2420a44d110c8f28723 100644 (file)
@@ -33,9 +33,7 @@
 
 using System;
 using System.Collections;
-#if NET_2_0
 using System.Collections.Generic;
-#endif
 using System.Collections.Specialized;
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
@@ -45,15 +43,16 @@ using System.Text;
     
 namespace System.Net 
 {
+#if MOONLIGHT
+       internal class WebHeaderCollection : NameValueCollection, ISerializable {
+#else
        [Serializable]
        [ComVisible(true)]
-       public class WebHeaderCollection : NameValueCollection, ISerializable
-       {
+       public class WebHeaderCollection : NameValueCollection, ISerializable {
+#endif
                private static readonly Hashtable restricted;
                private static readonly Hashtable multiValue;
-#if NET_2_0
                static readonly Dictionary<string, bool> restricted_response;
-#endif
                private bool internallyCreated = false;
                
                // Static Initializer
@@ -80,12 +79,11 @@ namespace System.Net
                        restricted.Add ("proxy-connection", true);                      
 
                        //
-#if NET_2_0
                        restricted_response = new Dictionary<string, bool> (StringComparer.InvariantCultureIgnoreCase);
                        restricted_response.Add ("Content-Length", true);
                        restricted_response.Add ("Transfer-Encoding", true);
                        restricted_response.Add ("WWW-Authenticate", true);
-#endif
+
                        // see par 14 of RFC 2068 to see which header names
                        // accept multiple values each separated by a comma
                        multiValue = new Hashtable (CaseInsensitiveHashCodeProvider.DefaultInvariant,
@@ -263,7 +261,6 @@ namespace System.Net
                        return restricted.ContainsKey (headerName);
                }
 
-#if NET_2_0
                public static bool IsRestricted (string headerName, bool response)
                {
                        if (String.IsNullOrEmpty (headerName))
@@ -277,7 +274,6 @@ namespace System.Net
                                return restricted_response.ContainsKey (headerName);
                        return restricted.ContainsKey (headerName);
                }
-#endif
 
                public override void OnDeserialization (object sender)
                {
@@ -380,7 +376,6 @@ namespace System.Net
                        return(base.GetKey (index));
                }
 
-#if NET_2_0
                public void Add (HttpRequestHeader header, string value)
                {
                        Add (RequestHeaderToString (header), value);
@@ -603,7 +598,6 @@ namespace System.Net
                {
                        return(base.GetEnumerator ());
                }
-#endif
 
                // Internal Methods
                
index 43ddcaaffd32e0b1fdb6becee915a409e7c791a8..06f3c72b4dc1e7deb8f15c71fe01b61fba5c7259 100644 (file)
@@ -40,7 +40,7 @@ using System.Net.Cache;
 using System.Security.Principal;
 #endif
 
-#if MONOTOUCH
+#if NET_2_1
 using ConfigurationException = System.ArgumentException;
 
 namespace System.Net.Configuration {
@@ -50,9 +50,12 @@ namespace System.Net.Configuration {
 
 namespace System.Net 
 {
+#if MOONLIGHT
+       internal abstract class WebRequest : ISerializable {
+#else
        [Serializable]
-       public abstract class WebRequest : MarshalByRefObject, ISerializable
-       {
+       public abstract class WebRequest : MarshalByRefObject, ISerializable {
+#endif
                static HybridDictionary prefixes = new HybridDictionary ();
 #if NET_2_0
                static bool isDefaultWebProxySet;
@@ -63,13 +66,15 @@ namespace System.Net
                
                static WebRequest ()
                {
-#if MONOTOUCH
+#if NET_2_1
                        AddPrefix ("http", typeof (HttpRequestCreator));
                        AddPrefix ("https", typeof (HttpRequestCreator));
+       #if MONOTOUCH
                        AddPrefix ("file", typeof (FileWebRequestCreator));
                        AddPrefix ("ftp", typeof (FtpRequestCreator));
+       #endif
 #else
-#if NET_2_0 && CONFIGURATION_DEP
+       #if NET_2_0 && CONFIGURATION_DEP
                        object cfg = ConfigurationManager.GetSection ("system.net/webRequestModules");
                        WebRequestModulesSection s = cfg as WebRequestModulesSection;
                        if (s != null) {
@@ -78,7 +83,7 @@ namespace System.Net
                                        AddPrefix (el.Prefix, el.Type);
                                return;
                        }
-#endif
+       #endif
                        ConfigurationSettings.GetConfig ("system.net/webRequestModules");
 #endif
                }
@@ -161,7 +166,7 @@ namespace System.Net
                        set { throw GetMustImplement (); }
                }
                
-#if NET_2_0
+#if NET_2_0 && !MOONLIGHT
                public TokenImpersonationLevel ImpersonationLevel {
                        get { throw GetMustImplement (); }
                        set { throw GetMustImplement (); }
index ac5fbc2546597e163360737d2ee04792777df5b0..b87d65b40c2e2f3b18c79f2672c4209949d8cdd5 100644 (file)
@@ -32,9 +32,12 @@ using System.Runtime.Serialization;
 \r
 namespace System.Net \r
 {\r
+#if MOONLIGHT\r
+       internal abstract class WebResponse : MarshalByRefObject, ISerializable, IDisposable {\r
+#else\r
        [Serializable]\r
-       public abstract class WebResponse : MarshalByRefObject, ISerializable, IDisposable\r
-       {\r
+       public abstract class WebResponse : MarshalByRefObject, ISerializable, IDisposable {\r
+#endif\r
                // Constructors\r
                \r
                protected WebResponse () { }\r
@@ -60,7 +63,6 @@ namespace System.Net
                        get { throw new NotSupportedException (); }\r
                }\r
 \r
-#if NET_2_0\r
                static Exception GetMustImplement ()\r
                {\r
                        return new NotImplementedException ();\r
@@ -81,7 +83,6 @@ namespace System.Net
                                throw GetMustImplement ();\r
                        }\r
                }\r
-#endif\r
                \r
                public virtual Uri ResponseUri {                \r
                        get { throw new NotSupportedException (); }\r
@@ -114,12 +115,10 @@ namespace System.Net
                        throw new NotSupportedException ();\r
                }\r
 \r
-#if NET_2_0\r
                [MonoTODO]\r
                protected virtual void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
                {\r
                        throw GetMustImplement ();\r
                }\r
-#endif\r
        }\r
 }\r
index 81ea79899f9e85099fd421162b34423c0a72ad4f..f84b86149104f17fc17cd45875aeffcfb1c0b61b 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * X509Chain.cs: use MOONLIGHT symbol to disambiguate MonoTouch
+       and Moonlight code.
+
 2010-03-11 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * OSX509Certificates.cs: moved here from Mono.Security.
index a8399891d2bb1395ebcff40e264c7a11092f0204..678cb8f9baee41335edf3b0cf230f373ea721050 100644 (file)
@@ -857,7 +857,7 @@ namespace System.Security.Cryptography.X509Certificates {
                }
        }
 }
-#elif NET_2_0 && (!NET_2_1 || MONOTOUCH)
+#elif NET_2_0 && !MOONLIGHT
 namespace System.Security.Cryptography.X509Certificates {
        public class X509Chain {
                public bool Build (X509Certificate2 cert)
index c3a8ba66e6238f7339ff3d10d3b48c8a3e7e96a5..972e2ccf3198af9a0452a5024ab81621f2c4e3ed 100644 (file)
@@ -47,7 +47,7 @@ namespace System.Text.RegularExpressions {
                static FieldInfo fi_stack = typeof (RxInterpreter).GetField ("stack", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
                static FieldInfo fi_mark_start = typeof (Mark).GetField ("Start", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
                static FieldInfo fi_mark_end = typeof (Mark).GetField ("End", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
-               static FieldInfo fi_mark_index = typeof (Mark).GetField ("Index", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
+               //static FieldInfo fi_mark_index = typeof (Mark).GetField ("Index", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
 
                static MethodInfo mi_stack_get_count, mi_stack_set_count, mi_stack_push, mi_stack_pop;
                static MethodInfo mi_set_start_of_match, mi_is_word_char, mi_reset_groups;
index d706ed3ffb5e4a255bce33d702c5fda577a06312..4850f74212a369dfc2bfb38252aaa0fea496bab3 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-20  Miguel de Icaza  <miguel@novell.com>
+
+       * RxInterpreter.cs: Removed warnings.
+
 2010-02-03  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * BaseMachine.cs (Split): Don't add empty strings if they don't come from
index 945b2634095350677d57b953efb8e5c8814770b4..3f5d987ed91d2484e6908ed635808da94d1c0af5 100644 (file)
@@ -1,6 +1,9 @@
 
 // Based upon interpreter.cs, written by Dan Lewis (dlewis@gmx.co.uk)
-
+//
+// There are a couple of bits flagged with DEAD_CODE which are bits that do
+// not seem to have been completed
+//
 using System;
 using System.Collections;
 using System.Globalization;
@@ -899,7 +902,7 @@ namespace System.Text.RegularExpressions {
                                
                                case RxOp.CategoryAnySingleline:
                                        if (strpos < string_end) {
-                                               char c = str [strpos];
+                                               // char c = str [strpos];
                                                if ((true)) {
                                                        strpos ++;
                                                        if (char_group_end != 0)
@@ -1258,6 +1261,7 @@ namespace System.Text.RegularExpressions {
                                        return false;
                                case RxOp.NoCategoryAnySingleline:
                                        if (strpos < string_end) {
+#if DEAD_CODE
                                                char c = str [strpos];
                                                if (!(true)) {
                                                        pc += 1;
@@ -1268,6 +1272,7 @@ namespace System.Text.RegularExpressions {
                                                        }
                                                        continue;
                                                }
+#endif
                                        }
                                        return false;
                                case RxOp.NoCategoryWord:
@@ -1575,7 +1580,7 @@ namespace System.Text.RegularExpressions {
                                        continue;
                                case RxOp.CategoryAnySinglelineReverse:
                                        if (strpos > 0) {
-                                               char c = str [strpos - 1];
+                                               //char c = str [strpos - 1];
                                                if ((true)) {
                                                        strpos --;
                                                        if (char_group_end != 0)
@@ -1904,6 +1909,7 @@ namespace System.Text.RegularExpressions {
                                        return false;
                                case RxOp.NoCategoryAnySinglelineReverse:
                                        if (strpos > 0) {
+#if DEAD_CODe
                                                char c = str [strpos - 1];
                                                if (!(true)) {
                                                        pc += 1;
@@ -1914,6 +1920,7 @@ namespace System.Text.RegularExpressions {
                                                        }
                                                        continue;
                                                }
+#endif
                                        }
                                        return false;
                                case RxOp.NoCategoryWordReverse:
index 1ef812cbaa43d521b4beb9efd1744bce83d78467..e417d1b4d09cfccd5d88f76e50473c14060b4146 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Timer.cs: Removed old NET_2_0 defines and added some new
+       MOONLIGHT defines (needed for the client stack)
+
 2009-09-29  Sebastien Pouliot  <sebastien@ximian.com>
 
        * Timer_2_1.cs: Removed. No longer needed by Moonlight
index fc907a6a8d44a131ac3bed1f4cdee02ab85f970b..6126b9dcb65bebed1aefb130676851099784859e 100644 (file)
@@ -35,10 +35,13 @@ using System.Threading;
 
 namespace System.Timers
 {
+#if MOONLIGHT
+       internal class Timer {
+#else
        [DefaultEventAttribute("Elapsed")]
        [DefaultProperty("Interval")]
-       public class Timer : Component, ISupportInitialize
-       {
+       public class Timer : Component, ISupportInitialize {
+#endif
                double interval;
                bool autoReset;
                System.Threading.Timer timer;
@@ -55,11 +58,9 @@ namespace System.Timers
 
                public Timer (double interval)
                {
-#if NET_2_0
                        // MSBUG: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=296761
                        if (interval > 0x7FFFFFFF)
                                throw new ArgumentException ("Invalid value: " + interval, "interval");
-#endif
 
                        autoReset = true;
                        Interval = interval;
@@ -119,18 +120,17 @@ namespace System.Timers
                        }
                }
 
+#if !MOONLIGHT
                public override ISite Site
                {
                        get { return base.Site; }
                        set { base.Site = value; }
                }
-
+#endif
                [DefaultValue(null)]
                [TimersDescriptionAttribute("The object used to marshal the event handler calls issued " +
                                            "when an interval has elapsed.")]
-#if NET_2_0
                [Browsable (false)]
-#endif
                public ISynchronizeInvoke SynchronizingObject
                {
                        get { return so; }
@@ -162,11 +162,18 @@ namespace System.Timers
                        Enabled = false;
                }
 
+#if MOONLIGHT
+               protected void Dispose (bool disposing)
+               {
+                       Close ();
+               }
+#else
                protected override void Dispose (bool disposing)
                {
                        Close ();
                        base.Dispose (disposing);
                }
+#endif
 
                static void Callback (object state)
                {
index d5b3fb9ac8fdb804c0a1ad73007b29d4db584a83..62df47af16a4301a294012337164f6f7b2a853df 100644 (file)
@@ -1,3 +1,16 @@
+2010-03-20  Miguel de Icaza  <miguel@novell.com>
+
+       * Uri.cs: Drop pre-2.0 support
+
+2010-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Uri.cs: Remove some MOONLIGHT defines
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Uri.cs, UriTypeConverter.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2010-01-27  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * Uri.cs: In IsWellFormedOriginalString(), call to our internal
index f3ccc02bf0adfc34836899011259585bded20cf3..591c197b5d6df094fc0e7739cb065f3bfe451c78 100644 (file)
@@ -55,12 +55,8 @@ using System.Globalization;
 namespace System {
 
        [Serializable]
-#if NET_2_0
        [TypeConverter (typeof (UriTypeConverter))]
        public class Uri : ISerializable {
-#else
-       public class Uri : MarshalByRefObject, ISerializable {
-#endif
                // NOTES:
                // o  scheme excludes the scheme delimiter
                // o  port is -1 to indicate no port is defined
@@ -106,14 +102,12 @@ namespace System {
                public static readonly string UriSchemeMailto = "mailto";
                public static readonly string UriSchemeNews = "news";
                public static readonly string UriSchemeNntp = "nntp";
-#if NET_2_0
                public static readonly string UriSchemeNetPipe = "net.pipe";
                public static readonly string UriSchemeNetTcp = "net.tcp";
-#endif
 
                // Constructors         
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                public Uri (string uriString) : this (uriString, UriKind.Absolute) 
                {
                }
@@ -128,7 +122,6 @@ namespace System {
                {
                }
 
-#if NET_2_0
                public Uri (string uriString, UriKind uriKind)
                {
                        source = uriString;
@@ -212,17 +205,6 @@ namespace System {
                                throw new UriFormatException("Invalid URI: The format of the URI could not be "
                                        + "determined: " + uriString);
                }
-#else
-               public Uri (string uriString, bool dontEscape) 
-               {
-                       userEscaped = dontEscape;
-                       source = uriString;
-                       Parse ();
-                       if (!isAbsoluteUri)
-                               throw new UriFormatException("Invalid URI: The format of the URI could not be "
-                                       + "determined.");
-               }
-#endif
 
                public Uri (Uri baseUri, string relativeUri) 
                {
@@ -230,9 +212,7 @@ namespace System {
                        // FIXME: this should call UriParser.Resolve
                }
 
-#if NET_2_0
                [Obsolete ("dontEscape is always false")]
-#endif
                public Uri (Uri baseUri, string relativeUri, bool dontEscape) 
                {
                        userEscaped = dontEscape;
@@ -241,27 +221,19 @@ namespace System {
 
                private void Merge (Uri baseUri, string relativeUri)
                {
-#if NET_2_0
                        if (baseUri == null)
                                throw new ArgumentNullException ("baseUri");
                        if (!baseUri.IsAbsoluteUri)
                                throw new ArgumentOutOfRangeException ("baseUri");
                        if (relativeUri == null)
                                relativeUri = String.Empty;
-#else
-                       if (baseUri == null)
-                               throw new NullReferenceException ("baseUri");
-#endif
+
                        // See RFC 2396 Par 5.2 and Appendix C
 
                        // Check Windows UNC (for // it is scheme/host separator)
                        if (relativeUri.Length >= 2 && relativeUri [0] == '\\' && relativeUri [1] == '\\') {
                                source = relativeUri;
-#if NET_2_0
                                ParseUri (UriKind.Absolute);
-#else
-                               Parse ();
-#endif
                                return;
                        }
 
@@ -286,11 +258,7 @@ namespace System {
                                            relativeUri.Length > pos + 1 &&
                                            relativeUri [pos + 1] == '/') {
                                                source = relativeUri;
-#if NET_2_0
                                                ParseUri (UriKind.Absolute);
-#else
-                                               Parse ();
-#endif
                                                return;
                                        }
                                        else
@@ -336,11 +304,7 @@ namespace System {
                        if (relativeUri.Length > 0 && relativeUri [0] == '/') {
                                if (relativeUri.Length > 1 && relativeUri [1] == '/') {
                                        source = scheme + ':' + relativeUri;
-#if NET_2_0
                                        ParseUri (UriKind.Absolute);
-#else
-                                       Parse ();
-#endif
                                        return;
                                } else {
                                        path = relativeUri;
@@ -421,7 +385,6 @@ namespace System {
                
                public string AbsolutePath { 
                        get {
-#if NET_2_0
                                EnsureAbsoluteUri ();
                                switch (Scheme) {
                                case "mailto":
@@ -438,9 +401,6 @@ namespace System {
                                        }
                                        return path;
                                }
-#else
-                               return path;
-#endif
                        }
                }
 
@@ -479,29 +439,22 @@ namespace System {
                                return host; 
                        } 
                }
-#if !NET_2_1 || MONOTOUCH
+
                public UriHostNameType HostNameType { 
                        get {
                                EnsureAbsoluteUri ();
                                UriHostNameType ret = CheckHostName (Host);
                                if (ret != UriHostNameType.Unknown)
                                        return ret;
-#if NET_2_0
                                switch (Scheme) {
                                case "mailto":
                                        return UriHostNameType.Basic;
                                default:
                                        return (IsFile) ? UriHostNameType.Basic : ret;
                                }
-#else
-                               // looks it always returns Basic...
-                               return UriHostNameType.Basic; //.Unknown;
-#endif
                        } 
                }
 
-#endif // NET_2_1
-
                public bool IsDefaultPort { 
                        get {
                                EnsureAbsoluteUri ();
@@ -516,17 +469,12 @@ namespace System {
                        }
                }
 
-#if !NET_2_1 || MONOTOUCH
                public bool IsLoopback { 
                        get {
                                EnsureAbsoluteUri ();
                                
                                if (Host.Length == 0) {
-#if NET_2_0
                                        return IsFile;
-#else
-                                       return false;
-#endif
                                }
 
                                if (host == "loopback" || host == "localhost") 
@@ -547,8 +495,6 @@ namespace System {
                        } 
                }
 
-#endif // NET_2_1
-
                public bool IsUnc {
                        // rule: This should be true only if
                        //   - uri string starts from "\\", or
@@ -592,13 +538,9 @@ namespace System {
                                        else if (System.IO.Path.DirectorySeparatorChar == '\\') {
                                                string h = host;
                                                if (path.Length > 0) {
-#if NET_2_0
                                                        if ((path.Length > 1) || (path[0] != '/')) {
                                                                h += path.Replace ('/', '\\');
                                                        }
-#else
-                                                       h += path.Replace ('/', '\\');
-#endif
                                                }
                                                cachedLocalPath = "\\\\" + Unescape (h);
                                        }  else
@@ -689,7 +631,6 @@ namespace System {
                        }
                }
                
-#if NET_2_0
                [MonoTODO ("add support for IPv6 address")]
                public string DnsSafeHost {
                        get {
@@ -701,18 +642,13 @@ namespace System {
                public bool IsAbsoluteUri {
                        get { return isAbsoluteUri; }
                }
-#endif
+
                // LAMESPEC: source field is supplied in such case that this
                // property makes sense. For such case that source field is
                // not supplied (i.e. .ctor(Uri, string), this property
                // makes no sense. To avoid silly regression it just returns
                // ToString() value now. See bug #78374.
-#if NET_2_0
-               public
-#else
-               internal
-#endif
-               string OriginalString {
+               public string OriginalString {
                        get { return source != null ? source : ToString (); }
                }
 
@@ -749,16 +685,8 @@ namespace System {
                                if (length == 0)
                                        return false;
                                uint number;
-#if NET_2_0
                                if (!UInt32.TryParse (captures [i], out number))
                                        return false;
-#else
-                               try {
-                                       number = UInt32.Parse (captures [i]);
-                               } catch (Exception) {
-                                       return false;
-                               }
-#endif
                                if (number > 255)
                                        return false;
                        }
@@ -788,9 +716,7 @@ namespace System {
                }
 #if !NET_2_1
 
-#if NET_2_0
                [Obsolete("This method does nothing, it has been obsoleted")]
-#endif
                protected virtual void Canonicalize ()
                {
                        //
@@ -800,9 +726,7 @@ namespace System {
                }
 
                [MonoTODO ("Find out what this should do")]
-#if NET_2_0
                [Obsolete]
-#endif
                protected virtual void CheckSecurity ()
                {
                }
@@ -830,15 +754,10 @@ namespace System {
 
                private static bool IsAlpha (char c)
                {
-#if NET_2_0
                        // as defined in rfc2234
                        // %x41-5A / %x61-7A (A-Z / a-z)
                        int i = (int) c;
                        return (((i >= 0x41) && (i <= 0x5A)) || ((i >= 0x61) && (i <= 0x7A)));
-#else
-                       // Fx 1.x got this too large
-                       return Char.IsLetter (c);
-#endif
                }
 
                public override bool Equals (object comparant) 
@@ -860,27 +779,19 @@ namespace System {
                // Assumes: uri != null
                bool InternalEquals (Uri uri)
                {
-#if NET_2_0
                        if (this.isAbsoluteUri != uri.isAbsoluteUri)
                                return false;
                        if (!this.isAbsoluteUri)
                                return this.source == uri.source;
-#endif
 
                        CultureInfo inv = CultureInfo.InvariantCulture;
                        return this.scheme.ToLower (inv) == uri.scheme.ToLower (inv)
                                && this.host.ToLower (inv) == uri.host.ToLower (inv)
                                && this.port == uri.port
-#if NET_2_0
                                && this.query == uri.query
-#else
-                               // Note: MS.NET 1.x has bug - ignores query check altogether
-                               && this.query.ToLower (inv) == uri.query.ToLower (inv)
-#endif
                                && this.path == uri.path;
                }
 
-#if NET_2_0
                public static bool operator == (Uri u1, Uri u2)
                {
                        return object.Equals(u1, u2);
@@ -890,7 +801,6 @@ namespace System {
                {
                        return !(u1 == u2);
                }
-#endif
 
                public override int GetHashCode () 
                {
@@ -900,11 +810,7 @@ namespace System {
                                        cachedHashCode = scheme.ToLower (inv).GetHashCode ()
                                                ^ host.ToLower (inv).GetHashCode ()
                                                ^ port
-#if NET_2_0
                                                ^ query.GetHashCode ()
-#else
-                                               ^ query.ToLower (inv).GetHashCode ()
-#endif
                                                ^ path.GetHashCode ();
                                }
                                else {
@@ -951,7 +857,6 @@ namespace System {
                                        sb.Append (':').Append (port);
 
                                if (path.Length > 0) {
-#if NET_2_0
                                        switch (Scheme) {
                                        case "mailto":
                                        case "news":
@@ -961,9 +866,6 @@ namespace System {
                                                sb.Append (Reduce (path));
                                                break;
                                        }
-#else
-                                       sb.Append (path);
-#endif
                                }
                                return sb.ToString ();
                        }
@@ -1029,7 +931,6 @@ namespace System {
                                IsHexDigit (pattern [index]));
                }
 
-#if NET_2_0
                //
                // Implemented by copying most of the MakeRelative code
                //
@@ -1064,7 +965,6 @@ namespace System {
                }
 
                [Obsolete ("Use MakeRelativeUri(Uri uri) instead.")]
-#endif
                public string MakeRelative (Uri toUri) 
                {
                        if ((this.Scheme != toUri.Scheme) ||
@@ -1118,12 +1018,10 @@ namespace System {
                        return cachedToString;
                }
 
-#if NET_2_0
                protected void GetObjectData (SerializationInfo info, StreamingContext context)
                {
                        info.AddValue ("AbsoluteUri", this.AbsoluteUri);
                }
-#endif
 
                void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
                {
@@ -1133,20 +1031,16 @@ namespace System {
 
                // Internal Methods             
 
-#if NET_2_0
                [Obsolete]
-#endif
                protected virtual void Escape ()
                {
                        path = EscapeString (path);
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                static string EscapeString (string str)
 #else
-       #if NET_2_0
                [Obsolete]
-       #endif
                protected static string EscapeString (string str) 
 #endif
                {
@@ -1201,14 +1095,9 @@ namespace System {
                // On .NET 1.x, this method is called from .ctor(). When overriden, we 
                // can avoid the "absolute uri" constraints of the .ctor() by
                // overriding with custom code.
-#if NET_2_0
                [Obsolete("The method has been deprecated. It is not used by the system.")]
-#endif
                protected virtual void Parse ()
                {
-#if !NET_2_0
-                       ParseUri (UriKind.Absolute);
-#endif
                }
 
                private void ParseUri (UriKind kind)
@@ -1229,12 +1118,10 @@ namespace System {
                        }
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                string Unescape (string str)
 #else
-       #if NET_2_0
                [Obsolete]
-       #endif
                protected virtual string Unescape (string str)
 #endif
                {
@@ -1386,7 +1273,7 @@ namespace System {
                        if (uriString [0] == '/' && Path.DirectorySeparatorChar == '/'){
                                //Unix Path
                                ParseAsUnixAbsoluteFilePath (uriString);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                isAbsoluteUri = false;
 #else
                                if (kind == UriKind.Relative)
@@ -1535,19 +1422,10 @@ namespace System {
                        if (pos != -1 && pos != endpos - 1) {
                                string portStr = uriString.Substring(pos + 1, endpos - (pos + 1));
                                if (portStr.Length > 0 && portStr[portStr.Length - 1] != ']') {
-#if NET_2_0
                                        if (!Int32.TryParse (portStr, NumberStyles.Integer, CultureInfo.InvariantCulture, out port) ||
                                            port < 0 || port > UInt16.MaxValue)
                                                return "Invalid URI: Invalid port number";
                                        endpos = pos;
-#else
-                                       try {
-                                               port = (int) UInt32.Parse (portStr, CultureInfo.InvariantCulture);
-                                               endpos = pos;
-                                       } catch (Exception) {
-                                               return "Invalid URI: Invalid port number";
-                                       }
-#endif
                                } else {
                                        if (port == -1) {
                                                port = GetDefaultPort (scheme);
@@ -1596,7 +1474,6 @@ namespace System {
                                else
                                        badhost = true;
                        }
-#if NET_2_0
                        if (badhost && (Parser is DefaultUriParser || Parser == null))
                                return Locale.GetText ("Invalid URI: The hostname could not be parsed. (" + host + ")");
 
@@ -1605,10 +1482,6 @@ namespace System {
                                Parser.InitializeAndValidate (this, out ex);
                        if (ex != null)
                                return ex.Message;
-#else
-                       if (badhost)
-                               return Locale.GetText ("Invalid URI: The hostname could not be parsed. (" + host + ")");
-#endif
 
                        if ((scheme != Uri.UriSchemeMailto) &&
                                        (scheme != Uri.UriSchemeNews) &&
@@ -1666,7 +1539,6 @@ namespace System {
 
                                if (current == "..") {
                                        int resultCount = result.Count;
-#if NET_2_0
                                        // in 2.0 profile, skip leading ".." parts
                                        if (resultCount == 0) {
                                                continue;
@@ -1674,16 +1546,6 @@ namespace System {
 
                                        result.RemoveAt (resultCount - 1);
                                        continue;
-#else
-                                       // in 1.x profile, retain leading ".." parts, and only reduce
-                                       // URI is previous part is not ".."
-                                       if (resultCount > 0) {
-                                               if ((string) result[resultCount - 1] != "..") {
-                                                       result.RemoveAt (resultCount - 1);
-                                                       continue;
-                                               }
-                                       }
-#endif
                                }
 
                                result.Add (current);
@@ -1836,17 +1698,10 @@ namespace System {
                
                internal static int GetDefaultPort (string scheme)
                {
-#if NET_2_0
                        UriParser parser = UriParser.GetParser (scheme);
                        if (parser == null)
                                return -1;
                        return parser.DefaultPort;
-#else
-                       for (int i = 0; i < schemes.Length; i++) 
-                               if (schemes [i].scheme == scheme)
-                                       return schemes [i].defaultPort;
-                       return -1;
-#endif
                }
 
                private string GetOpaqueWiseSchemeDelimiter ()
@@ -1857,9 +1712,7 @@ namespace System {
                                return GetSchemeDelimiter (scheme);
                }
 
-#if NET_2_0
                [Obsolete]
-#endif
                protected virtual bool IsBadFileSystemCharacter (char ch)
                {
                        // It does not always overlap with InvalidPathChars.
@@ -1882,9 +1735,7 @@ namespace System {
                        return false;
                }
 
-#if NET_2_0
                [Obsolete]
-#endif
                protected static bool IsExcludedCharacter (char ch)
                {
                        if (ch <= 32 || ch >= 127)
@@ -1921,19 +1772,15 @@ namespace System {
                        case "gopher":
                        case "mailto":
                        case "news":
-#if NET_2_0
                        case "net.pipe":
                        case "net.tcp":
-#endif
                                return true;
                        default:
                                return false;
                        }
                }
 
-#if NET_2_0
                [Obsolete]
-#endif
                protected virtual bool IsReservedCharacter (char ch)
                {
                        if (ch == '$' || ch == '&' || ch == '+' || ch == ',' ||
@@ -1942,7 +1789,7 @@ namespace System {
                                return true;
                        return false;
                }
-#if NET_2_0
+
                [NonSerialized]
                private UriParser parser;
 
@@ -2231,10 +2078,5 @@ namespace System {
                        if (!IsAbsoluteUri)
                                throw new InvalidOperationException ("This operation is not supported for a relative URI.");
                }
-#else
-               private void EnsureAbsoluteUri ()
-               {
-               }
-#endif
        }
 }
index cbf9446c37ea8c8ca4464cbfd20f696ee9f836d1..ea066b4f1d45146bf74420126d7179f95dae4ca2 100644 (file)
@@ -37,11 +37,12 @@ using System.Reflection;
 
 namespace System {
 
-#if NET_2_1 && !MONOTOUCH
-       public sealed class UriTypeConverter : TypeConverter {
-#else
-       public class UriTypeConverter : TypeConverter {
+       public
+#if MOONLIGHT
+       sealed
 #endif
+       class UriTypeConverter : TypeConverter {
+
                public UriTypeConverter ()
                {
                }
index 98d578110cce760a909b0beb64132b2c2e82d72b..354eca3153d92774bc2617a8b073a38a8dda1ca5 100644 (file)
@@ -1,4 +1,4 @@
-#include net_2_1_raw_System.dll.sources
+#include moonlight_raw_System.dll.sources
 ../../build/common/Consts.cs
 ../../build/common/Locale.cs
 ../../build/common/MonoTODOAttribute.cs
diff --git a/mcs/class/System/moonlight_bootstrap_System.dll.sources b/mcs/class/System/moonlight_bootstrap_System.dll.sources
new file mode 100644 (file)
index 0000000..f54a612
--- /dev/null
@@ -0,0 +1,6 @@
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+../../build/common/MonoTODOAttribute.cs
+../corlib/System.Collections/CollectionDebuggerView.cs
+../corlib/System.Collections.Generic/CollectionDebuggerView.cs
+#include moonlight_raw_System.dll.sources
diff --git a/mcs/class/System/moonlight_raw_System.dll.sources b/mcs/class/System/moonlight_raw_System.dll.sources
new file mode 100644 (file)
index 0000000..af6f2ec
--- /dev/null
@@ -0,0 +1,286 @@
+Assembly/AssemblyInfo.cs
+Mono.Http/NtlmClient.cs
+System.CodeDom.Compiler/GeneratedCodeAttribute.cs
+System.Collections.Generic/ISet.cs
+System.Collections.Generic/LinkedList.cs
+System.Collections.Generic/LinkedListNode.cs
+System.Collections.Generic/RBTree.cs
+System.Collections.Generic/Queue.cs
+System.Collections.Generic/SortedDictionary.cs
+System.Collections.Generic/SortedList.cs
+System.Collections.Generic/Stack.cs
+System.Collections.Specialized/BitVector32.cs
+System.Collections.Specialized/CollectionsUtil.cs
+System.Collections.Specialized/IOrderedDictionary.cs
+System.Collections.Specialized/ListDictionary.cs
+System.Collections.Specialized/HybridDictionary.cs
+System.Collections.Specialized/NameObjectCollectionBase.cs
+System.Collections.Specialized/NameValueCollection.cs
+System.Collections.Specialized/OrderedDictionary.cs
+System.Collections.Specialized/StringCollection.cs
+System.Collections.Specialized/StringDictionary.cs
+System.Collections.Specialized/StringEnumerator.cs
+System.ComponentModel/AsyncCompletedEventArgs.cs
+System.ComponentModel/AsyncCompletedEventHandler.cs
+System.ComponentModel/AsyncOperation.cs
+System.ComponentModel/AsyncOperationManager.cs
+System.ComponentModel/BackgroundWorker.cs
+System.ComponentModel/BrowsableAttribute.cs
+System.ComponentModel/CancelEventArgs.cs
+System.ComponentModel/CategoryAttribute.cs
+System.ComponentModel/ComponentCollection.cs
+System.ComponentModel/DefaultEventAttribute.cs
+System.ComponentModel/DefaultPropertyAttribute.cs
+System.ComponentModel/DefaultValueAttribute.cs
+System.ComponentModel/DescriptionAttribute.cs
+System.ComponentModel/DoWorkEventHandler.cs
+System.ComponentModel/DoWorkEventArgs.cs
+System.ComponentModel/EditorAttribute.cs
+System.ComponentModel/EditorBrowsableAttribute.cs
+System.ComponentModel/EditorBrowsableState.cs
+System.ComponentModel/IChangeTracking.cs
+System.ComponentModel/IContainer.cs
+System.ComponentModel/IComponent.cs
+System.ComponentModel/IDataErrorInfo.cs
+System.ComponentModel/IEditableObject.cs
+System.ComponentModel/INotifyPropertyChanged.cs
+System.ComponentModel/InvalidEnumArgumentException.cs
+System.ComponentModel/IRevertibleChangeTracking.cs
+System.ComponentModel/ISite.cs
+System.ComponentModel/ISynchronizeInvoke.cs
+System.ComponentModel/ITypeDescriptorContext.cs
+System.ComponentModel/ListSortDirection.cs
+System.ComponentModel/ProgressChangedEventHandler.cs
+System.ComponentModel/ProgressChangedEventArgs.cs
+System.ComponentModel/PropertyChangedEventArgs.cs
+System.ComponentModel/PropertyChangedEventHandler.cs
+System.ComponentModel/PropertyDescriptor.cs
+System.ComponentModel/ReadOnlyAttribute.cs
+System.ComponentModel/RecommendedAsConfigurableAttribute.cs
+System.ComponentModel/RunWorkerCompletedEventArgs.cs
+System.ComponentModel/RunWorkerCompletedEventHandler.cs
+System.ComponentModel/TypeConverterAttribute.cs
+System.ComponentModel/TypeConverter_2_1.cs
+System/DefaultUriParser.cs
+System.Diagnostics/Debug_2_1.cs
+System/FileStyleUriParser.cs
+System/FtpStyleUriParser.cs
+System/GenericUriParser.cs
+System/GenericUriParserOptions.cs
+System/GopherStyleUriParser.cs
+System/HttpStyleUriParser.cs
+System/UriIdnScope.cs
+System/UriTypeConverter.cs
+System.IO.Compression/CompressionMode.cs
+System.IO.Compression/DeflateStream.cs
+System.IO.Compression/GZipStream.cs
+System.IO/ErrorEventArgs.cs
+System.IO/ErrorEventHandler.cs
+System.IO/FileAction.cs
+System.IO/FileSystemEventArgs.cs
+System.IO/FileSystemEventHandler.cs
+System.IO/InternalBufferOverflowException.cs
+System.IO/InvalidDataException.cs
+System.IO/IODescriptionAttribute.cs
+System.IO/MonoIO.cs
+System.IO/MonoIOError.cs
+System.IO/MonoSyncFileStream.cs
+System.IO/NotifyFilters.cs
+System.IO/RenamedEventArgs.cs
+System.IO/RenamedEventHandler.cs
+System.IO/SearchPattern.cs
+System.IO/WaitForChangedResult.cs
+System.IO/WatcherChangeTypes.cs
+System/IUriData.cs
+System/LdapStyleUriParser.cs
+System.Net/AuthenticationManager.cs
+System.Net/AuthenticationSchemes.cs
+System.Net/AuthenticationSchemeSelector.cs
+System.Net/Authorization.cs
+System.Net/BasicClient.cs
+System.Net/BindIPEndPoint.cs
+System.Net.Cache/HttpCacheAgeControl.cs
+System.Net.Cache/HttpRequestCacheLevel.cs
+System.Net.Cache/HttpRequestCachePolicy.cs
+System.Net.Cache/RequestCacheLevel.cs
+System.Net.Cache/RequestCachePolicy.cs
+System.Net/ChunkedInputStream.cs
+System.Net/ChunkStream.cs
+System.Net/ConnectionModes.cs
+System.Net/CookieCollection.cs
+System.Net/CookieContainer.cs
+System.Net/Cookie.cs
+System.Net/CookieException.cs
+System.Net/CredentialCache.cs
+System.Net/DecompressionMethods.cs
+System.Net/DefaultCertificatePolicy.cs
+System.Net/DigestClient.cs
+System.Net/Dns.cs
+System.Net/DnsEndPoint.cs
+System.Net/EndPoint.cs
+System.Net/GlobalProxySelection.cs
+System.Net/HttpConnection.cs
+System.Net/HttpContinueDelegate.cs
+System.Net/HttpRequestCreator.cs
+System.Net/HttpRequestHeader.cs
+System.Net/HttpResponseHeader.cs
+System.Net/HttpStatusCode.cs
+System.Net/HttpStreamAsyncResult.cs
+System.Net/HttpUtility.cs
+System.Net/HttpVersion.cs
+System.Net/HttpWebRequest.cs
+System.Net/HttpWebResponse.cs
+System.Net/IAuthenticationModule.cs
+System.Net/ICertificatePolicy.cs
+System.Net/ICredentialLookup.cs
+System.Net/ICredentialPolicy.cs
+System.Net/ICredentialsByHost.cs
+System.Net/IPAddress.cs
+System.Net/IPEndPoint.cs
+System.Net/IPHostEntry.cs
+System.Net/IPv6Address.cs
+System.Net/IWebProxy.cs
+System.Net/IWebProxyScript.cs
+System.Net/IWebRequestCreate.cs
+System.Net/ListenerAsyncResult.cs
+System.Net/ListenerPrefix.cs
+System.Net/MonoHttpDate.cs
+System.Net/NetworkAccess.cs
+System.Net/NetworkCredential.cs
+System.Net/NtlmClient.cs
+System/NetPipeStyleUriParser.cs
+System.Net/ProtocolViolationException.cs
+System.Net/RequestStream.cs
+System.Net/ResponseStream.cs
+System.Net.Security/AuthenticatedStream.cs
+System.Net.Security/AuthenticationLevel.cs
+System.Net.Security/LocalCertificateSelectionCallback.cs
+System.Net.Security/ProtectionLevel.cs
+System.Net/SecurityProtocolType.cs
+System.Net.Security/RemoteCertificateValidationCallback.cs
+System.Net.Security/SslStream.cs
+System.Net.Security/SslPolicyErrors.cs
+System.Net/ServicePoint.cs
+System.Net/ServicePointManager.cs
+System.Net/SocketAddress.cs
+System.Net.Sockets/AddressFamily.cs
+System.Net.Sockets/IOControlCode.cs
+System.Net.Sockets/IPv6MulticastOption.cs
+System.Net.Sockets/IPPacketInformation.cs
+System.Net.Sockets/LingerOption.cs
+System.Net.Sockets/MulticastOption.cs
+System.Net.Sockets/NetworkStream.cs
+System.Net.Sockets/ProtocolFamily.cs
+System.Net.Sockets/ProtocolType.cs
+System.Net.Sockets/SelectMode.cs
+System.Net.Sockets/SendPacketsElement.cs
+System.Net.Sockets/Socket.cs
+System.Net.Sockets/Socket_2_1.cs
+System.Net.Sockets/SocketAsyncEventArgs.cs
+System.Net.Sockets/SocketAsyncOperation.cs
+System.Net.Sockets/SocketError.cs
+../System.Net/System.Net.Sockets/SocketException_2_1.cs
+System.Net.Sockets/SocketFlags.cs
+System.Net.Sockets/SocketInformation.cs
+System.Net.Sockets/SocketInformationOptions.cs
+System.Net.Sockets/SocketOptionLevel.cs
+System.Net.Sockets/SocketOptionName.cs
+System.Net.Sockets/SocketShutdown.cs
+System.Net.Sockets/SocketType.cs
+System.Net.Sockets/TcpClient.cs
+System.Net.Sockets/TcpListener.cs
+System.Net.Sockets/TransmitFileOptions.cs
+System.Net.Sockets/UdpClient.cs
+System/NetTcpStyleUriParser.cs
+System.Net/TransportType.cs
+System.Net/WebAsyncResult.cs
+System.Net/WebConnection.cs
+System.Net/WebConnectionData.cs
+System.Net/WebConnectionGroup.cs
+System.Net/WebConnectionStream.cs
+System.Net/WebException.cs
+System.Net/WebExceptionStatus.cs
+System.Net/WebHeaderCollection.cs
+System.Net/WebProxy.cs
+System.Net/WebRequest.cs
+System.Net/WebRequestMethods.cs
+System.Net/WebResponse.cs
+System/NewsStyleUriParser.cs
+System.Security.Authentication/AuthenticationException.cs
+System.Security.Authentication/CipherAlgorithmType.cs
+System.Security.Authentication/ExchangeAlgorithmType.cs
+System.Security.Authentication/HashAlgorithmType.cs
+System.Security.Authentication/SslProtocols.cs
+System.Security.Authentication/InvalidCredentialException.cs
+System.Security.Cryptography.X509Certificates/OpenFlags.cs
+System.Security.Cryptography.X509Certificates/PublicKey.cs
+System.Security.Cryptography.X509Certificates/StoreLocation.cs
+System.Security.Cryptography.X509Certificates/StoreName.cs
+System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs
+System.Security.Cryptography.X509Certificates/X500DistinguishedNameFlags.cs
+System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.cs
+System.Security.Cryptography.X509Certificates/X509Certificate2Collection.cs
+System.Security.Cryptography.X509Certificates/X509Certificate2.cs
+System.Security.Cryptography.X509Certificates/X509Certificate2Enumerator.cs
+System.Security.Cryptography.X509Certificates/X509CertificateCollection.cs
+System.Security.Cryptography.X509Certificates/X509Chain.cs
+System.Security.Cryptography.X509Certificates/X509ChainElementCollection.cs
+System.Security.Cryptography.X509Certificates/X509ChainElement.cs
+System.Security.Cryptography.X509Certificates/X509ChainElementEnumerator.cs
+System.Security.Cryptography.X509Certificates/X509ChainPolicy.cs
+System.Security.Cryptography.X509Certificates/X509ChainStatus.cs
+System.Security.Cryptography.X509Certificates/X509ChainStatusFlags.cs
+System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs
+System.Security.Cryptography.X509Certificates/X509ExtensionCollection.cs
+System.Security.Cryptography.X509Certificates/X509Extension.cs
+System.Security.Cryptography.X509Certificates/X509ExtensionEnumerator.cs
+System.Security.Cryptography.X509Certificates/X509FindType.cs
+System.Security.Cryptography.X509Certificates/X509IncludeOption.cs
+System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.cs
+System.Security.Cryptography.X509Certificates/X509KeyUsageFlags.cs
+System.Security.Cryptography.X509Certificates/X509NameType.cs
+System.Security.Cryptography.X509Certificates/X509RevocationFlag.cs
+System.Security.Cryptography.X509Certificates/X509RevocationMode.cs
+System.Security.Cryptography.X509Certificates/X509Store.cs
+System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs
+System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierHashAlgorithm.cs
+System.Security.Cryptography.X509Certificates/X509VerificationFlags.cs
+System/SRDescriptionAttribute.cs
+System.Text.RegularExpressions/arch.cs
+System.Text.RegularExpressions/BaseMachine.cs
+System.Text.RegularExpressions/cache.cs
+System.Text.RegularExpressions/CaptureCollection.cs
+System.Text.RegularExpressions/Capture.cs
+System.Text.RegularExpressions/category.cs
+System.Text.RegularExpressions/compiler.cs
+System.Text.RegularExpressions/debug.cs
+System.Text.RegularExpressions/GroupCollection.cs
+System.Text.RegularExpressions/Group.cs
+System.Text.RegularExpressions/interpreter.cs
+System.Text.RegularExpressions/interval.cs
+System.Text.RegularExpressions/MatchCollection.cs
+System.Text.RegularExpressions/Match.cs
+System.Text.RegularExpressions/MatchEvaluator.cs
+System.Text.RegularExpressions/parser.cs
+System.Text.RegularExpressions/quicksearch.cs
+System.Text.RegularExpressions/RegexCompilationInfo.cs
+System.Text.RegularExpressions/Regex.cs
+System.Text.RegularExpressions/RegexOptions.cs
+System.Text.RegularExpressions/RxInterpreter.cs
+System.Text.RegularExpressions/RxOp.cs
+System.Text.RegularExpressions/replace.cs
+System.Text.RegularExpressions/syntax.cs
+System.Timers/ElapsedEventArgs.cs
+System.Timers/ElapsedEventHandler.cs
+System.Timers/Timer.cs
+System.Timers/TimersDescriptionAttribute.cs
+System/UriBuilder.cs
+System/UriComponents.cs
+System/Uri.cs
+System/UriData.cs
+System/UriFormat.cs
+System/UriFormatException.cs
+System/UriHostNameType.cs
+System/UriKind.cs
+System/UriParser.cs
+System/UriPartial.cs
diff --git a/mcs/class/System/net_2_1_bootstrap_System.dll.sources b/mcs/class/System/net_2_1_bootstrap_System.dll.sources
deleted file mode 100644 (file)
index 5482dc9..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-../../build/common/Consts.cs
-../../build/common/Locale.cs
-../../build/common/MonoTODOAttribute.cs
-#include net_2_1_raw_System.dll.sources
diff --git a/mcs/class/System/net_2_1_raw_System.dll.sources b/mcs/class/System/net_2_1_raw_System.dll.sources
deleted file mode 100644 (file)
index 8f6c217..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-Assembly/AssemblyInfo.cs
-System.CodeDom.Compiler/GeneratedCodeAttribute.cs
-System.Collections.Generic/ISet.cs
-System.Collections.Generic/LinkedList.cs
-System.Collections.Generic/LinkedListNode.cs
-System.Collections.Generic/RBTree.cs
-System.Collections.Generic/Queue.cs
-System.Collections.Generic/SortedDictionary.cs
-System.Collections.Generic/SortedList.cs
-System.Collections.Generic/Stack.cs
-System.Collections.Specialized/BitVector32.cs
-System.Collections.Specialized/CollectionsUtil.cs
-System.Collections.Specialized/ListDictionary.cs
-System.Collections.Specialized/HybridDictionary.cs
-System.Collections.Specialized/StringDictionary.cs
-System.ComponentModel/AsyncCompletedEventArgs.cs
-System.ComponentModel/AsyncCompletedEventHandler.cs
-System.ComponentModel/AsyncOperation.cs
-System.ComponentModel/AsyncOperationManager.cs
-System.ComponentModel/BackgroundWorker.cs
-System.ComponentModel/CancelEventArgs.cs
-System.ComponentModel/CategoryAttribute.cs
-System.ComponentModel/ComponentCollection.cs
-System.ComponentModel/DefaultValueAttribute.cs
-System.ComponentModel/DescriptionAttribute.cs
-System.ComponentModel/DoWorkEventHandler.cs
-System.ComponentModel/DoWorkEventArgs.cs
-System.ComponentModel/EditorBrowsableAttribute.cs
-System.ComponentModel/EditorBrowsableState.cs
-System.ComponentModel/IChangeTracking.cs
-System.ComponentModel/IContainer.cs
-System.ComponentModel/IComponent.cs
-System.ComponentModel/IDataErrorInfo.cs
-System.ComponentModel/IEditableObject.cs
-System.ComponentModel/INotifyPropertyChanged.cs
-System.ComponentModel/InvalidEnumArgumentException.cs
-System.ComponentModel/IRevertibleChangeTracking.cs
-System.ComponentModel/ISite.cs
-System.ComponentModel/ITypeDescriptorContext.cs
-System.ComponentModel/ListSortDirection.cs
-System.ComponentModel/ProgressChangedEventHandler.cs
-System.ComponentModel/ProgressChangedEventArgs.cs
-System.ComponentModel/PropertyChangedEventArgs.cs
-System.ComponentModel/PropertyChangedEventHandler.cs
-System.ComponentModel/PropertyDescriptor.cs
-System.ComponentModel/ReadOnlyAttribute.cs
-System.ComponentModel/RunWorkerCompletedEventArgs.cs
-System.ComponentModel/RunWorkerCompletedEventHandler.cs
-System.ComponentModel/TypeConverterAttribute.cs
-System.ComponentModel/TypeConverter_2_1.cs
-System/DefaultUriParser.cs
-System.Diagnostics/Debug_2_1.cs
-System/FileStyleUriParser.cs
-System/FtpStyleUriParser.cs
-System/GenericUriParser.cs
-System/GenericUriParserOptions.cs
-System/HttpStyleUriParser.cs
-System/UriIdnScope.cs
-System/UriTypeConverter.cs
-System.Net/IPAddress.cs
-System.Net/IPv6Address.cs
-System.Net.Sockets/AddressFamily.cs
-System/SRDescriptionAttribute.cs
-System.Text.RegularExpressions/arch.cs
-System.Text.RegularExpressions/BaseMachine.cs
-System.Text.RegularExpressions/cache.cs
-System.Text.RegularExpressions/CaptureCollection.cs
-System.Text.RegularExpressions/Capture.cs
-System.Text.RegularExpressions/category.cs
-System.Text.RegularExpressions/compiler.cs
-System.Text.RegularExpressions/debug.cs
-System.Text.RegularExpressions/GroupCollection.cs
-System.Text.RegularExpressions/Group.cs
-System.Text.RegularExpressions/interpreter.cs
-System.Text.RegularExpressions/interval.cs
-System.Text.RegularExpressions/MatchCollection.cs
-System.Text.RegularExpressions/Match.cs
-System.Text.RegularExpressions/MatchEvaluator.cs
-System.Text.RegularExpressions/parser.cs
-System.Text.RegularExpressions/quicksearch.cs
-System.Text.RegularExpressions/RegexCompilationInfo.cs
-System.Text.RegularExpressions/Regex.cs
-System.Text.RegularExpressions/RegexOptions.cs
-System.Text.RegularExpressions/RxInterpreter.cs
-System.Text.RegularExpressions/RxOp.cs
-System.Text.RegularExpressions/replace.cs
-System.Text.RegularExpressions/syntax.cs
-System/UriBuilder.cs
-System/UriComponents.cs
-System/Uri.cs
-System/UriFormat.cs
-System/UriFormatException.cs
-System/UriHostNameType.cs
-System/UriKind.cs
-System/UriParser.cs
-System/UriPartial.cs
-
-../corlib/System.Collections/CollectionDebuggerView.cs
-../corlib/System.Collections.Generic/CollectionDebuggerView.cs
index bc52da976a966b425677e8a03daf84c93227c9db..3b68189f0bdd8973a4a22356d239d0011ca8ccce 100644 (file)
@@ -79,7 +79,7 @@ using System.Runtime.InteropServices;
        [assembly: DefaultDependency (LoadHint.Always)]
        [assembly: StringFreezing]
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
        [assembly: InternalsVisibleTo ("System, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
        [assembly: InternalsVisibleTo ("System.Windows, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
        [assembly: InternalsVisibleTo ("System.Windows.Browser, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
index e35c3ac83f926b1fc499093ac007fece56273922..d1f7178414d0ceef3ed94eba17ae572fdadcc1b6 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * AssemblyInfo.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2010-02-09  Sebastien Pouliot  <sebastien@ximian.com>
 
        * AssemblyInfo.cs: Mono.CompilerServices.SymbolWriter does not
index 57e212107bf1206e7e419e003bf788f09f539b90..afa11bd5aa188bf19fa08701b10902ba98222d61 100644 (file)
@@ -1,3 +1,19 @@
+2010-03-26  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * moonlight_raw_corlib.dll.sources: Add MonoAssembly to ML build
+       since it contains parts of the Assembly features (partial class)
+
+2010-03-18  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * corlib.dll.sources: Add Aes (for NET_4_0)
+       * moonlight_raw_corlib.dll.sources: Add Aes and System.Runtime.
+       CompilerServices/ReferenceAssemblyAttribute.cs
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: rename the net_2_1 profile to moonlight.
+       * net_2_1_*.dll.sources: rename to moonlight_*.dll.sources.
+
 2010-03-11  Sebastien Pouliot  <sebastien@ximian.com>
 
        * net_2_1_raw_corlib.dll.sources: Add System.Diagnostics.Contracts
index 820468c9380fcd1966a8dd8a0276f5b11b206c3e..4206ae2742ab1fd2622d311ab7771fdebe757575 100644 (file)
@@ -75,11 +75,3 @@ $(cmp_makefrag): $(cmp_response)
 
 $(cmp_response) $(cmp_makefrag): Makefile $(depsdir)/.stamp
 endif
-
-#
-# qh21 = Quick Hack for 2.1, to be used by impatient developers to get
-# test builds done quickly
-#
-qh21:
-       make PROFILE=net_2_1_raw
-       (cd ../../tools/tuner; rm tune.stamp; make tune.stamp && make PROFILE=net_2_1 install)
index bd7ee4b69c43b67eb070aa43dbd172f6372855e6..c766628f6fcdffe440286567bf94b9e4254f072c 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System;
 using System.IO;
index 389b01ddd7fc993eb492799435b9431917147999..647fd419659486bdc75dda78b5744ecb80505f86 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System;
 using System.IO;
index e1b8d247c02caf1be64bf215cddaf1bfe6fadba7..07ce4c9f149c46f7f9f39a0927d5314df08aeb17 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * AuthenticodeBase.cs, AuthenticodeDeformatter.cs: use MOONLIGHT
+       symbol to disambiguate MonoTouch and Moonlight code.
+
 2009-04-30  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * AuthenticodeBase.cs, AuthenticodeDeformatter.cs: Remove from NET_2_1
index 269daa3f55d069f2847c6f7ea610943a6b34a3f2..6ea278738869ffe05ba612b3585c39460f82e893 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * CryptoTools.cs, PKCS1.cs, PKCS8.cs, SymmetricTransform.cs,
+       KeyPairPersistence.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2009-09-18  Sebastien Pouliot  <sebastien@ximian.com>
 
        * PKCS1.cs: Fix compiler warning for NET_2_1
index e79dc6f1564cf3efa5aea4aacc56a5f62b61573e..a39cd48f292e2a933727a165df60d3be4fd20b8e 100644 (file)
@@ -48,7 +48,7 @@ namespace Mono.Security.Cryptography {
 
                static RandomNumberGenerator Rng {
                        get {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                if (rng == null)
                                        rng = new RNGCryptoServiceProvider ();
 #else
index 9a2cad9ba6c99df20f6897aadfbda34cd156ea10..ac694bb5ef0d1d2721a43743de6e688ef642e00f 100644 (file)
@@ -26,7 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System;
 using System.Globalization;
index dc2e8389b3038b4dd7556ad6405d8097045b117b..6cf82682f7be2d92c319b1be2931d1a375bfd17d 100644 (file)
@@ -68,7 +68,7 @@ namespace Mono.Security.Cryptography {
        
                private static byte[] emptySHA1   = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09 };
                private static byte[] emptySHA256 = { 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55 };
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                private static byte[] emptySHA384 = { 0x38, 0xb0, 0x60, 0xa7, 0x51, 0xac, 0x96, 0x38, 0x4c, 0xd9, 0x32, 0x7e, 0xb1, 0xb1, 0xe3, 0x6a, 0x21, 0xfd, 0xb7, 0x11, 0x14, 0xbe, 0x07, 0x43, 0x4c, 0x0c, 0xc7, 0xbf, 0x63, 0xf6, 0xe1, 0xda, 0x27, 0x4e, 0xde, 0xbf, 0xe7, 0x6f, 0x65, 0xfb, 0xd5, 0x1a, 0xd2, 0xf1, 0x48, 0x98, 0xb9, 0x5b };
                private static byte[] emptySHA512 = { 0xcf, 0x83, 0xe1, 0x35, 0x7e, 0xef, 0xb8, 0xbd, 0xf1, 0x54, 0x28, 0x50, 0xd6, 0x6d, 0x80, 0x07, 0xd6, 0x20, 0xe4, 0x05, 0x0b, 0x57, 0x15, 0xdc, 0x83, 0xf4, 0xa9, 0x21, 0xd3, 0x6c, 0xe9, 0xce, 0x47, 0xd0, 0xd1, 0x3c, 0x5d, 0x85, 0xf2, 0xb0, 0xff, 0x83, 0x18, 0xd2, 0x87, 0x7e, 0xec, 0x2f, 0x63, 0xb9, 0x31, 0xbd, 0x47, 0x41, 0x7a, 0x81, 0xa5, 0x38, 0x32, 0x7a, 0xf9, 0x27, 0xda, 0x3e };
 #endif
@@ -79,7 +79,7 @@ namespace Mono.Security.Cryptography {
                                return emptySHA1;
                        else if (hash is SHA256)
                                return emptySHA256;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        else if (hash is SHA384)
                                return emptySHA384;
                        else if (hash is SHA512)
index 577c8310be29f44daed0e3c9f8e8e2f584914c60..84b830f245835b9db8069e4f126f7261a636fa1f 100644 (file)
@@ -272,7 +272,7 @@ namespace Mono.Security.Cryptography {
                                param.InverseQ = Normalize (privateKey [8].Value, keysize2);
                                param.P = Normalize (privateKey [4].Value, keysize2);
                                param.Q = Normalize (privateKey [5].Value, keysize2);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                RSA rsa = RSA.Create ();
                                rsa.ImportParameters (param);
 #else
index 49982ba229ac9ff3886f82a0092af6406123ad5c..bda13d875c517bb0d079b9f005f7b311c332d528 100644 (file)
@@ -50,7 +50,7 @@ namespace Mono.Security.Cryptography {
                private byte[] temp2;
                private byte[] workBuff;
                private byte[] workout;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // Silverlight 2.0 does not support any feedback mode
                private int FeedBackByte;
                private int FeedBackIter;
@@ -79,7 +79,7 @@ namespace Mono.Security.Cryptography {
                        temp = new byte [BlockSizeByte];
                        Buffer.BlockCopy (rgbIV, 0, temp, 0, System.Math.Min (BlockSizeByte, rgbIV.Length));
                        temp2 = new byte [BlockSizeByte];
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        FeedBackByte = (algo.FeedbackSize >> 3);
                        if (FeedBackByte != 0)
                                FeedBackIter = (int) BlockSizeByte / FeedBackByte;
@@ -136,7 +136,7 @@ namespace Mono.Security.Cryptography {
                // i.e. Any padding must be done before calling this method
                protected virtual void Transform (byte[] input, byte[] output) 
                {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // Silverlight 2.0 only supports CBC
                        CBC (input, output);
 #else
@@ -183,7 +183,7 @@ namespace Mono.Security.Cryptography {
                        }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // Cipher-FeedBack (CFB)
                protected virtual void CFB (byte[] input, byte[] output) 
                {
@@ -254,7 +254,7 @@ namespace Mono.Security.Cryptography {
 
                        // ordered to avoid possible integer overflow
                        int len = outputBuffer.Length - inputCount - outputOffset;
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // only PKCS7 is supported Silverlight 2.0
                        if (KeepLastBlock) {
 #else
@@ -279,7 +279,7 @@ namespace Mono.Security.Cryptography {
 
                private bool KeepLastBlock {
                        get {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                // only PKCS7 is supported Silverlight 2.0
                                return !encrypt;
 #else
@@ -334,7 +334,7 @@ namespace Mono.Security.Cryptography {
                        return total;
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                RandomNumberGenerator _rng;
 
                private void Random (byte[] buffer, int start, int length)
@@ -365,7 +365,7 @@ namespace Mono.Security.Cryptography {
                        int rem = inputCount - full;
                        int total = full;
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // only PKCS7 is supported Silverlight 2.0
                        total += BlockSizeByte;
 #else
@@ -407,7 +407,7 @@ namespace Mono.Security.Cryptography {
 
                        // now we only have a single last block to encrypt
                        byte padding = (byte) (BlockSizeByte - rem);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // only PKCS7 is supported Silverlight 2.0
                        for (int i = res.Length; --i >= (res.Length - padding);) 
                                res [i] = padding;
@@ -474,7 +474,7 @@ namespace Mono.Security.Cryptography {
 
                        // total may be 0 (e.g. PaddingMode.None)
                        byte padding = ((total > 0) ? res [total - 1] : (byte) 0);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // only PKCS7 is supported Silverlight 2.0
                        if ((padding == 0) || (padding > BlockSizeByte))
                                throw new CryptographicException (Locale.GetText ("Bad padding length."));
index 23e3e27ca28435513fbb3a4d9e81a380d0ca9306..96c08c9e9a5efb34db298e3b77c608b87912d6e5 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * X509Certificate.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2009-04-30  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * X509Certificate.cs: Adapt to work with only [DSA|RSA]Managed when
index fd8d8d9164c6580ba7ad0aafa1e540c6d5997a64..e1f5f9b2286423f8f11b15051ef38e4ac971b6b4 100644 (file)
@@ -267,7 +267,7 @@ namespace Mono.Security.X509 {
                                        // BUG: MS BCL 1.0 can't import a key which 
                                        // isn't the same size as the one present in
                                        // the container.
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                        _dsa = new DSAManaged (dsaParams.Y.Length << 3);
 #else
                                        _dsa = (DSA) new DSACryptoServiceProvider (dsaParams.Y.Length << 3);
@@ -367,7 +367,7 @@ namespace Mono.Security.X509 {
                                        // isn't the same size as the one present in
                                        // the container.
                                        int keySize = (rsaParams.Modulus.Length << 3);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                        _rsa = new RSAManaged (keySize);
 #else
                                        _rsa = (RSA) new RSACryptoServiceProvider (keySize);
@@ -544,7 +544,7 @@ namespace Mono.Security.X509 {
 
                public bool CheckSignature (byte[] hash, string hashAlgorithm, byte[] signature) 
                {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        string hashName = GetHashNameFromOID (hashAlgorithm);
                        HashAlgorithm algo = HashAlgorithm.Create (hashName);
                        return PKCS1.Verify_v15 (RSA, algo, hash, signature);
index c878a999eacc0b5e21d4d57f24694283e50fa37c..3a1cf930183b92155e5fd1b872a803f6496de0e5 100644 (file)
@@ -206,7 +206,7 @@ namespace Mono.Security {
                                        mask = "yyyyMMddHHmmsszzz";
                                        break;
                        }
-                       return DateTime.ParseExact (t, mask, null, DateTimeStyles.AdjustToUniversal);
+                       return DateTime.ParseExact (t, mask, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
                }
        }
 }
index 6f406ac13a5c641de0110bb88736ac3ffe9fa6ef..9fe0c26ef4750b4f93a08b8564784e455552b954 100644 (file)
@@ -1,3 +1,13 @@
+2010-03-24  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ASN1Convert.cs: Specify CultureInfo.InvariantCulture (instead of 
+       null) to avoid crash on Windows. Patch by Yoni Shalom.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * StrongName.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2009-09-22  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * StrongName.cs: Moonlight NET_2_1 cannot depend on machine.config
index 64a1a38092e8d22904e0b0252fe9bb618526e4c9..2905a03c125c4a9302b0249f588504d2d4bae5cd 100644 (file)
@@ -160,7 +160,7 @@ namespace Mono.Security {
                        get {
                                if (rsa == null)
                                        return false;
-#if INSIDE_CORLIB && (!NET_2_1 || MONOTOUCH)
+#if INSIDE_CORLIB && !MOONLIGHT
                                // the easy way
                                if (RSA is RSACryptoServiceProvider) {
                                        // available as internal for corlib
index 953c63fc2a16929915d7de6d2d1401b3be8c06ac..920c545e6f701ce98255cc942a2491799c47a705 100644 (file)
@@ -59,7 +59,7 @@ namespace Mono {
                which produces faster code.
                */
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               internal static extern object NewObject (RuntimeTypeHandle h);
+               internal static extern object NewObject (IntPtr h);
        }
        
 }
index a180eb6fee11b04d78e59ebc6885c4835cd147cc..7bf258b8f23ea62143efbf1826e202a936d8ca5d 100644 (file)
@@ -1,3 +1,22 @@
+2010-03-24  Jérémie Laval  <jeremie.laval@gmail.com>
+
+       * ConcurrentDictionary.cs: Remove while looping
+
+2010-03-24  Jérémie Laval  <jeremie.laval@gmail.com>
+
+       * ConcurrentDictionary.cs: Enable tracking on SpinLock
+       * ConcurrentSkipList.cs: Use Spinlock instead of Monitor and
+       refactor to use a saner lock acquiring scheme.
+
+2010-03-24  Jérémie Laval  <jeremie.laval@gmail.com>
+
+       * ConcurrentDictionary.cs: Fix lock releasing
+
+2010-03-24  Jérémie Laval  <jeremie.laval@gmail.com>
+
+       * ConcurrentDictionary.cs: Use SpinLock instead of Monitor
+       for basket locking
+
 2010-02-02  Jérémie Laval  <jeremie.laval@gmail.com>
 
        * ConcurrentDictionary.cs:
index 3bc6d5c10577e49ca1eb7c22c6176ba952591a55..bf4e160a430e994a1daad94ab136b1cf2b519cf4 100644 (file)
@@ -31,116 +31,123 @@ using System.Runtime.Serialization;
 
 namespace System.Collections.Concurrent
 {
-       public class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>, 
-         ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, 
+       public class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>,
+         ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>,
          IDictionary, ICollection, IEnumerable
        {
                class Pair
                {
                        public readonly TKey Key;
                        public TValue Value;
-                       
+
                        public Pair (TKey key, TValue value)
                        {
                                Key = key;
                                Value = value;
                        }
-                       
+
                        public override bool Equals (object obj)
                        {
                                Pair rhs = obj as Pair;
                                return rhs == null ? false : Key.Equals (rhs.Key) && Value.Equals (rhs.Value);
                        }
-                       
+
                        public override int GetHashCode ()
                        {
                                return Key.GetHashCode ();
                        }
                }
-               
+
                class Basket: List<Pair>
                {
+                       public SpinLock Lock = new SpinLock (true);
                }
-               
+
                // Assumption: a List<T> is never empty
                ConcurrentSkipList<Basket> container
                        = new ConcurrentSkipList<Basket> ((value) => value[0].GetHashCode ());
                int count;
                IEqualityComparer<TKey> comparer;
-               
+
                public ConcurrentDictionary () : this (EqualityComparer<TKey>.Default)
                {
                }
-               
+
                public ConcurrentDictionary (IEnumerable<KeyValuePair<TKey, TValue>> values)
                        : this (values, EqualityComparer<TKey>.Default)
                {
                        foreach (KeyValuePair<TKey, TValue> pair in values)
                                Add (pair.Key, pair.Value);
                }
-               
+
                public ConcurrentDictionary (IEqualityComparer<TKey> comparer)
                {
                        this.comparer = comparer;
                }
-               
+
                public ConcurrentDictionary (IEnumerable<KeyValuePair<TKey, TValue>> values, IEqualityComparer<TKey> comparer)
                        : this (comparer)
-               {                       
+               {
                        foreach (KeyValuePair<TKey, TValue> pair in values)
                                Add (pair.Key, pair.Value);
                }
-               
+
                // Parameters unused
                public ConcurrentDictionary (int concurrencyLevel, int capacity)
                        : this (EqualityComparer<TKey>.Default)
                {
-                       
+
                }
-               
-               public ConcurrentDictionary (int concurrencyLevel, 
+
+               public ConcurrentDictionary (int concurrencyLevel,
                                             IEnumerable<KeyValuePair<TKey, TValue>> values,
                                             IEqualityComparer<TKey> comparer)
                        : this (values, comparer)
                {
-                       
+
                }
-               
+
                // Parameters unused
                public ConcurrentDictionary (int concurrencyLevel, int capacity, IEqualityComparer<TKey> comparer)
                        : this (comparer)
                {
-                       
+
                }
-               
+
                void Add (TKey key, TValue value)
                {
                        while (!TryAdd (key, value));
                }
-               
+
                void IDictionary<TKey, TValue>.Add (TKey key, TValue value)
                {
                        Add (key, value);
                }
-               
+
                public bool TryAdd (TKey key, TValue value)
-               {                       
+               {
                        Basket basket;
+                       bool taken = false;
+
                        // Add a value to an existing basket
                        if (TryGetBasket (key, out basket)) {
-                               // Find a maybe more sexy locking scheme later
-                               lock (basket) {
+                               try {
+                                       basket.Lock.Enter (ref taken);
+
                                        foreach (var p in basket) {
                                                if (comparer.Equals (p.Key, key))
-                                                       throw new ArgumentException ("An element with the same key already exists");
+                                                       return false;
                                        }
                                        basket.Add (new Pair (key, value));
+                               } finally {
+                                       if (taken)
+                                               basket.Lock.Exit ();
                                }
                        } else {
                                // Add a new basket
                                basket = new Basket ();
                                basket.Add (new Pair (key, value));
-                               
+
                                if (container.TryAdd (basket)) {
                                        Interlocked.Increment (ref count);
                                        return true;
@@ -148,41 +155,47 @@ namespace System.Collections.Concurrent
                                        return false;
                                }
                        }
-                       
+
                        Interlocked.Increment (ref count);
-                       
+
                        return true;
                }
-               
+
                void ICollection<KeyValuePair<TKey,TValue>>.Add (KeyValuePair<TKey, TValue> pair)
                {
                        Add (pair.Key, pair.Value);
                }
-               
+
                public TValue AddOrUpdate (TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)
                {
                        Basket basket;
-                       TValue temp;
-                       
+                       TValue temp = default (TValue);
+                       bool taken = false;
+
                        if (!TryGetBasket (key, out basket)) {
                                Add (key, (temp = addValueFactory (key)));
                        } else {
-                               lock (basket) {
+                               try {
+                                       basket.Lock.Enter (ref taken);
+
                                        Pair pair = basket.Find ((p) => comparer.Equals (p.Key, key));
                                        if (pair == null)
                                                throw new InvalidOperationException ("pair is null, shouldn't be");
                                        pair.Value = (temp = updateValueFactory (key, pair.Value));
+                               } finally {
+                                       if (taken)
+                                               basket.Lock.Exit ();
                                }
                        }
-                       
+
                        return temp;
                }
-               
+
                public TValue AddOrUpdate (TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
                {
                        return AddOrUpdate (key, (_) => addValue, updateValueFactory);
                }
-               
+
                TValue GetValue (TKey key)
                {
                        TValue temp;
@@ -191,98 +204,129 @@ namespace System.Collections.Concurrent
                                throw new ArgumentException ("Not a valid key for this dictionary", "key");
                        return temp;
                }
-               
+
                public bool TryGetValue (TKey key, out TValue value)
                {
                        Basket basket;
                        value = default (TValue);
-                       
+                       bool taken = false;
+
                        if (!TryGetBasket (key, out basket))
                                return false;
-                       
-                       lock (basket) {
+
+                       try {
+                               basket.Lock.Enter (ref taken);
+
                                Pair pair = basket.Find ((p) => comparer.Equals (p.Key, key));
                                if (pair == null)
                                        return false;
                                value = pair.Value;
+                       } finally {
+                               if (taken)
+                                       basket.Lock.Exit ();
                        }
-                       
+
                        return true;
                }
-               
+
                public bool TryUpdate (TKey key, TValue newValue, TValue comparand)
                {
                        Basket basket;
+                       bool taken = false;
+
                        if (!TryGetBasket (key, out basket))
                                return false;
-                       
-                       lock (basket) {
+
+                       try {
+                               basket.Lock.Enter (ref taken);
+
                                Pair pair = basket.Find ((p) => comparer.Equals (p.Key, key));
                                if (pair.Value.Equals (comparand)) {
                                        pair.Value = newValue;
-                                       
+
                                        return true;
                                }
+                       } finally {
+                               if (taken)
+                                       basket.Lock.Exit ();
                        }
-                       
+
                        return false;
                }
-               
+
                public TValue this[TKey key] {
                        get {
                                return GetValue (key);
                        }
                        set {
                                Basket basket;
+                               bool taken = false;
+
                                if (!TryGetBasket (key, out basket)) {
                                        Add (key, value);
                                        return;
                                }
-                               lock (basket) {
+
+                               try {
+                                       basket.Lock.Enter (ref taken);
+
                                        Pair pair = basket.Find ((p) => comparer.Equals (p.Key, key));
                                        if (pair == null)
                                                throw new InvalidOperationException ("pair is null, shouldn't be");
                                        pair.Value = value;
+                               } finally {
+                                       if (taken)
+                                               basket.Lock.Exit ();
                                }
                        }
                }
-               
+
                public TValue GetOrAdd (TKey key, Func<TKey, TValue> valueFactory)
                {
                        Basket basket;
                        TValue temp = default (TValue);
-                       
+
                        if (TryGetBasket (key, out basket)) {
                                Pair pair = null;
-                               lock (basket) {
+                               bool taken = false;
+
+                               try {
+                                       basket.Lock.Enter (ref taken);
+
                                        pair = basket.Find ((p) => comparer.Equals (p.Key, key));
                                        if (pair != null)
                                                temp = pair.Value;
+                               } finally {
+                                       if (taken)
+                                               basket.Lock.Exit ();
                                }
-                               
+
                                if (pair == null)
                                        Add (key, (temp = valueFactory (key)));
                        } else {
                                Add (key, (temp = valueFactory (key)));
                        }
-                       
+
                        return temp;
                }
-               
+
                public TValue GetOrAdd (TKey key, TValue value)
                {
                        return GetOrAdd (key, (_) => value);
                }
-               
+
                public bool TryRemove(TKey key, out TValue value)
                {
                        value = default (TValue);
                        Basket b;
-                       
+                       bool taken = false;
+
                        if (!TryGetBasket (key, out b))
                                return false;
-                       
-                       lock (b) {
+
+                       try {
+                               b.Lock.Enter (ref taken);
+
                                TValue temp = default (TValue);
                                // Should always be == 1 but who know
                                bool result = b.RemoveAll ((p) => {
@@ -291,275 +335,294 @@ namespace System.Collections.Concurrent
                                        return r;
                                }) >= 1;
                                value = temp;
-                               
+
                                if (result)
                                        Interlocked.Decrement (ref count);
-                               
+
                                return result;
+                       } finally {
+                               if (taken)
+                                       b.Lock.Exit ();
                        }
+
+                       return false;
                }
-               
+
                bool Remove (TKey key)
                {
                        TValue dummy;
-                       
+
                        return TryRemove (key, out dummy);
                }
-               
+
                bool IDictionary<TKey, TValue>.Remove (TKey key)
                {
                        return Remove (key);
                }
-               
+
                bool ICollection<KeyValuePair<TKey,TValue>>.Remove (KeyValuePair<TKey,TValue> pair)
                {
                        return Remove (pair.Key);
                }
-               
+
                public bool ContainsKey (TKey key)
                {
                        return container.ContainsFromHash (key.GetHashCode ());
                }
-               
+
                bool IDictionary.Contains (object key)
                {
                        if (!(key is TKey))
                                return false;
-                       
+
                        return ContainsKey ((TKey)key);
                }
-               
+
                void IDictionary.Remove (object key)
                {
                        if (!(key is TKey))
                                return;
-                       
+
                        Remove ((TKey)key);
                }
-               
+
                object IDictionary.this [object key]
                {
                        get {
                                if (!(key is TKey))
                                        throw new ArgumentException ("key isn't of correct type", "key");
-                               
+
                                return this[(TKey)key];
                        }
                        set {
                                if (!(key is TKey) || !(value is TValue))
                                        throw new ArgumentException ("key or value aren't of correct type");
-                               
+
                                this[(TKey)key] = (TValue)value;
                        }
                }
-               
+
                void IDictionary.Add (object key, object value)
                {
                        if (!(key is TKey) || !(value is TValue))
                                throw new ArgumentException ("key or value aren't of correct type");
-                       
+
                        Add ((TKey)key, (TValue)value);
                }
-               
+
                bool ICollection<KeyValuePair<TKey,TValue>>.Contains (KeyValuePair<TKey, TValue> pair)
                {
                        return ContainsKey (pair.Key);
                }
-               
+
                public KeyValuePair<TKey,TValue>[] ToArray ()
                {
                        // This is most certainly not optimum but there is
                        // not a lot of possibilities
-                       
+
                        return new List<KeyValuePair<TKey,TValue>> (this).ToArray ();
                }
-       
+
                public void Clear()
                {
                        // Pronk
                        container = new ConcurrentSkipList<Basket> ((value) => value [0].GetHashCode ());
                }
-               
+
                public int Count {
                        get {
                                return count;
                        }
                }
-               
+
                public bool IsEmpty {
                        get {
                                return count == 0;
                        }
                }
-               
+
                bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly {
                        get {
                                return false;
                        }
                }
-               
+
                bool IDictionary.IsReadOnly {
                        get {
                                return false;
                        }
                }
-               
+
                public ICollection<TKey> Keys {
                        get {
                                return GetPart<TKey> ((kvp) => kvp.Key);
                        }
                }
-               
+
                public ICollection<TValue> Values {
                        get {
                                return GetPart<TValue> ((kvp) => kvp.Value);
                        }
                }
-               
+
                ICollection IDictionary.Keys {
                        get {
                                return (ICollection)Keys;
                        }
                }
-               
+
                ICollection IDictionary.Values {
                        get {
                                return (ICollection)Values;
                        }
                }
-               
+
                ICollection<T> GetPart<T> (Func<KeyValuePair<TKey, TValue>, T> extractor)
                {
                        List<T> temp = new List<T> ();
-                       
+
                        foreach (KeyValuePair<TKey, TValue> kvp in this)
                                temp.Add (extractor (kvp));
-                       
+
                        return temp.AsReadOnly ();
                }
-               
+
                void ICollection.CopyTo (Array array, int startIndex)
                {
                        KeyValuePair<TKey, TValue>[] arr = array as KeyValuePair<TKey, TValue>[];
                        if (arr == null)
                                return;
-                       
+
                        CopyTo (arr, startIndex, count);
                }
-               
+
                void CopyTo (KeyValuePair<TKey, TValue>[] array, int startIndex)
                {
                        CopyTo (array, startIndex, count);
                }
-               
+
                void ICollection<KeyValuePair<TKey, TValue>>.CopyTo (KeyValuePair<TKey, TValue>[] array, int startIndex)
                {
                        CopyTo (array, startIndex);
                }
-               
+
                void CopyTo (KeyValuePair<TKey, TValue>[] array, int startIndex, int num)
                {
                        // TODO: This is quite unsafe as the count value will likely change during
                        // the copying. Watchout for IndexOutOfRange thingies
                        if (array.Length <= count + startIndex)
                                throw new InvalidOperationException ("The array isn't big enough");
-                       
+
                        int i = startIndex;
-                       
+
                        foreach (Basket b in container) {
-                               lock (b) {
+                               bool taken = false;
+
+                               try {
+                                       b.Lock.Enter (ref taken);
+
                                        foreach (Pair p in b) {
                                                if (i >= num)
                                                        break;
                                                array[i++] = new KeyValuePair<TKey, TValue> (p.Key, p.Value);
                                        }
+                               } finally {
+                                       if (taken)
+                                               b.Lock.Exit ();
                                }
                        }
                }
-               
+
                public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator ()
                {
                        return GetEnumeratorInternal ();
                }
-               
+
                IEnumerator IEnumerable.GetEnumerator ()
                {
                        return (IEnumerator)GetEnumeratorInternal ();
                }
-               
+
                IEnumerator<KeyValuePair<TKey, TValue>> GetEnumeratorInternal ()
-               {       
+               {
                        foreach (Basket b in container) {
-                               lock (b) {
+                               bool taken = false;
+
+                               try {
+                                       b.Lock.Enter (ref taken);
+
                                        foreach (Pair p in b)
                                                yield return new KeyValuePair<TKey, TValue> (p.Key, p.Value);
+                               } finally {
+                                       if (taken)
+                                               b.Lock.Exit ();
                                }
                        }
                }
-               
+
                IDictionaryEnumerator IDictionary.GetEnumerator ()
                {
                        return new ConcurrentDictionaryEnumerator (GetEnumeratorInternal ());
                }
-               
+
                class ConcurrentDictionaryEnumerator : IDictionaryEnumerator
                {
                        IEnumerator<KeyValuePair<TKey, TValue>> internalEnum;
-                       
+
                        public ConcurrentDictionaryEnumerator (IEnumerator<KeyValuePair<TKey, TValue>> internalEnum)
                        {
                                this.internalEnum = internalEnum;
                        }
-                       
+
                        public bool MoveNext ()
                        {
                                return internalEnum.MoveNext ();
                        }
-                       
+
                        public void Reset ()
                        {
                                internalEnum.Reset ();
                        }
-                       
+
                        public object Current {
                                get {
                                        return Entry;
                                }
                        }
-                       
+
                        public DictionaryEntry Entry {
                                get {
                                        KeyValuePair<TKey, TValue> current = internalEnum.Current;
                                        return new DictionaryEntry (current.Key, current.Value);
                                }
                        }
-                       
+
                        public object Key {
                                get {
                                        return internalEnum.Current.Key;
                                }
                        }
-                       
+
                        public object Value {
                                get {
                                        return internalEnum.Current.Value;
                                }
                        }
                }
-               
+
                object ICollection.SyncRoot {
                        get {
                                return this;
                        }
                }
 
-               
+
                bool IDictionary.IsFixedSize {
                        get {
                                return false;
                        }
                }
-               
+
                bool ICollection.IsSynchronized {
                        get { return true; }
                }
@@ -569,7 +632,7 @@ namespace System.Collections.Concurrent
                        basket = null;
                        if (!container.GetFromHash (key.GetHashCode (), out basket))
                                return false;
-                       
+
                        return true;
                }
        }
index 57e267c2ab58fd399f92adc26447cfa84e444365..247b5059756e2813fa7215609cf1ae95fe374090 100644 (file)
@@ -30,22 +30,24 @@ using System.Collections.Generic;
 
 namespace System.Collections.Concurrent
 {
-       
+
        internal class ConcurrentSkipList<T> : IProducerConsumerCollection<T>
        {
                // Used for randomSeed
                [ThreadStatic]
                static Random r;
                // Used in FindNodes and thus most others methods
-               // avoid heavy local array creation at each method call and use 
+               // avoid heavy local array creation at each method call and use
                // for thread locallity ThreadStatic attribute
-               [ThreadStaticAttribute]
-               static Node[] preds;
-               [ThreadStaticAttribute]
-               static Node[] succs;
+               [ThreadStatic]
+               static Node[] precedents;
+               [ThreadStatic]
+               static Node[] succedings;
+               [ThreadStatic]
+               static bool[] takenLocks;
 
                int count = 0;
-               
+
                class Node
                {
                        public readonly int      Key;
@@ -54,7 +56,7 @@ namespace System.Collections.Concurrent
                        public readonly Node[]   Nexts;
                        public volatile bool     Marked;
                        public volatile bool     FullyLinked;
-                       public readonly object   Lock;
+                       public SpinLock  Lock;
 
                        public Node (int key, T value, int heightValue)
                        {
@@ -62,7 +64,7 @@ namespace System.Collections.Concurrent
                                Value = value;
                                TopLayer = heightValue;
                                Nexts = new Node [heightValue + 1];
-                               Lock = new object ();
+                               Lock = new SpinLock (true);
                                Marked = FullyLinked = false;
                        }
                }
@@ -83,7 +85,7 @@ namespace System.Collections.Concurrent
                        : this ((value) => comparer.GetHashCode (value))
                {
                }
-               
+
                public ConcurrentSkipList(Func<T, int> hasher)
                {
                        GetKey = hasher;
@@ -92,11 +94,6 @@ namespace System.Collections.Concurrent
 
                void Init ()
                {
-                       if (succs == null)
-                               succs = new Node [MaxHeight];
-                       if (preds == null)
-                               preds = new Node [MaxHeight];
-                       
                        leftSentinel = new Node (int.MinValue, default (T), MaxHeight);
                        rightSentinel = new Node (int.MaxValue, default (T), MaxHeight);
 
@@ -106,46 +103,46 @@ namespace System.Collections.Concurrent
                        // The or ensures that randomSeed != 0
                        randomSeed = ((uint)Math.Abs (Next())) | 0x0100;
                }
-               
+
                public bool TryAdd (T value)
                {
                        if (value == null)
                                throw new ArgumentNullException ("value");
-                       
+
                        CleanArrays ();
                        int topLayer = GetRandomLevel ();
 
                        int v = GetKey (value);
 
                        while (true) {
-                               int found = FindNode (v, preds, succs);
+                               int found = FindNode (v, precedents, succedings);
                                if (found != -1) {
                                        // A node with the same key already exists
-                                       Node nodeFound = succs [found];
+                                       Node nodeFound = succedings [found];
                                        if (!nodeFound.Marked) {
                                                SpinWait sw = new SpinWait ();
-                                               while (!nodeFound.FullyLinked) {
+                                               while (!nodeFound.FullyLinked)
                                                        sw.SpinOnce ();
-                                               }
+
                                                return false;
                                        }
                                        continue;
                                }
                                int highestLocked = -1;
                                try {
-                                       bool valid = LockNodes (topLayer, ref highestLocked,
+                                       bool valid = LockNodes (topLayer, ref highestLocked, precedents, succedings,
                                                                (layer, pred, succ) => !pred.Marked && !succ.Marked && pred.Nexts [layer] == succ);
                                        if (!valid)
                                                continue;
-                                               
+
                                        Node newNode = new Node (v, value, topLayer);
                                        for (int layer = 0; layer <= topLayer; layer++) {
-                                               newNode.Nexts [layer] = succs [layer];
-                                               preds [layer].Nexts [layer] = newNode;
+                                               newNode.Nexts [layer] = succedings [layer];
+                                               precedents [layer].Nexts [layer] = newNode;
                                        }
                                        newNode.FullyLinked = true;
                                } finally {
-                                       Unlock (preds, highestLocked);
+                                       Unlock (precedents, takenLocks, highestLocked);
                                }
                                Interlocked.Increment (ref count);
                                return true;
@@ -161,7 +158,7 @@ namespace System.Collections.Concurrent
                {
                        int countSnapshot = count;
                        T[] temp = new T [countSnapshot];
-                       
+
                        CopyTo(temp, 0);
 
                        return temp;
@@ -203,7 +200,7 @@ namespace System.Collections.Concurrent
                {
                        if (value == null)
                                throw new ArgumentNullException ("value");
-                       
+
                        CleanArrays();
                        Node toDelete = null;
                        bool isMarked = false;
@@ -211,36 +208,39 @@ namespace System.Collections.Concurrent
                        int v = GetKey (value);
 
                        while (true) {
-                               int found = FindNode (v, preds, succs);
-                               
-                               if (isMarked || (found != -1 && OkToDelete (succs [found], found))) {
+                               int found = FindNode (v, precedents, succedings);
+                               bool taken = false;
+                               int highestLocked = -1;
+
+                               if (isMarked || (found != -1 && OkToDelete (succedings [found], found))) {
                                        // If not marked then logically delete the node
-                                       if (!isMarked) {
-                                               toDelete = succs [found];
-                                               topLayer = toDelete.TopLayer;
-                                               Monitor.Enter (toDelete.Lock);
-                                               // Now that we have the lock, check if the node hasn't already been marked
-                                               if (toDelete.Marked) {
-                                                       Monitor.Exit (toDelete.Lock);
-                                                       return false;
-                                               }
-                                               toDelete.Marked = true;
-                                               isMarked = true;
-                                       }
-                                       int highestLocked = -1;
                                        try {
-                                               bool valid = LockNodes (topLayer, ref highestLocked,
+                                               if (!isMarked) {
+                                                       toDelete = succedings [found];
+                                                       topLayer = toDelete.TopLayer;
+
+                                                       toDelete.Lock.Enter (ref taken);
+                                                       // Now that we have the lock, check if the node hasn't already been marked
+                                                       if (toDelete.Marked)
+                                                               return false;
+
+                                                       toDelete.Marked = true;
+                                                       isMarked = true;
+                                               }
+
+                                               bool valid = LockNodes (topLayer, ref highestLocked, precedents, succedings,
                                                                        (layer, pred, succ) => !pred.Marked && pred.Nexts [layer] == succ);
                                                if (!valid)
                                                        continue;
 
-                                               for (int layer = topLayer; layer >= 0; layer--) {
-                                                       preds [layer].Nexts [layer] = toDelete.Nexts [layer];
-                                               }
-                                               Monitor.Exit (toDelete.Lock);
+                                               for (int layer = topLayer; layer >= 0; layer--)
+                                                       precedents [layer].Nexts [layer] = toDelete.Nexts [layer];
                                        } finally {
-                                               Unlock (preds, highestLocked);
+                                               if (taken)
+                                                       toDelete.Lock.Exit ();
+                                               Unlock (precedents, takenLocks, highestLocked);
                                        }
+
                                        Interlocked.Decrement (ref count);
                                        return true;
                                } else {
@@ -253,38 +253,42 @@ namespace System.Collections.Concurrent
                {
                        if (value == null)
                                throw new ArgumentNullException ("value");
-                       
+
                        return ContainsFromHash (GetKey (value));
                }
-               
+
                internal bool ContainsFromHash (int hash)
                {
                        CleanArrays ();
-                       int found = FindNode (hash, preds, succs);
-                       return found != -1 && succs [found].FullyLinked && !succs [found].Marked;
+                       int found = FindNode (hash, precedents, succedings);
+                       return found != -1 && succedings [found].FullyLinked && !succedings [found].Marked;
                }
-               
+
                internal bool GetFromHash (int hash, out T value)
                {
                        value = default (T);
                        CleanArrays ();
                        // We are blindly supposing that the hash is correct
                        // i.e. I trust myself :-)
-                       int found = FindNode (hash, preds, succs);
+                       int found = FindNode (hash, precedents, succedings);
                        if (found == -1)
                                return false;
-                       
+
+                       bool taken = false;
+                       Node node = succedings [found];
+
                        try {
-                               Monitor.Enter (succs [found].Lock);
-                               Node node = succs [found];
+                               node.Lock.Enter (ref taken);
+
                                if (node.FullyLinked && !node.Marked) {
                                        value = node.Value;
                                        return true;
                                }
                        } finally {
-                               Monitor.Exit (succs [found].Lock);
+                               if (taken)
+                                       node.Lock.Exit ();
                        }
-                       
+
                        return false;
                }
 
@@ -303,7 +307,7 @@ namespace System.Collections.Concurrent
                {
                        return GetInternalEnumerator ();
                }
-               
+
                IEnumerator<T> GetInternalEnumerator ()
                {
                        Node curr = leftSentinel;
@@ -311,34 +315,37 @@ namespace System.Collections.Concurrent
                                // If there is an Add operation ongoing we wait a little
                                // Possible optimization : use a helping scheme
                                SpinWait sw = new SpinWait ();
-                               while (!curr.FullyLinked) {
+                               while (!curr.FullyLinked)
                                        sw.SpinOnce ();
-                               }
+
                                yield return curr.Value;
                        }
                }
 
-               void Unlock(Node[] preds, int highestLocked)
+               void Unlock (Node[] preds, bool[] takenLocks, int highestLocked)
                {
-                       for (int i = 0; i <= highestLocked; i++) {
-                               Monitor.Exit (preds [i].Lock);
-                       }
+                       for (int layer = 0; layer <= highestLocked; layer++)
+                               if (takenLocks [layer])
+                                       preds [layer].Lock.Exit ();
                }
 
-               bool LockNodes (int topLayer, ref int highestLocked, Func<int, Node, Node, bool> validityTest)
+               bool LockNodes (int topLayer, ref int highestLocked, Node[] preds, Node[] succs, Func<int, Node, Node, bool> validityTest)
                {
                        Node pred, succ, prevPred = null;
                        bool valid = true;
-                       
+
                        for (int layer = 0; valid && (layer <= topLayer); layer++) {
                                pred = preds [layer];
                                succ = succs [layer];
+                               takenLocks[layer] = false;
+
                                if (pred != prevPred) {
                                        // Possible optimization : limit topLayer to the first refused lock
-                                       Monitor.Enter (pred.Lock);
+                                       pred.Lock.Enter (ref takenLocks[layer]);
                                        highestLocked = layer;
                                        prevPred = pred;
                                }
+
                                valid = validityTest (layer, pred, succ);
                        }
 
@@ -349,7 +356,7 @@ namespace System.Collections.Concurrent
                {
                        // With preds and succs we record the path we use for searching v
                        if (preds.Length != MaxHeight || succs.Length != MaxHeight)
-                               throw new Exception ("precs or succs don't have the  good length");
+                               throw new Exception ("preds or succs don't have the  good length");
 
                        int found = -1;
                        Node pred = leftSentinel;
@@ -368,7 +375,7 @@ namespace System.Collections.Concurrent
                                preds [layer] = pred;
                                succs [layer] = curr;
                        }
-                       
+
                        return found;
                }
 
@@ -391,18 +398,23 @@ namespace System.Collections.Concurrent
                        while (((x >>= 1) & 1) != 0) ++level;
                        return level;
                }
-               
+
                void CleanArrays ()
                {
-                       if (succs == null)
-                               succs = new Node [MaxHeight];
-                       if (preds == null)
-                               preds = new Node [MaxHeight];
-                       
+                       // If one is null, the others too
+                       if (succedings == null) {
+                               succedings = new Node [MaxHeight];
+                               precedents = new Node [MaxHeight];
+                               takenLocks = new bool [MaxHeight];
+
+                               return;
+                       }
+
                        // Hopefully these are more optimized than a bare for loop
                        // (I suppose it uses memset internally)
-                       Array.Clear (preds, 0, preds.Length);
-                       Array.Clear (succs, 0, succs.Length);
+                       Array.Clear (precedents, 0, precedents.Length);
+                       Array.Clear (succedings, 0, succedings.Length);
+                       Array.Clear (takenLocks, 0, takenLocks.Length);
                }
 
                int Next ()
index 6def189150d3f9aeea352a732efe63ec4aaed240..aa07be9838330f6b323534cd6cd9eee58019dbee 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * CollectionDebuggerView.cs: Change to internal so we can avoid
+       a duplicating the type in assemblies that have [InternalsVisibleTo]
+
 2010-01-25 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * EqualityComparer.cs: (Equals) the arguments are checked to be
index f90dc48a35ad3511be5158c227e3e9dbf3481fdd..8f87050b599c7573f72a33372d3cb6e5813b0c49 100644 (file)
@@ -34,7 +34,7 @@ namespace System.Collections.Generic
        //
        // Custom debugger type proxy to display collections as arrays
        //
-       sealed class CollectionDebuggerView<T>
+       internal sealed class CollectionDebuggerView<T>
        {
                readonly ICollection<T> c;
 
@@ -53,7 +53,7 @@ namespace System.Collections.Generic
                }
        }
        
-       sealed class CollectionDebuggerView<T, U>
+       internal sealed class CollectionDebuggerView<T, U>
        {
                readonly ICollection<KeyValuePair<T, U>> c;
 
index 4af1c69d7c72c8f0a42cbf52ef8fe84c0f67f1a3..22fdde9768a6d0f88cd2f4d6ab06604eef6041c6 100644 (file)
@@ -1,3 +1,13 @@
+2010-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * CollectionDebuggerView.cs: Change to internal so we can avoid
+       a duplicating the type in assemblies that have [InternalsVisibleTo]
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * IStructuralComparable.cs, IStructuralEquatable.cs: use
+       MOONLIGHT symbol to disambiguate MonoTouch and Moonlight code.
+
 2010-03-12  Sebastien Pouliot  <sebastien@ximian.com>
 
        * IStructuralComparable.cs, IStructuralEquatable.cs: Add them to
index 4ee8fa26ff4ed25bb20cab7b0af4005377a8c5cd..f8abdd3239e12fc6849d295ec41e165939667296 100644 (file)
@@ -34,7 +34,7 @@ namespace System.Collections
        //
        // Custom debugger type proxy to display collections as arrays
        //
-       sealed class CollectionDebuggerView
+       internal sealed class CollectionDebuggerView
        {
                readonly ICollection c;
 
index beca4a2ae38e4f16841ac5d84ea9b7a4646982cc..f7695f9ac81cbedcdf5b2625b27248a09feaa86e 100644 (file)
@@ -26,7 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if (NET_2_1 && !MONOTOUCH) || NET_4_0
+#if MOONLIGHT || NET_4_0
 
 using System;
 
index 62d75d44d121e87adfcebedc2b735f1be39ae08b..a3d4ef5117a466722c70438213d9acc17cc2e07d 100644 (file)
@@ -26,7 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if (NET_2_1 && !MONOTOUCH) || NET_4_0
+#if MOONLIGHT || NET_4_0
 
 using System;
 
index 5f89d64130f73e3b037047b7fdaa9f66357fd4ca..e30a01a1843a16044f7c7931e8124d77cfa96690 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * StackFrame.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2010-03-07 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * Debugger.cs: Add Obsolete attribute to .ctor().
index 38796071e9e90aaabb7bb192b8e1c160120f2e82..8d9c83f7368a390dda37f18202c0542be5e9605e 100644 (file)
@@ -140,7 +140,7 @@ namespace System.Diagnostics {
                        string filename = "<filename unknown>";
                        if (fileName == null)
                                return filename;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        try {
                                filename = GetFileName ();
                        }
index 35c1392fe87358fb2e183ea8ccefd1906bea3219..d4d8bb64f11d7873f3cb50ea6b090b48f507bdec 100644 (file)
@@ -128,7 +128,7 @@ public abstract class Calendar : ICloneable
        [NonSerialized]
        bool m_isReadOnly;
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
        [System.Runtime.InteropServices.ComVisible(false)]
        public virtual CalendarAlgorithmType AlgorithmType {
                get {
index 2952608b60df24b4f7bf219b810d0b3b87617b5b..5a8ae1113f71a6b07f7cf960f6beb261c52cdcc8 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * CultureInfo.cs, CompareInfo.cs, Calendar.cs: use MOONLIGHT symbol
+       to disambiguate MonoTouch and Moonlight code.
+
 2010-02-28 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * CultureNotFoundException.cs: new 4.0 type.
index f72ce7390f680ec729685b8b75f4609b970682f5..d6dca63c7e16c0ab910029a6195ae27ec1bf1101 100644 (file)
@@ -41,7 +41,7 @@ using Mono.Globalization.Unicode;
 namespace System.Globalization
 {
        [Serializable]
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
        [ComVisible (true)]
        public class CompareInfo : IDeserializationCallback {
 
@@ -149,7 +149,7 @@ namespace System.Globalization
                                        }
                                }
                        } else {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                                this.icu_name = ci.IcuName;
                                this.construct_compareinfo (icu_name);
 #endif
@@ -158,12 +158,12 @@ namespace System.Globalization
 
                ~CompareInfo ()
                {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        free_internal_collator ();
 #endif
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                private int internal_compare_managed (string str1, int offset1,
                                                int length1, string str2,
                                                int offset2, int length2,
@@ -409,7 +409,7 @@ namespace System.Globalization
                        case CompareOptions.OrdinalIgnoreCase:
                                throw new ArgumentException ("Now allowed CompareOptions.", "options");
                        }
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        if (UseManagedCollation)
                                return collator.GetSortKey (source, options);
                        SortKey key=new SortKey (culture, source, options);
@@ -498,7 +498,7 @@ namespace System.Globalization
                                        CompareOptions.None));
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                private int internal_index_managed (string s, int sindex,
                        int count, char c, CompareOptions opt,
                        bool first)
@@ -567,7 +567,7 @@ namespace System.Globalization
                        }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                private int internal_index_managed (string s1, int sindex,
                        int count, string s2, CompareOptions opt,
                        bool first)
index d4e63c1329603dee81712d55a9541544719f4b5e..438dc0f28ec9a6b2b5196cf685d7b994d76028b8 100644 (file)
@@ -266,7 +266,7 @@ namespace System.Globalization
 
                public virtual string Name {
                        get {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                if (m_name == "zh-CHS")
                                        return "zh-Hans";
                                if (m_name == "zh-CHT")
@@ -404,7 +404,7 @@ namespace System.Globalization
                        return false;
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static CultureInfo[] GetCultures(CultureTypes types)
                {
                        bool neutral=((types & CultureTypes.NeutralCultures)!=0);
@@ -494,7 +494,7 @@ namespace System.Globalization
 
                internal void CheckNeutral ()
                {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        if (IsNeutralCulture) {
                                throw new NotSupportedException ("Culture \"" + m_name + "\" is " +
                                                "a neutral culture. It can not be used in formatting " +
@@ -619,7 +619,7 @@ namespace System.Globalization
                        // It is sort of hack to get those new pseudo-alias
                        // culture names that are not supported in good old
                        // Windows.
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        if (locale == "zh-chs" || locale == "zh-cht")
                                return false;
 #endif
index f7d405326aba151c006341f961ffe5f5546e240c..e1ab06e62c78b45fe272371f80d1a54414de8ffb 100644 (file)
@@ -1,3 +1,15 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * IsolatedStorageFileEnumerator.cs
+       * MoonIsolatedStorageFileStream.cs
+       * MoonIsolatedStorageFile.cs
+       * MoonIsolatedStorage.cs
+       * IsolatedStorageScope.cs
+       * IsolatedStorageFileStream.cs
+       * IsolatedStorage.cs
+       * IsolatedStorageFile.cs:
+               use MOONLIGHT symbol to disambiguate MonoTouch and Moonlight code.
+
 2009-11-01  Sebastien Pouliot  <sebastien@ximian.com>
 
        * MoonIsolatedStorageFile.cs: Add new CheckSearchPattern 
index 479e723fbabd327de5c483afc478da124ab258af..fcb24c984fdf585c34fbff4644c6ddf569417be1 100644 (file)
@@ -28,7 +28,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using System.Globalization;
 using System.Reflection;
 using System.Runtime.InteropServices;
@@ -153,5 +153,5 @@ namespace System.IO.IsolatedStorage {
                public abstract void Remove ();
        }
 }
-/* NET_2_1 */
+/* MOONLIGHT */
 #endif 
\ No newline at end of file
index 00f2494f626a82d9e74bc1009ab4b4f97aada5fc..583231ec13d0cad16609437454ab2891522693b8 100644 (file)
@@ -27,7 +27,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using System.Collections;
 using System.Reflection;
 using System.Runtime.InteropServices;
index 25641e2c7a96c9278cedf431fbba737822e13f3b..08457bff978ea0448ab4dfb942520ab3731bc131 100644 (file)
@@ -28,7 +28,7 @@
 
 using System.Collections;
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 namespace System.IO.IsolatedStorage {
 
index 75d5c74b250dd6bef40e9ba28b15c34eedc60566..4479dab7f3dcfafb916dd078b966106011a3821d 100644 (file)
@@ -27,7 +27,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using System.Diagnostics;
 using System.Globalization;
 using System.Reflection;
index 3e17bcb41f32b54d59218466b67bf708e6a7576d..bde8468ccc8f2ee09efbbe4ffc5bd5c8fea5579c 100644 (file)
@@ -41,7 +41,7 @@ namespace System.IO.IsolatedStorage {
 
                None = 0,
                User = 1,
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                // Available in Silverlight
                Application = 32,
 #else
index 9698309fef9bdfe29274d66bb6b3ad07d9d606af..9ea31ee08bb3a9feedc2804596c3b63104be2f86 100644 (file)
@@ -26,7 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
 
 using System;
 using System.IO;
index af4560d712346ac576ea1f36e970bec992643a8a..0c0fe270416bd8036b89ad985dff5e382d012f1f 100644 (file)
@@ -28,7 +28,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
 using System;
 using System.IO;
 using System.Runtime.InteropServices;
index 60d05549487803b1259badd1c0fef72abc6deffd..23b90e52ce774808399a38cd380177afe128ba38 100644 (file)
@@ -28,7 +28,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
 using System;
 using System.IO;
 
index 7cec76790ef7111f745cb30bcec1bb1e1e4fd543..aecd32bf7f10aa8497af547d1fe8f388bd490013 100644 (file)
@@ -1,3 +1,40 @@
+2010-03-25 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * Directory.cs: a directory named ":" is legal in unix.
+       This gets rid of the annoying ":" folder when running
+       corlib tests.
+
+2010-03-22  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Directory.cs, DirectoryInfo.cs: Disble new NET_4_0 API used in
+       SL4 until we have elevated trust working correctly (since they 
+       are *not* decorated as [SecurityCritical])
+
+2010-03-17 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * StreamReader.cs: if the detected encoding is different from the
+       provided to the constructor, adjust the decoded buffer size if
+       needed. Fixes bug #589236.
+
+2010-03-17  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Stream.cs: CopyTo methods are part of SL4 too
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * FileStream.cs, File.cs, DirectoryInfo.cs, Directory.cs: use
+       MOONLIGHT symbol to disambiguate MonoTouch and Moonlight code.
+
+2010-03-16  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * Path.cs:
+       * Directory.cs:
+       * DirectoryInfo.cs: Add some of the 4.0 methods to Moonlight.
+
+2010-03-15  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * SearchOption.cs: Make public for Moonlight, this type is in SL4.
+
 2010-03-12  Sebastien Pouliot  <sebastien@ximian.com>
 
        * File.cs: Enable some NET_4_0 features in NET_2_1 since they are
index 58a74aea3825f90aeac13b6f68191229fdd89570..6dad4c4df8800773a1c17af6bed1509cc80853a9 100644 (file)
@@ -44,7 +44,7 @@ using System.Security.Permissions;
 using System.Text;
 using System.Runtime.InteropServices;
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using System.Security.AccessControl;
 #endif
 
@@ -73,13 +73,13 @@ namespace System.IO
                        
                        // LAMESPEC: with .net 1.0 version this throw NotSupportedException and msdn says so too
                        // but v1.1 throws ArgumentException.
-                       if (path == ":")
+                       if (Environment.IsRunningOnWindows && path == ":")
                                throw new ArgumentException ("Only ':' In path");
                        
                        return CreateDirectoriesInternal (path);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoLimitation ("DirectorySecurity not implemented")]
                public static DirectoryInfo CreateDirectory (string path, DirectorySecurity directorySecurity)
                {
@@ -89,7 +89,7 @@ namespace System.IO
 
                static DirectoryInfo CreateDirectoriesInternal (string path)
                {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        if (SecurityManager.SecurityEnabled) {
                                new FileIOPermission (FileIOPermissionAccess.Read | FileIOPermissionAccess.Write, path).Demand ();
                        }
@@ -131,7 +131,7 @@ namespace System.IO
                        if (path.Trim().Length == 0)
                                throw new ArgumentException ("Only blank characters in path");
 
-                       if (path == ":")
+                       if (Environment.IsRunningOnWindows && path == ":")
                                throw new NotSupportedException ("Only ':' In path");
 
                        MonoIOError error;
@@ -240,7 +240,7 @@ namespace System.IO
                        string result = MonoIO.GetCurrentDirectory (out error);
                        if (error != MonoIOError.ERROR_SUCCESS)
                                throw MonoIO.GetException (error);
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        if ((result != null) && (result.Length > 0) && SecurityManager.SecurityEnabled) {
                                new FileIOPermission (FileIOPermissionAccess.PathDiscovery, result).Demand ();
                        }
@@ -258,7 +258,7 @@ namespace System.IO
                        return GetFileSystemEntries (path, searchPattern, FileAttributes.Directory, FileAttributes.Directory);
                }
                
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static string [] GetDirectories (string path, string searchPattern, SearchOption searchOption)
                {
                        if (searchOption == SearchOption.TopDirectoryOnly)
@@ -291,7 +291,7 @@ namespace System.IO
                        return GetFileSystemEntries (path, searchPattern, FileAttributes.Directory, 0);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static string[] GetFiles (string path, string searchPattern, SearchOption searchOption)
                {
                        if (searchOption == SearchOption.TopDirectoryOnly)
@@ -386,7 +386,7 @@ namespace System.IO
                                throw MonoIO.GetException (error);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static void SetAccessControl (string path, DirectorySecurity directorySecurity)
                {
                        throw new NotImplementedException ();
@@ -522,7 +522,15 @@ namespace System.IO
                        return result;
                }
 
-#if NET_4_0
+               internal static void ValidatePath (string path)
+               {
+#if MOONLIGHT
+                       // On Moonlight (SL4+) this is possible, with limitations, in "Elevated Trust"
+                       throw new SecurityException ("we're not ready to enable this SL4 feature yet");
+#endif
+               }
+
+#if NET_4_0 || MOONLIGHT
                public static string[] GetFileSystemEntries (string path, string searchPattern, SearchOption searchOption)
                {
                        // Take the simple way home:
@@ -540,6 +548,8 @@ namespace System.IO
                        if (searchOption != SearchOption.TopDirectoryOnly && searchOption != SearchOption.AllDirectories)
                                throw new ArgumentOutOfRangeException ("searchoption");
 
+                       ValidatePath (path);
+
                        bool stop;
                        string path_with_pattern = ValidateDirectoryListing (path, searchPattern, out stop);
                        if (stop){
@@ -624,7 +634,7 @@ namespace System.IO
                
 #endif
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoNotSupported ("DirectorySecurity isn't implemented")]
                public static DirectorySecurity GetAccessControl (string path, AccessControlSections includeSections)
                {
index 16b6e19dc27a0f5690a083f19d0a40d973863eb3..f8f1f4be845ae7d927a2d286fe6e8f6803ca36ea 100644 (file)
@@ -36,7 +36,7 @@ using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
 using System.Text;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using System.Security.AccessControl;
 #endif
 
@@ -262,7 +262,7 @@ namespace System.IO {
                        return OriginalPath;
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public DirectoryInfo[] GetDirectories (string searchPattern, SearchOption searchOption)
                {
                        switch (searchOption) {
@@ -370,7 +370,7 @@ namespace System.IO {
                }
 #endif
 
-#if NET_4_0
+#if NET_4_0 || MOONLIGHT
 
                public IEnumerable<DirectoryInfo> EnumerateDirectories ()
                {
@@ -431,6 +431,8 @@ namespace System.IO {
                        MonoIOError error;
                        FileAttributes rattr;
                        bool subdirs = searchOption == SearchOption.AllDirectories;
+
+                       Directory.ValidatePath (full); // required for Moonlight, nop-op otherwise
                        
                        string s = MonoIO.FindFirst (full, path_with_pattern, out rattr, out error, out handle);
                        if (s == null)
index 3ef678e26ebaa3755e0e5ac0b233831fa3029052..d183c19eddd80bc5c7dd6421fcd01cf8af60f2a2 100644 (file)
@@ -54,7 +54,7 @@ namespace System.IO
                                throw new ArgumentNullException ("path");
                        if (path.Length == 0)
                                throw new ArgumentException ("path");
-#if NET_2_1 && !MONOTOUCH && !DEBUG
+#if MOONLIGHT && !DEBUG
                        // On Moonlight (SL4+) this is possible, with limitations, in "Elevated Trust"
                        throw new SecurityException ("we're not ready to enable this SL4 feature yet");
 #endif
@@ -641,7 +641,7 @@ namespace System.IO
                        throw new NotSupportedException (Locale.GetText ("File encryption isn't supported on any file system."));
                }
 
-#if (NET_2_1 && !MONOTOUCH) || NET_4_0
+#if MOONLIGHT || NET_4_0
                public static IEnumerable<string> ReadLines (string path)
                {
                        ValidatePath (path);
index 04479da45e52c9c227e74800923ea9e6f84cd563..4767e4bfc4bb4f395fda37bc84d73630a43aa034 100644 (file)
@@ -98,7 +98,7 @@ namespace System.IO
                        this.access = access;
                        this.owner = ownsHandle;
                        this.async = isAsync;
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // default the browser to 'all' anonymous files and let other usage (like smcs) with 'normal'
                        // (i.e. non-anonymous except for isolated storage) files and paths
                        this.anonymous = SecurityManager.SecurityEnabled;
index 0c78b0350aae11adb712d5d98c9d4eab38cf6dda..471d37c227fd58c3e47f2f543b4d2612c8103b33 100644 (file)
@@ -736,7 +736,7 @@ namespace System.IO {
                        return String.Compare (subset, slast, path, slast, subset.Length - slast) == 0;
                }
 
-#if NET_4_0
+#if NET_4_0 || MOONLIGHT
                public static string Combine (params string [] paths)
                {
                        if (paths == null)
index d77ec7bf58cad5ebe602dad0b208f624fde1f656..9c2bfd341c0ec0a963412da7dc3dc0594414cfd7 100644 (file)
 using System.Runtime.InteropServices;
 
 namespace System.IO {
-#if !NET_2_1 || MONOTOUCH
        [ComVisible (true)]
        [Serializable]
        public
-#endif
        enum SearchOption {
                TopDirectoryOnly = 0,
                AllDirectories = 1
index 2d1f4fb45d090b46b33cf1d24d6c65ca3cd8801b..17c8cc457eb82bc3b2733a00659fb5546c423e09 100644 (file)
@@ -261,7 +261,7 @@ namespace System.IO
                                throw result.Exception;
                }
 
-#if NET_4_0
+#if MOONLIGHT || NET_4_0
                public void CopyTo (Stream destination)
                {
                        CopyTo (destination, 16*1024);
index 9e5f558585cc855ee4d9b226d871e4088cc6be2f..279922b43edb9c6eea0923df3a38070fdaf1864b 100644 (file)
@@ -383,6 +383,10 @@ namespace System.IO {
                                        Encoding old = encoding;
                                        parse_start = DoChecks (cbEncoded);
                                        if (old != encoding){
+                                               int old_decoded_size = old.GetMaxCharCount (buffer_size) + 1;
+                                               int new_decoded_size = encoding.GetMaxCharCount (buffer_size) + 1;
+                                               if (old_decoded_size != new_decoded_size)
+                                                       decoded_buffer = new char [new_decoded_size];
                                                decoder = encoding.GetDecoder ();
                                        }
                                        do_checks = 0;
index 96d4401f4a1cd30f62dee31367eba5f47da323de..2d5b6ea4817ec68903ebc9b0fbdf8a0812195386 100644 (file)
@@ -262,7 +262,7 @@ namespace System.Reflection.Emit
                        // remove Mono specific flag to allow enum check to pass
                        access &= ~COMPILER_ACCESS;
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // only "Run" is supported by Silverlight
                        // however SMCS requires more than this but runs outside the CoreCLR sandbox
                        if (SecurityManager.SecurityEnabled && (access != AssemblyBuilderAccess.Run))
@@ -1197,5 +1197,55 @@ namespace System.Reflection.Emit
                {
                        throw new NotImplementedException ();
                }
+
+#if NET_4_0
+               public override Type GetType (string name, bool throwOnError, bool ignoreCase)
+               {
+                       if (name == null)
+                               throw new ArgumentNullException (name);
+                       if (name.Length == 0)
+                       throw new ArgumentException ("name", "Name cannot be empty");
+
+                       var res = InternalGetType (null, name, throwOnError, ignoreCase);
+                       if (res is TypeBuilder) {
+                               if (throwOnError)
+                                       throw new TypeLoadException (string.Format ("Could not load type '{0}' from assembly '{1}'", name, this.name));
+                               return null;
+                       }
+                       return res;
+               }
+
+               public override Module GetModule (String name)
+               {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       if (name.Length == 0)
+                               throw new ArgumentException ("Name can't be empty");
+
+                       if (modules == null)
+                               return null;
+
+                       foreach (Module module in modules) {
+                               if (module.ScopeName == name)
+                                       return module;
+                       }
+
+                       return null;
+               }
+
+               public override Module[] GetModules (bool getResourceModules)
+               {
+                       Module[] modules = GetModulesInternal ();
+
+                       if (!getResourceModules) {
+                               ArrayList result = new ArrayList (modules.Length);
+                               foreach (Module m in modules)
+                                       if (!m.IsResource ())
+                                               result.Add (m);
+                               return (Module[])result.ToArray (typeof (Module));
+                       }
+                       return modules;
+               }
+#endif
        }
 }
index 9c88a72a857c2efce198411c956d7740a151d912..3e9bd24475ad3f7eba5c154191f694dff811cc14 100644 (file)
@@ -1,3 +1,21 @@
+2010-03-25 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * AssemblyBuilder.cs: Implement v4 GetModule(s).
+
+2010-03-25 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * AssemblyBuilder.cs: Implement v4 GetType.
+
+2010-03-23 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * MethodOnTypeBuilderInst.cs (ContainsGenericParameters): Check
+       the base_method first.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * AssemblyBuilder.cs, ModuleBuilder.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2010-03-12  Jb Evain  <jbevain@novell.com>
 
        * AssemblyBuilder.cs (AddTypeForwarder): throw if the
index 68b5d3ab7dac6157aa2e23349d8385c6cbe82a03..6b976e8a9812f687ae174d48d45d902f9ecc4ed1 100644 (file)
@@ -286,6 +286,8 @@ namespace System.Reflection.Emit
 
                public override bool ContainsGenericParameters {
                        get {
+                               if (base_method.ContainsGenericParameters)
+                                       return true;
                                if (!base_method.IsGenericMethodDefinition)
                                        throw new NotSupportedException ();
                                if (method_arguments == null)
index 672be8b6b6129c6830d81650b440bb8dc32d7280..102b28f5b26219f7ed4a7799bc4b4f763c33d404 100644 (file)
@@ -101,7 +101,7 @@ namespace System.Reflection.Emit {
                        }
 
                        if (emitSymbolInfo) {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                symbolWriter = new Mono.CompilerServices.SymbolWriter.SymbolWriterImpl (this);
 #else
                                Assembly asm = Assembly.LoadWithPartialName ("Mono.CompilerServices.SymbolWriter");
index 0a436cf11e2aff3052f26427ac9e62f8640e2a45..2442e925b960ebc00658853278a1db1651c7b668 100644 (file)
@@ -52,11 +52,12 @@ namespace System.Reflection {
        [Serializable]
        [ClassInterface(ClassInterfaceType.None)]
 #if NET_2_1
-       public class Assembly : ICustomAttributeProvider, _Assembly {
+       public partial class Assembly : ICustomAttributeProvider, _Assembly {
+#elif NET_4_0
+       public abstract class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
 #else
-       public class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
+       public partial class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
 #endif
-
                internal class ResolveEventHolder {
                        public event ModuleResolveEventHandler ModuleResolve;
                }
@@ -76,7 +77,12 @@ namespace System.Reflection {
                private bool fromByteArray;
                private string assemblyName;
 
-               internal Assembly () 
+#if NET_4_0
+               protected
+#else
+               internal
+#endif
+               Assembly () 
                {
                        resolve_event_holder = new ResolveEventHolder ();
                }
@@ -146,7 +152,7 @@ namespace System.Reflection {
                        [MethodImplAttribute (MethodImplOptions.InternalCall)]
                        get;
                }
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public virtual Evidence Evidence {
                        [SecurityPermission (SecurityAction.Demand, ControlEvidence = true)]
                        get { return UnprotectedGetEvidence (); }
@@ -166,13 +172,8 @@ namespace System.Reflection {
                }
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               private extern bool get_global_assembly_cache ();
+               internal extern bool get_global_assembly_cache ();
 
-               public bool GlobalAssemblyCache {
-                       get {
-                               return get_global_assembly_cache ();
-                       }
-               }
 #endif
                internal bool FromByteArray {
                        set { fromByteArray = value; }
@@ -292,7 +293,7 @@ namespace System.Reflection {
 
                                string location = Path.GetDirectoryName (Location);
                                string filename = Path.Combine (location, info.FileName);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                // we don't control the content of 'info.FileName' so we want to make sure we keep to ourselves
                                filename = Path.GetFullPath (filename);
                                if (!filename.StartsWith (location))
@@ -363,16 +364,6 @@ namespace System.Reflection {
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal extern Type InternalGetType (Module module, String name, Boolean throwOnError, Boolean ignoreCase);
 
-               public Type GetType (string name, bool throwOnError, bool ignoreCase)
-               {
-                       if (name == null)
-                               throw new ArgumentNullException (name);
-                       if (name.Length == 0)
-                       throw new ArgumentException ("name", "Name cannot be empty");
-
-                       return InternalGetType (null, name, throwOnError, ignoreCase);
-               }
-
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal extern static void InternalGetAssemblyName (string assemblyFile, AssemblyName aname);
 
@@ -429,22 +420,12 @@ namespace System.Reflection {
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                public static extern Assembly GetEntryAssembly();
 
-               public Assembly GetSatelliteAssembly (CultureInfo culture)
-               {
-                       return GetSatelliteAssembly (culture, null, true);
-               }
-
-               public Assembly GetSatelliteAssembly (CultureInfo culture, Version version)
-               {
-                       return GetSatelliteAssembly (culture, version, true);
-               }
-
                internal Assembly GetSatelliteAssemblyNoThrow (CultureInfo culture, Version version)
                {
                        return GetSatelliteAssembly (culture, version, false);
                }
 
-               private Assembly GetSatelliteAssembly (CultureInfo culture, Version version, bool throwOnError)
+               internal Assembly GetSatelliteAssembly (CultureInfo culture, Version version, bool throwOnError)
                {
                        if (culture == null)
                                throw new ArgumentException ("culture");
@@ -469,7 +450,7 @@ namespace System.Reflection {
                        // Try the assembly directory
                        string location = Path.GetDirectoryName (Location);
                        string fullName = Path.Combine (location, Path.Combine (culture.Name, aname.Name + ".dll"));
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        // it's unlikely that culture.Name or aname.Name could contain stuff like ".." but...
                        fullName = Path.GetFullPath (fullName);
                        if (!fullName.StartsWith (location)) {
@@ -492,6 +473,9 @@ namespace System.Reflection {
                        return LoadFrom (assemblyFile, false);
                }
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public static Assembly LoadFrom (String assemblyFile, Evidence securityEvidence)
                {
                        Assembly a = LoadFrom (assemblyFile, false);
@@ -504,6 +488,9 @@ namespace System.Reflection {
                        return a;
                }
 
+#if NET_4_0
+               [Obsolete]
+#endif
                [MonoTODO("This overload is not currently implemented")]
                // FIXME: What are we missing?
                public static Assembly LoadFrom (String assemblyFile, Evidence securityEvidence, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
@@ -515,6 +502,9 @@ namespace System.Reflection {
                        throw new NotImplementedException ();
                }
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public static Assembly LoadFile (String path, Evidence securityEvidence)
                {
                        if (path == null)
@@ -534,7 +524,10 @@ namespace System.Reflection {
                {
                        return AppDomain.CurrentDomain.Load (assemblyString);
                }
-               
+
+#if NET_4_0
+               [Obsolete]
+#endif         
                public static Assembly Load (String assemblyString, Evidence assemblySecurity)
                {
                        return AppDomain.CurrentDomain.Load (assemblyString, assemblySecurity);
@@ -545,6 +538,9 @@ namespace System.Reflection {
                        return AppDomain.CurrentDomain.Load (assemblyRef);
                }
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public static Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
                {
                        return AppDomain.CurrentDomain.Load (assemblyRef, assemblySecurity);
@@ -560,6 +556,9 @@ namespace System.Reflection {
                        return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore);
                }
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public static Assembly Load (Byte[] rawAssembly, Byte[] rawSymbolStore,
                                             Evidence securityEvidence)
                {
@@ -584,6 +583,9 @@ namespace System.Reflection {
                        return LoadFrom (assemblyFile, true);
                }
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public static Assembly LoadWithPartialName (string partialName)
                {
                        return LoadWithPartialName (partialName, null);
@@ -596,7 +598,11 @@ namespace System.Reflection {
                }
 
                [MonoTODO ("Not implemented")]
-               public Module LoadModule (string moduleName, byte [] rawModule, byte [] rawSymbolStore)
+               public
+#if NET_4_0
+               virtual
+#endif
+               Module LoadModule (string moduleName, byte [] rawModule, byte [] rawSymbolStore)
                {
                        throw new NotImplementedException ();
                }
@@ -604,6 +610,9 @@ namespace System.Reflection {
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                private static extern Assembly load_with_partial_name (string name, Evidence e);
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public static Assembly LoadWithPartialName (string partialName, Evidence securityEvidence)
                {
                        return LoadWithPartialName (partialName, securityEvidence, true);
@@ -646,7 +655,11 @@ namespace System.Reflection {
                        }
                }
 
-               public Object CreateInstance (String typeName, Boolean ignoreCase,
+               public
+#if NET_4_0
+               virtual
+#endif
+               Object CreateInstance (String typeName, Boolean ignoreCase,
                                              BindingFlags bindingAttr, Binder binder,
                                              Object[] args, CultureInfo culture,
                                              Object[] activationAttributes)
@@ -667,49 +680,14 @@ namespace System.Reflection {
                        return GetLoadedModules (false);
                }
 
-               // FIXME: Currently, the two sets of modules are equal
-               public Module[] GetLoadedModules (bool getResourceModules)
-               {
-                       return GetModules (getResourceModules);
-               }
-
                public Module[] GetModules ()
                {
                        return GetModules (false);
                }
 
-               public Module GetModule (String name)
-               {
-                       if (name == null)
-                               throw new ArgumentNullException ("name");
-                       if (name.Length == 0)
-                               throw new ArgumentException ("Name can't be empty");
-
-                       Module[] modules = GetModules (true);
-                       foreach (Module module in modules) {
-                               if (module.ScopeName == name)
-                                       return module;
-                       }
-
-                       return null;
-               }
-
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal virtual extern Module[] GetModulesInternal ();
 
-               public Module[] GetModules (bool getResourceModules) {
-                       Module[] modules = GetModulesInternal ();
-
-                       if (!getResourceModules) {
-                               ArrayList result = new ArrayList (modules.Length);
-                               foreach (Module m in modules)
-                                       if (!m.IsResource ())
-                                               result.Add (m);
-                               return (Module[])result.ToArray (typeof (Module));
-                       }
-                       else
-                               return modules;
-               }
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal extern string[] GetNamespaces ();
@@ -724,7 +702,7 @@ namespace System.Reflection {
                public extern static Assembly GetCallingAssembly ();
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               public extern AssemblyName[] GetReferencedAssemblies ();
+               internal static extern AssemblyName[] GetReferencedAssemblies (Assembly module);
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                private extern bool GetManifestResourceInfoInternal (String name, ManifestResourceInfo info);
@@ -767,16 +745,14 @@ namespace System.Reflection {
 
                [MonoTODO ("Currently it always returns zero")]
                [ComVisible (false)]
-               public long HostContext {
+               public
+#if NET_4_0
+               virtual
+#endif
+               long HostContext {
                        get { return 0; }
                }
 
-               [ComVisible (false)]
-               public Module ManifestModule {
-                       get {
-                               return GetManifestModule ();
-                       }
-               }
 
                internal virtual Module GetManifestModule () {
                        return GetManifestModuleInternal ();
@@ -809,7 +785,7 @@ namespace System.Reflection {
                }
 #endif
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // Code Access Security
 
                internal void Resolve () 
@@ -891,6 +867,56 @@ namespace System.Reflection {
                        }
                }
 #endif
+
+#if NET_4_0
+               static Exception CreateNIE ()
+               {
+                       return new NotSupportedException ("Derived classes must implement it");
+               }
+
+               public virtual Type GetType (string name, bool throwOnError, bool ignoreCase)
+               {
+                       throw CreateNIE ();
+               }
+
+               public virtual Module GetModule (String name)
+               {
+                       throw CreateNIE ();
+               }
+
+               public virtual AssemblyName[] GetReferencedAssemblies ()
+               {
+                       throw CreateNIE ();
+               }
+
+               public virtual Module[] GetModules (bool getResourceModules)
+               {
+                       throw CreateNIE ();
+               }
+
+               public virtual Module[] GetLoadedModules (bool getResourceModules)
+               {
+                       throw CreateNIE ();
+               }
+
+               public virtual Assembly GetSatelliteAssembly (CultureInfo culture)
+               {
+                       throw CreateNIE ();
+               }
+
+               public virtual Assembly GetSatelliteAssembly (CultureInfo culture, Version version)
+               {
+                       throw CreateNIE ();
+               }
+
+               public virtual Module ManifestModule {
+                       get { throw CreateNIE (); }
+               }
+
+               public virtual bool GlobalAssemblyCache {
+                       get { throw CreateNIE (); }
+               }
+#endif
        }
 }
 
index fda76e313a03394c5f659057b51fab6d94037ecc..cf38738b594753f9f8ecf6950f981afbd70c0013 100644 (file)
@@ -1,3 +1,36 @@
+2010-03-25 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * Assembly.cs: Add v4 obsolete attribute.
+
+2010-03-25 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * Assembly.cs:
+       * MonoAssembly.cs: Move a dozen methods from Assembly.cs
+       to MonoAssembly.cs, so they can either be the concrete impl
+       on v4 of the only impl on v2.
+       Add to Assembly.cs versions that throws NotImplementedException.
+       Mask Assembly.cs as abstract.
+
+2010-03-24 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * Assembly.cs: Make it a partial class under !v4.
+
+       * MonoAssembly.cs: New type that exists only under
+       v4. Under v2 it is a part of Assembly.
+
+       This is the initial setup to make v4 Assembly an
+       abstract type where all methods raise exceptions.
+
+2010-03-24  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * MethodInfo.cs: Exclude IsGenericMethod* and ContainsGenericParameters
+       from moonlight too.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Assembly.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2010-03-07 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * EventInfo.cs: Some v4 adjustments.
index 3a51d0046d9066ece67ab6672ccd56860fa172ee..13578f3aec8556a077b7953e919bfcb443cd91e8 100644 (file)
@@ -107,7 +107,7 @@ namespace System.Reflection {
                        return Type.EmptyTypes;
                }
 
-#if !NET_4_0
+#if !NET_4_0 && !MOONLIGHT
                public override bool IsGenericMethod {
                        get {
                                return false;
diff --git a/mcs/class/corlib/System.Reflection/MonoAssembly.cs b/mcs/class/corlib/System.Reflection/MonoAssembly.cs
new file mode 100644 (file)
index 0000000..51ec250
--- /dev/null
@@ -0,0 +1,161 @@
+//
+// System.Reflection/MonoAssembly.cs
+//
+// Author:
+//   Rodrigo Kumpera (rkumpera@novell.com)
+//
+// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Runtime.InteropServices;
+
+
+namespace System.Reflection {
+
+#if NET_4_0
+       [ComVisible (true)]
+       [ComDefaultInterfaceAttribute (typeof (_Assembly))]
+       [Serializable]
+       [ClassInterface(ClassInterfaceType.None)]
+       public class MonoAssembly : Assembly {
+#else
+       public partial class Assembly {
+#endif
+               public
+#if NET_4_0
+               override
+#endif
+               Type GetType (string name, bool throwOnError, bool ignoreCase)
+               {
+                       if (name == null)
+                               throw new ArgumentNullException (name);
+                       if (name.Length == 0)
+                       throw new ArgumentException ("name", "Name cannot be empty");
+
+                       return InternalGetType (null, name, throwOnError, ignoreCase);
+               }
+
+               public
+#if NET_4_0
+               override
+#endif
+               Module GetModule (String name)
+               {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       if (name.Length == 0)
+                               throw new ArgumentException ("Name can't be empty");
+
+                       Module[] modules = GetModules (true);
+                       foreach (Module module in modules) {
+                               if (module.ScopeName == name)
+                                       return module;
+                       }
+
+                       return null;
+               }
+
+               public
+#if NET_4_0
+               override
+#endif
+               AssemblyName[] GetReferencedAssemblies () {
+                       return GetReferencedAssemblies (this);
+               }
+
+               public
+#if NET_4_0
+               override
+#endif
+               Module[] GetModules (bool getResourceModules) {
+                       Module[] modules = GetModulesInternal ();
+
+                       if (!getResourceModules) {
+                               ArrayList result = new ArrayList (modules.Length);
+                               foreach (Module m in modules)
+                                       if (!m.IsResource ())
+                                               result.Add (m);
+                               return (Module[])result.ToArray (typeof (Module));
+                       }
+                       else
+                               return modules;
+               }
+
+               // FIXME: Currently, the two sets of modules are equal
+               public
+#if NET_4_0
+               override
+#endif
+               Module[] GetLoadedModules (bool getResourceModules)
+               {
+                       return GetModules (getResourceModules);
+               }
+
+               public
+#if NET_4_0
+               override
+#endif
+               Assembly GetSatelliteAssembly (CultureInfo culture)
+               {
+                       return GetSatelliteAssembly (culture, null, true);
+               }
+
+               public
+#if NET_4_0
+               override
+#endif
+               Assembly GetSatelliteAssembly (CultureInfo culture, Version version)
+               {
+                       return GetSatelliteAssembly (culture, version, true);
+               }
+
+               //FIXME remove GetManifestModule under v4, it's a v2 artifact
+               [ComVisible (false)]
+               public
+#if NET_4_0
+               override
+#endif
+               Module ManifestModule {
+                       get {
+                               return GetManifestModule ();
+                       }
+               }
+
+#if !MOONLIGHT
+               public
+#if NET_4_0
+               override
+#endif
+               bool GlobalAssemblyCache {
+                       get {
+                               return get_global_assembly_cache ();
+                       }
+               }
+#endif
+
+       }
+}
+
+
index 4b0fe5e655905f39911a7c54ba0d7e73bfd301d8..6027a5bd4fb4a3a95b01be66da85110f666e824c 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * ResourceManager.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2010-03-01  Miguel de Icaza  <miguel@novell.com>
 
        * Win32Resources.cs: Prevent infinite loops if the resource that
index 58c87fee00e2967e7800f41328f66e795ff0b378..c0979a045a3e1f1aef4b98b136243d33234c1ac1 100644 (file)
@@ -281,7 +281,7 @@ namespace System.Resources
 
                private string GetResourceFilePath (CultureInfo culture)
                {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        if (resourceDir != null)
                                return Path.Combine (resourceDir, GetResourceFileName (culture));
                        else
index b7bf33b135195698c2535fe860e4d618188c8ad6..f32d1c8818c438cb19e112eb1a58640306e61694 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-18  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ConditionalWeakTable.cs:
+       * ReferenceAssemblyAttribute.cs:
+       * TypeForwardedFromAttribute.cs:
+               Build them into Moonlight too (SL4)
 
 Fri Feb 12 19:03:11 CET 2010 Paolo Molaro <lupus@ximian.com>
 
index b9909bb16ca272b20602c2a729e5f37938aca09e..203ab4dc49d401d1214bf57962a7faeefa78ff01 100644 (file)
@@ -11,7 +11,7 @@
        //   "I think our table is weak, but does not do proper compacting"
        //
 
-#if NET_4_0 || BOOTSTRAP_NET_4_0
+#if NET_4_0 || BOOTSTRAP_NET_4_0 || MOONLIGHT
 using System;
 using System.Collections;
 using System.Collections.Generic;
index 579e0a7b9d2336cb4e6f8b553814c4933388e5b5..0d1358f66d73df457851f48f1381762559a87a95 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if NET_4_0 || MOONLIGHT
 
 using System;
 using System.Runtime.InteropServices;
 
-#if NET_4_0
-
 namespace System.Runtime.CompilerServices {
 
        [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=false)] 
index d5b48c6b454c494d974798bad6bed8be71adbb31..8f09155abdfed653d183a9980f7dd8b4a015517b 100644 (file)
@@ -26,7 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_4_0 || BOOTSTRAP_NET_4_0
+#if NET_4_0 || BOOTSTRAP_NET_4_0 || MOONLIGHT
 
 namespace System.Runtime.CompilerServices
 {
index 2bef9444084cb33865c0c1e14ed34d013449e7b2..05c70839ba2196169a857f4f6eabc12589ebcc6e 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * MarshalAsAttribute.cs, Marshal.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2009-12-13  Miguel de Icaza  <miguel@novell.com>
 
        * SafeBuffer.cs: When comparing the end, we only need to compare
index 0fa52fe70889c9b6922bd0206e20722f39823fcd..fa0344c771e185b9b0bf8ce078f780851b8e666d 100644 (file)
@@ -38,11 +38,11 @@ using System.Reflection;
 using System.Threading;
 
 using System.Runtime.ConstrainedExecution;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using System.Runtime.InteropServices.ComTypes;
 #endif
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using Mono.Interop;
 #endif
 
@@ -189,7 +189,7 @@ namespace System.Runtime.InteropServices
                        throw new NotImplementedException ();
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static object CreateWrapperOfType (object o, Type t)
                {
                        __ComObject co = o as __ComObject;
@@ -272,7 +272,7 @@ namespace System.Runtime.InteropServices
                        FreeHGlobal (s);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static Guid GenerateGuidForType (Type type)
                {
                        return type.GUID;
@@ -374,7 +374,7 @@ namespace System.Runtime.InteropServices
                {
                        throw new NotImplementedException ();
                }
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                private extern static IntPtr GetIDispatchForObjectInternal (object o);
 
@@ -744,7 +744,7 @@ namespace System.Runtime.InteropServices
                        return ReleaseInternal (pUnk);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                private extern static int ReleaseComObjectInternal (object co);
 
@@ -833,7 +833,7 @@ namespace System.Runtime.InteropServices
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                public extern static IntPtr StringToHGlobalUni (string s);
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static IntPtr SecureStringToBSTR (SecureString s)
                {
                        if (s == null)
@@ -1049,7 +1049,7 @@ namespace System.Runtime.InteropServices
                        return null;
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static int FinalReleaseComObject (object o)
                {
                        while (ReleaseComObject (o) != 0);
index 4b5bd0a02a7ef64ede92af663a3f91034e3d7368..9bb9e9a92576c4320e4cc0437d5218784e0b4215 100644 (file)
@@ -46,7 +46,7 @@ namespace System.Runtime.InteropServices {
                [ComVisible(true)]
                public Type MarshalTypeRef;
                
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public VarEnum SafeArraySubType;
 #endif
 
index 9f0309eb136b174e3c867f8b229adf0ba58caed2..4b23af65c8e7331619d10118e5267d9c756df94d 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Context.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2009-10-07  Sebastien Pouliot  <sebastien@ximian.com>
 
        * Context.cs: Remove LocalDataStoreSlot-related methods from
index e3766b8cbca4640beba287debb8f6ec1ae96b5ae..ca52953270878766b5b489ab51073759f0430b68 100644 (file)
@@ -346,7 +346,7 @@ namespace System.Runtime.Remoting.Contexts {
                        callback_object.DoCallBack (deleg);
                }
                
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static LocalDataStoreSlot AllocateDataSlot ()
                {
                        return new LocalDataStoreSlot (false);
index 5f44c6b6fb851d8c2b024ac5837bf24aa430ddf8..7b756fd75fc607224d867cd7f0cdf64a8c1aa0b8 100644 (file)
@@ -51,6 +51,7 @@ public class AsyncResult : IAsyncResult, IMessageSink {
        object async_callback;
        ExecutionContext current;
        ExecutionContext original;
+       long add_time;
 #pragma warning restore 169, 414, 649
 
        // not part of MonoAsyncResult...
@@ -61,7 +62,15 @@ public class AsyncResult : IAsyncResult, IMessageSink {
        internal AsyncResult ()
        {
        }
-       
+
+       internal AsyncResult (WaitCallback cb, object state, bool capture_context)
+       {
+               async_state = state;
+               async_delegate = cb;
+               if (capture_context)
+                       current = ExecutionContext.Capture ();
+       }
+
        public virtual object AsyncState
        {
                get {
index 1c24c712326303ff9e259d66757c5a2b7dabd48d..3ff486ed9c8736fbc333570de9573e02069ee735 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-25 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * AsyncResult.cs: add new constructor used by the threadpool and new
+       field that stores the time that the work item was added to the pool.
+
 2010-03-03  Robert Jordan  <robertj@gmx.net>
 
        * CADMessages.cs (GetMethod): don't continue if the type
index e8338d99d22017e97da8712856473e3a73019e65..ffe5b4320df8081c106ae61ecf9458606173de92 100644 (file)
@@ -81,7 +81,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
 
                        // TimeStamp does not have a TypeCode, so it is managed as a special
                        // case in GetTypeCode()
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        // This environment variable is only for test and benchmarking purposes.
                        // By default, mono will always use IL generated class serializers.
                        string s = Environment.GetEnvironmentVariable("MONO_REFLECTION_SERIALIZER");
index 3975be4a7ecdb09136a9928055521b22384aaf27..510fe781b7ef312ac4e0f104f8c218760aa8fdcd 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * BinaryCommon.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2010-02-26  Robert Jordan  <robertj@gmx.net>
 
        * ObjectReader.cs (ReadType, GetDeserializationType):
index 115cbc6462f7c3f20cd4f47534c5452a0ae9e025..86217bd8cb05bc6b1148253a59084a0fa7f0b2fc 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * X509KeyStorageFlags.cs, X509ContentType.cs, X509Certificate.cs
+       X509Certificate20.cs: use MOONLIGHT symbol to disambiguate
+       MonoTouch and Moonlight code.
+
 2009-09-22  Sebastien Pouliot  <sebastien@ximian.com>
 
        * X509Certificate20.cs: Don't depend on SecureString for NET_2_1
index 96d3540ad697ad2bc16119587fb051f3a8af5a78..7830a6b91131af330a332282279f1174bcffa6fd 100644 (file)
@@ -36,7 +36,7 @@ using Mono.Security;
 using Mono.Security.X509;
 
 using System.Runtime.Serialization;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using Mono.Security.Authenticode;
 #endif
 
@@ -100,7 +100,7 @@ namespace System.Security.Cryptography.X509Certificates {
                        return new X509Certificate (data);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("Incomplete - minimal validation in this version")]
                public static X509Certificate CreateFromSignedFile (string filename)
                {
@@ -152,7 +152,7 @@ namespace System.Security.Cryptography.X509Certificates {
 #endif
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
                private void InitFromHandle (IntPtr handle)
                {
index f124684aada413817c7ff8687a7f1ba3b106f1ba..21ff22e3dc48d11e7e9d1b713053ae937c473dd4 100644 (file)
@@ -41,7 +41,7 @@ namespace System.Security.Cryptography.X509Certificates {
 
        [ComVisible (true)]
        [MonoTODO ("X509ContentType.SerializedCert isn't supported (anywhere in the class)")]
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
        public partial class X509Certificate {
 #else
        public partial class X509Certificate : IDeserializationCallback, ISerializable {
@@ -60,7 +60,7 @@ namespace System.Security.Cryptography.X509Certificates {
                        Import (rawData, password, X509KeyStorageFlags.DefaultKeySet);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("SecureString support is incomplete")]
                public X509Certificate (byte[] rawData, SecureString password)
                {
@@ -73,7 +73,7 @@ namespace System.Security.Cryptography.X509Certificates {
                        Import (rawData, password, keyStorageFlags);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("SecureString support is incomplete")]
                public X509Certificate (byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
                {
@@ -91,7 +91,7 @@ namespace System.Security.Cryptography.X509Certificates {
                        Import (fileName, password, X509KeyStorageFlags.DefaultKeySet);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("SecureString support is incomplete")]
                public X509Certificate (string fileName, SecureString password)
                {
@@ -104,7 +104,7 @@ namespace System.Security.Cryptography.X509Certificates {
                        Import (fileName, password, keyStorageFlags);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("SecureString support is incomplete")]
                public X509Certificate (string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
                {
@@ -171,7 +171,7 @@ namespace System.Security.Cryptography.X509Certificates {
                        return Export (contentType, pwd);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("X509ContentType.Pfx/Pkcs12 and SerializedCert are not supported. SecureString support is incomplete.")]
                public virtual byte[] Export (X509ContentType contentType, SecureString password)
                {
@@ -189,7 +189,7 @@ namespace System.Security.Cryptography.X509Certificates {
                                switch (contentType) {
                                case X509ContentType.Cert:
                                        return x509.RawData;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                                case X509ContentType.Pfx: // this includes Pkcs12
                                        // TODO
                                        throw new NotSupportedException ();
@@ -256,7 +256,7 @@ namespace System.Security.Cryptography.X509Certificates {
                        }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("SecureString support is incomplete")]
                public virtual void Import (byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
                {
@@ -279,7 +279,7 @@ namespace System.Security.Cryptography.X509Certificates {
                        Import (rawData, password, keyStorageFlags);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("SecureString support is incomplete, missing KeyStorageFlags support")]
                public virtual void Import (string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
                {
@@ -288,7 +288,7 @@ namespace System.Security.Cryptography.X509Certificates {
                }
 #endif
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                void IDeserializationCallback.OnDeserialization (object sender)
                {
                }
index e07ae398707ca12e14a1dd5cb180e5db6217d278..e7b0f14a554833a850974cbd370bc7cbdb3276a8 100644 (file)
@@ -37,7 +37,7 @@ namespace System.Security.Cryptography.X509Certificates {
        enum X509ContentType {
                Unknown,
                Cert,
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // not supported by Silverlight 2.0 (NET_2_1)
                SerializedCert,
                Pfx,
index a36aec8534c24d43fd1e67eaac3b4a012fd1c20b..b7b2d9e62d71eedbcc63bd584102fcf2550edf72 100644 (file)
@@ -35,7 +35,7 @@ namespace System.Security.Cryptography.X509Certificates {
        [ComVisible (true)]
        public enum X509KeyStorageFlags {
                DefaultKeySet = 0,
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // not supported by Silverlight 2.0 (NET_2_1)
                UserKeySet = 1,
                MachineKeySet = 2,
index 77dde0efef8bfd6581a99a5f284398ed17dd5069..fd63654d727e04e3d33078c9b2e9f1b0b18abb18 100644 (file)
@@ -1,3 +1,33 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Rijndael.cs
+       * HMACSHA512.cs
+       * RijndaelManagedTransform.cs
+       * HMACSHA384.cs
+       * RijndaelManaged.cs
+       * CryptoConfig.cs
+       * CryptoConfig_2_1.cs
+       * DESCryptoServiceProvider.cs
+       * SHA512Managed.cs
+       * RC2.cs
+       * TripleDES.cs
+       * HMACRIPEMD160.cs
+       * RIPEMD160.cs
+       * RC2CryptoServiceProvider.cs
+       * SymmetricAlgorithm.cs
+       * SHA384Managed.cs
+       * DSACryptoServiceProvider.cs
+       * DES.cs
+       * MACTripleDES.cs
+       * HMACMD5.cs
+       * RSACryptoServiceProvider.cs
+       * RIPEMD160Managed.cs
+       * TripleDESCryptoServiceProvider.cs
+       * SHA1CryptoServiceProvider.cs
+       * SHA512.cs
+       * SHA384.cs:
+               Use MOONLIGHT symbol to disambiguate MonoTouch and Moonlight code.
+
 2010-01-07  Sebastien Pouliot  <sebastien@ximian.com>
 
        * ToBase64Transform.cs: Static-ify some methods to make it easier 
index fab9c67842661d8a79cf67c08c1d10d538f6f666..1d0e78d99ea4e970f7dcb9f13c44744860c2da54 100644 (file)
@@ -29,7 +29,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Collections;
 using System.Globalization;
index d308a8a6f400c57864fbaefc22ee7fce09b2ed12..657c7aa4368ff0085f29607983b418fae532c55d 100644 (file)
@@ -124,7 +124,7 @@ namespace System.Security.Cryptography {
                        }
                        return num;
                }
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                // we need SHA1 support to verify the codecs binary integrity
                public static string MapNameToOID (string name)
                {
index cece541a0ad7c8f698b8d4301e4232af3e51df7e..0a664838bec9f03ca1a7ad5b88f2b29c49cc65c4 100644 (file)
@@ -28,7 +28,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Globalization;
 using System.Runtime.InteropServices;
index f8d410f1fa3148312eab535ca0cb78f760ac3b8d..d1fbf26edd2eca03b57c7f3c2db4b95a52f981c7 100644 (file)
@@ -28,7 +28,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 using Mono.Security.Cryptography;
index fbb5e4fab08f1ca27bdce3afc63e35f5971b5a3b..41951ff66ccf22575abf1a1ddddf321141ed3f34 100644 (file)
@@ -31,7 +31,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.IO;
 using System.Globalization;
index cb5feaf336a2fa7edfb6750958cbfa3349456c38..a84aee8a3d66976e8ef2c38b66d02c7bb40f47ef 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index f8a6dc2e4f6b23e04a98f6354f7d5c4012a4f211..0a039c5801be78a0df77851ad7524e24303c5ac1 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index e27387ef0b179bbf2f70f77a9894c0c55c572814..007caf5129930014fc1a74c35dc22eaeb458ed00 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index d04722104fe6950f8287eff285bfd6b20f454f2b..562d40d6f59580bad385708832796c853f591484 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index aebd4b4086f3bc73ffaefe19dae3a8f06543c27d..89089707fdf385ee3e807cde56ef0c4ff9e574b3 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index 2b808cb67583c976290deb266cf945dc633efdc1..e7e7ecdf9ca62b70db13f77f1b9a6e464c7eed4e 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index 732486edfca7528e85252c210b44335b6310a907..6a5d8461ac051421ff8ee69dedae29570ce6e097 100644 (file)
@@ -28,7 +28,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Globalization;
 using System.Runtime.InteropServices;
index c98781e7b2888859ccd75c00e194abea29f6e53a..2102a480c0f391a341bc99820d8f5494848ab6e2 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index c242aabb5c870c7a0da7ed0983ee4da2f81b0269..634d9accbef05d8e954716bacbafc5389ad4abbe 100644 (file)
@@ -30,7 +30,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index c254c17e5ba7a2663be01d5bc1d940e550e6802b..ef607bc5fd28b0274dfcca13685009223baf6f17 100644 (file)
@@ -29,7 +29,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.IO;
 using System.Runtime.InteropServices;
index 1ccd1fd3bb71989b5c76700d5a54fcec11713835..a1343db1b853fd960c93c0fa61b8840c34cd0cb6 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 \r
 using System.Runtime.InteropServices;
 \r
index 156b9515f16e1cf0f03fa92b06d56ae3d9efa6d1..f92a6a54f54d962b15b9df9cc7f989b77c679bf5 100644 (file)
@@ -31,7 +31,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 using Mono.Security.Cryptography;
index aa44aed17711a0f5f3bb8260f354f727d22b2e1d..ccc4da333b8d2e36360639019b09d25d5c67775c 100644 (file)
@@ -26,7 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if  !NET_2_1 || MONOTOUCH
+#if  !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index c6e8fa60e9acaf218e66b49be322c4a81f842a02..465adc8f35bf358b68c97223b7235b18d9e69c80 100644 (file)
@@ -316,7 +316,7 @@ namespace System.Security.Cryptography {
                }
        }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
        [ComVisible (true)]
        public sealed class SHA1CryptoServiceProvider : SHA1 {
index 6cf037bb988fd83bffe892c02d4e4b025a1b5cbf..2daff34a694ddd48475813c9f7cd2f334d293162 100644 (file)
@@ -29,7 +29,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 \r
index 8b79b5f8ddbc5c7672e7d6d465e026787e9bb9d7..43495bef6b11ed4e70869b0dce3bc1f9305e4eab 100644 (file)
@@ -30,7 +30,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index 94d943fe739a5116f63e832c6499a966cff17a60..00baef00d084cc62d6143499109c145893b2798c 100644 (file)
@@ -29,7 +29,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 \r
index 2dc5c1498237938bf7b3d57514f0dfe659579342..190adeb327e4a6bd42677edac659a615f7469e77 100644 (file)
@@ -30,7 +30,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 
index d306b56728f056dbb2c52115b931ba0f82741e91..2ee27a7fabcbdea3b57f808622b05abb2c89b935 100644 (file)
@@ -42,7 +42,7 @@ namespace System.Security.Cryptography {
                protected byte[] KeyValue; 
                protected KeySizes[] LegalBlockSizesValue; 
                protected KeySizes[] LegalKeySizesValue; 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                // Silverlight 2.0 only supports CBC
                internal int FeedbackSizeValue;
                internal CipherMode ModeValue;
@@ -61,7 +61,7 @@ namespace System.Security.Cryptography {
                        m_disposed = false;
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                // No Finalizer or IDisposable.Dispose in Silverlight 2.0
                // Documentation makes it "clear" that Clear MUST BE CALLED to zero out sensitive information
 #else          
index 9af792158e0d60ea0b2346c361e1f5347f7fd7c6..f368f7ca1ca147118a8796d1a429d063fa29976c 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Globalization;
 using System.Runtime.InteropServices;
index 61c2729b77df89d9c05c7bb8d2277b90c26404bf..8a93cb90d2f2e471334a2aa8a0a2b82fd808fe53 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 using Mono.Security.Cryptography;
index a2683cb943ecc28ded7a3da0be1ca9ccd68e924f..86d9705e6966345705e4d25f56bba4c0a30e47d0 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * PublisherIdentityPermissionAttribute.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2009-09-22  Sebastien Pouliot  <sebastien@ximian.com>
 
        * PermissionSetAttribute.cs: Don't create a pset for NET_2_1
index 2740291d494cb48f7f846df6c43668de77ed3a89..d5ae1319b1a9e843167d82d26ab50939a9ceea99 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Runtime.InteropServices;
 using SSCX = System.Security.Cryptography.X509Certificates;
index 1a2429495d3c63f685a084971b390dc77216a61e..b1caf8bfd76c1a04c8df7d12ec5fae1a36f6e750 100644 (file)
@@ -1,3 +1,15 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Zone.cs
+       * Hash.cs
+       * Evidence.cs
+       * PolicyLevel.cs
+       * PolicyLevel_2_1.cs
+       * ZoneMembershipCondition.cs
+       * HashMembershipCondition.cs:
+               Use MOONLIGHT symbol to disambiguate MonoTouch
+               and Moonlight code.
+
 2010-02-27 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * Evidence.cs: Add some v4 bits.
index a876dfd3c9ccd5320c0d3c411903787bbfcd4068..5d932f5259d0fec1b475152154acaa88b9129246 100644 (file)
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices;
 using System.Security.Permissions;
 using System.Security.Cryptography.X509Certificates;
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using Mono.Security.Authenticode;
 #endif
 
index ce8bb46ba8881a0b9f6e9f1d9dafd72cb9d3c38e..7287b97f31a45757e9a53d162aa3b82130aa14c6 100644 (file)
@@ -29,7 +29,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.IO;
 using System.Reflection;
index 75204b3f40496a8bd2fc653b20455848119e9e86..6918f250f85c6ba3b6e522512d6eface402663fa 100644 (file)
@@ -28,7 +28,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Collections;
 using System.Globalization;
index b13c05154a21298e094e0aea601e88a04a59e9d0..a124af3d3202dd0570c0450508911b6b2d8313ac 100644 (file)
@@ -31,7 +31,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Collections; // for IList
 using System.Globalization;
index dae7c7e5fc76c7c3ec307d249b63d7f932ace504..6582f73a03707940a4893b642b0f9171b367c6f2 100644 (file)
@@ -31,7 +31,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
 
 using System.Reflection;
 
index 88736f0008b2adf341d150aaf37ccbd1c2a60830..6b40975ad0ed55da8af4aaff9fe96038b1ebad93 100644 (file)
@@ -28,7 +28,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.IO;
 using System.Globalization;
index 794b32985f7df6c3328470f21da094793979b03f..d3a831b2814bf141f50c7d34621693915cd64de7 100644 (file)
@@ -28,7 +28,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Collections;
 using System.Globalization;
index 16023fc31ae791a431739ea3029348d3d526d279..1dab8893fb833370f93775863d4c17f0b18c6b25 100644 (file)
@@ -1,3 +1,19 @@
+2010-03-23  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SecurityManager_2_1.cs: Add an internal HasElevatedPermissions 
+       property to mscorlib since the "real" (i.e. visible) one in 
+       System.Windows.dll is not accessible by most code.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * SecurityTransparentAttribute.cs
+       * SecurityFrame.cs
+       * IPermission.cs
+       * SecurityManager.cs
+       * SecurityManager_2_1.cs
+       * SecuritySafeCriticalAttribute.cs:
+               use MOONLIGHT symbol to disambiguate MonoTouch and Moonlight code.
+
 2009-10-30     Marek Safar  <marek.safar@gmail.com>
 
        * SecurityRuleSet.cs, SecurityRulesAttribute.cs: Implemented.
index 4155b32463d48b8310fbb632a7f064b9e392098d..d045a2a9498daffd67a0e13d49852c6a5e9cd44b 100644 (file)
@@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
 namespace System.Security {
 
        [ComVisible (true)]
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
        public interface IPermission {
 #else
        public interface IPermission : ISecurityEncodable {
index 404ada19995cefa1ede28c034404ace3905772f9..340c8764386c62a6dc3b0e4aa48b85d5a2c48895 100644 (file)
@@ -53,7 +53,7 @@ namespace System.Security {
        }
 #pragma warning restore 649    
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
        internal struct SecurityFrame {
 
                private AppDomain _domain;
index 7040a08128fe7b361fd958c0c49575fae96df782..531b5439a410f1a87bf772c47752c13c442eb1e6 100644 (file)
@@ -29,7 +29,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
 using System.Collections;
 using System.Globalization;
index 7e726a84bbf0a9a19bbc53e8fbed2e0f1504ea6c..216f03da15fe55de36542cc4989f8fd01491f714 100644 (file)
@@ -7,7 +7,7 @@
 //
 // (C) Nick Drochak
 // Portions (C) 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005, 2009 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005, 2009-2010 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -29,7 +29,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
 
 using System.Reflection;
 using System.Runtime.CompilerServices;
@@ -54,6 +54,10 @@ namespace System.Security {
                        get;
                }
 
+               public static bool HasElevatedPermissions {
+                       get; set;
+               }
+
                internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas)
                {
                        return null;
index 0b641438a43102eb6bbfc4ae378ae7a1ecc3510e..7524ec55459d9fe6b3b67b679b9e544d992ad77d 100644 (file)
@@ -28,7 +28,7 @@
 
 namespace System.Security {
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
        [MonoTODO ("Only supported by the runtime when CoreCLR is enabled")]
 #endif
        [AttributeUsage (AttributeTargets.All, AllowMultiple=false, Inherited=false)]
index f5190aece2763bfa0d09c69399bda4a5a3d98791..ef89603dbf601ebe43f225e7acfc306d4a00189d 100644 (file)
@@ -28,7 +28,7 @@
 
 namespace System.Security {
 
-#if !NET_2_1 || MONOTOUCH
+#if MOONLIGHT
        [MonoTODO ("Only supported by the runtime when CoreCLR is enabled")]
 #endif
        [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
index 8ce7828fc903f988e136737c8882afe23d5da3e5..9bae2a7034915c2f532f7ba129d58f6cabc480ea 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * StringBuilder.cs, Encoding.cs: use MOONLIGHT symbol to
+       disambiguate MonoTouch and Moonlight code.
+
 2010-02-02  Jb Evain  <jbevain@novell.com>
 
        * ASCIIEncoding.cs, Latin1Encoding.cs: remove duplicated code.
index 303b150a7304721c699be7d5bbc4154b1957f8e7..32e2312b45d8419a73118bbfe7ad01bce96521a0 100644 (file)
@@ -444,13 +444,13 @@ public abstract class Encoding : ICloneable
                        case UnicodeEncoding.BIG_UNICODE_CODE_PAGE:
                                return BigEndianUnicode;
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        case Latin1Encoding.ISOLATIN_CODE_PAGE:
                                return ISOLatin1;
 #endif
                        default: break;
                }
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // Try to obtain a code page handler from the I18N handler.
                Encoding enc = (Encoding)(InvokeI18N ("GetEncoding", codepage));
                if (enc != null) {
@@ -494,7 +494,7 @@ public abstract class Encoding : ICloneable
                return e;
        }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
        public static Encoding GetEncoding (int codepage,
                EncoderFallback encoderFallback, DecoderFallback decoderFallback)
@@ -565,7 +565,7 @@ public abstract class Encoding : ICloneable
                return encoding_infos;
        }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
        [ComVisible (false)]
        public bool IsAlwaysNormalized ()
        {
@@ -610,7 +610,7 @@ public abstract class Encoding : ICloneable
                        UTF32Encoding.BIG_UTF32_CODE_PAGE,
                        "UTF_32BE",
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        Latin1Encoding.ISOLATIN_CODE_PAGE,
                        "iso_8859_1", "latin1"
 #endif // !NET_2_1
@@ -639,7 +639,7 @@ public abstract class Encoding : ICloneable
                        if (converted == ((string)encodings [i]))
                                return GetEncoding (code);
                }
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // Try to obtain a web encoding handler from the I18N handler.
                Encoding enc = (Encoding)(InvokeI18N ("GetEncoding", name));
                if (enc != null) {
@@ -875,14 +875,14 @@ public abstract class Encoding : ICloneable
                                                                case 3: code_page = UTF8Encoding.UTF8_CODE_PAGE; break;
                                                                case 4: code_page = UnicodeEncoding.UNICODE_CODE_PAGE; break;
                                                                case 5: code_page = UnicodeEncoding.BIG_UNICODE_CODE_PAGE; break;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                                                                case 6: code_page = Latin1Encoding.ISOLATIN_CODE_PAGE; break;
 #endif
                                                                }
                                                                defaultEncoding = GetEncoding (code_page);
                                                        }
                                                } catch (NotSupportedException) {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                                        defaultEncoding = UTF8;
 #else
                                                        // code_page is not supported on underlying platform
@@ -891,7 +891,7 @@ public abstract class Encoding : ICloneable
                                                } catch (ArgumentException) {
                                                        // code_page_name is not a valid code page, or is 
                                                        // not supported by underlying OS
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                                                        defaultEncoding = UTF8;
 #else
                                                        defaultEncoding = UTF8Unmarked;
@@ -906,7 +906,7 @@ public abstract class Encoding : ICloneable
                }
        }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
        // Get the ISO Latin1 encoding object.
        private static Encoding ISOLatin1
index d3033b1b00e34e3da2c3bb35fa92b8ff407889f9..d68cb8939e6fb0de3c6d671ca231a25167ecbbbd 100644 (file)
@@ -536,7 +536,7 @@ namespace System.Text {
                        return this;
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                internal
 #else
                public
@@ -546,7 +546,7 @@ namespace System.Text {
                        return AppendFormat (null, format, new object [] { arg0 });
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                internal
 #else
                public
@@ -556,7 +556,7 @@ namespace System.Text {
                        return AppendFormat (null, format, new object [] { arg0, arg1 });
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                internal
 #else
                public
index 41ef999b0324dc039b84704e5b15f64dbe932a3d..050e42627f369688a5f1b7672b9b88f8dd1f0c63 100644 (file)
@@ -1,3 +1,17 @@
+2010-03-25 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * ThreadPool.cs: add fast path to queue work items in the runtime.
+
+2010-03-23  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Monitor.cs: Implement new NET_4_0 (and SL4) Enter overload 
+       required to run some DRT tests (e.g. 7007)
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * ThreadPool.cs, Thread.cs, ExecutionContext.cs: use MOONLIGHT
+       symbol to disambiguate MonoTouch and Moonlight code.
+
 2010-03-08  Jérémie Laval  <jeremie.laval@gmail.com>
 
        * SpinLock.cs: Merge algorithm back in SpinLock struct
index 6deff9db0e222052e26516008bb8410a77d778a6..684caf0a2e4fc928c72e11a6fe4ae096e2563c71 100644 (file)
@@ -36,7 +36,7 @@ namespace System.Threading {
 
        [Serializable]
        public sealed class ExecutionContext : ISerializable {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                private SecurityContext _sc;
 #endif
                private bool _suppressFlow;
@@ -48,7 +48,7 @@ namespace System.Threading {
 
                internal ExecutionContext (ExecutionContext ec)
                {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        if (ec._sc != null)
                                _sc = new SecurityContext (ec._sc);
 #endif
@@ -69,7 +69,7 @@ namespace System.Threading {
                                return null;
 
                        ExecutionContext capture = new ExecutionContext (ec);
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        if (SecurityManager.SecurityEnabled)
                                capture.SecurityContext = SecurityContext.Capture ();
 #endif
@@ -94,7 +94,7 @@ namespace System.Threading {
                }
                
                // internal stuff
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                internal SecurityContext SecurityContext {
                        get {
                                if (_sc == null)
@@ -127,7 +127,7 @@ namespace System.Threading {
                        ec.FlowSuppressed = false;
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("only the SecurityContext is considered")]
                [SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
                public static void Run (ExecutionContext executionContext, ContextCallback callback, object state)
index ac78672ecb6f93d3cb4df95daa7a717ec0322229..6320b39f5219cb78aa66aa835c35f561e9c7fdf9 100644 (file)
@@ -176,5 +176,19 @@ namespace System.Threading
                                if (exitContext) SynchronizationAttribute.EnterContext ();
                        }
                }
+
+#if NET_4_0 || MOONLIGHT
+               public static void Enter (object obj, ref bool lockTaken)
+               {
+                       if (obj == null)
+                               throw new ArgumentNullException ("obj");
+                       if (lockTaken)
+                               throw new ArgumentException ("lockTaken");
+
+                       Enter (obj);
+                       // if Enter throws then lockTaken will be false
+                       lockTaken = true;
+               }
+#endif
        }
 }
index 86e797c764815b88fd3bc9ad93a5a3f9d36b8641..60b3871f61559f8ccc348e365bb85e82ff24e3e6 100644 (file)
@@ -197,7 +197,7 @@ namespace System.Threading {
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private extern static byte[] ByteArrayToCurrentDomain (byte[] arr);
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public static IPrincipal CurrentPrincipal {
                        get {
                                Thread th = CurrentThread;
@@ -262,7 +262,7 @@ namespace System.Threading {
                        }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // Stores a hash keyed by strings of LocalDataStoreSlot objects
                static Hashtable datastorehash;
                private static object datastore_lock = new object ();
@@ -404,7 +404,7 @@ namespace System.Threading {
                        internal_thread = it;
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [Obsolete ("Deprecated in favor of GetApartmentState, SetApartmentState and TrySetApartmentState.")]
                public ApartmentState ApartmentState {
                        get {
@@ -681,7 +681,7 @@ namespace System.Threading {
                        }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public ThreadPriority Priority {
                        get {
                                return(ThreadPriority.Lowest);
@@ -708,7 +708,7 @@ namespace System.Threading {
                        Abort_internal (Internal, null);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [SecurityPermission (SecurityAction.Demand, ControlThread=true)]
                public void Abort (object stateInfo) 
                {
@@ -746,7 +746,7 @@ namespace System.Threading {
                        return Join_internal (Internal, millisecondsTimeout, Internal.system_thread_handle);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public bool Join(TimeSpan timeout)
                {
                        long ms = (long) timeout.TotalMilliseconds;
@@ -762,7 +762,7 @@ namespace System.Threading {
                public extern static void MemoryBarrier ();
 #endif
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private extern void Resume_internal();
 
@@ -789,7 +789,7 @@ namespace System.Threading {
                        }
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                private void StartSafe ()
                {
                        current_thread = this;
@@ -847,7 +847,7 @@ namespace System.Threading {
                        Internal._serialized_principal = CurrentThread.Internal._serialized_principal;
 
                        // Thread_internal creates and starts the new thread, 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        if (Thread_internal((ThreadStart) StartSafe) == (IntPtr) 0)
 #else
                        if (Thread_internal((ThreadStart) StartUnsafe) == (IntPtr) 0)
@@ -855,7 +855,7 @@ namespace System.Threading {
                                throw new SystemException ("Thread creation failed.");
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private extern static void Suspend_internal(InternalThread thread);
 
@@ -1049,7 +1049,7 @@ namespace System.Threading {
                        // Managed and native threads are currently bound together.
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public ApartmentState GetApartmentState ()
                {
                        return (ApartmentState)Internal.apartment_state;
@@ -1091,7 +1091,7 @@ namespace System.Threading {
                        Start ();
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // NOTE: This method doesn't show in the class library status page because
                // it cannot be "found" with the StrongNameIdentityPermission for ECMA key.
                // But it's there!
index 21578734bd630329c4d25f9562e242b9d31b8948..7dfee45fc808f18c8f9e64f52a3fc26afed7434b 100644 (file)
@@ -82,15 +82,26 @@ namespace System.Threading {
                        if (callBack == null)
                                throw new ArgumentNullException ("callBack");
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        callBack = MoonlightHandler (callBack);
 #endif
-                       IAsyncResult ar = callBack.BeginInvoke (state, null, null);
-                       if (ar == null)
-                               return false;
+                       if (callBack.IsTransparentProxy ()) {
+                               IAsyncResult ar = callBack.BeginInvoke (state, null, null);
+                               if (ar == null)
+                                       return false;
+                       } else {
+                               if (!callBack.HasSingleTarget)
+                                       throw new Exception ("The delegate must have only one target");
+
+                               AsyncResult ares = new AsyncResult (callBack, state, true);
+                               pool_queue (ares);
+                       }
                        return true;
                }
 
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               static extern void pool_queue (AsyncResult ares);
+
                public static RegisteredWaitHandle RegisterWaitForSingleObject (WaitHandle waitObject,
                                                                                WaitOrTimerCallback callBack,
                                                                                object state,
@@ -155,18 +166,25 @@ namespace System.Threading {
                public static bool UnsafeQueueUserWorkItem (WaitCallback callBack, object state)
                {
                        // no stack propagation here (that's why it's unsafe and requires extra security permissions)
-                       IAsyncResult ar = null;
+                       if (!callBack.IsTransparentProxy ()) {
+                               if (!callBack.HasSingleTarget)
+                                       throw new Exception ("The delegate must have only one target");
+
+                               AsyncResult ares = new AsyncResult (callBack, state, false);
+                               pool_queue (ares);
+                               return true;
+                       }
                        try {
                                if (!ExecutionContext.IsFlowSuppressed ())
                                        ExecutionContext.SuppressFlow (); // on current thread only
-
-                               ar = callBack.BeginInvoke (state, null, null);
-                       }
-                       finally {
+                               IAsyncResult ar = callBack.BeginInvoke (state, null, null);
+                               if (ar == null)
+                                       return false;
+                       finally {
                                if (ExecutionContext.IsFlowSuppressed ())
                                        ExecutionContext.RestoreFlow ();
                        }
-                       return (ar != null);
+                       return true;
                }
                
                [MonoTODO("Not implemented")]
@@ -208,7 +226,7 @@ namespace System.Threading {
 
 #endif
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                static WaitCallback MoonlightHandler (WaitCallback callback)
                {
                        return delegate (object o) {
index 06ea67fd6542572017bcd563efd8faaf124f75e6..245f28e39d066a7e21b2b0e40aea4121307cb10d 100644 (file)
@@ -37,7 +37,7 @@ using System.Security.Permissions;
 using System.Security.Policy;
 using System.Configuration.Assemblies;
 using System.Text;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 using System.Runtime.Remoting;
 using System.Runtime.Remoting.Activation;
 #endif
@@ -58,7 +58,7 @@ namespace System
                {
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [MonoTODO ("No COM support")]
                public static ObjectHandle CreateComInstanceFrom (string assemblyName, string typeName)
                {
@@ -286,7 +286,7 @@ namespace System
                        }
 
                        CheckAbstractType (type);
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        if (activationAttributes != null && activationAttributes.Length > 0) {
                                if (!type.IsMarshalByRef) {
                                        string msg = Locale.GetText ("Type '{0}' doesn't derive from MarshalByRefObject.", type.FullName);
@@ -357,7 +357,7 @@ namespace System
                        }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                [SecurityPermission (SecurityAction.LinkDemand, RemotingConfiguration = true)]
                public static object GetObject (Type type, string url)
                {
index 852bbe9ebefdefadbe77fdfab13001c6020aae32..b2e1e57f46f218ea7b49f2c76761a688db3e972e 100644 (file)
@@ -81,7 +81,7 @@ namespace System {
 
                [ThreadStatic]
                static Hashtable assembly_resolve_in_progress_refonly;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                // CAS
                private Evidence _evidence;
                private PermissionSet _granted;
@@ -121,7 +121,7 @@ namespace System {
                        get { throw new NotImplementedException (); }
                }
 #endif
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public string BaseDirectory {
                        get {
                                string path = SetupInformationNoCopy.ApplicationBase;
@@ -174,7 +174,7 @@ namespace System {
                                return getFriendlyName ();
                        }
                }
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public Evidence Evidence {
                        get {
                                // if the host (runtime) hasn't provided it's own evidence...
@@ -248,7 +248,7 @@ namespace System {
                        }
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
                [Obsolete ("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead.")]
                [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
@@ -793,7 +793,7 @@ namespace System {
                        assembly.FromByteArray = true;
                        return assembly;
                }
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 #if NET_4_0
                [Obsolete ("AppDomain policy levels are obsolete")]
 #endif
@@ -945,7 +945,7 @@ namespace System {
                        return _process_guid;
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
 
                public static AppDomain CreateDomain (string friendlyName)
                {
@@ -1155,7 +1155,7 @@ namespace System {
 
                public override string ToString ()
                {
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        return getFriendlyName ();
 #else
                        StringBuilder sb = new StringBuilder ("Name:");
@@ -1369,7 +1369,7 @@ namespace System {
                        get { return _domain_manager; }
                }
 
-#if (!NET_2_1 || MONOTOUCH)
+#if (!MOONLIGHT)
 
                public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
 
@@ -1477,9 +1477,9 @@ namespace System {
                {
                        return GetAssemblies (true);
                }
-#endif
 
-#if NET_2_1 && !MONOTOUCH
+#else // MOONLIGHT
+
                public int ExecuteAssemblyByName (string assemblyName)
                {
                        // critical code in SL that we're not calling in ML
@@ -1509,5 +1509,42 @@ namespace System {
                        throw new NotImplementedException ();
                }
 #endif
+
+#if NET_4_0 || MOONLIGHT
+               [MonoTODO ("Currently always returns false")]
+               public bool? IsCompatibilitySwitchSet (string value)
+               {
+                       if (value == null)
+                               throw new ArgumentNullException ("value");
+                       // default (at least for SL4) is to return false for unknown values (can't get a null out of it)
+                       return false;
+               }
+
+               [MonoTODO ("Currently always returns false")]
+               public static bool MonitoringIsEnabled { 
+                       get { return false; }
+                       set { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public long MonitoringSurvivedMemorySize {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public static long MonitoringSurvivedProcessMemorySize {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public long MonitoringTotalAllocatedMemorySize {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public TimeSpan MonitoringTotalProcessorTime {
+                       get { throw new NotImplementedException (); }
+               }
+#endif
        }
 }
index 45f2d81395e71911727671248a0e6dc022a6f5a2..d6d569d1c5efd2dcf6b209ba70cd5e2f9f1dea7e 100644 (file)
@@ -37,7 +37,7 @@ using System.Runtime.InteropServices;
 using System.Security;
 using System.Runtime.Serialization.Formatters.Binary;
 
-#if(!NET_2_1 || MONOTOUCH)
+#if(!MOONLIGHT)
 using System.Runtime.Hosting;
 using System.Security.Policy;
 #endif
@@ -69,7 +69,7 @@ namespace System
                bool disallow_binding_redirects;
                bool disallow_code_downloads;
 
-#if (!NET_2_1 || MONOTOUCH)
+#if (!MOONLIGHT)
                private ActivationArguments _activationArguments;
                AppDomainInitializer domain_initializer;
                [NonSerialized]
@@ -116,7 +116,7 @@ namespace System
                        configuration_bytes = setup.configuration_bytes;
                }
 
-#if (!NET_2_1 || MONOTOUCH)
+#if (!MOONLIGHT)
                public AppDomainSetup (ActivationArguments activationArguments)
                {
                        _activationArguments = activationArguments;
@@ -162,7 +162,7 @@ namespace System
                                application_name = value;
                        }
                }
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public string CachePath {
                        get {
                                return cache_path;
@@ -235,7 +235,7 @@ namespace System
                                loader_optimization = value;
                        }
                }
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public string PrivateBinPath {
                        get {
                                return private_bin_path;
index b2c326eb421d62f65207400c528bc371edc893a4..3801fbe3a36a687079817c49cad1af4bf82d358e 100644 (file)
@@ -1,3 +1,109 @@
+2010-03-25 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * MonoAsyncCall.cs: remove unused field.
+       * Delegate.cs: add new IsTransparentProxy property.
+       * MulticastDelegate.cs: add new HasSingleTarget property.
+       * Environment.cs: bump up corlib version.
+
+2010-03-25  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * AppDomain.cs: Add new properties that are in both FX4 and SL4
+       since Moonlight needs them (for testing purpose).
+       * Environment.cs: FailFast overloads are present in SL4 (and also
+       needed for testing Moonlight)
+
+2010-03-24  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * AppDomain.cs: Change default value from null to false for new
+       (NET_4_0 and SL4) IsCompatibilitySwitchSet. Not sure when (or even
+       if) it can return null (at least not when testing SL4 RC). 
+       Fix DRT198
+
+2010-03-22  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpan.cs: When parsing ticks, we used to only parse
+       the first 7 digits, and more than that would cause a FormatException -
+       starting in 4.0 we need to throw an OverflowException, however. Also,
+       for hours/minutes/seconds, two or more preceding zeroes will cause an
+       OverflowException as well.
+
+2010-03-22  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpan.cs: Create a new Parser.Execute method for 4.0 -and use the
+       previous impl for 2.0-, to handle the new semantics gracefully -
+       specifically the new 'dd:hh:mm:ss' format and related bits, instead of
+       of a ton of #ifdef blocks. Remove any 4.0 bits from the previous
+       version as well, to keep it clean.
+
+2010-03-19  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpan.cs: Move the error detection code to a separate method.
+       This way depending on the version we decide what error takes
+       precedence: OverlowException in 2.0, and FormatException in 4.0. This
+       also lets us keep the Execute() code cleaner and easier to understand.
+
+2010-03-18  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpan.cs: Put the error info in a single field, to make it easier
+       to preserve the very first error we get while parsing, and discard the
+       next ones. This will help us in a pair of cases where we were
+       overriding the previous error and reporting the wrong exception.
+
+2010-03-17  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * String.cs: SL4 includes new IsNullOrWhiteSpace and Concat/Join 
+       overloads.
+
+2010-03-17  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpan.cs: TimeSpan is actually implementing IFormattable.
+
+2010-03-17  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * AppDomain.cs: Added MonoTODO for IsCompatibilitySwitchSet.
+
+2010-03-16  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpan.cs: In 4.0 the Parse/TryParse methods always try to use its
+       associated CultureInfo.NumberFormat.NumberDecimalSeparator value, as well as
+       providing backwards compatibility by also supporting '.' as the
+       separator.
+
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * AppDomainSetup.cs
+       * Tuple.cs
+       * ChangeLog
+       * Exception.cs
+       * String.cs
+       * Console.cs
+       * Tuples.cs
+       * Activator.cs
+       * AppDomain.cs:
+               Use MOONLIGHT symbol to disambiguate MonoTouch and Moonlight code.
+
+2010-03-16  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * Enum.cs: Added a few 4.0 api to Moonlight.
+
+2010-03-16  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * AppDomain.cs: Added IsCompatibilitySwitchSet for .NET 4.0 and Moonlight.
+
+2010-03-15  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpan.cs: In 4.0 if the part parsed as days exceeds the allowed
+       range -this is, 23-, then it is processed as days instead - opposed to
+       2.0, where we are throwing an OverflowException.
+
+2010-03-15  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpan.cs: Make the colon parsing optional -and adjust the name to
+       reflect it-, so we can properly parse the case where we only have the
+       hours and minutes. This subtle bug was hidden before, since a string
+       such "10:12" would be parsed correctly, but "10:12  " (trailing white
+       space) was getting a FormatException.
+
 2010-03-12  Sebastien Pouliot  <sebastien@ximian.com>
 
        * Tuple.cs, Tuples.cs: Add them to NET_2_1 since they are parts
index f4221d7e46c6a05bda37e966effe86fa03fd447b..3da209a3d4f7d3abdeb42a77db361cc5a348421d 100644 (file)
@@ -38,7 +38,7 @@ namespace System
 {
        [Serializable]
        [ComVisible (true)]
-       public sealed class CharEnumerator : IEnumerator, ICloneable, IEnumerator <char>
+       public sealed class CharEnumerator : IEnumerator, ICloneable, IEnumerator<char>
        {
                private string str;
                private int index;
index c2d78fd01b346c95138834a5686901bb98717cab..ea9365e689fae20a2f144e5a859ac854217e1d35 100644 (file)
@@ -152,7 +152,7 @@ namespace System
 
                private static Stream Open (IntPtr handle, FileAccess access, int bufferSize)
                {
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                        if (SecurityManager.SecurityEnabled && !Debugger.IsAttached && Environment.GetEnvironmentVariable ("MOONLIGHT_ENABLE_CONSOLE") == null)
                                return new NullStream ();
 #endif
index 0108b42582f6ca00d3be46de7b5e43f62d0d3342..733eac9a4d3f132eab175fecdeed571364b4145f 100644 (file)
@@ -33,6 +33,7 @@
 //
 
 using System.Reflection;
+using System.Runtime.Remoting;
 using System.Runtime.Serialization;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
@@ -521,5 +522,10 @@ namespace System
                {
                        return !(d1 == d2);
                }
+
+               internal bool IsTransparentProxy ()
+               {
+                       return RemotingServices.IsTransparentProxy (m_target);
+               }
        }
 }
index 8c050dce7afb4147c0b6b0889e22dd92db65e0a5..49a4fd795a8333da2b22ef76891c94608399996a 100644 (file)
@@ -615,7 +615,7 @@ namespace System
                        return true;
                }
 
-#if BOOTSTRAP_NET_4_0 || NET_4_0
+#if BOOTSTRAP_NET_4_0 || NET_4_0 || MOONLIGHT
                public static bool TryParse<TEnum> (string value, out TEnum result) where TEnum : struct
                {
                        return TryParse (value, false, out result);
@@ -1005,7 +1005,7 @@ namespace System
                        }
                        return retVal;
                }
-#if NET_4_0
+#if NET_4_0 || MOONLIGHT
                public bool HasFlag (Enum flag)
                {
                        ulong mvalue = Convert.ToUInt64 (get_value (), null);
index 0dc905db1f7c89dab08c53be67175d796f195ef2..1cb2def12464ee6c296d9ba13a6c448d20cedd20 100644 (file)
@@ -55,7 +55,7 @@ namespace System {
                 * of icalls, do not require an increment.
                 */
 #pragma warning disable 169
-               private const int mono_corlib_version = 89;
+               private const int mono_corlib_version = 90;
 #pragma warning restore 169
 
                [ComVisible (true)]
@@ -701,20 +701,22 @@ namespace System {
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal static extern void InternalSetEnvironmentVariable (string variable, string value);
-
+#endif
                [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode=true)]
                public static void FailFast (string message)
                {
                        throw new NotImplementedException ();
                }
-#endif
-#if NET_4_0
+
+#if NET_4_0 || MOONLIGHT
                [SecurityCritical]
                public static void FailFast (string message, Exception exception)
                {
                        throw new NotImplementedException ();
                }
+#endif
 
+#if NET_4_0
                public static bool Is64BitOperatingSystem {
                        get { return IntPtr.Size == 8; } // FIXME: is this good enough?
                }
index 0f0ea62ce9c905abe5245f7c37083d5eba61744c..b4a2f1ee665cf1c2faf13efd5797fdaf1548e158 100644 (file)
@@ -262,7 +262,7 @@ namespace System
                        info.AddValue ("RemoteStackTraceString", _remoteStackTraceString);
                        info.AddValue ("RemoteStackIndex", remote_stack_index);
                        info.AddValue ("HResult", hresult);
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                        info.AddValue ("Source", Source);
 #else
                        info.AddValue ("Source", null);
index 5de35956f3ef5ca4e560a8a436bd7e97b441523f..14ac8d311a33685ceff66bc802778289d91599cb 100644 (file)
@@ -45,7 +45,6 @@ namespace System {
                object     state;
                object     res;
                object     out_args;
-               long       wait_event;
                #endregion
        }
 
index 85252bf5394035bcbcf21d5baa6d9650cbdc8035..df7becdea425ed5e4c8ae7e0deabf29e4f4ad6e8 100644 (file)
@@ -69,6 +69,9 @@ namespace System
                        return base.DynamicInvokeImpl (args);
                }
 
+               internal bool HasSingleTarget {
+                       get { return prev == null; }
+               }
                // <remarks>
                //   Equals: two multicast delegates are equal if their base is equal
                //   and their invocations list is equal.
index ff0a8d96e2a019b4e0e0c1d80eae518c05ff5f75..8d05c9187659899ba5aa8c4b308942df4cea552e 100644 (file)
@@ -1393,7 +1393,7 @@ namespace System
                        return (value == null) || (value.Length == 0);
                }
 
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
                public string Normalize ()
                {
                        return Normalization.Normalize (this, 0);
@@ -2519,7 +2519,7 @@ namespace System
                        }
                }
 
-#if NET_4_0
+#if MOONLIGHT || NET_4_0
                public static bool IsNullOrWhiteSpace (string value)
                {
                        if (value == null)
index d0ab4c2f78c10837b5d0a402b7dc9fb5a01c9c97..cc9ad78300f7796cc26bb0f536ccad7dc0c24356 100644 (file)
@@ -39,6 +39,9 @@ namespace System
        [Serializable]
        [System.Runtime.InteropServices.ComVisible (true)]
        public struct TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable <TimeSpan>
+#if NET_4_0
+                                , IFormattable
+#endif
        {
 #if MONOTOUCH
                static TimeSpan () {
@@ -541,19 +544,27 @@ namespace System
                        return t;
                }
 
+               enum ParseError {
+                       None,
+                       Format,
+                       Overflow
+               }
+
                // Class Parser implements parser for TimeSpan.Parse
                private class Parser
                {
                        private string _src;
                        private int _cur = 0;
                        private int _length;
-                       private bool formatError;
-                       private bool overflowError;
+                       ParseError parse_error;
 
                        public Parser (string src)
                        {
                                _src = src;
                                _length = _src.Length;
+#if NET_4_0
+                               number_format = GetNumberFormatInfo (null);
+#endif
                        }
 
 #if NET_4_0
@@ -626,8 +637,13 @@ namespace System
 
                                while (!AtEnd && Char.IsDigit (_src, _cur)) {
                                        res = res * 10 + _src[_cur] - '0';
+#if NET_4_0
+                                       // more than one preceding zero will case an OverflowException
+                                       if (res > Int32.MaxValue || (count >= 2 && res == 0)) {
+#else
                                        if (res > Int32.MaxValue) {
-                                               overflowError = true;
+#endif
+                                               SetParseError (ParseError.Overflow);
                                                break;
                                        }
                                        _cur++;
@@ -635,7 +651,11 @@ namespace System
                                }
 
                                if (!optional && (count == 0))
-                                       formatError = true;
+                                       SetParseError (ParseError.Format);
+#if NET_4_0
+                               if (count > 0)
+                                       parsed_numbers_count++;
+#endif
 
                                return (int)res;
                        }
@@ -654,42 +674,55 @@ namespace System
                        }       
 
 #if NET_4_0
-                       // Just as ParseOptDot, but for decimal separator
-                       private bool ParseOptDecimalSeparator ()
+                       // This behaves pretty much like ParseOptDot, but we need to have it
+                       // as a separated routine for both days and decimal separators.
+                       private bool ParseOptDaysSeparator ()
                        {
                                if (AtEnd)
                                        return false;
 
-                               // Use culture information if available.
-                               if (number_format != null) {
-                                       string decimal_separator = number_format.NumberDecimalSeparator;
-                                       if (String.Compare (_src, _cur, decimal_separator, 0, decimal_separator.Length) == 0) {
-                                               _cur += decimal_separator.Length;
-                                               return true;
-                                       }
+                               if (_src[_cur] == '.') {
+                                       _cur++;
+                                       parsed_days_separator = true;
+                                       return true;
+                               }
+                               return false;
+                       }
 
+                       // Just as ParseOptDot, but for decimal separator
+                       private bool ParseOptDecimalSeparator ()
+                       {
+                               if (AtEnd)
                                        return false;
-                               } else if (_src [_cur] == '.') {
+
+                               // we need to provide compatibility with old versions using '.'
+                               if (_src [_cur] == '.') {
                                        _cur++;
                                        return true;
                                }
 
+                               string decimal_separator = number_format.NumberDecimalSeparator;
+                               if (String.Compare (_src, _cur, decimal_separator, 0, decimal_separator.Length) == 0) {
+                                       _cur += decimal_separator.Length;
+                                       return true;
+                               }
+
                                return false;
                        }
 #endif
 
-                       // Parse optional (LAMESPEC) colon
-                       private void ParseOptColon ()
+                       private void ParseColon (bool optional)
                        {
                                if (!AtEnd) {
                                        if (_src[_cur] == ':')
                                                _cur++;
-                                       else 
-                                               formatError = true;
+                                       else if (!optional)
+                                               SetParseError (ParseError.Format);
                                }
                        }
 
                        // Parse [1..7] digits, representing fractional seconds (ticks)
+                       // In 4.0 more than 7 digits will cause an OverflowException
                        private long ParseTicks ()
                        {
                                long mag = 1000000;
@@ -704,11 +737,158 @@ namespace System
                                }
 
                                if (!digitseen)
-                                       formatError = true;
+                                       SetParseError (ParseError.Format);
+#if NET_4_0
+                               else if (!AtEnd && Char.IsDigit (_src, _cur))
+                                       SetParseError (ParseError.Overflow);
+#endif
 
                                return res;
                        }
 
+                       void SetParseError (ParseError error)
+                       {
+                               // We preserve the very first error.
+                               if (parse_error != ParseError.None)
+                                       return;
+
+                               parse_error = error;
+                       }
+
+                       bool CheckParseSuccess (int hours, int minutes, int seconds, bool tryParse)
+                       {
+                               // FormatException has precedence over OverflowException starting with 4.0
+                               // so put the block before/after properly.
+#if NET_4_0
+                               if (parse_error == ParseError.Format) {
+                                       if (tryParse)
+                                               return false;
+                                       throw new FormatException (
+                                               Locale.GetText ("Invalid format for TimeSpan.Parse."));
+                               }
+#endif
+                               if (parse_error == ParseError.Overflow || hours > 23 || minutes > 59 || seconds > 59) {
+                                       if (tryParse)
+                                               return false;
+                                       throw new OverflowException (
+                                               Locale.GetText ("Invalid time data."));
+                               }
+#if !NET_4_0
+                               // Respect the Overflow precedence for 2.0, putting the format check last.
+                               if (parse_error == ParseError.Format) {
+                                       if (tryParse)
+                                               return false;
+                                       throw new FormatException (
+                                               Locale.GetText ("Invalid format for TimeSpan.Parse."));
+                               }
+#endif
+
+                               return true;
+                       }
+
+#if NET_4_0
+                       int parsed_numbers_count;
+                       bool parsed_days_separator;
+
+                       // We are using a different parse approach in 4.0, due to some changes in the behaviour
+                       // of the parse routines.
+                       // The input string is documented as:
+                       //      Parse [ws][-][dd.]hh:mm:ss[.ff][ws]
+                       //
+                       // There are some special cases as part of 4.0, however:
+                       // 1. ':' *can* be used as days separator, instead of '.', making valid the format 'dd:hh:mm:ss'
+                       // 2. A input in the format 'hh:mm:ss' will end up assigned as 'dd.hh:mm' if the first int has a value
+                       // exceeding the valid range for hours: 0-23.
+                       // 3. The decimal separator can be retrieved from the current culture, as well as keeping support
+                       // for the '.' value as part of keeping compatibility.
+                       //
+                       // So we take the approach to parse, if possible, 4 integers, and depending on both how many were
+                       // actually parsed and what separators were read, assign the values to days/hours/minutes/seconds.
+                       //
+                       public bool Execute (bool tryParse, out TimeSpan result)
+                       {
+                               bool sign;
+                               int value1, value2, value3, value4;
+                               int days, hours, minutes, seconds;
+                               long ticks = 0;
+
+                               result = TimeSpan.Zero;
+                               value1 = value2 = value3 = value4 = 0;
+                               days = hours = minutes = seconds = 0;
+
+                               ParseWhiteSpace ();
+                               sign = ParseSign ();
+
+                               // Parse 4 integers, making only the first one non-optional.
+                               value1 = ParseInt (false);
+                               if (!ParseOptDaysSeparator ()) // Parse either day separator or colon
+                                       ParseColon (false);
+                               value2 = ParseInt (true);
+                               ParseColon (true);
+                               value3 = ParseInt (true);
+                               ParseColon (true);
+                               value4 = ParseInt (true);
+
+                               // We know the precise separator for ticks, so there's no need to guess.
+                               if (ParseOptDecimalSeparator ())
+                                       ticks = ParseTicks ();
+
+                               ParseWhiteSpace ();
+
+                               if (!AtEnd)
+                                       SetParseError (ParseError.Format);
+
+                               switch (parsed_numbers_count) {
+                                       case 1:
+                                               days = value1;
+                                               break;
+                                       case 2: // Two elements are valid only if they are *exactly* in the format: 'hh:mm'
+                                               if (parsed_days_separator)
+                                                       SetParseError (ParseError.Format);
+                                               else {
+                                                       hours = value1;
+                                                       minutes = value2;
+                                               }
+                                               break;
+                                       case 3: // Assign the first value to days if we parsed a day separator or the value
+                                               // is not in the valid range for hours.
+                                               if (parsed_days_separator || value1 > 23) {
+                                                       days = value1;
+                                                       hours = value2;
+                                                       minutes = value3;
+                                               } else {
+                                                       hours = value1;
+                                                       minutes = value2;
+                                                       seconds = value3;
+                                               }
+                                               break;
+                                       case 4: // We are either on 'dd.hh:mm:ss' or 'dd:hh:mm:ss'
+                                               days = value1;
+                                               hours = value2;
+                                               minutes = value3;
+                                               seconds = value4;
+                                               break;
+                               }
+
+                               if (!CheckParseSuccess (hours, minutes, seconds, tryParse))
+                                       return false;
+
+                               long t;
+                               if (!TimeSpan.CalculateTicks (days, hours, minutes, seconds, 0, false, out t))
+                                       return false;
+
+                               try {
+                                       t = checked ((sign) ? (-t - ticks) : (t + ticks));
+                               } catch (OverflowException) {
+                                       if (tryParse)
+                                               return false;
+                                       throw;
+                               }
+
+                               result = new TimeSpan (t);
+                               return true;
+                       }
+#else
                        public bool Execute (bool tryParse, out TimeSpan result)
                        {
                                bool sign;
@@ -734,15 +914,12 @@ namespace System
                                        hours = days;
                                        days = 0;
                                }
-                               ParseOptColon();
+                               ParseColon(false);
                                minutes = ParseInt (true);
-                               ParseOptColon ();
+                               ParseColon (true);
                                seconds = ParseInt (true);
-#if NET_4_0
-                               if ( ParseOptDecimalSeparator () ) {
-#else
+
                                if ( ParseOptDot () ) {
-#endif
                                        ticks = ParseTicks ();
                                }
                                else {
@@ -751,21 +928,10 @@ namespace System
                                ParseWhiteSpace ();
        
                                if (!AtEnd)
-                                       formatError = true;
+                                       SetParseError (ParseError.Format);
 
-                               // Overflow has presceance over FormatException
-                               if (overflowError || hours > 23 || minutes > 59 || seconds > 59) {
-                                       if (tryParse)
-                                               return false;
-                                       throw new OverflowException (
-                                               Locale.GetText ("Invalid time data."));
-                               }
-                               else if (formatError) {
-                                       if (tryParse)
-                                               return false;
-                                       throw new FormatException (
-                                               Locale.GetText ("Invalid format for TimeSpan.Parse."));
-                               }
+                               if (!CheckParseSuccess (hours, minutes, seconds, tryParse))
+                                       return false;
 
                                long t;
                                if (!TimeSpan.CalculateTicks (days, hours, minutes, seconds, 0, false, out t))
@@ -782,6 +948,7 @@ namespace System
                                result = new TimeSpan (t);
                                return true;
                        }
+#endif
                }
        }
 }
index 078669e1cafb3311df9090ff71e6dd84cd537818..081071787274f5ede65ec79f14fcbe181954b7ac 100644 (file)
@@ -26,7 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if (NET_2_1 && !MONOTOUCH) || NET_4_0
+#if MOONLIGHT || NET_4_0
 
 using System;
 
index a00e5384082cb7c33f7f0b8a899b0a1b0361dc05..6404a923303e33b3104001b92a63f7cb2279e1ae 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if (NET_2_1 && !MONOTOUCH) || NET_4_0
+#if MOONLIGHT || NET_4_0
 
 using System;
 using System.Collections;
index 7749106d2f57be16fa7f4fc68f582fc903a95fa5..c81fae3d0aab161bdc58fc4d0cc069366e458f31 100644 (file)
@@ -1,3 +1,12 @@
+2010-03-24  Jérémie Laval  <jeremie.laval@gmail.com>
+
+       * ConcurrentDictionaryTests.cs: Renaming in Assert
+
+2010-03-24  Jérémie Laval  <jeremie.laval@gmail.com>
+
+       * ConcurrentDictionaryTests.cs: Update behavior of TryAddDuplicateTest
+       The method returns false and doesn't throw exception anymore
+
 2010-02-02  Jérémie Laval  <jeremie.laval@gmail.com>
 
        * CollectionStressTestHelper.cs:
index be1e22760cfe0961975bd2cbc784bcda156f7687..4f1ad64ce2f2af1628dcae9fd7be5773de7ac1b2 100644 (file)
@@ -47,7 +47,7 @@ namespace MonoTests.System.Collections.Concurrent
                
                void AddStuff ()
                {
-                 map.TryAdd ("foo", 1);
+                       map.TryAdd ("foo", 1);
                        map.TryAdd ("bar", 2);
                        map.TryAdd ("foobar", 3);
                }
@@ -82,16 +82,16 @@ namespace MonoTests.System.Collections.Concurrent
                                int value;
                                
                                Assert.IsTrue (map.TryGetValue ("monkey1", out value), "#1");
-                               Assert.AreEqual (3, value, "#1");
+                               Assert.AreEqual (3, value, "#1b");
                                
                                Assert.IsTrue (map.TryGetValue ("monkey2", out value), "#2");
-                               Assert.AreEqual (3, value, "#2");
+                               Assert.AreEqual (3, value, "#2b");
                                
                                Assert.IsTrue (map.TryGetValue ("monkey3", out value), "#3");
-                               Assert.AreEqual (3, value, "#3");
+                               Assert.AreEqual (3, value, "#3b");
                                
                                Assert.IsTrue (map.TryGetValue ("monkey4", out value), "#4");
-                               Assert.AreEqual (3, value, "#4");
+                               Assert.AreEqual (3, value, "#4b");
                        });
                }
                
@@ -132,16 +132,16 @@ namespace MonoTests.System.Collections.Concurrent
                        });
                }
                
-               [Test, ExpectedException(typeof(ArgumentException))]
+               [Test]
                public void AddWithDuplicate()
                {
-                       map.TryAdd("foo", 6);
+                       Assert.IsFalse (map.TryAdd("foo", 6));
                }
                
                [Test]
                public void GetValueTest()
                {
-                 Assert.AreEqual(1, map["foo"], "#1");
+                       Assert.AreEqual(1, map["foo"], "#1");
                        Assert.AreEqual(2, map["bar"], "#2");
                        Assert.AreEqual(3, map.Count, "#3");
                }
index 0d05bd8c7fa67cd0b23da462cec4931d4862a52c..c1fd0abda355a209819eb60af741d1da9341e7d0 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-17 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * StreamReaderTest.cs: test for bug 589236. The detected encoding is
+       different from the one provided in the ctor.
+
 2010-02-22  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * MemoryStreamTest.cs: Add a new test for Capacity.
index f83dc905e97eaed99278378bc5021d1ea9f61c4b..18d8fc6cc435fa3dd34edff0eb2c9ee73bdf2a16 100644 (file)
@@ -59,6 +59,7 @@ public class DirectoryTest
                }\r
        }\r
        \r
+       /* Commented out: a directory named ":" is legal in unix\r
        [Test]\r
        public void CreateDirectoryNotSupportedException ()\r
        {\r
@@ -75,6 +76,7 @@ public class DirectoryTest
                }\r
                DeleteDirectory (":");\r
        }\r
+       */\r
 \r
        [Test]\r
        public void CreateDirectory_Path_Null ()\r
index db6108060a9c2867daec65d2f07a8e3005041a1c..51b70cd2b68068d38f135046cc15310ba413ba1d 100644 (file)
@@ -815,6 +815,28 @@ public class StreamReaderTest
                string str = reader.ReadToEnd ();
                Assert.AreEqual ("bc", str);
        }
+
+       [Test]
+       public void EncodingChangedAuto ()
+       {
+               int testlines = 2048; // all data should larger than stream reader default buffer size
+               string testdata = "test";
+               MemoryStream ms = new MemoryStream();
+               // write utf8 encoding data.
+               using (StreamWriter sw = new StreamWriter (ms, Encoding.UTF8)) {
+                       for (int i = 0; i < testlines; i++)
+                               sw.WriteLine (testdata);
+               }
+
+               MemoryStream readms = new MemoryStream (ms.GetBuffer());
+               using (StreamReader sr = new StreamReader(readms, Encoding.Unicode, true)) {
+                       for (int i = 0; i < testlines; i++) {
+                               string line = sr.ReadLine ();
+                               if (line != testdata)
+                                       Assert.Fail ("Wrong line content");
+                       }
+               }
+       }
 }
 
 class MyStream : Stream {
index 02aabcd241f92b6f967a6f79962287bab02cc8a1..08943319ac7710bd27caca772f77c3c73f00753d 100644 (file)
@@ -1684,11 +1684,10 @@ public class AssemblyBuilderTest
        }
 
        [Test]
-       [Category ("NotDotNet")]
        public void GetType_IgnoreCase ()
        {
                TypeBuilder tb = mb.DefineType ("Foo.Test2", TypeAttributes.Public, typeof (object));
-               // the previous line throws a TypeLoadException under MS 1.1 SP1
+               tb.CreateType ();
 
                Type t;
 
@@ -1702,6 +1701,50 @@ public class AssemblyBuilderTest
                Assert.AreEqual ("Test2", t.Name, "#3");
        }
 
+
+       [Test]
+       public void GetType ()
+       {
+               TypeBuilder tb = mb.DefineType ("Test", TypeAttributes.Public);
+
+               Assert.IsNull (ab.GetType ("Test", false, true), "#1");
+               try {
+                       ab.GetType ("Test", true, true);
+                       Assert.Fail ("#2");
+               } catch (TypeLoadException) { }
+
+               var res = tb.CreateType ();
+
+               Assert.AreSame (res, ab.GetType ("Test", false, true), "#3");
+       }
+
+       [Test]
+       public void GetModule ()
+       {
+               var ab = genAssembly ();
+               Assert.IsNull (ab.GetModule ("Foo"), "#1");
+
+               var modA = ab.DefineDynamicModule ("Foo");
+               var modB = ab.DefineDynamicModule ("Bar");
+
+               Assert.AreSame (modA, ab.GetModule ("Foo"), "#2"); 
+               Assert.AreSame (modB, ab.GetModule ("Bar"), "#3"); 
+               Assert.IsNull (ab.GetModule ("FooBar"), "#4");
+       }
+       
+       [Test]
+       public void GetModules2 ()
+       {
+               //XXX this is not the v4 behavior since it returns
+               //the manifest module in the place of the first one
+               var ab = genAssembly ();
+               var modA = ab.DefineDynamicModule ("Foo");
+               var modB = ab.DefineDynamicModule ("Bar");
+               Assert.AreEqual (2, ab.GetModules ().Length, "#1");
+               Assert.AreSame (modA, ab.GetModules () [0], "#2");
+               Assert.AreSame (modB, ab.GetModules () [1], "#3");
+       }
+
        [ExpectedException (typeof (TypeLoadException))]
        public void GetCustomAttributes_NotCreated ()
        {
index b2e7ad4f2048259058c35092c20aa69b70d20dfd..a6e1ecd323f90c59cf0d30bdf56ddb670c316e31 100644 (file)
@@ -1,3 +1,15 @@
+2010-03-25 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * AssemblyBuilderTest.cs: Add test for v4 GetModule(s).
+
+2010-03-24 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * DerivedTypesTests.cs: Fix some tests under v4.
+
+2010-03-23 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * MethodOnTypeBuilderInstTest.cs: Add Test for ContainsGenericParameters.
+
 2010-03-11 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * TypeBuilderTest.cs: New tests for GetMethod, GetConstructor and GetField.
index 3425623f13de61f5a3c8a45404de0276d33c9938..17912b4fd4c1c22d877a476699e44a6090c3d2b6 100644 (file)
@@ -526,10 +526,14 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.IsFalse (ptr.IsGenericType, "#9");
                        Assert.IsFalse (ptr.IsGenericTypeDefinition, "#10");
 
+#if NET_4_0
+                       Assert.AreEqual (TypeAttributes.Public, ptr.Attributes, "#11");
+#else
                        try {
-                               var x = ptr.Attributes; 
+                               var x = ptr.Attributes; //This is because GenericTypeParameterBuilder doesn't support Attributes 
                                Assert.Fail ("#11");
                        } catch (NotSupportedException) {}
+#endif
 
                        Assert.IsTrue (ptr.HasElementType, "#12");
                        Assert.IsTrue (ptr.IsPointer, "#13");
@@ -1030,10 +1034,15 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.IsFalse (byref.IsGenericType, "#9");
                        Assert.IsFalse (byref.IsGenericTypeDefinition, "#10");
 
+
+#if NET_4_0
+                       Assert.AreEqual (TypeAttributes.Public, byref.Attributes, "#11");
+#else
                        try {
-                               var x = byref.Attributes; 
+                               var x = byref.Attributes; //This is because GenericTypeParameterBuilder doesn't support Attributes 
                                Assert.Fail ("#11");
                        } catch (NotSupportedException) {}
+#endif
 
                        Assert.IsTrue (byref.HasElementType, "#12");
                        Assert.IsTrue (byref.IsByRef, "#13");
@@ -1653,10 +1662,14 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.IsFalse (arr.IsGenericType, "#9");
                        Assert.IsFalse (arr.IsGenericTypeDefinition, "#10");
 
+#if NET_4_0
+                       Assert.AreEqual (TypeAttributes.Public, arr.Attributes, "#11");
+#else
                        try {
                                var x = arr.Attributes; //This is because GenericTypeParameterBuilder doesn't support Attributes 
                                Assert.Fail ("#11");
                        } catch (NotSupportedException) {}
+#endif
 
                        Assert.IsTrue (arr.HasElementType, "#12");
                        Assert.IsTrue (arr.IsArray, "#13");
index ee80a484d72677162de2f4447ef8c0056a0ed17e..6c558448030ba51691d8ae7673f7516d158c95ea 100644 (file)
@@ -29,6 +29,7 @@
 #if NET_2_0
 
 using System;
+using System.Collections.Generic;
 using System.Globalization;
 using System.IO;
 using System.Reflection;
@@ -684,6 +685,21 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.AreEqual (typeof (int), minst.GetParameters ()[0].ParameterType, "#5");
                        Assert.AreEqual (typeof (int[]), minst.GetParameters ()[1].ParameterType, "#6");
                }
+
+               [Test]
+               public void PropertiesOfANonGenericMethodOnGenericType ()
+               {
+                       Type t = typeof (List<>);
+                       Type a = t.GetGenericArguments () [0];
+                       MethodInfo m = t.GetMethod ("IndexOf", new Type [] { a });
+       
+                       var tb = module.DefineType ("foo.type");
+                       Type ttt = t.MakeGenericType (tb);
+                       MethodInfo mm = TypeBuilder.GetMethod (ttt, m);
+                       Assert.IsTrue (mm.GetGenericMethodDefinition ().ContainsGenericParameters, "#1");
+                       Assert.IsTrue (mm.ContainsGenericParameters, "#2");
+               }
+
        }
 }
 
index afcb4c996a90e94feef1ed864e837bf5e0c45543..d2647294ec949edebaed7fe418b022eb4ee1f6a2 100644 (file)
@@ -218,7 +218,7 @@ namespace MonoTests.System.Reflection
                        Assert.IsTrue (corlib_test.GetReferencedAssemblies ().Length > 0, "GetReferencedAssemblies");
                        Assert.AreEqual (0, corlib_test.HostContext, "HostContext");
 #if NET_4_0
-                       Assert.AreEqual ("v4.0.21006", corlib_test.ImageRuntimeVersion, "ImageRuntimeVersion");
+                       Assert.AreEqual ("v4.0.30128", corlib_test.ImageRuntimeVersion, "ImageRuntimeVersion");
 #else
                        Assert.AreEqual ("v2.0.50727", corlib_test.ImageRuntimeVersion, "ImageRuntimeVersion");
 #endif
@@ -421,7 +421,7 @@ namespace MonoTests.System.Reflection
                [Test]
                public void LoadWithPartialName ()
                {
-                       string [] names = { "corlib_test_net_1_1", "corlib_test_net_2_0", "corlib_plattest" };
+                       string [] names = { "corlib_test_net_1_1", "corlib_test_net_2_0", "corlib_test_net_4_0", "corlib_plattest" };
 
                        foreach (string s in names)
                                if (Assembly.LoadWithPartialName (s) != null)
index 70a0e519fbcabaee4c3e9192859b0ab019fe3429..ce8c0f28850b6d61bec3f82b85864c2b7f808fe8 100644 (file)
@@ -1,3 +1,11 @@
+2010-03-25 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       *AssemblyTest.cs: Fix one more tests under v4.
+
+2010-03-24 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       *AssemblyTest.cs: Fix some tests under v4.
+
 2010-03-11 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * FieldInfoTest.cs: Remove invalid assert.
index 988631ffa60fbfddc7fffc4bf14eee24c5f99a92..271d3cc1b370dd895a23b51de5ef44903a192e3b 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-24  Jérémie Laval  <jeremie.laval@gmail.com>
+
+       * SpinLockTests.cs: Add a correctness check unit test
+
 2010-03-08  Jérémie Laval  <jeremie.laval@gmail.com>
 
        * SpinLockTests.cs: Added unit tests for SpinLock
index 48149a3ddc1cf88c1997c32b8861106f15031b23..a7ef1cad00b5594e65a632fe8439cc1287f88942 100644 (file)
@@ -1,22 +1,22 @@
 #if NET_4_0
-// 
+//
 // SpinLockTests.cs
-//  
+//
 // Author:
 //       Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
-// 
+//
 // Copyright (c) 2010 Jérémie "Garuma" Laval
-// 
+//
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
 // in the Software without restriction, including without limitation the rights
 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 // copies of the Software, and to permit persons to whom the Software is
 // furnished to do so, subject to the following conditions:
-// 
+//
 // The above copyright notice and this permission notice shall be included in
 // all copies or substantial portions of the Software.
-// 
+//
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -30,35 +30,37 @@ using System.Threading;
 
 using NUnit.Framework;
 
+using MonoTests.System.Threading.Tasks;
+
 namespace MonoTests.System.Threading
 {
        [TestFixture]
        public class SpinLockTests
        {
                SpinLock sl;
-               
+
                [SetUp]
                public void Setup ()
                {
-                       sl = new SpinLock (false);
+                       sl = new SpinLock (true);
                }
-               
+
                [Test, ExpectedException (typeof (LockRecursionException))]
                public void RecursionExceptionTest ()
                {
                        sl = new SpinLock (true);
                        bool taken = false, taken2 = false;
-                       
+
                        sl.Enter (ref taken);
                        Assert.IsTrue (taken, "#1");
                        sl.Enter (ref taken2);
                }
-               
+
                [Test]
                public void SimpleEnterExitSchemeTest ()
                {
                        bool taken = false;
-                       
+
                        for (int i = 0; i < 50000; i++) {
                                sl.Enter (ref taken);
                                Assert.IsTrue (taken, "#" + i.ToString ());
@@ -66,51 +68,85 @@ namespace MonoTests.System.Threading
                                taken = false;
                        }
                }
-               
+
                [Test]
                public void SemanticCorrectnessTest ()
                {
+                       sl = new SpinLock (false);
+
                        bool taken = false;
                        bool taken2 = false;
-                       
+
                        sl.Enter (ref taken);
                        Assert.IsTrue (taken, "#1");
                        sl.TryEnter (ref taken2);
                        Assert.IsFalse (taken2, "#2");
                        sl.Exit ();
-                       
+
                        sl.TryEnter (ref taken2);
                        Assert.IsTrue (taken2, "#3");
                }
-               
+
                [Test, ExpectedException (typeof (ArgumentException))]
                public void FirstTakenParameterTest ()
                {
                        bool taken = true;
-                       
+
                        sl.Enter (ref taken);
                }
-               
+
                [Test, ExpectedException (typeof (ArgumentException))]
                public void SecondTakenParameterTest ()
                {
                        bool taken = true;
-                       
+
                        sl.TryEnter (ref taken);
                }
-               
+
+               internal class SpinLockWrapper
+               {
+                       public SpinLock Lock = new SpinLock (false);
+               }
+
+               [Test]
+               public void LockUnicityTest ()
+               {
+                       ParallelTestHelper.Repeat (delegate {
+                               int currentCount = 0;
+                               bool fail = false;
+                               SpinLockWrapper wrapper = new SpinLockWrapper ();
+
+                               ParallelTestHelper.ParallelStressTest (wrapper, delegate {
+                                       bool taken = false;
+                                       wrapper.Lock.Enter (ref taken);
+                                       int current = currentCount++;
+                                       if (current != 0)
+                                               fail = true;
+
+                                       SpinWait sw = new SpinWait ();
+                                       for (int i = 0; i < 200; i++)
+                                               sw.SpinOnce ();
+                                       currentCount -= 1;
+
+                                       wrapper.Lock.Exit ();
+                               }, 4);
+
+                               Assert.IsFalse (fail);
+                       }, 200);
+               }
+
                [Test]
                public void IsHeldByCurrentThreadTest ()
                {
                        bool lockTaken = false;
-                       
+
                        sl.Enter (ref lockTaken);
                        Assert.IsTrue (lockTaken, "#1");
                        Assert.IsTrue (sl.IsHeldByCurrentThread, "#2");
-                       
+
                        lockTaken = false;
                        sl = new SpinLock (true);
-                       
+
                        sl.Enter (ref lockTaken);
                        Assert.IsTrue (lockTaken, "#3");
                        Assert.IsTrue (sl.IsHeldByCurrentThread, "#4");
index 79b9842990bd6d08245252ad8fdc26ad8cae6a99..57c224bfa7a4d9f50706ea71ff679f37f3bc036a 100644 (file)
@@ -1,3 +1,14 @@
+2010-03-23  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpan.cs: Add some new assertions for old/new stuff in
+       TimeSpan.
+
+2010-03-22  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * TimeSpanTest.cs: It seems somebody forgot to actually mark the
+       TestParse method with TestAttribute. Also, add a bunch of asserions
+       to reflect the new behaviour for 4.0 in the needed test cases.
+
 2010-03-08  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * TimeSpanTest.cs: New tests for the 4.0 ToString overloads.
index eb0b18acedde47e528db31016ef79d9d5f7906c0..a85947d748fa0f4049b1dc92196e46ac583c8d16 100644 (file)
@@ -12,6 +12,7 @@
 using NUnit.Framework;
 using System;
 using System.Globalization;
+using System.Threading;
 
 namespace MonoTests.System
 {
@@ -787,21 +788,62 @@ public class TimeSpanTest {
                }
        }
 
+       [Test]
        public void TestParse ()
        {
                ParseHelper (" 13:45:15 ",false, false, "13:45:15");
                ParseHelper (" -1:2:3 ", false, false, "-01:02:03");
 
+#if NET_4_0
+               // In 4.0 when the first part is out of range, it parses it as day.
+               ParseHelper (" 25:11:12 ", false, false, "25.11:12:00");
+               ParseHelper (" 24:11:12 ", false, false, "24.11:12:00");
+               ParseHelper (" 23:11:12 ", false, false, "23:11:12");
+#else
                ParseHelper (" 25:0:0 ",false, true, "dontcare");
-               ParseHelper ("aaa", true, false, "dontcare");
+#endif
 
                ParseHelper ("-21.23:59:59.9999999", false, false, "-21.23:59:59.9999999");
+               ParseHelper ("10:12  ", false, false, "10:12:00");
+               ParseHelper ("aaa", true, false, "dontcare");
 
                ParseHelper ("100000000000000.1:1:1", false, true, "dontcare");
                ParseHelper ("24:60:60", false, true, "dontcare");
+
+#if NET_4_0
+               // In 4.0 we get an overflow exception here, as opposed to a successful operation in 2.0,
+               // due to more than one preceding zero.
+               ParseHelper ("0001:0002:0003.12     ", false, true, "dontcare");
+               ParseHelper ("01:02:03.12    ", false, false, "01:02:03.1200000");
+#else
                ParseHelper ("0001:0002:0003.12     ", false, false, "01:02:03.1200000");
+#endif
 
+#if NET_4_0
+               // In 4.0 when a section has more than 7 digits an OverflowException is thrown.
+               ParseHelper (" 1:2:3:12345678 ", false, true, "dontcare");
+#else
                ParseHelper (" 1:2:3:12345678 ", true, false, "dontcare"); 
+#endif
+
+#if NET_4_0            
+               ParseHelper ("10:11:12:13", false, false, "10.11:12:13"); // Days using : instead of . as separator
+               ParseHelper ("10.11", true, false, "dontcare"); // days+hours is invalid
+
+               // Force the use of french culture -which is using a non common NumberDecimalSeparator-
+               // as current culture, to show that the Parse method is *actually* being culture sensitive
+               // *and* also keeping the compatibility with '.'
+               CultureInfo french_culture = CultureInfo.GetCultureInfo ("fr-FR");
+               CultureInfo prev_culture = CultureInfo.CurrentCulture;
+               try {
+                       Thread.CurrentThread.CurrentCulture = french_culture;
+                       ParseHelper ("10:10:10,006", false, false, "10:10:10.0060000");
+                       ParseHelper ("10:10:10.006", false, false, "10:10:10.0060000");
+               } finally {
+                       // restore culture
+                       Thread.CurrentThread.CurrentCulture = prev_culture;
+               }
+#endif
        }
 
        // LAMESPEC: timespan in documentation is wrong - hh:mm:ss isn't mandatory
@@ -853,11 +895,23 @@ public class TimeSpanTest {
        }
 
        [Test]
-       [ExpectedException (typeof (OverflowException))]
        public void Parse_InvalidValuesAndFormat_ExceptionOrder () 
        {
                // hours should be between 0 and 23 but format is also invalid (too many dots)
-               TimeSpan.Parse ("0.99.99.0");
+               // In 2.0 overflow as precedence over format, but not in 4.0
+#if NET_4_0
+               try {
+                       TimeSpan.Parse ("0.99.99.0");
+                       Assert.Fail ("#A1");
+               } catch (FormatException) {
+               }
+#else
+               try {
+                       TimeSpan.Parse ("0.99.99.0");
+                       Assert.Fail ("#A1");
+               } catch (OverflowException) {
+               }
+#endif
        }
 
        [Test]
@@ -912,7 +966,6 @@ public class TimeSpanTest {
                Assert.AreEqual (true, TimeSpan.TryParse (" -1:2:3 ", out result), "#B1");
                Assert.AreEqual ("-01:02:03", result.ToString (), "#B2");
 
-               Assert.AreEqual (false, TimeSpan.TryParse (" 25:0:0 ", out result), "#C1");
                Assert.AreEqual (false, TimeSpan.TryParse ("aaa", out result), "#C2");
 
                Assert.AreEqual (true, TimeSpan.TryParse ("-21.23:59:59.9999999", out result), "#D1");
@@ -921,9 +974,12 @@ public class TimeSpanTest {
                Assert.AreEqual (false, TimeSpan.TryParse ("100000000000000.1:1:1", out result), "#E1");
                Assert.AreEqual (false, TimeSpan.TryParse ("24:60:60", out result), "#E2");
 
-               ParseHelper ("0001:0002:0003.12     ", false, false, "01:02:03.1200000");
+#if NET_4_0
+               Assert.AreEqual (false, TimeSpan.TryParse ("0001:0002:0003.12     ", out result), "#F1");
+#else
                Assert.AreEqual (true, TimeSpan.TryParse ("0001:0002:0003.12     ", out result), "#F1");
                Assert.AreEqual ("01:02:03.1200000", result.ToString (), "#F2");
+#endif
 
                Assert.AreEqual (false, TimeSpan.TryParse (" 1:2:3:12345678 ", out result), "#G1");
 
@@ -932,6 +988,22 @@ public class TimeSpanTest {
                Assert.AreEqual (TimeSpan.MaxValue, result, "MaxValue#2");
                Assert.AreEqual (true, TimeSpan.TryParse ("-10675199.02:48:05.4775808", out result), "MinValue#1");
                Assert.AreEqual (TimeSpan.MinValue, result, "MinValue#2");
+
+#if NET_4_0
+               // Force the use of french culture -which is using a non common NumberDecimalSeparator-
+               // as current culture, to show that the Parse method is *actually* being culture sensitive
+               CultureInfo french_culture = CultureInfo.GetCultureInfo ("fr-FR");
+               CultureInfo prev_culture = CultureInfo.CurrentCulture;
+               result = new TimeSpan (0, 10, 10, 10, 6);
+               try {
+                       Thread.CurrentThread.CurrentCulture = french_culture;
+                       Assert.AreEqual (true, TimeSpan.TryParse ("10:10:10,006", out result), "#CultureSensitive1");
+                       Assert.AreEqual ("10:10:10.0060000", result.ToString (), "#CultureSensitive2");
+               } finally {
+                       // restore culture
+                       Thread.CurrentThread.CurrentCulture = prev_culture;
+               }
+#endif
        }
 
        [Test]
@@ -945,6 +1017,24 @@ public class TimeSpanTest {
        }
 
 #if NET_4_0
+       [Test]
+       public void TryParseOverloads ()
+       { 
+               TimeSpan result;
+
+               // We use fr-FR culture since its NumericDecimalSeparator is not the same used by
+               // most cultures - including the invariant one.
+               CultureInfo french_culture = CultureInfo.GetCultureInfo ("fr-FR");
+               Assert.AreEqual (true, TimeSpan.TryParse ("11:50:50,006", french_culture, out result), "#A1");
+
+               // LAMESPEC - msdn states that an instance of DateTimeFormatInfo is retrieved to
+               // obtain culture sensitive information, but at least in the betas that's false
+               DateTimeFormatInfo format_info = new DateTimeFormatInfo ();
+               format_info.TimeSeparator = ";";
+               Assert.AreEqual (false, TimeSpan.TryParse ("11;50;50", format_info, out result), "#B1");
+               Assert.AreEqual (true, TimeSpan.TryParse ("11:50:50", format_info, out result), "#B2");
+       }
+
        [Test]
        public void ToStringOverloads ()
        {
index 20f46d9ba80299b16620db9fb791d87328fdc5f6..683bcbadae673ad66a24d586d4e7d76b5fdb6073 100644 (file)
@@ -506,6 +506,7 @@ System.Reflection/MethodInfo.cs
 System.Reflection/Missing.cs
 System.Reflection/Module.cs
 System.Reflection/ModuleResolveEventHandler.cs
+System.Reflection/MonoAssembly.cs
 System.Reflection/MonoGenericClass.cs
 System.Reflection/MonoGenericMethod.cs
 System.Reflection/MonoEvent.cs
@@ -1207,6 +1208,7 @@ System.Security.AccessControl/RegistrySecurity.cs
 System.Security.AccessControl/ResourceType.cs
 System.Security.AccessControl/SecurityInfos.cs
 System.Security.AccessControl/SystemAcl.cs
+../System.Core/System.Security.Cryptography/Aes.cs
 System.Security.Cryptography/AsymmetricAlgorithm.cs
 System.Security.Cryptography/AsymmetricKeyExchangeDeformatter.cs
 System.Security.Cryptography/AsymmetricKeyExchangeFormatter.cs
diff --git a/mcs/class/corlib/moonlight_bootstrap_corlib.dll.sources b/mcs/class/corlib/moonlight_bootstrap_corlib.dll.sources
new file mode 100644 (file)
index 0000000..346a842
--- /dev/null
@@ -0,0 +1,2 @@
+#include moonlight_raw_corlib.dll.sources
+
diff --git a/mcs/class/corlib/moonlight_raw_corlib.dll.sources b/mcs/class/corlib/moonlight_raw_corlib.dll.sources
new file mode 100644 (file)
index 0000000..c941a7d
--- /dev/null
@@ -0,0 +1,1036 @@
+Assembly/AssemblyInfo.cs
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+Microsoft.Win32.SafeHandles/CriticalHandleMinusOneIsInvalid.cs
+Microsoft.Win32.SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs
+Microsoft.Win32.SafeHandles/SafeHandleMinusOneIsInvalid.cs
+Microsoft.Win32.SafeHandles/SafeFileHandle.cs
+Microsoft.Win32.SafeHandles/SafeWaitHandle.cs
+Mono.Globalization.Unicode/CodePointIndexer.cs
+Mono.Globalization.Unicode/MSCompatUnicodeTable.cs
+Mono.Globalization.Unicode/MSCompatUnicodeTableUtil.cs
+Mono.Globalization.Unicode/SimpleCollator.cs
+Mono.Globalization.Unicode/SortKey.cs
+Mono.Globalization.Unicode/SortKeyBuffer.cs
+Mono/Runtime.cs
+Mono/DataConverter.cs
+Mono.Math/BigInteger.cs
+Mono.Math.Prime/ConfidenceFactor.cs
+Mono.Math.Prime/PrimalityTests.cs
+Mono.Math.Prime.Generator/NextPrimeFinder.cs
+Mono.Math.Prime.Generator/PrimeGeneratorBase.cs
+Mono.Math.Prime.Generator/SequentialSearchPrimeGeneratorBase.cs
+Mono.Security/ASN1.cs
+Mono.Security/ASN1Convert.cs
+Mono.Security/BitConverterLE.cs
+Mono.Security/PKCS7.cs
+Mono.Security/StrongName.cs
+Mono.Security/StrongNameManager_2_1.cs
+Mono.Security/Uri.cs
+Mono.Security.Cryptography/CryptoConvert.cs
+Mono.Security.Cryptography/CryptoTools.cs
+Mono.Security.Cryptography/DSAManaged.cs
+Mono.Security.Cryptography/KeyPairPersistence.cs
+Mono.Security.Cryptography/PKCS1.cs
+Mono.Security.Cryptography/PKCS8.cs
+Mono.Security.Cryptography/HMACAlgorithm.cs
+Mono.Security.Cryptography/SymmetricTransform.cs
+Mono.Security.Cryptography/RSAManaged.cs
+Mono.Security.X509/PKCS12.cs
+Mono.Security.X509/X501Name.cs
+Mono.Security.X509/X509Certificate.cs
+Mono.Security.X509/X509CertificateCollection.cs
+Mono.Security.X509/X509Chain.cs
+Mono.Security.X509/X509ChainStatusFlags.cs
+Mono.Security.X509/X509CRL.cs
+Mono.Security.X509/X509Extension.cs
+Mono.Security.X509/X509Extensions.cs
+Mono.Security.X509/X509Store.cs
+Mono.Security.X509/X509Stores.cs
+Mono.Security.X509/X509StoreManager.cs
+Mono.Security.X509/X520Attributes.cs
+Mono.Security.X509.Extensions/BasicConstraintsExtension.cs
+Mono.Security.X509.Extensions/KeyUsageExtension.cs
+Mono.Security.X509.Extensions/SubjectKeyIdentifierExtension.cs
+Mono.Xml/SmallXmlParser.cs
+System/AccessViolationException.cs
+System/Activator.cs
+System/AppDomain.cs
+System/AppDomainInitializer.cs
+System/AppDomainManager_2_1.cs
+System/AppDomainSetup.cs
+System/AppDomainUnloadedException.cs
+System/ApplicationException.cs
+System/ArgIterator.cs
+System/ArgumentException.cs
+System/ArgumentNullException.cs
+System/ArgumentOutOfRangeException.cs
+System/ArithmeticException.cs
+System/Array.cs
+System/ArrayTypeMismatchException.cs
+System/AssemblyLoadEventArgs.cs
+System/AssemblyLoadEventHandler.cs
+System/AsyncCallback.cs
+System/Attribute.cs
+System/AttributeTargets.cs
+System/AttributeUsageAttribute.cs
+System/BadImageFormatException.cs
+System/Base64FormattingOptions.cs
+System/BitConverter.cs
+System/Boolean.cs
+System/Buffer.cs
+System/Byte.cs
+System/CannotUnloadAppDomainException.cs
+System/Char.cs
+System/CharEnumerator.cs
+System/CLSCompliantAttribute.cs
+System/CStreamReader.cs
+System/CStreamWriter.cs
+System/Console.cs
+System/ConsoleCancelEventArgs.cs
+System/ConsoleCancelEventHandler.cs
+System/ConsoleColor.cs
+System/ConsoleDriver.cs
+System/ConsoleKey.cs
+System/ConsoleKeyInfo.cs
+System/ConsoleModifiers.cs
+System/ConsoleSpecialKey.cs
+System/ContextBoundObject.cs
+System/ContextMarshalException.cs
+System/ContextStaticAttribute.cs
+System/ControlCharacters.cs
+System/Convert.cs
+System/CrossAppDomainDelegate.cs
+System/DataMisalignedException.cs
+System/DateTime.cs
+System/DateTimeKind.cs
+System/DateTimeOffset.cs
+System/DateTimeUtils.cs
+System/DayOfWeek.cs
+System/DBNull.cs
+System/Decimal.cs
+System/Delegate.cs
+System/DelegateSerializationHolder.cs
+System/DivideByZeroException.cs
+System/DllNotFoundException.cs
+System/DomainManagerInitializationFlags.cs
+System/Double.cs
+System/DuplicateWaitObjectException.cs
+System/EntryPointNotFoundException.cs
+System/Enum.cs
+System/Environment.cs
+System/EnvironmentVariableTarget.cs
+System/EventArgs.cs
+System/EventHandler.cs
+System/Exception.cs
+System/ExecutionEngineException.cs
+System/FieldAccessException.cs
+System/FlagsAttribute.cs
+System/FormatException.cs
+System/Funcs.cs
+System/GC.cs
+System/GCCollectionMode.cs
+System/GCNotificationStatus.cs
+System/Guid.cs
+System/IAppDomainSetup.cs
+System/IAsyncResult.cs
+System/ICloneable.cs
+System/IComparable.cs
+System/IEquatable.cs
+System/IConsoleDriver.cs
+System/IConvertible.cs
+System/ICustomFormatter.cs
+System/IDisposable.cs
+System/IFormatProvider.cs
+System/IFormattable.cs
+System/IndexOutOfRangeException.cs
+System/InsufficientMemoryException.cs
+System/Int16.cs
+System/Int32.cs
+System/Int64.cs
+System/IntPtr.cs
+System/InvalidCastException.cs
+System/InvalidOperationException.cs
+System/InvalidProgramException.cs
+System/InvalidTimeZoneException.cs
+System/IServiceProvider.cs
+System/KnownTerminals.cs
+System/Lazy.cs
+System/LoaderOptimization.cs
+System/LoaderOptimizationAttribute.cs
+System/MarshalByRefObject.cs
+System/Math.cs
+System/MemberAccessException.cs
+System/MethodAccessException.cs
+System/MidpointRounding.cs
+System/MissingFieldException.cs
+System/MissingMemberException.cs
+System/MissingMethodException.cs
+System/MonoAsyncCall.cs
+System/MonoCustomAttrs.cs
+System/MonoListItem.cs
+System/MonoType.cs
+System/MTAThreadAttribute.cs
+System/MulticastDelegate.cs
+System/MulticastNotSupportedException.cs
+System/NonSerializedAttribute.cs
+System/NotFiniteNumberException.cs
+System/NotImplementedException.cs
+System/NotSupportedException.cs
+System/NullConsoleDriver.cs
+System/Nullable.cs
+System/NullReferenceException.cs
+System/NumberFormatter.cs
+System/Object.cs
+System/ObjectDisposedException.cs
+System/ObsoleteAttribute.cs
+System/OperatingSystem.cs
+System/OperationCanceledException.cs
+System/OutOfMemoryException.cs
+System/OverflowException.cs
+System/ParamArrayAttribute.cs
+System/PlatformID.cs
+System/PlatformNotSupportedException.cs
+System/Random.cs
+System/RankException.cs
+System/ResolveEventArgs.cs
+System/ResolveEventHandler.cs
+System/RuntimeArgumentHandle.cs
+System/RuntimeFieldHandle.cs
+System/RuntimeMethodHandle.cs
+System/RuntimeTypeHandle.cs
+System/ModuleHandle.cs
+System/SByte.cs
+System/SerializableAttribute.cs
+System/Single.cs
+System/StackOverflowException.cs
+System/STAThreadAttribute.cs
+System/String.cs
+System/StringSplitOptions.cs
+System/StringComparer.cs
+System/StringComparison.cs
+System/SystemException.cs
+System/TermInfoBooleans.cs
+System/TermInfoDriver.cs
+System/TermInfoNumbers.cs
+System/TermInfoReader.cs
+System/TermInfoStrings.cs
+System/ThreadStaticAttribute.cs
+System/TimeSpan.cs
+System/TimeZone.cs
+System/TimeoutException.cs
+../../build/common/MonoTODOAttribute.cs
+System/Type.cs
+System/TypeCode.cs
+System/TypedReference.cs
+System/TypeInitializationException.cs
+System/TypeLoadException.cs
+System/TypeUnloadedException.cs
+System/Tuple.cs
+System/Tuples.cs
+System/UInt16.cs
+System/UInt32.cs
+System/UInt64.cs
+System/UIntPtr.cs
+System/UnauthorizedAccessException.cs
+System/UnhandledExceptionEventArgs.cs
+System/UnhandledExceptionEventHandler.cs
+System/UnitySerializationHolder.cs
+System/ValueType.cs
+System/Version.cs
+System/Void.cs
+System/WeakReference.cs
+System/WindowsConsoleDriver.cs
+System.Collections/ArrayList.cs
+System.Collections/BitArray.cs
+System.Collections/CaseInsensitiveComparer.cs
+System.Collections/CaseInsensitiveHashCodeProvider.cs
+System.Collections/CollectionBase.cs
+System.Collections/Comparer.cs
+System.Collections/CollectionDebuggerView.cs
+System.Collections/DictionaryBase.cs
+System.Collections/DictionaryEntry.cs
+System.Collections/Hashtable.cs
+System.Collections/ICollection.cs
+System.Collections/IComparer.cs
+System.Collections/IDictionary.cs
+System.Collections/IDictionaryEnumerator.cs
+System.Collections/IEnumerable.cs
+System.Collections/IEnumerator.cs
+System.Collections/IEqualityComparer.cs
+System.Collections/IHashCodeProvider.cs
+System.Collections/IList.cs
+System.Collections/IStructuralComparable.cs
+System.Collections/IStructuralEquatable.cs
+System.Collections/Queue.cs
+System.Collections/ReadOnlyCollectionBase.cs
+System.Collections/SortedList.cs
+System.Collections/Stack.cs
+System.Configuration.Assemblies/AssemblyHashAlgorithm.cs
+System.Configuration.Assemblies/AssemblyVersionCompatibility.cs
+System.Diagnostics/ConditionalAttribute.cs
+System.Diagnostics/DebuggableAttribute.cs
+System.Diagnostics/Debugger.cs
+System.Diagnostics/DebuggerBrowsableState.cs
+System.Diagnostics/DebuggerBrowsableAttribute.cs
+System.Diagnostics/DebuggerDisplayAttribute.cs
+System.Diagnostics/DebuggerHiddenAttribute.cs
+System.Diagnostics/DebuggerNonUserCodeAttribute.cs
+System.Diagnostics/DebuggerStepThroughAttribute.cs
+System.Diagnostics/DebuggerTypeProxyAttribute.cs
+System.Diagnostics/StackFrame.cs
+System.Diagnostics/StackTrace.cs
+System.Diagnostics.CodeAnalysis/SuppressMessageAttribute.cs
+System.Diagnostics.Contracts/Contract.cs
+System.Diagnostics.Contracts/ContractClassAttribute.cs
+System.Diagnostics.Contracts/ContractClassForAttribute.cs
+System.Diagnostics.Contracts/ContractFailedEventArgs.cs
+System.Diagnostics.Contracts/ContractFailureKind.cs
+System.Diagnostics.Contracts/ContractInvariantMethodAttribute.cs
+System.Diagnostics.Contracts/ContractPublicPropertyNameAttribute.cs
+System.Diagnostics.Contracts/ContractReferenceAssemblyAttribute.cs
+System.Diagnostics.Contracts/ContractRuntimeIgnoredAttribute.cs
+System.Diagnostics.Contracts/ContractVerificationAttribute.cs
+System.Diagnostics.Contracts/PureAttribute.cs
+System.Diagnostics.SymbolStore/ISymbolBinder.cs
+System.Diagnostics.SymbolStore/ISymbolBinder1.cs
+System.Diagnostics.SymbolStore/ISymbolDocument.cs
+System.Diagnostics.SymbolStore/ISymbolDocumentWriter.cs
+System.Diagnostics.SymbolStore/ISymbolMethod.cs
+System.Diagnostics.SymbolStore/ISymbolNamespace.cs
+System.Diagnostics.SymbolStore/ISymbolReader.cs
+System.Diagnostics.SymbolStore/ISymbolScope.cs
+System.Diagnostics.SymbolStore/ISymbolVariable.cs
+System.Diagnostics.SymbolStore/ISymbolWriter.cs
+System.Diagnostics.SymbolStore/SymAddressKind.cs
+System.Diagnostics.SymbolStore/SymbolToken.cs
+System.Diagnostics.SymbolStore/SymDocumentType.cs
+System.Diagnostics.SymbolStore/SymLanguageType.cs
+System.Diagnostics.SymbolStore/SymLanguageVendor.cs
+System.Globalization/Calendar.cs
+System.Globalization/CalendarWeekRule.cs
+System.Globalization/CalendricalCalculations.cs
+System.Globalization/CharUnicodeInfo.cs
+System.Globalization/CompareInfo.cs
+System.Globalization/CompareOptions.cs
+System.Globalization/CultureInfo.cs
+System.Globalization/DateTimeFormatInfo.cs
+System.Globalization/DateTimeStyles.cs
+System.Globalization/DaylightTime.cs
+System.Globalization/GregorianCalendar.cs
+System.Globalization/GregorianCalendarTypes.cs
+System.Globalization/HebrewCalendar.cs
+System.Globalization/HijriCalendar.cs
+System.Globalization/JapaneseCalendar.cs
+System.Globalization/KoreanCalendar.cs
+System.Globalization/NumberFormatInfo.cs
+System.Globalization/NumberStyles.cs
+System.Globalization/RegionInfo.cs
+System.Globalization/StringInfo.cs
+System.Globalization/TaiwanCalendar.cs
+System.Globalization/TextElementEnumerator.cs
+System.Globalization/TextInfo.cs
+System.Globalization/ThaiBuddhistCalendar.cs
+System.Globalization/UmAlQuraCalendar.cs
+System.Globalization/UnicodeCategory.cs
+System.IO/BinaryReader.cs
+System.IO/BinaryWriter.cs
+System.IO/BufferedStream.cs
+System.IO/Directory.cs
+System.IO/DirectoryInfo.cs
+System.IO/DirectoryNotFoundException.cs
+System.IO/EndOfStreamException.cs
+System.IO/File.cs
+System.IO/FileAccess.cs
+System.IO/FileAttributes.cs
+System.IO/FileInfo.cs
+System.IO/FileLoadException.cs
+System.IO/FileMode.cs
+System.IO/FileNotFoundException.cs
+System.IO/FileOptions.cs
+System.IO/FileShare.cs
+System.IO/FileStream.cs
+System.IO/FileStreamAsyncResult.cs
+System.IO/FileSystemInfo.cs
+System.IO/IOException.cs
+System.IO/MemoryStream.cs
+System.IO/MonoIO.cs
+System.IO/MonoIOError.cs
+System.IO/MonoFileType.cs
+System.IO/MonoIOStat.cs
+System.IO/Path.cs
+System.IO/PathTooLongException.cs
+System.IO/SearchOption.cs
+System.IO/SearchPattern.cs
+System.IO/SeekOrigin.cs
+System.IO/Stream.cs
+System.IO/StreamAsyncResult.cs
+System.IO/StreamReader.cs
+System.IO/StreamWriter.cs
+System.IO/StringReader.cs
+System.IO/StringWriter.cs
+System.IO/TextReader.cs
+System.IO/TextWriter.cs
+System.IO/UnexceptionalStreamReader.cs
+System.IO/UnexceptionalStreamWriter.cs
+System.IO/UnmanagedMemoryAccessor.cs
+System.IO/UnmanagedMemoryStream.cs
+System.IO.IsolatedStorage/MoonIsolatedStorage.cs
+System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs
+System.IO.IsolatedStorage/MoonIsolatedStorageFileStream.cs
+System.IO.IsolatedStorage/IsolatedStorageException.cs
+System.Reflection/AmbiguousMatchException.cs
+System.Reflection/Assembly.cs
+System.Reflection/AssemblyAlgorithmIdAttribute.cs
+System.Reflection/AssemblyCompanyAttribute.cs
+System.Reflection/AssemblyConfigurationAttribute.cs
+System.Reflection/AssemblyCopyrightAttribute.cs
+System.Reflection/AssemblyCultureAttribute.cs
+System.Reflection/AssemblyDefaultAliasAttribute.cs
+System.Reflection/AssemblyDelaySignAttribute.cs
+System.Reflection/AssemblyDescriptionAttribute.cs
+System.Reflection/AssemblyFileVersionAttribute.cs
+System.Reflection/AssemblyFlagsAttribute.cs
+System.Reflection/AssemblyInformationalVersionAttribute.cs
+System.Reflection/AssemblyKeyFileAttribute.cs
+System.Reflection/AssemblyKeyNameAttribute.cs
+System.Reflection/AssemblyName.cs
+System.Reflection/AssemblyNameFlags.cs
+System.Reflection/AssemblyNameProxy.cs
+System.Reflection/AssemblyProductAttribute.cs
+System.Reflection/AssemblyTitleAttribute.cs
+System.Reflection/AssemblyTradeMarkAttribute.cs
+System.Reflection/AssemblyVersionAttribute.cs
+System.Reflection/Binder.cs
+System.Reflection/BindingFlags.cs
+System.Reflection/CallingConventions.cs
+System.Reflection/ConstructorInfo.cs
+System.Reflection/CustomAttributeData.cs
+System.Reflection/CustomAttributeFormatException.cs
+System.Reflection/CustomAttributeNamedArgument.cs
+System.Reflection/CustomAttributeTypedArgument.cs
+System.Reflection/DefaultMemberAttribute.cs
+System.Reflection/EventAttributes.cs
+System.Reflection/EventInfo.cs
+System.Reflection/ExceptionHandlingClause.cs
+System.Reflection/ExceptionHandlingClauseOptions.cs
+System.Reflection/FieldAttributes.cs
+System.Reflection/FieldInfo.cs
+System.Reflection/GenericParameterAttributes.cs
+System.Reflection/ICustomAttributeProvider.cs
+System.Reflection/ImageFileMachine.cs
+System.Reflection/InterfaceMapping.cs
+System.Reflection/IReflect.cs
+System.Reflection/LocalVariableInfo.cs
+System.Reflection/ManifestResourceInfo.cs
+System.Reflection/MemberFilter.cs
+System.Reflection/MemberInfo.cs
+System.Reflection/MemberInfoSerializationHolder.cs
+System.Reflection/MemberTypes.cs
+System.Reflection/MethodAttributes.cs
+System.Reflection/MethodBase.cs
+System.Reflection/MethodBody.cs
+System.Reflection/MethodImplAttributes.cs
+System.Reflection/MethodInfo.cs
+System.Reflection/Missing.cs
+System.Reflection/Module.cs
+System.Reflection/ModuleResolveEventHandler.cs
+System.Reflection/MonoAssembly.cs
+System.Reflection/MonoGenericClass.cs
+System.Reflection/MonoGenericMethod.cs
+System.Reflection/MonoEvent.cs
+System.Reflection/MonoField.cs
+System.Reflection/MonoMethod.cs
+System.Reflection/MonoProperty.cs
+System.Reflection/ObfuscateAssemblyAttribute.cs
+System.Reflection/ObfuscationAttribute.cs
+System.Reflection/ParameterAttributes.cs
+System.Reflection/ParameterInfo.cs
+System.Reflection/ParameterModifier.cs
+System.Reflection/Pointer.cs
+System.Reflection/PortableExecutableKinds.cs
+System.Reflection/ProcessorArchitecture.cs
+System.Reflection/PropertyAttributes.cs
+System.Reflection/PropertyInfo.cs
+System.Reflection/ReflectionTypeLoadException.cs
+System.Reflection/ResourceAttributes.cs
+System.Reflection/ResourceLocation.cs
+System.Reflection/StrongNameKeyPair.cs
+System.Reflection/TargetException.cs
+System.Reflection/TargetInvocationException.cs
+System.Reflection/TargetParameterCountException.cs
+System.Reflection/TypeAttributes.cs
+System.Reflection/TypeDelegator.cs
+System.Reflection/TypeFilter.cs
+System.Reflection.Emit/AssemblyBuilder.cs
+System.Reflection.Emit/AssemblyBuilderAccess.cs
+System.Reflection.Emit/ConstructorBuilder.cs
+System.Reflection.Emit/ConstructorOnTypeBuilderInst.cs
+System.Reflection.Emit/CustomAttributeBuilder.cs
+System.Reflection.Emit/DerivedTypes.cs
+System.Reflection.Emit/DynamicILInfo.cs
+System.Reflection.Emit/DynamicMethod.cs
+System.Reflection.Emit/EnumBuilder.cs
+System.Reflection.Emit/EventBuilder.cs
+System.Reflection.Emit/EventOnTypeBuilderInst.cs
+System.Reflection.Emit/EventToken.cs
+System.Reflection.Emit/FieldBuilder.cs
+System.Reflection.Emit/FieldOnTypeBuilderInst.cs
+System.Reflection.Emit/FieldToken.cs
+System.Reflection.Emit/FlowControl.cs
+System.Reflection.Emit/GenericTypeParameterBuilder.cs
+System.Reflection.Emit/ILGenerator.cs
+System.Reflection.Emit/Label.cs
+System.Reflection.Emit/LocalBuilder.cs
+System.Reflection.Emit/MethodBuilder.cs
+System.Reflection.Emit/MethodOnTypeBuilderInst.cs
+System.Reflection.Emit/MethodToken.cs
+System.Reflection.Emit/MethodRental.cs
+System.Reflection.Emit/ModuleBuilder.cs
+System.Reflection.Emit/MonoArrayMethod.cs
+System.Reflection.Emit/OpCodeNames.cs
+System.Reflection.Emit/OpCode.cs
+System.Reflection.Emit/OpCodes.cs
+System.Reflection.Emit/OpCodeType.cs
+System.Reflection.Emit/OperandType.cs
+System.Reflection.Emit/PackingSize.cs
+System.Reflection.Emit/ParameterBuilder.cs
+System.Reflection.Emit/ParameterToken.cs
+System.Reflection.Emit/PEFileKinds.cs
+System.Reflection.Emit/PropertyBuilder.cs
+System.Reflection.Emit/PropertyOnTypeBuilderInst.cs
+System.Reflection.Emit/PropertyToken.cs
+System.Reflection.Emit/SignatureHelper.cs
+System.Reflection.Emit/SignatureToken.cs
+System.Reflection.Emit/StackBehaviour.cs
+System.Reflection.Emit/StringToken.cs
+System.Reflection.Emit/TypeBuilder.cs
+System.Reflection.Emit/TypeToken.cs
+System.Reflection.Emit/UnmanagedMarshal.cs
+System.Resources/IResourceReader.cs
+System.Resources/IResourceWriter.cs
+System.Resources/MissingManifestResourceException.cs
+System.Resources/NeutralResourcesLanguageAttribute.cs
+System.Resources/ResourceManager.cs
+System.Resources/ResourceReader.cs
+System.Resources/ResourceSet.cs
+System.Resources/ResourceWriter.cs
+System.Resources/RuntimeResourceSet.cs
+System.Resources/SatelliteContractVersionAttribute.cs
+System.Resources/UltimateResourceFallbackLocation.cs
+System.Resources/Win32Resources.cs
+System.Runtime.CompilerServices/AccessedThroughPropertyAttribute.cs
+System.Runtime.CompilerServices/CallConvCdecl.cs
+System.Runtime.CompilerServices/CallConvFastcall.cs
+System.Runtime.CompilerServices/CallConvThiscall.cs
+System.Runtime.CompilerServices/CallConvStdcall.cs
+System.Runtime.CompilerServices/CompilationRelaxations.cs
+System.Runtime.CompilerServices/CompilationRelaxationsAttribute.cs
+System.Runtime.CompilerServices/CompilerGeneratedAttribute.cs
+System.Runtime.CompilerServices/CompilerGlobalScopeAttribute.cs
+System.Runtime.CompilerServices/CompilerMarshalOverride.cs
+System.Runtime.CompilerServices/ConditionalWeakTable.cs
+System.Runtime.CompilerServices/CustomConstantAttribute.cs
+System.Runtime.CompilerServices/DateTimeConstantAttribute.cs
+System.Runtime.CompilerServices/DecimalConstantAttribute.cs
+System.Runtime.CompilerServices/DefaultDependencyAttribute.cs
+System.Runtime.CompilerServices/DependencyAttribute.cs
+System.Runtime.CompilerServices/DiscardableAttribute.cs
+System.Runtime.CompilerServices/FixedAddressValueTypeAttribute.cs
+System.Runtime.CompilerServices/FixedBufferAttribute.cs
+System.Runtime.CompilerServices/HasCopySemanticsAttribute.cs
+System.Runtime.CompilerServices/IDispatchConstantAttribute.cs
+System.Runtime.CompilerServices/IUnknownConstantAttribute.cs
+System.Runtime.CompilerServices/IndexerNameAttribute.cs
+System.Runtime.CompilerServices/InternalsVisibleToAttribute.cs
+System.Runtime.CompilerServices/IsBoxed.cs
+System.Runtime.CompilerServices/IsByValue.cs
+System.Runtime.CompilerServices/IsConst.cs
+System.Runtime.CompilerServices/IsCopyConstructed.cs
+System.Runtime.CompilerServices/IsExplicitlyDereferenced.cs
+System.Runtime.CompilerServices/IsImplicitlyDereferenced.cs
+System.Runtime.CompilerServices/IsJitIntrinsic.cs
+System.Runtime.CompilerServices/IsLong.cs
+System.Runtime.CompilerServices/IsPinned.cs
+System.Runtime.CompilerServices/IsSignUnspecifiedByte.cs
+System.Runtime.CompilerServices/IsUdtReturn.cs
+System.Runtime.CompilerServices/IsVolatile.cs
+System.Runtime.CompilerServices/LoadHint.cs
+System.Runtime.CompilerServices/MethodCodeType.cs
+System.Runtime.CompilerServices/MethodImplAttribute.cs
+System.Runtime.CompilerServices/MethodImplOptions.cs
+System.Runtime.CompilerServices/NativeCppClassAttribute.cs
+System.Runtime.CompilerServices/ReferenceAssemblyAttribute.cs
+System.Runtime.CompilerServices/RequiredAttributeAttribute.cs
+System.Runtime.CompilerServices/RuntimeCompatibilityAttribute.cs
+System.Runtime.CompilerServices/RuntimeHelpers.cs
+System.Runtime.CompilerServices/RuntimeWrappedException.cs
+System.Runtime.CompilerServices/SpecialNameAttribute.cs 
+System.Runtime.CompilerServices/ScopelessEnumAttribute.cs
+System.Runtime.CompilerServices/SuppressIldasmAttribute.cs
+System.Runtime.CompilerServices/StringFreezingAttribute.cs 
+System.Runtime.CompilerServices/UnsafeValueTypeAttribute.cs
+System.Runtime.CompilerServices/TypeForwardedFromAttribute.cs
+System.Runtime.CompilerServices/TypeForwardedToAttribute.cs
+System.Runtime.ConstrainedExecution/CriticialFinalizerObject.cs
+System.Runtime.ConstrainedExecution/CER.cs
+System.Runtime.ConstrainedExecution/Consistency.cs
+System.Runtime.ConstrainedExecution/PrePrepareMethodAttribute.cs
+System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.cs
+System.Runtime.InteropServices/_Activator.cs
+System.Runtime.InteropServices/_Assembly.cs
+System.Runtime.InteropServices/_AssemblyBuilder.cs
+System.Runtime.InteropServices/_AssemblyName.cs
+System.Runtime.InteropServices/_Attribute.cs
+System.Runtime.InteropServices/_ConstructorBuilder.cs
+System.Runtime.InteropServices/_ConstructorInfo.cs
+System.Runtime.InteropServices/_CustomAttributeBuilder.cs
+System.Runtime.InteropServices/_EnumBuilder.cs
+System.Runtime.InteropServices/_EventBuilder.cs
+System.Runtime.InteropServices/_EventInfo.cs
+System.Runtime.InteropServices/_Exception.cs
+System.Runtime.InteropServices/_FieldBuilder.cs
+System.Runtime.InteropServices/_FieldInfo.cs
+System.Runtime.InteropServices/_ILGenerator.cs
+System.Runtime.InteropServices/_LocalBuilder.cs
+System.Runtime.InteropServices/_MemberInfo.cs
+System.Runtime.InteropServices/_MethodBase.cs
+System.Runtime.InteropServices/_MethodBuilder.cs
+System.Runtime.InteropServices/_MethodInfo.cs
+System.Runtime.InteropServices/_MethodRental.cs
+System.Runtime.InteropServices/_Module.cs
+System.Runtime.InteropServices/_ModuleBuilder.cs
+System.Runtime.InteropServices/_ParameterBuilder.cs
+System.Runtime.InteropServices/_ParameterInfo.cs
+System.Runtime.InteropServices/_PropertyBuilder.cs
+System.Runtime.InteropServices/_PropertyInfo.cs
+System.Runtime.InteropServices/_SignatureHelper.cs
+System.Runtime.InteropServices/_Thread.cs
+System.Runtime.InteropServices/_Type.cs
+System.Runtime.InteropServices/_TypeBuilder.cs
+System.Runtime.InteropServices/AllowReversePInvokeCallsAttribute.cs
+System.Runtime.InteropServices/CallingConvention.cs
+System.Runtime.InteropServices/CharSet.cs
+System.Runtime.InteropServices/ClassInterfaceAttribute.cs
+System.Runtime.InteropServices/ClassInterfaceType.cs
+System.Runtime.InteropServices/CoClassAttribute.cs
+System.Runtime.InteropServices/ComDefaultInterfaceAttribute.cs
+System.Runtime.InteropServices/COMException.cs
+System.Runtime.InteropServices/ComImportAttribute.cs
+System.Runtime.InteropServices/ComInterfaceType.cs
+System.Runtime.InteropServices/ComVisible.cs
+System.Runtime.InteropServices/CriticalHandle.cs
+System.Runtime.InteropServices/DefaultCharSetAttribute.cs
+System.Runtime.InteropServices/DispIdAttribute.cs
+System.Runtime.InteropServices/DllImportAttribute.cs
+System.Runtime.InteropServices/ExternalException.cs
+System.Runtime.InteropServices/FieldOffsetAttribute.cs
+System.Runtime.InteropServices/GCHandle.cs
+System.Runtime.InteropServices/GCHandleType.cs
+System.Runtime.InteropServices/GuidAttribute.cs
+System.Runtime.InteropServices/HandleRef.cs
+System.Runtime.InteropServices/InAttribute.cs
+System.Runtime.InteropServices/InterfaceTypeAttribute.cs
+System.Runtime.InteropServices/LayoutKind.cs
+System.Runtime.InteropServices/Marshal.cs
+System.Runtime.InteropServices/MarshalAsAttribute.cs
+System.Runtime.InteropServices/MarshalDirectiveException.cs
+System.Runtime.InteropServices/OptionalAttribute.cs
+System.Runtime.InteropServices/OutAttribute.cs
+System.Runtime.InteropServices/PreserveSigAttribute.cs
+System.Runtime.InteropServices/SEHException.cs
+System.Runtime.InteropServices/SafeHandle.cs
+System.Runtime.InteropServices/StructLayoutAttribute.cs
+System.Runtime.InteropServices/TypeLibImportClassAttribute.cs
+System.Runtime.InteropServices/TypeLibVersionAttribute.cs
+System.Runtime.InteropServices/UnmanagedFunctionPointerAttribute.cs
+System.Runtime.InteropServices/UnmanagedType.cs
+System.Runtime.Remoting/ActivatedClientTypeEntry.cs
+System.Runtime.Remoting/ActivatedServiceTypeEntry.cs
+System.Runtime.Remoting/CustomErrorsModes.cs
+System.Runtime.Remoting/EnvoyInfo.cs
+System.Runtime.Remoting/IObjectHandle.cs
+System.Runtime.Remoting/IChannelInfo.cs
+System.Runtime.Remoting/Identity.cs
+System.Runtime.Remoting/InternalRemotingServices.cs
+System.Runtime.Remoting/IEnvoyInfo.cs
+System.Runtime.Remoting/IRemotingTypeInfo.cs
+System.Runtime.Remoting/ObjectHandle.cs
+System.Runtime.Remoting/ObjRef.cs
+System.Runtime.Remoting/RemotingConfiguration.cs
+System.Runtime.Remoting/RemotingException.cs
+System.Runtime.Remoting/RemotingTimeoutException.cs
+System.Runtime.Remoting/RemotingServices.cs
+System.Runtime.Remoting/ServerException.cs
+System.Runtime.Remoting/ServerIdentity.cs
+System.Runtime.Remoting/SoapServices.cs
+System.Runtime.Remoting/TypeEntry.cs
+System.Runtime.Remoting/TypeInfo.cs
+System.Runtime.Remoting/WellKnownObjectMode.cs
+System.Runtime.Remoting/WellKnownClientTypeEntry.cs
+System.Runtime.Remoting/WellKnownServiceTypeEntry.cs
+System.Runtime.Remoting.Activation/ActivationServices.cs
+System.Runtime.Remoting.Activation/ActivatorLevel.cs
+System.Runtime.Remoting.Activation/AppDomainLevelActivator.cs
+System.Runtime.Remoting.Activation/ConstructionLevelActivator.cs
+System.Runtime.Remoting.Activation/ContextLevelActivator.cs
+System.Runtime.Remoting.Activation/IActivator.cs
+System.Runtime.Remoting.Activation/IConstructionCallMessage.cs
+System.Runtime.Remoting.Activation/IConstructionReturnMessage.cs
+System.Runtime.Remoting.Activation/RemoteActivator.cs
+System.Runtime.Remoting.Activation/RemoteActivationAttribute.cs
+System.Runtime.Remoting.Activation/UrlAttribute.cs
+System.Runtime.Remoting.Channels/AggregateDictionary.cs
+System.Runtime.Remoting.Channels/BaseChannelObjectWithProperties.cs
+System.Runtime.Remoting.Channels/BaseChannelSinkWithProperties.cs
+System.Runtime.Remoting.Channels/BaseChannelWithProperties.cs
+System.Runtime.Remoting.Channels/ChannelDataStore.cs
+System.Runtime.Remoting.Channels/ChannelServices.cs
+System.Runtime.Remoting.Channels/ChannelSinkStackEntry.cs
+System.Runtime.Remoting.Channels/ClientChannelSinkStack.cs
+System.Runtime.Remoting.Channels/IChannel.cs
+System.Runtime.Remoting.Channels/IChannelDataStore.cs
+System.Runtime.Remoting.Channels/IChannelReceiver.cs
+System.Runtime.Remoting.Channels/IChannelReceiverHook.cs
+System.Runtime.Remoting.Channels/IChannelSender.cs
+System.Runtime.Remoting.Channels/IChannelSinkBase.cs
+System.Runtime.Remoting.Channels/IClientChannelSink.cs
+System.Runtime.Remoting.Channels/IClientChannelSinkProvider.cs
+System.Runtime.Remoting.Channels/IClientChannelSinkStack.cs
+System.Runtime.Remoting.Channels/IClientFormatterSink.cs
+System.Runtime.Remoting.Channels/IClientFormatterSinkProvider.cs
+System.Runtime.Remoting.Channels/IClientResponseChannelSinkStack.cs
+System.Runtime.Remoting.Channels/ISecurableChannel.cs
+System.Runtime.Remoting.Channels/IServerResponseChannelSinkStack.cs
+System.Runtime.Remoting.Channels/ServerDispatchSink.cs
+System.Runtime.Remoting.Channels/ServerDispatchSinkProvider.cs
+System.Runtime.Remoting.Channels/IServerChannelSink.cs
+System.Runtime.Remoting.Channels/IServerChannelSinkProvider.cs
+System.Runtime.Remoting.Channels/IServerChannelSinkStack.cs
+System.Runtime.Remoting.Channels/IServerFormatterSinkProvider.cs
+System.Runtime.Remoting.Channels/ITransportHeaders.cs
+System.Runtime.Remoting.Channels/ServerChannelSinkStack.cs
+System.Runtime.Remoting.Channels/ServerProcessing.cs
+System.Runtime.Remoting.Channels/SinkProviderData.cs
+System.Runtime.Remoting.Channels/TransportHeaders.cs
+System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs
+System.Runtime.Remoting.Contexts/Context.cs
+System.Runtime.Remoting.Contexts/ContextAttribute.cs
+System.Runtime.Remoting.Contexts/ContextProperty.cs
+System.Runtime.Remoting.Contexts/CrossContextChannel.cs
+System.Runtime.Remoting.Contexts/CrossContextDelegate.cs
+System.Runtime.Remoting.Contexts/IContextAttribute.cs
+System.Runtime.Remoting.Contexts/IContextProperty.cs
+System.Runtime.Remoting.Contexts/IContextPropertyActivator.cs
+System.Runtime.Remoting.Contexts/IContributeClientContextSink.cs
+System.Runtime.Remoting.Contexts/IContributeDynamicSink.cs
+System.Runtime.Remoting.Contexts/IContributeEnvoySink.cs
+System.Runtime.Remoting.Contexts/IContributeObjectSink.cs
+System.Runtime.Remoting.Contexts/IContributeServerContextSink.cs
+System.Runtime.Remoting.Contexts/IDynamicMessageSink.cs
+System.Runtime.Remoting.Contexts/IDynamicProperty.cs
+System.Runtime.Remoting.Contexts/SynchronizationAttribute.cs
+System.Runtime.Remoting.Lifetime/ClientSponsor.cs
+System.Runtime.Remoting.Lifetime/ILease.cs
+System.Runtime.Remoting.Lifetime/ISponsor.cs
+System.Runtime.Remoting.Lifetime/Lease.cs
+System.Runtime.Remoting.Lifetime/LeaseManager.cs
+System.Runtime.Remoting.Lifetime/LeaseSink.cs
+System.Runtime.Remoting.Lifetime/LeaseState.cs
+System.Runtime.Remoting.Lifetime/LifetimeServices.cs
+System.Runtime.Remoting.Messaging/ArgInfo.cs
+System.Runtime.Remoting.Messaging/AsyncResult.cs
+System.Runtime.Remoting.Messaging/CallContext.cs
+System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs
+System.Runtime.Remoting.Messaging/ConstructionCall.cs
+System.Runtime.Remoting.Messaging/ConstructionCallDictionary.cs
+System.Runtime.Remoting.Messaging/ConstructionResponse.cs
+System.Runtime.Remoting.Messaging/EnvoyTerminatorSink.cs
+System.Runtime.Remoting.Messaging/Header.cs
+System.Runtime.Remoting.Messaging/HeaderHandler.cs
+System.Runtime.Remoting.Messaging/ErrorMessage.cs
+System.Runtime.Remoting.Messaging/IInternalMessage.cs
+System.Runtime.Remoting.Messaging/IMessage.cs
+System.Runtime.Remoting.Messaging/IMessageCtrl.cs
+System.Runtime.Remoting.Messaging/IMessageSink.cs
+System.Runtime.Remoting.Messaging/IMethodCallMessage.cs
+System.Runtime.Remoting.Messaging/IMethodMessage.cs
+System.Runtime.Remoting.Messaging/IMethodReturnMessage.cs
+System.Runtime.Remoting.Messaging/IRemotingFormatter.cs
+System.Runtime.Remoting.Messaging/InternalMessageWrapper.cs
+System.Runtime.Remoting.Messaging/ISerializationRootObject.cs
+System.Runtime.Remoting.Messaging/LogicalCallContext.cs
+System.Runtime.Remoting.Messaging/MessageSurrogateFilter.cs
+System.Runtime.Remoting.Messaging/MethodCall.cs
+System.Runtime.Remoting.Messaging/MethodCallMessageWrapper.cs
+System.Runtime.Remoting.Messaging/MethodResponse.cs
+System.Runtime.Remoting.Messaging/MethodCallDictionary.cs
+System.Runtime.Remoting.Messaging/MethodDictionary.cs
+System.Runtime.Remoting.Messaging/MethodReturnDictionary.cs
+System.Runtime.Remoting.Messaging/MethodReturnMessageWrapper.cs
+System.Runtime.Remoting.Messaging/MonoMethodMessage.cs
+System.Runtime.Remoting.Messaging/OneWayAttribute.cs
+System.Runtime.Remoting.Messaging/RemotingSurrogateSelector.cs
+System.Runtime.Remoting.Messaging/RemotingSurrogate.cs
+System.Runtime.Remoting.Messaging/ReturnMessage.cs
+System.Runtime.Remoting.Messaging/ServerContextTerminatorSink.cs
+System.Runtime.Remoting.Messaging/ServerObjectTerminatorSink.cs
+System.Runtime.Remoting.Messaging/StackBuilderSink.cs
+System.Runtime.Remoting.Messaging/CADMessages.cs
+System.Runtime.Remoting.Metadata/SoapAttribute.cs
+System.Runtime.Remoting.Metadata/SoapFieldAttribute.cs
+System.Runtime.Remoting.Metadata/SoapMethodAttribute.cs
+System.Runtime.Remoting.Metadata/SoapOption.cs
+System.Runtime.Remoting.Metadata/SoapParameterAttribute.cs
+System.Runtime.Remoting.Metadata/SoapTypeAttribute.cs
+System.Runtime.Remoting.Metadata/XmlFieldOrderOption.cs
+System.Runtime.Remoting.Proxies/RealProxy.cs
+System.Runtime.Remoting.Proxies/RemotingProxy.cs
+System.Runtime.Remoting.Proxies/ProxyAttribute.cs
+System.Runtime.Remoting.Services/EnterpriseServicesHelper.cs
+System.Runtime.Remoting.Services/ITrackingHandler.cs
+System.Runtime.Remoting.Services/TrackingServices.cs
+System.Runtime.Serialization/Formatter.cs
+System.Runtime.Serialization/FormatterConverter.cs
+System.Runtime.Serialization/FormatterServices.cs
+System.Runtime.Serialization/IDeserializationCallback.cs
+System.Runtime.Serialization/IFormatter.cs
+System.Runtime.Serialization/IFormatterConverter.cs
+System.Runtime.Serialization/IObjectReference.cs
+System.Runtime.Serialization/ISerializable.cs
+System.Runtime.Serialization/ISerializationSurrogate.cs
+System.Runtime.Serialization/ISurrogateSelector.cs
+System.Runtime.Serialization/ObjectIDGenerator.cs
+System.Runtime.Serialization/ObjectManager.cs
+System.Runtime.Serialization/OnDeserializedAttribute.cs
+System.Runtime.Serialization/OnDeserializingAttribute.cs
+System.Runtime.Serialization/OnSerializedAttribute.cs
+System.Runtime.Serialization/OnSerializingAttribute.cs
+System.Runtime.Serialization/OptionalFieldAttribute.cs
+System.Runtime.Serialization/SerializationBinder.cs
+System.Runtime.Serialization/SerializationCallbacks.cs
+System.Runtime.Serialization/SerializationEntry.cs
+System.Runtime.Serialization/SerializationException.cs
+System.Runtime.Serialization/SerializationInfo.cs
+System.Runtime.Serialization/SerializationInfoEnumerator.cs
+System.Runtime.Serialization/SerializationObjectManager.cs
+System.Runtime.Serialization/StreamingContext.cs
+System.Runtime.Serialization/StreamingContextStates.cs
+System.Runtime.Serialization/SurrogateSelector.cs
+System.Runtime.Serialization.Formatters/FormatterAssemblyStyle.cs
+System.Runtime.Serialization.Formatters/FormatterTopObjectStyle.cs
+System.Runtime.Serialization.Formatters/FormatterTypeStyle.cs
+System.Runtime.Serialization.Formatters/IFieldInfo.cs
+System.Runtime.Serialization.Formatters/InternalArrayTypeE.cs
+System.Runtime.Serialization.Formatters/InternalElementTypeE.cs
+System.Runtime.Serialization.Formatters/InternalMemberTypeE.cs
+System.Runtime.Serialization.Formatters/InternalMemberValueE.cs
+System.Runtime.Serialization.Formatters/InternalNameSpaceE.cs
+System.Runtime.Serialization.Formatters/InternalObjectPositionE.cs
+System.Runtime.Serialization.Formatters/InternalObjectTypeE.cs
+System.Runtime.Serialization.Formatters/InternalParseStateE.cs
+System.Runtime.Serialization.Formatters/InternalParseTypeE.cs
+System.Runtime.Serialization.Formatters/InternalPrimitiveTypeE.cs
+System.Runtime.Serialization.Formatters/InternalRM.cs
+System.Runtime.Serialization.Formatters/InternalSerializerTypeE.cs
+System.Runtime.Serialization.Formatters/InternalST.cs
+System.Runtime.Serialization.Formatters/ISoapMessage.cs
+System.Runtime.Serialization.Formatters/ServerFault.cs
+System.Runtime.Serialization.Formatters/SoapFault.cs
+System.Runtime.Serialization.Formatters/SoapMessage.cs
+System.Runtime.Serialization.Formatters/TypeFilterLevel.cs
+System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs
+System.Runtime.Serialization.Formatters.Binary/BinaryCommon.cs
+System.Runtime.Serialization.Formatters.Binary/CodeGenerator.cs
+System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs
+System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs
+System.Runtime.Serialization.Formatters.Binary/MessageFormatter.cs
+System.Runtime.Versioning/ResourceExposureAttribute.cs
+System.Runtime.Versioning/ResourceScope.cs
+System.Runtime.Versioning/VersioningHelper.cs
+System.Security/AllowPartiallyTrustedCallersAttribute.cs
+System.Security/CodeAccessPermission_2_1.cs
+System.Security/IPermission.cs
+System.Security/PermissionSet_2_1.cs
+System.Security/SecurityCriticalAttribute.cs
+System.Security/SecurityFrame.cs
+System.Security/SecurityException_2_1.cs
+System.Security/SecurityManager_2_1.cs
+System.Security/SecuritySafeCriticalAttribute.cs
+System.Security/SecurityState.cs
+System.Security/SecurityTransparentAttribute.cs
+System.Security/SuppressUnmanagedCodeSecurityAttribute.cs
+System.Security/UnverifiableCodeAttribute.cs
+System.Security/VerificationException.cs
+../System.Core/System.Security.Cryptography/Aes.cs
+System.Security.Cryptography/AsymmetricAlgorithm.cs
+System.Security.Cryptography/AsymmetricKeyExchangeDeformatter.cs
+System.Security.Cryptography/AsymmetricKeyExchangeFormatter.cs
+System.Security.Cryptography/AsymmetricSignatureDeformatter.cs
+System.Security.Cryptography/AsymmetricSignatureFormatter.cs
+System.Security.Cryptography/Base64Constants.cs
+System.Security.Cryptography/CipherMode.cs
+System.Security.Cryptography/CryptoAPITransform.cs
+System.Security.Cryptography/CryptoConfig_2_1.cs
+System.Security.Cryptography/CryptographicException.cs
+System.Security.Cryptography/CryptographicUnexpectedOperationExcpetion.cs
+System.Security.Cryptography/CryptoStream.cs
+System.Security.Cryptography/CryptoStreamMode.cs
+System.Security.Cryptography/DeriveBytes.cs
+System.Security.Cryptography/DES.cs
+System.Security.Cryptography/DESCryptoServiceProvider.cs
+System.Security.Cryptography/DSA.cs
+System.Security.Cryptography/DSAParameters.cs
+System.Security.Cryptography/DSASignatureDeformatter.cs
+System.Security.Cryptography/DSASignatureFormatter.cs
+System.Security.Cryptography/FromBase64Transform.cs
+System.Security.Cryptography/HashAlgorithm.cs
+System.Security.Cryptography/HMAC.cs
+System.Security.Cryptography/HMACMD5.cs
+System.Security.Cryptography/HMACSHA1.cs
+System.Security.Cryptography/HMACSHA256.cs
+System.Security.Cryptography/ICryptoTransform.cs
+System.Security.Cryptography/KeyedHashAlgorithm.cs
+System.Security.Cryptography/KeyNumber.cs
+System.Security.Cryptography/KeySizes.cs
+System.Security.Cryptography/MaskGenerationMethod.cs
+System.Security.Cryptography/MD5.cs
+System.Security.Cryptography/MD5CryptoServiceProvider.cs
+System.Security.Cryptography/PaddingMode.cs
+System.Security.Cryptography/PKCS1MaskGenerationMethod.cs
+System.Security.Cryptography/RandomNumberGenerator.cs
+System.Security.Cryptography/RC2.cs
+System.Security.Cryptography/RC2CryptoServiceProvider.cs
+System.Security.Cryptography/Rfc2898DeriveBytes.cs
+System.Security.Cryptography/Rijndael.cs
+System.Security.Cryptography/RijndaelManaged.cs
+System.Security.Cryptography/RijndaelManagedTransform.cs
+System.Security.Cryptography/RNGCryptoServiceProvider.cs
+System.Security.Cryptography/RSA.cs
+System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.cs
+System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.cs
+System.Security.Cryptography/RSAParameters.cs
+System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatter.cs
+System.Security.Cryptography/RSAPKCS1KeyExchangeFormatter.cs
+System.Security.Cryptography/RSAPKCS1SignatureDeformatter.cs
+System.Security.Cryptography/RSAPKCS1SignatureFormatter.cs
+System.Security.Cryptography/SHA1.cs
+System.Security.Cryptography/SHA1CryptoServiceProvider.cs
+System.Security.Cryptography/SHA1Managed.cs
+System.Security.Cryptography/SHA256.cs
+System.Security.Cryptography/SHA256Managed.cs
+System.Security.Cryptography/SHAConstants.cs
+System.Security.Cryptography/SymmetricAlgorithm.cs
+System.Security.Cryptography/ToBase64Transform.cs
+System.Security.Cryptography/TripleDES.cs
+System.Security.Cryptography/TripleDESCryptoServiceProvider.cs
+System.Security.Cryptography.X509Certificates/X509Certificate.cs
+System.Security.Cryptography.X509Certificates/X509Certificate20.cs
+System.Security.Cryptography.X509Certificates/X509ContentType.cs
+System.Security.Cryptography.X509Certificates/X509KeyStorageFlags.cs
+System.Security.Permissions/CodeAccessSecurityAttribute.cs
+System.Security.Permissions/EnvironmentPermissionAccess.cs
+System.Security.Permissions/EnvironmentPermissionAttribute.cs
+System.Security.Permissions/FileIOPermissionAccess.cs
+System.Security.Permissions/FileIOPermissionAttribute.cs
+System.Security.Permissions/HostProtectionAttribute.cs
+System.Security.Permissions/HostProtectionResource.cs
+System.Security.Permissions/PermissionSetAttribute.cs
+System.Security.Permissions/PermissionState.cs
+System.Security.Permissions/ReflectionPermissionAttribute.cs
+System.Security.Permissions/ReflectionPermissionFlag.cs
+System.Security.Permissions/SecurityAction.cs
+System.Security.Permissions/SecurityAttribute.cs
+System.Security.Permissions/SecurityPermissionAttribute.cs
+System.Security.Permissions/SecurityPermissionFlag.cs
+System.Security.Permissions/StrongNamePermissionAttribute.cs
+System.Security.Permissions/StrongNamePublicKeyBlob.cs
+System.Security.Policy/Evidence_2_1.cs
+System.Security.Policy/PolicyLevel_2_1.cs
+System.Security.Principal/IIdentity.cs
+System.Security.Principal/IPrincipal.cs
+System.Text/ASCIIEncoding.cs
+System.Text/Decoder.cs
+System.Text/DecoderExceptionFallback.cs
+System.Text/DecoderExceptionFallbackBuffer.cs
+System.Text/DecoderFallback.cs
+System.Text/DecoderFallbackBuffer.cs
+System.Text/DecoderFallbackException.cs
+System.Text/DecoderReplacementFallback.cs
+System.Text/DecoderReplacementFallbackBuffer.cs
+System.Text/Encoder.cs
+System.Text/EncoderExceptionFallback.cs
+System.Text/EncoderExceptionFallbackBuffer.cs
+System.Text/EncoderFallback.cs
+System.Text/EncoderFallbackBuffer.cs
+System.Text/EncoderFallbackException.cs
+System.Text/EncoderReplacementFallback.cs
+System.Text/EncoderReplacementFallbackBuffer.cs
+System.Text/Encoding.cs
+System.Text/EncodingInfo.cs
+System.Text/StringBuilder.cs
+System.Text/SurrogateEncoder.cs
+System.Text/UnicodeEncoding.cs
+System.Text/UTF7Encoding.cs
+System.Text/UTF8Encoding.cs
+System.Text/UTF32Encoding.cs
+System.Threading/AbandonedMutexException.cs
+System.Threading/AutoResetEvent.cs
+System.Threading/ContextCallback.cs
+System.Threading/EventResetMode.cs
+System.Threading/EventWaitHandle.cs
+System.Threading/ExecutionContext.cs
+System.Threading/Interlocked.cs
+System.Threading/IOCompletionCallback.cs
+System.Threading/ManualResetEvent.cs
+System.Threading/Monitor.cs
+System.Threading/Mutex.cs
+System.Threading/NativeEventCalls.cs
+System.Threading/NativeOverlapped.cs
+System.Threading/Overlapped.cs
+System.Threading/ParameterizedThreadStart.cs
+System.Threading/RegisteredWaitHandle.cs
+System.Threading/SendOrPostCallback.cs
+System.Threading/SynchronizationContext.cs
+System.Threading/SynchronizationLockException.cs
+System.Threading/Thread.cs
+System.Threading/ThreadAbortException.cs
+System.Threading/ThreadInterruptedException.cs
+System.Threading/ThreadPool.cs
+System.Threading/ThreadStart.cs
+System.Threading/ThreadStartException.cs
+System.Threading/ThreadState.cs
+System.Threading/ThreadStateException.cs
+System.Threading/Timeout.cs
+System.Threading/Timer.cs
+System.Threading/TimerCallback.cs
+System.Threading/WaitCallback.cs
+System.Threading/WaitHandle.cs
+System.Threading/WaitOrTimerCallback.cs
+System.Collections.Generic/CollectionDebuggerView.cs
+System.Collections.Generic/Dictionary.cs
+System.Collections.Generic/ICollection.cs
+System.Collections.Generic/IEnumerable.cs
+System.Collections.Generic/IEnumerator.cs
+System.Collections.Generic/IList.cs
+System.Collections.Generic/IComparer.cs
+System.Collections.Generic/IEqualityComparer.cs
+System.Collections.Generic/IDictionary.cs
+System.Collections.Generic/KeyValuePair.cs
+System.Collections.Generic/EqualityComparer.cs
+System.Collections.Generic/KeyNotFoundException.cs
+System.Collections.Generic/List.cs
+System.Collections.ObjectModel/Collection.cs
+System.Collections.ObjectModel/KeyedCollection.cs
+System.Collections.ObjectModel/ReadOnlyCollection.cs
+System/Action.cs
+System/ArraySegment.cs
+System/Comparison.cs
+System/Converter.cs
+System/Predicate.cs
+System.Collections.Generic/Comparer.cs
+../Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
+../Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
+../Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
+../Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs
+
diff --git a/mcs/class/corlib/net_2_1_bootstrap_corlib.dll.sources b/mcs/class/corlib/net_2_1_bootstrap_corlib.dll.sources
deleted file mode 100644 (file)
index c2216ab..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include net_2_1_raw_corlib.dll.sources
-
diff --git a/mcs/class/corlib/net_2_1_raw_corlib.dll.sources b/mcs/class/corlib/net_2_1_raw_corlib.dll.sources
deleted file mode 100644 (file)
index 111cace..0000000
+++ /dev/null
@@ -1,1033 +0,0 @@
-Assembly/AssemblyInfo.cs
-../../build/common/Consts.cs
-../../build/common/Locale.cs
-Microsoft.Win32.SafeHandles/CriticalHandleMinusOneIsInvalid.cs
-Microsoft.Win32.SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs
-Microsoft.Win32.SafeHandles/SafeHandleMinusOneIsInvalid.cs
-Microsoft.Win32.SafeHandles/SafeFileHandle.cs
-Microsoft.Win32.SafeHandles/SafeWaitHandle.cs
-Mono.Globalization.Unicode/CodePointIndexer.cs
-Mono.Globalization.Unicode/MSCompatUnicodeTable.cs
-Mono.Globalization.Unicode/MSCompatUnicodeTableUtil.cs
-Mono.Globalization.Unicode/SimpleCollator.cs
-Mono.Globalization.Unicode/SortKey.cs
-Mono.Globalization.Unicode/SortKeyBuffer.cs
-Mono/Runtime.cs
-Mono/DataConverter.cs
-Mono.Math/BigInteger.cs
-Mono.Math.Prime/ConfidenceFactor.cs
-Mono.Math.Prime/PrimalityTests.cs
-Mono.Math.Prime.Generator/NextPrimeFinder.cs
-Mono.Math.Prime.Generator/PrimeGeneratorBase.cs
-Mono.Math.Prime.Generator/SequentialSearchPrimeGeneratorBase.cs
-Mono.Security/ASN1.cs
-Mono.Security/ASN1Convert.cs
-Mono.Security/BitConverterLE.cs
-Mono.Security/PKCS7.cs
-Mono.Security/StrongName.cs
-Mono.Security/StrongNameManager_2_1.cs
-Mono.Security/Uri.cs
-Mono.Security.Cryptography/CryptoConvert.cs
-Mono.Security.Cryptography/CryptoTools.cs
-Mono.Security.Cryptography/DSAManaged.cs
-Mono.Security.Cryptography/KeyPairPersistence.cs
-Mono.Security.Cryptography/PKCS1.cs
-Mono.Security.Cryptography/PKCS8.cs
-Mono.Security.Cryptography/HMACAlgorithm.cs
-Mono.Security.Cryptography/SymmetricTransform.cs
-Mono.Security.Cryptography/RSAManaged.cs
-Mono.Security.X509/PKCS12.cs
-Mono.Security.X509/X501Name.cs
-Mono.Security.X509/X509Certificate.cs
-Mono.Security.X509/X509CertificateCollection.cs
-Mono.Security.X509/X509Chain.cs
-Mono.Security.X509/X509ChainStatusFlags.cs
-Mono.Security.X509/X509CRL.cs
-Mono.Security.X509/X509Extension.cs
-Mono.Security.X509/X509Extensions.cs
-Mono.Security.X509/X509Store.cs
-Mono.Security.X509/X509Stores.cs
-Mono.Security.X509/X509StoreManager.cs
-Mono.Security.X509/X520Attributes.cs
-Mono.Security.X509.Extensions/BasicConstraintsExtension.cs
-Mono.Security.X509.Extensions/KeyUsageExtension.cs
-Mono.Security.X509.Extensions/SubjectKeyIdentifierExtension.cs
-Mono.Xml/SmallXmlParser.cs
-System/AccessViolationException.cs
-System/Activator.cs
-System/AppDomain.cs
-System/AppDomainInitializer.cs
-System/AppDomainManager_2_1.cs
-System/AppDomainSetup.cs
-System/AppDomainUnloadedException.cs
-System/ApplicationException.cs
-System/ArgIterator.cs
-System/ArgumentException.cs
-System/ArgumentNullException.cs
-System/ArgumentOutOfRangeException.cs
-System/ArithmeticException.cs
-System/Array.cs
-System/ArrayTypeMismatchException.cs
-System/AssemblyLoadEventArgs.cs
-System/AssemblyLoadEventHandler.cs
-System/AsyncCallback.cs
-System/Attribute.cs
-System/AttributeTargets.cs
-System/AttributeUsageAttribute.cs
-System/BadImageFormatException.cs
-System/Base64FormattingOptions.cs
-System/BitConverter.cs
-System/Boolean.cs
-System/Buffer.cs
-System/Byte.cs
-System/CannotUnloadAppDomainException.cs
-System/Char.cs
-System/CharEnumerator.cs
-System/CLSCompliantAttribute.cs
-System/CStreamReader.cs
-System/CStreamWriter.cs
-System/Console.cs
-System/ConsoleCancelEventArgs.cs
-System/ConsoleCancelEventHandler.cs
-System/ConsoleColor.cs
-System/ConsoleDriver.cs
-System/ConsoleKey.cs
-System/ConsoleKeyInfo.cs
-System/ConsoleModifiers.cs
-System/ConsoleSpecialKey.cs
-System/ContextBoundObject.cs
-System/ContextMarshalException.cs
-System/ContextStaticAttribute.cs
-System/ControlCharacters.cs
-System/Convert.cs
-System/CrossAppDomainDelegate.cs
-System/DataMisalignedException.cs
-System/DateTime.cs
-System/DateTimeKind.cs
-System/DateTimeOffset.cs
-System/DateTimeUtils.cs
-System/DayOfWeek.cs
-System/DBNull.cs
-System/Decimal.cs
-System/Delegate.cs
-System/DelegateSerializationHolder.cs
-System/DivideByZeroException.cs
-System/DllNotFoundException.cs
-System/DomainManagerInitializationFlags.cs
-System/Double.cs
-System/DuplicateWaitObjectException.cs
-System/EntryPointNotFoundException.cs
-System/Enum.cs
-System/Environment.cs
-System/EnvironmentVariableTarget.cs
-System/EventArgs.cs
-System/EventHandler.cs
-System/Exception.cs
-System/ExecutionEngineException.cs
-System/FieldAccessException.cs
-System/FlagsAttribute.cs
-System/FormatException.cs
-System/Funcs.cs
-System/GC.cs
-System/GCCollectionMode.cs
-System/GCNotificationStatus.cs
-System/Guid.cs
-System/IAppDomainSetup.cs
-System/IAsyncResult.cs
-System/ICloneable.cs
-System/IComparable.cs
-System/IEquatable.cs
-System/IConsoleDriver.cs
-System/IConvertible.cs
-System/ICustomFormatter.cs
-System/IDisposable.cs
-System/IFormatProvider.cs
-System/IFormattable.cs
-System/IndexOutOfRangeException.cs
-System/InsufficientMemoryException.cs
-System/Int16.cs
-System/Int32.cs
-System/Int64.cs
-System/IntPtr.cs
-System/InvalidCastException.cs
-System/InvalidOperationException.cs
-System/InvalidProgramException.cs
-System/InvalidTimeZoneException.cs
-System/IServiceProvider.cs
-System/KnownTerminals.cs
-System/Lazy.cs
-System/LoaderOptimization.cs
-System/LoaderOptimizationAttribute.cs
-System/MarshalByRefObject.cs
-System/Math.cs
-System/MemberAccessException.cs
-System/MethodAccessException.cs
-System/MidpointRounding.cs
-System/MissingFieldException.cs
-System/MissingMemberException.cs
-System/MissingMethodException.cs
-System/MonoAsyncCall.cs
-System/MonoCustomAttrs.cs
-System/MonoListItem.cs
-System/MonoType.cs
-System/MTAThreadAttribute.cs
-System/MulticastDelegate.cs
-System/MulticastNotSupportedException.cs
-System/NonSerializedAttribute.cs
-System/NotFiniteNumberException.cs
-System/NotImplementedException.cs
-System/NotSupportedException.cs
-System/NullConsoleDriver.cs
-System/Nullable.cs
-System/NullReferenceException.cs
-System/NumberFormatter.cs
-System/Object.cs
-System/ObjectDisposedException.cs
-System/ObsoleteAttribute.cs
-System/OperatingSystem.cs
-System/OperationCanceledException.cs
-System/OutOfMemoryException.cs
-System/OverflowException.cs
-System/ParamArrayAttribute.cs
-System/PlatformID.cs
-System/PlatformNotSupportedException.cs
-System/Random.cs
-System/RankException.cs
-System/ResolveEventArgs.cs
-System/ResolveEventHandler.cs
-System/RuntimeArgumentHandle.cs
-System/RuntimeFieldHandle.cs
-System/RuntimeMethodHandle.cs
-System/RuntimeTypeHandle.cs
-System/ModuleHandle.cs
-System/SByte.cs
-System/SerializableAttribute.cs
-System/Single.cs
-System/StackOverflowException.cs
-System/STAThreadAttribute.cs
-System/String.cs
-System/StringSplitOptions.cs
-System/StringComparer.cs
-System/StringComparison.cs
-System/SystemException.cs
-System/TermInfoBooleans.cs
-System/TermInfoDriver.cs
-System/TermInfoNumbers.cs
-System/TermInfoReader.cs
-System/TermInfoStrings.cs
-System/ThreadStaticAttribute.cs
-System/TimeSpan.cs
-System/TimeZone.cs
-System/TimeoutException.cs
-../../build/common/MonoTODOAttribute.cs
-System/Type.cs
-System/TypeCode.cs
-System/TypedReference.cs
-System/TypeInitializationException.cs
-System/TypeLoadException.cs
-System/TypeUnloadedException.cs
-System/Tuple.cs
-System/Tuples.cs
-System/UInt16.cs
-System/UInt32.cs
-System/UInt64.cs
-System/UIntPtr.cs
-System/UnauthorizedAccessException.cs
-System/UnhandledExceptionEventArgs.cs
-System/UnhandledExceptionEventHandler.cs
-System/UnitySerializationHolder.cs
-System/ValueType.cs
-System/Version.cs
-System/Void.cs
-System/WeakReference.cs
-System/WindowsConsoleDriver.cs
-System.Collections/ArrayList.cs
-System.Collections/BitArray.cs
-System.Collections/CaseInsensitiveComparer.cs
-System.Collections/CaseInsensitiveHashCodeProvider.cs
-System.Collections/CollectionBase.cs
-System.Collections/Comparer.cs
-System.Collections/CollectionDebuggerView.cs
-System.Collections/DictionaryBase.cs
-System.Collections/DictionaryEntry.cs
-System.Collections/Hashtable.cs
-System.Collections/ICollection.cs
-System.Collections/IComparer.cs
-System.Collections/IDictionary.cs
-System.Collections/IDictionaryEnumerator.cs
-System.Collections/IEnumerable.cs
-System.Collections/IEnumerator.cs
-System.Collections/IEqualityComparer.cs
-System.Collections/IHashCodeProvider.cs
-System.Collections/IList.cs
-System.Collections/IStructuralComparable.cs
-System.Collections/IStructuralEquatable.cs
-System.Collections/Queue.cs
-System.Collections/ReadOnlyCollectionBase.cs
-System.Collections/SortedList.cs
-System.Collections/Stack.cs
-System.Configuration.Assemblies/AssemblyHashAlgorithm.cs
-System.Configuration.Assemblies/AssemblyVersionCompatibility.cs
-System.Diagnostics/ConditionalAttribute.cs
-System.Diagnostics/DebuggableAttribute.cs
-System.Diagnostics/Debugger.cs
-System.Diagnostics/DebuggerBrowsableState.cs
-System.Diagnostics/DebuggerBrowsableAttribute.cs
-System.Diagnostics/DebuggerDisplayAttribute.cs
-System.Diagnostics/DebuggerHiddenAttribute.cs
-System.Diagnostics/DebuggerNonUserCodeAttribute.cs
-System.Diagnostics/DebuggerStepThroughAttribute.cs
-System.Diagnostics/DebuggerTypeProxyAttribute.cs
-System.Diagnostics/StackFrame.cs
-System.Diagnostics/StackTrace.cs
-System.Diagnostics.CodeAnalysis/SuppressMessageAttribute.cs
-System.Diagnostics.Contracts/Contract.cs
-System.Diagnostics.Contracts/ContractClassAttribute.cs
-System.Diagnostics.Contracts/ContractClassForAttribute.cs
-System.Diagnostics.Contracts/ContractFailedEventArgs.cs
-System.Diagnostics.Contracts/ContractFailureKind.cs
-System.Diagnostics.Contracts/ContractInvariantMethodAttribute.cs
-System.Diagnostics.Contracts/ContractPublicPropertyNameAttribute.cs
-System.Diagnostics.Contracts/ContractReferenceAssemblyAttribute.cs
-System.Diagnostics.Contracts/ContractRuntimeIgnoredAttribute.cs
-System.Diagnostics.Contracts/ContractVerificationAttribute.cs
-System.Diagnostics.Contracts/PureAttribute.cs
-System.Diagnostics.SymbolStore/ISymbolBinder.cs
-System.Diagnostics.SymbolStore/ISymbolBinder1.cs
-System.Diagnostics.SymbolStore/ISymbolDocument.cs
-System.Diagnostics.SymbolStore/ISymbolDocumentWriter.cs
-System.Diagnostics.SymbolStore/ISymbolMethod.cs
-System.Diagnostics.SymbolStore/ISymbolNamespace.cs
-System.Diagnostics.SymbolStore/ISymbolReader.cs
-System.Diagnostics.SymbolStore/ISymbolScope.cs
-System.Diagnostics.SymbolStore/ISymbolVariable.cs
-System.Diagnostics.SymbolStore/ISymbolWriter.cs
-System.Diagnostics.SymbolStore/SymAddressKind.cs
-System.Diagnostics.SymbolStore/SymbolToken.cs
-System.Diagnostics.SymbolStore/SymDocumentType.cs
-System.Diagnostics.SymbolStore/SymLanguageType.cs
-System.Diagnostics.SymbolStore/SymLanguageVendor.cs
-System.Globalization/Calendar.cs
-System.Globalization/CalendarWeekRule.cs
-System.Globalization/CalendricalCalculations.cs
-System.Globalization/CharUnicodeInfo.cs
-System.Globalization/CompareInfo.cs
-System.Globalization/CompareOptions.cs
-System.Globalization/CultureInfo.cs
-System.Globalization/DateTimeFormatInfo.cs
-System.Globalization/DateTimeStyles.cs
-System.Globalization/DaylightTime.cs
-System.Globalization/GregorianCalendar.cs
-System.Globalization/GregorianCalendarTypes.cs
-System.Globalization/HebrewCalendar.cs
-System.Globalization/HijriCalendar.cs
-System.Globalization/JapaneseCalendar.cs
-System.Globalization/KoreanCalendar.cs
-System.Globalization/NumberFormatInfo.cs
-System.Globalization/NumberStyles.cs
-System.Globalization/RegionInfo.cs
-System.Globalization/StringInfo.cs
-System.Globalization/TaiwanCalendar.cs
-System.Globalization/TextElementEnumerator.cs
-System.Globalization/TextInfo.cs
-System.Globalization/ThaiBuddhistCalendar.cs
-System.Globalization/UmAlQuraCalendar.cs
-System.Globalization/UnicodeCategory.cs
-System.IO/BinaryReader.cs
-System.IO/BinaryWriter.cs
-System.IO/BufferedStream.cs
-System.IO/Directory.cs
-System.IO/DirectoryInfo.cs
-System.IO/DirectoryNotFoundException.cs
-System.IO/EndOfStreamException.cs
-System.IO/File.cs
-System.IO/FileAccess.cs
-System.IO/FileAttributes.cs
-System.IO/FileInfo.cs
-System.IO/FileLoadException.cs
-System.IO/FileMode.cs
-System.IO/FileNotFoundException.cs
-System.IO/FileOptions.cs
-System.IO/FileShare.cs
-System.IO/FileStream.cs
-System.IO/FileStreamAsyncResult.cs
-System.IO/FileSystemInfo.cs
-System.IO/IOException.cs
-System.IO/MemoryStream.cs
-System.IO/MonoIO.cs
-System.IO/MonoIOError.cs
-System.IO/MonoFileType.cs
-System.IO/MonoIOStat.cs
-System.IO/Path.cs
-System.IO/PathTooLongException.cs
-System.IO/SearchOption.cs
-System.IO/SearchPattern.cs
-System.IO/SeekOrigin.cs
-System.IO/Stream.cs
-System.IO/StreamAsyncResult.cs
-System.IO/StreamReader.cs
-System.IO/StreamWriter.cs
-System.IO/StringReader.cs
-System.IO/StringWriter.cs
-System.IO/TextReader.cs
-System.IO/TextWriter.cs
-System.IO/UnexceptionalStreamReader.cs
-System.IO/UnexceptionalStreamWriter.cs
-System.IO/UnmanagedMemoryAccessor.cs
-System.IO/UnmanagedMemoryStream.cs
-System.IO.IsolatedStorage/MoonIsolatedStorage.cs
-System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs
-System.IO.IsolatedStorage/MoonIsolatedStorageFileStream.cs
-System.IO.IsolatedStorage/IsolatedStorageException.cs
-System.Reflection/AmbiguousMatchException.cs
-System.Reflection/Assembly.cs
-System.Reflection/AssemblyAlgorithmIdAttribute.cs
-System.Reflection/AssemblyCompanyAttribute.cs
-System.Reflection/AssemblyConfigurationAttribute.cs
-System.Reflection/AssemblyCopyrightAttribute.cs
-System.Reflection/AssemblyCultureAttribute.cs
-System.Reflection/AssemblyDefaultAliasAttribute.cs
-System.Reflection/AssemblyDelaySignAttribute.cs
-System.Reflection/AssemblyDescriptionAttribute.cs
-System.Reflection/AssemblyFileVersionAttribute.cs
-System.Reflection/AssemblyFlagsAttribute.cs
-System.Reflection/AssemblyInformationalVersionAttribute.cs
-System.Reflection/AssemblyKeyFileAttribute.cs
-System.Reflection/AssemblyKeyNameAttribute.cs
-System.Reflection/AssemblyName.cs
-System.Reflection/AssemblyNameFlags.cs
-System.Reflection/AssemblyNameProxy.cs
-System.Reflection/AssemblyProductAttribute.cs
-System.Reflection/AssemblyTitleAttribute.cs
-System.Reflection/AssemblyTradeMarkAttribute.cs
-System.Reflection/AssemblyVersionAttribute.cs
-System.Reflection/Binder.cs
-System.Reflection/BindingFlags.cs
-System.Reflection/CallingConventions.cs
-System.Reflection/ConstructorInfo.cs
-System.Reflection/CustomAttributeData.cs
-System.Reflection/CustomAttributeFormatException.cs
-System.Reflection/CustomAttributeNamedArgument.cs
-System.Reflection/CustomAttributeTypedArgument.cs
-System.Reflection/DefaultMemberAttribute.cs
-System.Reflection/EventAttributes.cs
-System.Reflection/EventInfo.cs
-System.Reflection/ExceptionHandlingClause.cs
-System.Reflection/ExceptionHandlingClauseOptions.cs
-System.Reflection/FieldAttributes.cs
-System.Reflection/FieldInfo.cs
-System.Reflection/GenericParameterAttributes.cs
-System.Reflection/ICustomAttributeProvider.cs
-System.Reflection/ImageFileMachine.cs
-System.Reflection/InterfaceMapping.cs
-System.Reflection/IReflect.cs
-System.Reflection/LocalVariableInfo.cs
-System.Reflection/ManifestResourceInfo.cs
-System.Reflection/MemberFilter.cs
-System.Reflection/MemberInfo.cs
-System.Reflection/MemberInfoSerializationHolder.cs
-System.Reflection/MemberTypes.cs
-System.Reflection/MethodAttributes.cs
-System.Reflection/MethodBase.cs
-System.Reflection/MethodBody.cs
-System.Reflection/MethodImplAttributes.cs
-System.Reflection/MethodInfo.cs
-System.Reflection/Missing.cs
-System.Reflection/Module.cs
-System.Reflection/ModuleResolveEventHandler.cs
-System.Reflection/MonoGenericClass.cs
-System.Reflection/MonoGenericMethod.cs
-System.Reflection/MonoEvent.cs
-System.Reflection/MonoField.cs
-System.Reflection/MonoMethod.cs
-System.Reflection/MonoProperty.cs
-System.Reflection/ObfuscateAssemblyAttribute.cs
-System.Reflection/ObfuscationAttribute.cs
-System.Reflection/ParameterAttributes.cs
-System.Reflection/ParameterInfo.cs
-System.Reflection/ParameterModifier.cs
-System.Reflection/Pointer.cs
-System.Reflection/PortableExecutableKinds.cs
-System.Reflection/ProcessorArchitecture.cs
-System.Reflection/PropertyAttributes.cs
-System.Reflection/PropertyInfo.cs
-System.Reflection/ReflectionTypeLoadException.cs
-System.Reflection/ResourceAttributes.cs
-System.Reflection/ResourceLocation.cs
-System.Reflection/StrongNameKeyPair.cs
-System.Reflection/TargetException.cs
-System.Reflection/TargetInvocationException.cs
-System.Reflection/TargetParameterCountException.cs
-System.Reflection/TypeAttributes.cs
-System.Reflection/TypeDelegator.cs
-System.Reflection/TypeFilter.cs
-System.Reflection.Emit/AssemblyBuilder.cs
-System.Reflection.Emit/AssemblyBuilderAccess.cs
-System.Reflection.Emit/ConstructorBuilder.cs
-System.Reflection.Emit/ConstructorOnTypeBuilderInst.cs
-System.Reflection.Emit/CustomAttributeBuilder.cs
-System.Reflection.Emit/DerivedTypes.cs
-System.Reflection.Emit/DynamicILInfo.cs
-System.Reflection.Emit/DynamicMethod.cs
-System.Reflection.Emit/EnumBuilder.cs
-System.Reflection.Emit/EventBuilder.cs
-System.Reflection.Emit/EventOnTypeBuilderInst.cs
-System.Reflection.Emit/EventToken.cs
-System.Reflection.Emit/FieldBuilder.cs
-System.Reflection.Emit/FieldOnTypeBuilderInst.cs
-System.Reflection.Emit/FieldToken.cs
-System.Reflection.Emit/FlowControl.cs
-System.Reflection.Emit/GenericTypeParameterBuilder.cs
-System.Reflection.Emit/ILGenerator.cs
-System.Reflection.Emit/Label.cs
-System.Reflection.Emit/LocalBuilder.cs
-System.Reflection.Emit/MethodBuilder.cs
-System.Reflection.Emit/MethodOnTypeBuilderInst.cs
-System.Reflection.Emit/MethodToken.cs
-System.Reflection.Emit/MethodRental.cs
-System.Reflection.Emit/ModuleBuilder.cs
-System.Reflection.Emit/MonoArrayMethod.cs
-System.Reflection.Emit/OpCodeNames.cs
-System.Reflection.Emit/OpCode.cs
-System.Reflection.Emit/OpCodes.cs
-System.Reflection.Emit/OpCodeType.cs
-System.Reflection.Emit/OperandType.cs
-System.Reflection.Emit/PackingSize.cs
-System.Reflection.Emit/ParameterBuilder.cs
-System.Reflection.Emit/ParameterToken.cs
-System.Reflection.Emit/PEFileKinds.cs
-System.Reflection.Emit/PropertyBuilder.cs
-System.Reflection.Emit/PropertyOnTypeBuilderInst.cs
-System.Reflection.Emit/PropertyToken.cs
-System.Reflection.Emit/SignatureHelper.cs
-System.Reflection.Emit/SignatureToken.cs
-System.Reflection.Emit/StackBehaviour.cs
-System.Reflection.Emit/StringToken.cs
-System.Reflection.Emit/TypeBuilder.cs
-System.Reflection.Emit/TypeToken.cs
-System.Reflection.Emit/UnmanagedMarshal.cs
-System.Resources/IResourceReader.cs
-System.Resources/IResourceWriter.cs
-System.Resources/MissingManifestResourceException.cs
-System.Resources/NeutralResourcesLanguageAttribute.cs
-System.Resources/ResourceManager.cs
-System.Resources/ResourceReader.cs
-System.Resources/ResourceSet.cs
-System.Resources/ResourceWriter.cs
-System.Resources/RuntimeResourceSet.cs
-System.Resources/SatelliteContractVersionAttribute.cs
-System.Resources/UltimateResourceFallbackLocation.cs
-System.Resources/Win32Resources.cs
-System.Runtime.CompilerServices/AccessedThroughPropertyAttribute.cs
-System.Runtime.CompilerServices/CallConvCdecl.cs
-System.Runtime.CompilerServices/CallConvFastcall.cs
-System.Runtime.CompilerServices/CallConvThiscall.cs
-System.Runtime.CompilerServices/CallConvStdcall.cs
-System.Runtime.CompilerServices/CompilationRelaxations.cs
-System.Runtime.CompilerServices/CompilationRelaxationsAttribute.cs
-System.Runtime.CompilerServices/CompilerGeneratedAttribute.cs
-System.Runtime.CompilerServices/CompilerGlobalScopeAttribute.cs
-System.Runtime.CompilerServices/CompilerMarshalOverride.cs
-System.Runtime.CompilerServices/ConditionalWeakTable.cs
-System.Runtime.CompilerServices/CustomConstantAttribute.cs
-System.Runtime.CompilerServices/DateTimeConstantAttribute.cs
-System.Runtime.CompilerServices/DecimalConstantAttribute.cs
-System.Runtime.CompilerServices/DefaultDependencyAttribute.cs
-System.Runtime.CompilerServices/DependencyAttribute.cs
-System.Runtime.CompilerServices/DiscardableAttribute.cs
-System.Runtime.CompilerServices/FixedAddressValueTypeAttribute.cs
-System.Runtime.CompilerServices/FixedBufferAttribute.cs
-System.Runtime.CompilerServices/HasCopySemanticsAttribute.cs
-System.Runtime.CompilerServices/IDispatchConstantAttribute.cs
-System.Runtime.CompilerServices/IUnknownConstantAttribute.cs
-System.Runtime.CompilerServices/IndexerNameAttribute.cs
-System.Runtime.CompilerServices/InternalsVisibleToAttribute.cs
-System.Runtime.CompilerServices/IsBoxed.cs
-System.Runtime.CompilerServices/IsByValue.cs
-System.Runtime.CompilerServices/IsConst.cs
-System.Runtime.CompilerServices/IsCopyConstructed.cs
-System.Runtime.CompilerServices/IsExplicitlyDereferenced.cs
-System.Runtime.CompilerServices/IsImplicitlyDereferenced.cs
-System.Runtime.CompilerServices/IsJitIntrinsic.cs
-System.Runtime.CompilerServices/IsLong.cs
-System.Runtime.CompilerServices/IsPinned.cs
-System.Runtime.CompilerServices/IsSignUnspecifiedByte.cs
-System.Runtime.CompilerServices/IsUdtReturn.cs
-System.Runtime.CompilerServices/IsVolatile.cs
-System.Runtime.CompilerServices/LoadHint.cs
-System.Runtime.CompilerServices/MethodCodeType.cs
-System.Runtime.CompilerServices/MethodImplAttribute.cs
-System.Runtime.CompilerServices/MethodImplOptions.cs
-System.Runtime.CompilerServices/NativeCppClassAttribute.cs
-System.Runtime.CompilerServices/RequiredAttributeAttribute.cs
-System.Runtime.CompilerServices/RuntimeCompatibilityAttribute.cs
-System.Runtime.CompilerServices/RuntimeHelpers.cs
-System.Runtime.CompilerServices/RuntimeWrappedException.cs
-System.Runtime.CompilerServices/SpecialNameAttribute.cs 
-System.Runtime.CompilerServices/ScopelessEnumAttribute.cs
-System.Runtime.CompilerServices/SuppressIldasmAttribute.cs
-System.Runtime.CompilerServices/StringFreezingAttribute.cs 
-System.Runtime.CompilerServices/UnsafeValueTypeAttribute.cs
-System.Runtime.CompilerServices/TypeForwardedFromAttribute.cs
-System.Runtime.CompilerServices/TypeForwardedToAttribute.cs
-System.Runtime.ConstrainedExecution/CriticialFinalizerObject.cs
-System.Runtime.ConstrainedExecution/CER.cs
-System.Runtime.ConstrainedExecution/Consistency.cs
-System.Runtime.ConstrainedExecution/PrePrepareMethodAttribute.cs
-System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.cs
-System.Runtime.InteropServices/_Activator.cs
-System.Runtime.InteropServices/_Assembly.cs
-System.Runtime.InteropServices/_AssemblyBuilder.cs
-System.Runtime.InteropServices/_AssemblyName.cs
-System.Runtime.InteropServices/_Attribute.cs
-System.Runtime.InteropServices/_ConstructorBuilder.cs
-System.Runtime.InteropServices/_ConstructorInfo.cs
-System.Runtime.InteropServices/_CustomAttributeBuilder.cs
-System.Runtime.InteropServices/_EnumBuilder.cs
-System.Runtime.InteropServices/_EventBuilder.cs
-System.Runtime.InteropServices/_EventInfo.cs
-System.Runtime.InteropServices/_Exception.cs
-System.Runtime.InteropServices/_FieldBuilder.cs
-System.Runtime.InteropServices/_FieldInfo.cs
-System.Runtime.InteropServices/_ILGenerator.cs
-System.Runtime.InteropServices/_LocalBuilder.cs
-System.Runtime.InteropServices/_MemberInfo.cs
-System.Runtime.InteropServices/_MethodBase.cs
-System.Runtime.InteropServices/_MethodBuilder.cs
-System.Runtime.InteropServices/_MethodInfo.cs
-System.Runtime.InteropServices/_MethodRental.cs
-System.Runtime.InteropServices/_Module.cs
-System.Runtime.InteropServices/_ModuleBuilder.cs
-System.Runtime.InteropServices/_ParameterBuilder.cs
-System.Runtime.InteropServices/_ParameterInfo.cs
-System.Runtime.InteropServices/_PropertyBuilder.cs
-System.Runtime.InteropServices/_PropertyInfo.cs
-System.Runtime.InteropServices/_SignatureHelper.cs
-System.Runtime.InteropServices/_Thread.cs
-System.Runtime.InteropServices/_Type.cs
-System.Runtime.InteropServices/_TypeBuilder.cs
-System.Runtime.InteropServices/AllowReversePInvokeCallsAttribute.cs
-System.Runtime.InteropServices/CallingConvention.cs
-System.Runtime.InteropServices/CharSet.cs
-System.Runtime.InteropServices/ClassInterfaceAttribute.cs
-System.Runtime.InteropServices/ClassInterfaceType.cs
-System.Runtime.InteropServices/CoClassAttribute.cs
-System.Runtime.InteropServices/ComDefaultInterfaceAttribute.cs
-System.Runtime.InteropServices/COMException.cs
-System.Runtime.InteropServices/ComImportAttribute.cs
-System.Runtime.InteropServices/ComInterfaceType.cs
-System.Runtime.InteropServices/ComVisible.cs
-System.Runtime.InteropServices/CriticalHandle.cs
-System.Runtime.InteropServices/DefaultCharSetAttribute.cs
-System.Runtime.InteropServices/DispIdAttribute.cs
-System.Runtime.InteropServices/DllImportAttribute.cs
-System.Runtime.InteropServices/ExternalException.cs
-System.Runtime.InteropServices/FieldOffsetAttribute.cs
-System.Runtime.InteropServices/GCHandle.cs
-System.Runtime.InteropServices/GCHandleType.cs
-System.Runtime.InteropServices/GuidAttribute.cs
-System.Runtime.InteropServices/HandleRef.cs
-System.Runtime.InteropServices/InAttribute.cs
-System.Runtime.InteropServices/InterfaceTypeAttribute.cs
-System.Runtime.InteropServices/LayoutKind.cs
-System.Runtime.InteropServices/Marshal.cs
-System.Runtime.InteropServices/MarshalAsAttribute.cs
-System.Runtime.InteropServices/MarshalDirectiveException.cs
-System.Runtime.InteropServices/OptionalAttribute.cs
-System.Runtime.InteropServices/OutAttribute.cs
-System.Runtime.InteropServices/PreserveSigAttribute.cs
-System.Runtime.InteropServices/SEHException.cs
-System.Runtime.InteropServices/SafeHandle.cs
-System.Runtime.InteropServices/StructLayoutAttribute.cs
-System.Runtime.InteropServices/TypeLibImportClassAttribute.cs
-System.Runtime.InteropServices/TypeLibVersionAttribute.cs
-System.Runtime.InteropServices/UnmanagedFunctionPointerAttribute.cs
-System.Runtime.InteropServices/UnmanagedType.cs
-System.Runtime.Remoting/ActivatedClientTypeEntry.cs
-System.Runtime.Remoting/ActivatedServiceTypeEntry.cs
-System.Runtime.Remoting/CustomErrorsModes.cs
-System.Runtime.Remoting/EnvoyInfo.cs
-System.Runtime.Remoting/IObjectHandle.cs
-System.Runtime.Remoting/IChannelInfo.cs
-System.Runtime.Remoting/Identity.cs
-System.Runtime.Remoting/InternalRemotingServices.cs
-System.Runtime.Remoting/IEnvoyInfo.cs
-System.Runtime.Remoting/IRemotingTypeInfo.cs
-System.Runtime.Remoting/ObjectHandle.cs
-System.Runtime.Remoting/ObjRef.cs
-System.Runtime.Remoting/RemotingConfiguration.cs
-System.Runtime.Remoting/RemotingException.cs
-System.Runtime.Remoting/RemotingTimeoutException.cs
-System.Runtime.Remoting/RemotingServices.cs
-System.Runtime.Remoting/ServerException.cs
-System.Runtime.Remoting/ServerIdentity.cs
-System.Runtime.Remoting/SoapServices.cs
-System.Runtime.Remoting/TypeEntry.cs
-System.Runtime.Remoting/TypeInfo.cs
-System.Runtime.Remoting/WellKnownObjectMode.cs
-System.Runtime.Remoting/WellKnownClientTypeEntry.cs
-System.Runtime.Remoting/WellKnownServiceTypeEntry.cs
-System.Runtime.Remoting.Activation/ActivationServices.cs
-System.Runtime.Remoting.Activation/ActivatorLevel.cs
-System.Runtime.Remoting.Activation/AppDomainLevelActivator.cs
-System.Runtime.Remoting.Activation/ConstructionLevelActivator.cs
-System.Runtime.Remoting.Activation/ContextLevelActivator.cs
-System.Runtime.Remoting.Activation/IActivator.cs
-System.Runtime.Remoting.Activation/IConstructionCallMessage.cs
-System.Runtime.Remoting.Activation/IConstructionReturnMessage.cs
-System.Runtime.Remoting.Activation/RemoteActivator.cs
-System.Runtime.Remoting.Activation/RemoteActivationAttribute.cs
-System.Runtime.Remoting.Activation/UrlAttribute.cs
-System.Runtime.Remoting.Channels/AggregateDictionary.cs
-System.Runtime.Remoting.Channels/BaseChannelObjectWithProperties.cs
-System.Runtime.Remoting.Channels/BaseChannelSinkWithProperties.cs
-System.Runtime.Remoting.Channels/BaseChannelWithProperties.cs
-System.Runtime.Remoting.Channels/ChannelDataStore.cs
-System.Runtime.Remoting.Channels/ChannelServices.cs
-System.Runtime.Remoting.Channels/ChannelSinkStackEntry.cs
-System.Runtime.Remoting.Channels/ClientChannelSinkStack.cs
-System.Runtime.Remoting.Channels/IChannel.cs
-System.Runtime.Remoting.Channels/IChannelDataStore.cs
-System.Runtime.Remoting.Channels/IChannelReceiver.cs
-System.Runtime.Remoting.Channels/IChannelReceiverHook.cs
-System.Runtime.Remoting.Channels/IChannelSender.cs
-System.Runtime.Remoting.Channels/IChannelSinkBase.cs
-System.Runtime.Remoting.Channels/IClientChannelSink.cs
-System.Runtime.Remoting.Channels/IClientChannelSinkProvider.cs
-System.Runtime.Remoting.Channels/IClientChannelSinkStack.cs
-System.Runtime.Remoting.Channels/IClientFormatterSink.cs
-System.Runtime.Remoting.Channels/IClientFormatterSinkProvider.cs
-System.Runtime.Remoting.Channels/IClientResponseChannelSinkStack.cs
-System.Runtime.Remoting.Channels/ISecurableChannel.cs
-System.Runtime.Remoting.Channels/IServerResponseChannelSinkStack.cs
-System.Runtime.Remoting.Channels/ServerDispatchSink.cs
-System.Runtime.Remoting.Channels/ServerDispatchSinkProvider.cs
-System.Runtime.Remoting.Channels/IServerChannelSink.cs
-System.Runtime.Remoting.Channels/IServerChannelSinkProvider.cs
-System.Runtime.Remoting.Channels/IServerChannelSinkStack.cs
-System.Runtime.Remoting.Channels/IServerFormatterSinkProvider.cs
-System.Runtime.Remoting.Channels/ITransportHeaders.cs
-System.Runtime.Remoting.Channels/ServerChannelSinkStack.cs
-System.Runtime.Remoting.Channels/ServerProcessing.cs
-System.Runtime.Remoting.Channels/SinkProviderData.cs
-System.Runtime.Remoting.Channels/TransportHeaders.cs
-System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs
-System.Runtime.Remoting.Contexts/Context.cs
-System.Runtime.Remoting.Contexts/ContextAttribute.cs
-System.Runtime.Remoting.Contexts/ContextProperty.cs
-System.Runtime.Remoting.Contexts/CrossContextChannel.cs
-System.Runtime.Remoting.Contexts/CrossContextDelegate.cs
-System.Runtime.Remoting.Contexts/IContextAttribute.cs
-System.Runtime.Remoting.Contexts/IContextProperty.cs
-System.Runtime.Remoting.Contexts/IContextPropertyActivator.cs
-System.Runtime.Remoting.Contexts/IContributeClientContextSink.cs
-System.Runtime.Remoting.Contexts/IContributeDynamicSink.cs
-System.Runtime.Remoting.Contexts/IContributeEnvoySink.cs
-System.Runtime.Remoting.Contexts/IContributeObjectSink.cs
-System.Runtime.Remoting.Contexts/IContributeServerContextSink.cs
-System.Runtime.Remoting.Contexts/IDynamicMessageSink.cs
-System.Runtime.Remoting.Contexts/IDynamicProperty.cs
-System.Runtime.Remoting.Contexts/SynchronizationAttribute.cs
-System.Runtime.Remoting.Lifetime/ClientSponsor.cs
-System.Runtime.Remoting.Lifetime/ILease.cs
-System.Runtime.Remoting.Lifetime/ISponsor.cs
-System.Runtime.Remoting.Lifetime/Lease.cs
-System.Runtime.Remoting.Lifetime/LeaseManager.cs
-System.Runtime.Remoting.Lifetime/LeaseSink.cs
-System.Runtime.Remoting.Lifetime/LeaseState.cs
-System.Runtime.Remoting.Lifetime/LifetimeServices.cs
-System.Runtime.Remoting.Messaging/ArgInfo.cs
-System.Runtime.Remoting.Messaging/AsyncResult.cs
-System.Runtime.Remoting.Messaging/CallContext.cs
-System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs
-System.Runtime.Remoting.Messaging/ConstructionCall.cs
-System.Runtime.Remoting.Messaging/ConstructionCallDictionary.cs
-System.Runtime.Remoting.Messaging/ConstructionResponse.cs
-System.Runtime.Remoting.Messaging/EnvoyTerminatorSink.cs
-System.Runtime.Remoting.Messaging/Header.cs
-System.Runtime.Remoting.Messaging/HeaderHandler.cs
-System.Runtime.Remoting.Messaging/ErrorMessage.cs
-System.Runtime.Remoting.Messaging/IInternalMessage.cs
-System.Runtime.Remoting.Messaging/IMessage.cs
-System.Runtime.Remoting.Messaging/IMessageCtrl.cs
-System.Runtime.Remoting.Messaging/IMessageSink.cs
-System.Runtime.Remoting.Messaging/IMethodCallMessage.cs
-System.Runtime.Remoting.Messaging/IMethodMessage.cs
-System.Runtime.Remoting.Messaging/IMethodReturnMessage.cs
-System.Runtime.Remoting.Messaging/IRemotingFormatter.cs
-System.Runtime.Remoting.Messaging/InternalMessageWrapper.cs
-System.Runtime.Remoting.Messaging/ISerializationRootObject.cs
-System.Runtime.Remoting.Messaging/LogicalCallContext.cs
-System.Runtime.Remoting.Messaging/MessageSurrogateFilter.cs
-System.Runtime.Remoting.Messaging/MethodCall.cs
-System.Runtime.Remoting.Messaging/MethodCallMessageWrapper.cs
-System.Runtime.Remoting.Messaging/MethodResponse.cs
-System.Runtime.Remoting.Messaging/MethodCallDictionary.cs
-System.Runtime.Remoting.Messaging/MethodDictionary.cs
-System.Runtime.Remoting.Messaging/MethodReturnDictionary.cs
-System.Runtime.Remoting.Messaging/MethodReturnMessageWrapper.cs
-System.Runtime.Remoting.Messaging/MonoMethodMessage.cs
-System.Runtime.Remoting.Messaging/OneWayAttribute.cs
-System.Runtime.Remoting.Messaging/RemotingSurrogateSelector.cs
-System.Runtime.Remoting.Messaging/RemotingSurrogate.cs
-System.Runtime.Remoting.Messaging/ReturnMessage.cs
-System.Runtime.Remoting.Messaging/ServerContextTerminatorSink.cs
-System.Runtime.Remoting.Messaging/ServerObjectTerminatorSink.cs
-System.Runtime.Remoting.Messaging/StackBuilderSink.cs
-System.Runtime.Remoting.Messaging/CADMessages.cs
-System.Runtime.Remoting.Metadata/SoapAttribute.cs
-System.Runtime.Remoting.Metadata/SoapFieldAttribute.cs
-System.Runtime.Remoting.Metadata/SoapMethodAttribute.cs
-System.Runtime.Remoting.Metadata/SoapOption.cs
-System.Runtime.Remoting.Metadata/SoapParameterAttribute.cs
-System.Runtime.Remoting.Metadata/SoapTypeAttribute.cs
-System.Runtime.Remoting.Metadata/XmlFieldOrderOption.cs
-System.Runtime.Remoting.Proxies/RealProxy.cs
-System.Runtime.Remoting.Proxies/RemotingProxy.cs
-System.Runtime.Remoting.Proxies/ProxyAttribute.cs
-System.Runtime.Remoting.Services/EnterpriseServicesHelper.cs
-System.Runtime.Remoting.Services/ITrackingHandler.cs
-System.Runtime.Remoting.Services/TrackingServices.cs
-System.Runtime.Serialization/Formatter.cs
-System.Runtime.Serialization/FormatterConverter.cs
-System.Runtime.Serialization/FormatterServices.cs
-System.Runtime.Serialization/IDeserializationCallback.cs
-System.Runtime.Serialization/IFormatter.cs
-System.Runtime.Serialization/IFormatterConverter.cs
-System.Runtime.Serialization/IObjectReference.cs
-System.Runtime.Serialization/ISerializable.cs
-System.Runtime.Serialization/ISerializationSurrogate.cs
-System.Runtime.Serialization/ISurrogateSelector.cs
-System.Runtime.Serialization/ObjectIDGenerator.cs
-System.Runtime.Serialization/ObjectManager.cs
-System.Runtime.Serialization/OnDeserializedAttribute.cs
-System.Runtime.Serialization/OnDeserializingAttribute.cs
-System.Runtime.Serialization/OnSerializedAttribute.cs
-System.Runtime.Serialization/OnSerializingAttribute.cs
-System.Runtime.Serialization/OptionalFieldAttribute.cs
-System.Runtime.Serialization/SerializationBinder.cs
-System.Runtime.Serialization/SerializationCallbacks.cs
-System.Runtime.Serialization/SerializationEntry.cs
-System.Runtime.Serialization/SerializationException.cs
-System.Runtime.Serialization/SerializationInfo.cs
-System.Runtime.Serialization/SerializationInfoEnumerator.cs
-System.Runtime.Serialization/SerializationObjectManager.cs
-System.Runtime.Serialization/StreamingContext.cs
-System.Runtime.Serialization/StreamingContextStates.cs
-System.Runtime.Serialization/SurrogateSelector.cs
-System.Runtime.Serialization.Formatters/FormatterAssemblyStyle.cs
-System.Runtime.Serialization.Formatters/FormatterTopObjectStyle.cs
-System.Runtime.Serialization.Formatters/FormatterTypeStyle.cs
-System.Runtime.Serialization.Formatters/IFieldInfo.cs
-System.Runtime.Serialization.Formatters/InternalArrayTypeE.cs
-System.Runtime.Serialization.Formatters/InternalElementTypeE.cs
-System.Runtime.Serialization.Formatters/InternalMemberTypeE.cs
-System.Runtime.Serialization.Formatters/InternalMemberValueE.cs
-System.Runtime.Serialization.Formatters/InternalNameSpaceE.cs
-System.Runtime.Serialization.Formatters/InternalObjectPositionE.cs
-System.Runtime.Serialization.Formatters/InternalObjectTypeE.cs
-System.Runtime.Serialization.Formatters/InternalParseStateE.cs
-System.Runtime.Serialization.Formatters/InternalParseTypeE.cs
-System.Runtime.Serialization.Formatters/InternalPrimitiveTypeE.cs
-System.Runtime.Serialization.Formatters/InternalRM.cs
-System.Runtime.Serialization.Formatters/InternalSerializerTypeE.cs
-System.Runtime.Serialization.Formatters/InternalST.cs
-System.Runtime.Serialization.Formatters/ISoapMessage.cs
-System.Runtime.Serialization.Formatters/ServerFault.cs
-System.Runtime.Serialization.Formatters/SoapFault.cs
-System.Runtime.Serialization.Formatters/SoapMessage.cs
-System.Runtime.Serialization.Formatters/TypeFilterLevel.cs
-System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs
-System.Runtime.Serialization.Formatters.Binary/BinaryCommon.cs
-System.Runtime.Serialization.Formatters.Binary/CodeGenerator.cs
-System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs
-System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs
-System.Runtime.Serialization.Formatters.Binary/MessageFormatter.cs
-System.Runtime.Versioning/ResourceExposureAttribute.cs
-System.Runtime.Versioning/ResourceScope.cs
-System.Runtime.Versioning/VersioningHelper.cs
-System.Security/AllowPartiallyTrustedCallersAttribute.cs
-System.Security/CodeAccessPermission_2_1.cs
-System.Security/IPermission.cs
-System.Security/PermissionSet_2_1.cs
-System.Security/SecurityCriticalAttribute.cs
-System.Security/SecurityFrame.cs
-System.Security/SecurityException_2_1.cs
-System.Security/SecurityManager_2_1.cs
-System.Security/SecuritySafeCriticalAttribute.cs
-System.Security/SecurityState.cs
-System.Security/SecurityTransparentAttribute.cs
-System.Security/SuppressUnmanagedCodeSecurityAttribute.cs
-System.Security/UnverifiableCodeAttribute.cs
-System.Security/VerificationException.cs
-System.Security.Cryptography/AsymmetricAlgorithm.cs
-System.Security.Cryptography/AsymmetricKeyExchangeDeformatter.cs
-System.Security.Cryptography/AsymmetricKeyExchangeFormatter.cs
-System.Security.Cryptography/AsymmetricSignatureDeformatter.cs
-System.Security.Cryptography/AsymmetricSignatureFormatter.cs
-System.Security.Cryptography/Base64Constants.cs
-System.Security.Cryptography/CipherMode.cs
-System.Security.Cryptography/CryptoAPITransform.cs
-System.Security.Cryptography/CryptoConfig_2_1.cs
-System.Security.Cryptography/CryptographicException.cs
-System.Security.Cryptography/CryptographicUnexpectedOperationExcpetion.cs
-System.Security.Cryptography/CryptoStream.cs
-System.Security.Cryptography/CryptoStreamMode.cs
-System.Security.Cryptography/DeriveBytes.cs
-System.Security.Cryptography/DES.cs
-System.Security.Cryptography/DESCryptoServiceProvider.cs
-System.Security.Cryptography/DSA.cs
-System.Security.Cryptography/DSAParameters.cs
-System.Security.Cryptography/DSASignatureDeformatter.cs
-System.Security.Cryptography/DSASignatureFormatter.cs
-System.Security.Cryptography/FromBase64Transform.cs
-System.Security.Cryptography/HashAlgorithm.cs
-System.Security.Cryptography/HMAC.cs
-System.Security.Cryptography/HMACMD5.cs
-System.Security.Cryptography/HMACSHA1.cs
-System.Security.Cryptography/HMACSHA256.cs
-System.Security.Cryptography/ICryptoTransform.cs
-System.Security.Cryptography/KeyedHashAlgorithm.cs
-System.Security.Cryptography/KeyNumber.cs
-System.Security.Cryptography/KeySizes.cs
-System.Security.Cryptography/MaskGenerationMethod.cs
-System.Security.Cryptography/MD5.cs
-System.Security.Cryptography/MD5CryptoServiceProvider.cs
-System.Security.Cryptography/PaddingMode.cs
-System.Security.Cryptography/PKCS1MaskGenerationMethod.cs
-System.Security.Cryptography/RandomNumberGenerator.cs
-System.Security.Cryptography/RC2.cs
-System.Security.Cryptography/RC2CryptoServiceProvider.cs
-System.Security.Cryptography/Rfc2898DeriveBytes.cs
-System.Security.Cryptography/Rijndael.cs
-System.Security.Cryptography/RijndaelManaged.cs
-System.Security.Cryptography/RijndaelManagedTransform.cs
-System.Security.Cryptography/RNGCryptoServiceProvider.cs
-System.Security.Cryptography/RSA.cs
-System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.cs
-System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.cs
-System.Security.Cryptography/RSAParameters.cs
-System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatter.cs
-System.Security.Cryptography/RSAPKCS1KeyExchangeFormatter.cs
-System.Security.Cryptography/RSAPKCS1SignatureDeformatter.cs
-System.Security.Cryptography/RSAPKCS1SignatureFormatter.cs
-System.Security.Cryptography/SHA1.cs
-System.Security.Cryptography/SHA1CryptoServiceProvider.cs
-System.Security.Cryptography/SHA1Managed.cs
-System.Security.Cryptography/SHA256.cs
-System.Security.Cryptography/SHA256Managed.cs
-System.Security.Cryptography/SHAConstants.cs
-System.Security.Cryptography/SymmetricAlgorithm.cs
-System.Security.Cryptography/ToBase64Transform.cs
-System.Security.Cryptography/TripleDES.cs
-System.Security.Cryptography/TripleDESCryptoServiceProvider.cs
-System.Security.Cryptography.X509Certificates/X509Certificate.cs
-System.Security.Cryptography.X509Certificates/X509Certificate20.cs
-System.Security.Cryptography.X509Certificates/X509ContentType.cs
-System.Security.Cryptography.X509Certificates/X509KeyStorageFlags.cs
-System.Security.Permissions/CodeAccessSecurityAttribute.cs
-System.Security.Permissions/EnvironmentPermissionAccess.cs
-System.Security.Permissions/EnvironmentPermissionAttribute.cs
-System.Security.Permissions/FileIOPermissionAccess.cs
-System.Security.Permissions/FileIOPermissionAttribute.cs
-System.Security.Permissions/HostProtectionAttribute.cs
-System.Security.Permissions/HostProtectionResource.cs
-System.Security.Permissions/PermissionSetAttribute.cs
-System.Security.Permissions/PermissionState.cs
-System.Security.Permissions/ReflectionPermissionAttribute.cs
-System.Security.Permissions/ReflectionPermissionFlag.cs
-System.Security.Permissions/SecurityAction.cs
-System.Security.Permissions/SecurityAttribute.cs
-System.Security.Permissions/SecurityPermissionAttribute.cs
-System.Security.Permissions/SecurityPermissionFlag.cs
-System.Security.Permissions/StrongNamePermissionAttribute.cs
-System.Security.Permissions/StrongNamePublicKeyBlob.cs
-System.Security.Policy/Evidence_2_1.cs
-System.Security.Policy/PolicyLevel_2_1.cs
-System.Security.Principal/IIdentity.cs
-System.Security.Principal/IPrincipal.cs
-System.Text/ASCIIEncoding.cs
-System.Text/Decoder.cs
-System.Text/DecoderExceptionFallback.cs
-System.Text/DecoderExceptionFallbackBuffer.cs
-System.Text/DecoderFallback.cs
-System.Text/DecoderFallbackBuffer.cs
-System.Text/DecoderFallbackException.cs
-System.Text/DecoderReplacementFallback.cs
-System.Text/DecoderReplacementFallbackBuffer.cs
-System.Text/Encoder.cs
-System.Text/EncoderExceptionFallback.cs
-System.Text/EncoderExceptionFallbackBuffer.cs
-System.Text/EncoderFallback.cs
-System.Text/EncoderFallbackBuffer.cs
-System.Text/EncoderFallbackException.cs
-System.Text/EncoderReplacementFallback.cs
-System.Text/EncoderReplacementFallbackBuffer.cs
-System.Text/Encoding.cs
-System.Text/EncodingInfo.cs
-System.Text/StringBuilder.cs
-System.Text/SurrogateEncoder.cs
-System.Text/UnicodeEncoding.cs
-System.Text/UTF7Encoding.cs
-System.Text/UTF8Encoding.cs
-System.Text/UTF32Encoding.cs
-System.Threading/AbandonedMutexException.cs
-System.Threading/AutoResetEvent.cs
-System.Threading/ContextCallback.cs
-System.Threading/EventResetMode.cs
-System.Threading/EventWaitHandle.cs
-System.Threading/ExecutionContext.cs
-System.Threading/Interlocked.cs
-System.Threading/IOCompletionCallback.cs
-System.Threading/ManualResetEvent.cs
-System.Threading/Monitor.cs
-System.Threading/Mutex.cs
-System.Threading/NativeEventCalls.cs
-System.Threading/NativeOverlapped.cs
-System.Threading/Overlapped.cs
-System.Threading/ParameterizedThreadStart.cs
-System.Threading/RegisteredWaitHandle.cs
-System.Threading/SendOrPostCallback.cs
-System.Threading/SynchronizationContext.cs
-System.Threading/SynchronizationLockException.cs
-System.Threading/Thread.cs
-System.Threading/ThreadAbortException.cs
-System.Threading/ThreadInterruptedException.cs
-System.Threading/ThreadPool.cs
-System.Threading/ThreadStart.cs
-System.Threading/ThreadStartException.cs
-System.Threading/ThreadState.cs
-System.Threading/ThreadStateException.cs
-System.Threading/Timeout.cs
-System.Threading/Timer.cs
-System.Threading/TimerCallback.cs
-System.Threading/WaitCallback.cs
-System.Threading/WaitHandle.cs
-System.Threading/WaitOrTimerCallback.cs
-System.Collections.Generic/CollectionDebuggerView.cs
-System.Collections.Generic/Dictionary.cs
-System.Collections.Generic/ICollection.cs
-System.Collections.Generic/IEnumerable.cs
-System.Collections.Generic/IEnumerator.cs
-System.Collections.Generic/IList.cs
-System.Collections.Generic/IComparer.cs
-System.Collections.Generic/IEqualityComparer.cs
-System.Collections.Generic/IDictionary.cs
-System.Collections.Generic/KeyValuePair.cs
-System.Collections.Generic/EqualityComparer.cs
-System.Collections.Generic/KeyNotFoundException.cs
-System.Collections.Generic/List.cs
-System.Collections.ObjectModel/Collection.cs
-System.Collections.ObjectModel/KeyedCollection.cs
-System.Collections.ObjectModel/ReadOnlyCollection.cs
-System/Action.cs
-System/ArraySegment.cs
-System/Comparison.cs
-System/Converter.cs
-System/Predicate.cs
-System.Collections.Generic/Comparer.cs
-../Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
-../Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
-../Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
-../Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs
-
index 6362b22582761ba9b2f3ce06991c443e5c0ffb77..98c9c1e06c77a9a6a833adf8d51f84d91ce37ae4 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: rename the net_2_1 profile to moonlight.
+
 2009-06-18  Raja R Harinath  <harinath@hurrynot.org>
 
        * Makefile (run-test-local): Make parallel-make safe.
index 605731dd5065f4cb0a5207472cedf0a81834f89c..105862568c6489b267e1939b138fec733eb5a8a2 100644 (file)
@@ -35,7 +35,7 @@ TEST_SUPPORT_FILES = \
 # mention all targets
 all-local $(STD_TARGETS:=-local):
 
-VALID_PROFILE := $(filter net_2_0 net_2_1 net_4_0, $(PROFILE))
+VALID_PROFILE := $(filter net_2_0 moonlight net_4_0, $(PROFILE))
 ifdef VALID_PROFILE
 
 check: run-mcs-tests 
@@ -53,7 +53,7 @@ ifeq (net_4_0, $(PROFILE))
 COMPILER_NAME = dmcs
 TEST_PATTERN = 'v4'
 endif
-ifeq (net_2_1, $(PROFILE))
+ifeq (moonlight, $(PROFILE))
 COMPILER_NAME = smcs
 TEST_PATTERN = 'v2'
 LOCAL_RUNTIME_FLAGS = --security=temporary-smcs-hack
diff --git a/mcs/errors/gcs0701-3.cs b/mcs/errors/gcs0701-3.cs
deleted file mode 100644 (file)
index 4522501..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-// CS0703: `string[]' is not a valid constraint. A constraint must be an interface, a non-sealed class or a type parameter\r
-// Line: 4\r
-\r
-public class C<T>  where T : string[]\r
-{\r
-}
\ No newline at end of file
diff --git a/mcs/errors/gcs0706.cs b/mcs/errors/gcs0706.cs
new file mode 100644 (file)
index 0000000..08edb3f
--- /dev/null
@@ -0,0 +1,6 @@
+// CS0706: Invalid constraint type `string[]'\r
+// Line: 4\r
+\r
+public class C<T>  where T : string[]\r
+{\r
+}\r
index 5480e0f957cfec8b8cbbc544108bb553702a52c9..4d3ff33de2f2d8c612d9cca8398cb206333c9a74 100644 (file)
@@ -1,3 +1,11 @@
+2010-03-14  Zoltan Varga  <vargaz@gmail.com>
+
+       * ILParser.jay: Fix the float32(<long>) case in the previous change.
+
+2010-03-14  Zoltan Varga  <vargaz@gmail.com>
+
+       * ILParser.jay: Fix support for hex float literals on big-endian platforms.
+
 2009-04-20  Ankit Jain  <jankit@novell.com>
 
        Fix bug #494221.
index 32247371fefc22465ed8c5e60be600366e836ae9..b94d64121b1a36638fffc5c6fdd68b3f5c57b352 100644 (file)
@@ -3274,7 +3274,7 @@ float64                   : FLOAT64
                           {\r
                                 int i = (int) $3;\r
                                 byte[] intb = BitConverter.GetBytes (i);\r
-                                $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4);\r
+                                $$ = (double) BitConverter.ToSingle (intb, 0);\r
                           }\r
                         | K_FLOAT32 OPEN_PARENS INT64 CLOSE_PARENS\r
                           {\r
@@ -3285,12 +3285,12 @@ float64                 : FLOAT64
                        | K_FLOAT64 OPEN_PARENS INT64 CLOSE_PARENS\r
                           {\r
                                 byte[] intb = BitConverter.GetBytes ((long) $3);\r
-                               $$ = BitConverter.ToDouble (intb, BitConverter.IsLittleEndian ? 0 : 4);\r
+                               $$ = BitConverter.ToDouble (intb, 0);\r
                           }\r
                         | K_FLOAT64 OPEN_PARENS INT32 CLOSE_PARENS\r
                           {\r
                                 byte[] intb = BitConverter.GetBytes ((int) $3);\r
-                                $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4);\r
+                                $$ = (double) BitConverter.ToSingle (intb, 0);\r
                           }\r
                        ;\r
 \r
index 32230c2096a6fb84aa4b2a6f4f614af83d55a5b2..e3f2443dc421ce37f9251f5cd269195df1d99fb3 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: rename the net_2_1 profile to moonlight.
+
 2010-03-11  Marek Safar  <marek.safar@gmail.com>
 
        * statement.cs, cs-parser.jay: Use correct location for empty
index 6d496c57f5e2d2146558e4047f81b38aac7b6c78..43a2780851e2951341f0ad3643d120cb53c7de59 100644 (file)
@@ -18,7 +18,7 @@ ifeq (net_2_0, $(PROFILE))
 INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/gmcs.exe
 endif
 
-ifeq (net_2_1_bootstrap, $(PROFILE))
+ifeq (moonlight_bootstrap, $(PROFILE))
 INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/gmcs.exe
 endif
 
index 4ddeabc7ca84c6ba023a57e5bf10227816956c0e..956b930e7b379081f52a131319a4aff7329416a9 100644 (file)
@@ -19,7 +19,7 @@ USE_MCS_FLAGS :=
 # mention all targets
 all-local $(STD_TARGETS:=-local):
 
-VALID_PROFILE := $(filter net_2_0 net_2_1 net_4_0, $(PROFILE))
+VALID_PROFILE := $(filter net_2_0 moonlight net_4_0, $(PROFILE))
 ifdef VALID_PROFILE
 # casts
 bootstrap-cast.exe: gen-cast-test.cs
@@ -52,7 +52,7 @@ TEST_PATTERN = 'v4'
 LOCAL_RUNTIME_FLAGS = --verify-all
 #TOPTIONS += '-il:ver-il-dmcs.xml'
 endif
-ifeq (net_2_1, $(PROFILE))
+ifeq (moonlight, $(PROFILE))
 COMPILER_NAME = smcs
 TEST_PATTERN = 'v2'
 LOCAL_RUNTIME_FLAGS = --security=temporary-smcs-hack
diff --git a/mcs/tests/gtest-232.cs b/mcs/tests/gtest-232.cs
deleted file mode 100644 (file)
index 8b01949..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-public class H
-{
-       public static void Main(String[] args) { }
-
-       public static IEnumerable<T> Merge<T> (IEnumerator<T> xEtor)
-               where T : IComparable<T>
-       {
-               int order = xEtor.Current.CompareTo (xEtor.Current);
-               yield return xEtor.Current;
-       }
-}
index ca1f8faa1d35e207026fcc1f7c09c53049a869d5..b2139bf8546735816c3416569440203b849a96b2 100644 (file)
@@ -3,8 +3,11 @@ using System;
 
 class X
 {
-       static void Main ()
-       { }
+       static int Main ()
+       {
+               new Derived ().Method<Foo> ();
+               return 0;
+       }
 }
 
 class Foo
diff --git a/mcs/tests/gtest-473.cs b/mcs/tests/gtest-473.cs
new file mode 100644 (file)
index 0000000..d5aa66a
--- /dev/null
@@ -0,0 +1,22 @@
+class A<X>
+{
+       public virtual void Foo<T> () where T : A<T>
+       {
+       }
+}
+
+class B : A<int>
+{
+       public override void Foo<T> ()
+       {
+       }
+}
+
+class C
+{
+       public static int Main ()
+       {
+               new B ();
+               return 0;
+       }
+}
\ No newline at end of file
index 6bd016b19941a412e2b2dd0920f4a94cbc4e1022..0c24a68174def16754a0c7fe103df009f3947330 100644 (file)
@@ -16,6 +16,7 @@ public class Test<R>
                Foo foo = delegate {
                        World (u, v);
                };
+               foo ();
        }
 }
 
diff --git a/mcs/tests/gtest-iter-12.cs b/mcs/tests/gtest-iter-12.cs
new file mode 100644 (file)
index 0000000..8b01949
--- /dev/null
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+public class H
+{
+       public static void Main(String[] args) { }
+
+       public static IEnumerable<T> Merge<T> (IEnumerator<T> xEtor)
+               where T : IComparable<T>
+       {
+               int order = xEtor.Current.CompareTo (xEtor.Current);
+               yield return xEtor.Current;
+       }
+}
index 58cc9c7e589e1c5d0d216ebfa6c953ce78d7de05..1d055f5a7cb5d6ff4bc29e81585dc80ad323cf88 100644 (file)
@@ -7,6 +7,7 @@
 test-xml-027.cs
 
 gtest-230.cs
+gtest-316.cs verifier
 gtest-437.cs
 
 test-416.cs bug #504085
index 58cc9c7e589e1c5d0d216ebfa6c953ce78d7de05..9cfdc19fbd618c20cc58df0f089ec3baf3494beb 100644 (file)
@@ -7,6 +7,7 @@
 test-xml-027.cs
 
 gtest-230.cs
+gtest-316.cs verifier
 gtest-437.cs
 
 test-416.cs bug #504085
@@ -14,4 +15,3 @@ test-418.cs bug #504085
 test-682.cs bug #530861
 test-704.cs IGNORE #472845
 test-715.cs bug #504085
-test-733.cs
index 20c0857a800dccaa9de481fa02fcfa129d2eb742..1131908f089a31fa48feb00293aabea1f12f9f84 100644 (file)
@@ -7,8 +7,9 @@ public class Test
                float a = 1f / 3;
                float b = (float) Math.Acos ((float) (a * 3));
                Console.WriteLine (b);
-               if (b != 0 && b != float.NaN)
-                       return 1;
+               if (b != 0 && !float.IsNaN (b)) {
+                       throw new ApplicationException (b.ToString () + b.GetType ().ToString ());
+               }
 
                return 0;
        }
diff --git a/mcs/tests/test-743-lib.cs b/mcs/tests/test-743-lib.cs
new file mode 100644 (file)
index 0000000..5451849
--- /dev/null
@@ -0,0 +1,18 @@
+// Compiler options: -t:library
+
+public class A
+{
+       public int Prop {
+               get {
+                       return 1;
+               }
+               private set { }
+       }
+       
+       protected internal string this [int i] {
+               private get {
+                       return null;
+               }
+               set { }
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-743.cs b/mcs/tests/test-743.cs
new file mode 100644 (file)
index 0000000..9300166
--- /dev/null
@@ -0,0 +1,18 @@
+// Compiler options: -r:test-743-lib.dll
+
+using System;
+
+public class C : A
+{
+       public static void Main ()
+       {
+               new C ().Test ();
+       }
+       
+       void Test ()
+       {
+               var a = new C ();
+               Console.WriteLine (a.Prop);
+               a [5] = "2";
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-744.cs b/mcs/tests/test-744.cs
new file mode 100644 (file)
index 0000000..cd3b7fa
--- /dev/null
@@ -0,0 +1,37 @@
+class M
+{
+       sealed class Nested : C
+       {
+               protected override void Extra ()
+               {
+               }
+       }
+       
+       public static void Main ()
+       {
+               new Nested ();
+       }
+}
+
+abstract class A
+{
+       protected abstract void AMethod ();
+}
+
+abstract class B : A
+{
+       protected abstract void BMethod ();
+}
+
+abstract class C : B
+{
+       protected override void AMethod ()
+       {
+       }
+       
+       protected override void BMethod ()
+       {
+       }
+       
+       protected abstract void Extra ();
+}
diff --git a/mcs/tests/test-745.cs b/mcs/tests/test-745.cs
new file mode 100644 (file)
index 0000000..73a8c03
--- /dev/null
@@ -0,0 +1,17 @@
+using System;
+
+interface ITest
+{
+}
+
+class C : ITest
+{
+       public static void Main ()
+       {
+               ITest it = new C ();
+               it.GetType ();
+
+               IConvertible ic = 1 as IConvertible;
+               var t = ic.GetType ();
+       }
+}
index f02c01910401e3926f8e09b0c7d607373795917f..7552517219817b9d7fab02b0e39b339a692461e0 100644 (file)
       </method>
     </type>
   </test>
-  <test name="gtest-232.cs">
-    <type name="H">
-      <method name="Void .ctor()">
-        <size>7</size>
-      </method>
-      <method name="IEnumerable`1 Merge[T](IEnumerator`1)">
-        <size>30</size>
-      </method>
-      <method name="Void Main(System.String[])">
-        <size>1</size>
-      </method>
-    </type>
-    <type name="H+&lt;Merge&gt;c__Iterator0`1[T]">
-      <method name="Void .ctor()">
-        <size>7</size>
-      </method>
-      <method name="System.Object System.Collections.IEnumerator.get_Current()">
-        <size>12</size>
-      </method>
-      <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()">
-        <size>7</size>
-      </method>
-      <method name="Boolean MoveNext()">
-        <size>117</size>
-      </method>
-      <method name="Void Dispose()">
-        <size>8</size>
-      </method>
-      <method name="Void Reset()">
-        <size>6</size>
-      </method>
-      <method name="T System.Collections.Generic.IEnumerator&lt;T&gt;.get_Current()">
-        <size>7</size>
-      </method>
-      <method name="IEnumerator`1 System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator()">
-        <size>40</size>
-      </method>
-    </type>
-  </test>
   <test name="gtest-233.cs">
     <type name="Program">
       <method name="Void .ctor()">
       </method>
     </type>
   </test>
-  <test name="gtest-316.cs">
-    <type name="X">
-      <method name="Void .ctor()">
-        <size>7</size>
-      </method>
-      <method name="Void Main()">
-        <size>1</size>
-      </method>
-    </type>
-    <type name="Foo">
-      <method name="Void .ctor()">
-        <size>7</size>
-      </method>
-    </type>
-    <type name="Base">
-      <method name="Void .ctor()">
-        <size>7</size>
-      </method>
-      <method name="Void Method[R]()">
-        <size>0</size>
-      </method>
-    </type>
-    <type name="Derived">
-      <method name="Void .ctor()">
-        <size>7</size>
-      </method>
-      <method name="Void Method[S]()">
-        <size>7</size>
-      </method>
-      <method name="Void Method2[T]()">
-        <size>18</size>
-      </method>
-    </type>
-  </test>
   <test name="gtest-317.cs">
     <type name="Foo`1[K]">
       <method name="Void .ctor()">
       </method>
     </type>
   </test>
+  <test name="gtest-473.cs">
+    <type name="A`1[X]">
+      <method name="Void Foo[T]()">
+        <size>1</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="B">
+      <method name="Void Foo[T]()">
+        <size>1</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="C">
+      <method name="Int32 Main()">
+        <size>8</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-anon-1.cs">
     <type name="X">
       <method name="Void .ctor()">
         <size>1</size>
       </method>
       <method name="Void Hello[U,V](U, V)">
-        <size>41</size>
+        <size>47</size>
       </method>
     </type>
     <type name="X">
       </method>
     </type>
   </test>
+  <test name="gtest-iter-12.cs">
+    <type name="H">
+      <method name="Void Main(System.String[])">
+        <size>1</size>
+      </method>
+      <method name="IEnumerable`1 Merge[T](IEnumerator`1)">
+        <size>30</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="H+&lt;Merge&gt;c__Iterator0`1[T]">
+      <method name="T System.Collections.Generic.IEnumerator&lt;T&gt;.get_Current()">
+        <size>7</size>
+      </method>
+      <method name="System.Object System.Collections.IEnumerator.get_Current()">
+        <size>12</size>
+      </method>
+      <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()">
+        <size>7</size>
+      </method>
+      <method name="IEnumerator`1 System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator()">
+        <size>40</size>
+      </method>
+      <method name="Boolean MoveNext()">
+        <size>117</size>
+      </method>
+      <method name="Void Dispose()">
+        <size>8</size>
+      </method>
+      <method name="Void Reset()">
+        <size>6</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-lambda-01.cs">
     <type name="X">
       <method name="Int32 Main()">
       </method>
     </type>
   </test>
-  <test name="test-454.cs">
-    <type name="FooAttribute">
-      <method name="Void .ctor()">
-        <size>7</size>
-      </method>
-    </type>
-    <type name="Test">
-      <method name="Void .ctor()">
-        <size>7</size>
-      </method>
-      <method name="Int32 Main()">
-        <size>237</size>
-      </method>
-    </type>
-  </test>
   <test name="test-455.cs">
     <type name="Test">
       <method name="Void .ctor()">
   <test name="test-733.cs">
     <type name="Test">
       <method name="Int32 Main()">
-        <size>54</size>
+        <size>86</size>
       </method>
       <method name="Void .ctor()">
         <size>7</size>
       </method>
     </type>
   </test>
+  <test name="test-741.cs">
+    <type name="Test">
+      <method name="Void test()">
+        <size>18</size>
+      </method>
+      <method name="Void Main()">
+        <size>1</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-742.cs">
+    <type name="Test">
+      <method name="Test Set(C)">
+        <size>20</size>
+      </method>
+    </type>
+    <type name="C">
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Driver">
+      <method name="Int32 Main()">
+        <size>41</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-743.cs">
+    <type name="C">
+      <method name="Void Main()">
+        <size>11</size>
+      </method>
+      <method name="Void Test()">
+        <size>30</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-744.cs">
+    <type name="M">
+      <method name="Void Main()">
+        <size>7</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="M+Nested">
+      <method name="Void Extra()">
+        <size>1</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="A">
+      <method name="Void AMethod()">
+        <size>0</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="B">
+      <method name="Void BMethod()">
+        <size>0</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="C">
+      <method name="Void AMethod()">
+        <size>1</size>
+      </method>
+      <method name="Void BMethod()">
+        <size>1</size>
+      </method>
+      <method name="Void Extra()">
+        <size>0</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-75.cs">
     <type name="X">
       <method name="Void .ctor()">
       </method>
     </type>
   </test>
+  <test name="test-cls-19.cs">
+    <type name="A">
+      <method name="Void Main()">
+        <size>1</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="A+PartialClass">
+      <method name="Void Method1(Int32)">
+        <size>1</size>
+      </method>
+      <method name="Void Method2(UInt32)">
+        <size>1</size>
+      </method>
+      <method name="Void Method3(UInt32)">
+        <size>1</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-externalias-01.cs">
     <type name="Test">
       <method name="Void .ctor()">
index c30da1899780202f720c6e9cbfe83c929be451c1..6906d62759a26c7c3960b5fdef8e98e90f4227dc 100644 (file)
@@ -1,3 +1,12 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: rename the net_2_1 profile to moonlight.
+
+2010-03-15  Andrew Jorgensen  <ajorgensen@novell.com>
+
+       * Makefile: Add DIST_SUBDIRS with SUBDIRS and net_4_0_dirs so that all
+       that stuff gets dist'd
+
 2010-03-03  Rolf Bjarne Kvinge  <RKvinge@novell.com>
 
        * gensources.sh: Reverted to plain bash, cygwin/make seems to end up confused
index dd44aad6b0a9b342d008448d5ee04d7eacd8e5cf..34abc62fc540fdf9614a39c11eb2ecfd16e623d5 100644 (file)
@@ -48,18 +48,19 @@ net_2_0_dirs := \
        monodoc         \
        compiler-tester
 
-net_2_1_dirs := \
+moonlight_dirs := \
        compiler-tester
 
 basic_SUBDIRS = gacutil security
 net_2_0_bootstrap_SUBDIRS = resgen culevel
 net_2_0_SUBDIRS := $(basic_SUBDIRS) $(net_2_0_dirs)
-net_2_1_raw_SUBDIRS := $(net_2_1_dirs)
-net_2_1_SUBDIRS := $(net_2_1_dirs)
+moonlight_raw_SUBDIRS := $(moonlight_dirs)
+moonlight_SUBDIRS := $(moonlight_dirs)
 net_4_0_bootstrap_SUBDIRS = resgen culevel
 net_4_0_SUBDIRS := $(net_4_0_dirs) $(basic_SUBDIRS)
 
-SUBDIRS = $(basic_SUBDIRS) $(net_2_0_bootstrap_SUBDIRS) $(net_2_0_SUBDIRS) $(net_2_1_SUBDIRS)
+SUBDIRS = $(basic_SUBDIRS) $(net_2_0_bootstrap_SUBDIRS) $(net_2_0_SUBDIRS) $(moonlight_SUBDIRS)
+DIST_SUBDIRS = $(SUBDIRS) $(net_4_0_dirs)
 
 include ../build/rules.make
 
index ac3dd5e358dbbf6df8cdd155f87d1a8d79822000..062bc5acaa6bd6e2badb291eff5d483546c392fa 100644 (file)
@@ -5,14 +5,14 @@ include ../../build/rules.make
 PROGRAM = $(topdir)/class/lib/$(PROFILE)/compiler-tester.exe
 NO_INSTALL = yes
 
-ifeq (net_2_1, $(PROFILE))
+ifeq (moonlight, $(PROFILE))
 
 all-local: $(PROGRAM)
 clean-local:
        rm -f $(PROGRAM)
 
 $(PROGRAM): $(dir $(PROGRAM))/.stamp
-$(PROGRAM): $(topdir)/class/lib/net_2_1_raw/compiler-tester.exe
+$(PROGRAM): $(topdir)/class/lib/moonlight_raw/compiler-tester.exe
        cp $< $@
 
 dist-local: dist-default
index 5b45d75a6eb96a10c26c97209a4ca44947050974..1681e91c53dc70bdf8879b6aaeda5943eb42c7d9 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-18  Zoltan Varga  <vargaz@gmail.com>
+
+       * mkbundle.cs: Update after the mono.pc and libmono version bump.
+
 2009-05-29  Steven Munroe  <munroesj@us.ibm.com>
 
        This patch is contributed under the terms of the MIT/X11 license
index 16b17d30d3a11959cabfba53c0c575720ffddb02..41cf26fb7bcad57969681a520d89007bb3842bbd 100644 (file)
@@ -396,16 +396,16 @@ class MakeBundle {
                        if (static_link) {
                                string smonolib;
                                if (style == "osx")
-                                       smonolib = "`pkg-config --variable=libdir mono`/libmono.a ";
+                                       smonolib = "`pkg-config --variable=libdir mono-2`/libmono-2.0.a ";
                                else
-                                       smonolib = "-Wl,-Bstatic -lmono -Wl,-Bdynamic ";
-                               cmd = String.Format ("{4} -o {2} -Wall `pkg-config --cflags mono` {0} {3} " +
-                                                    "`pkg-config --libs-only-L mono` " + smonolib +
-                                                    "`pkg-config --libs-only-l mono | sed -e \"s/\\-lmono //\"` {1}",
+                                       smonolib = "-Wl,-Bstatic -lmono-2.0 -Wl,-Bdynamic ";
+                               cmd = String.Format ("{4} -o {2} -Wall `pkg-config --cflags mono-2` {0} {3} " +
+                                                    "`pkg-config --libs-only-L mono-2` " + smonolib +
+                                                    "`pkg-config --libs-only-l mono-2 | sed -e \"s/\\-lmono-2.0 //\"` {1}",
                                                     temp_c, temp_o, output, zlib, cc);
                        } else {
                                
-                               cmd = String.Format ("{4} " + debugging + " -o {2} -Wall {0} `pkg-config --cflags --libs mono` {3} {1}",
+                               cmd = String.Format ("{4} " + debugging + " -o {2} -Wall {0} `pkg-config --cflags --libs mono-2` {3} {1}",
                                                     temp_c, temp_o, output, zlib, cc);
                        }
                             
index d35967b025d5b0c1ab86eb8dbd2e87e486b45b7e..e756d354f96582e1137559c73f50cc7542b1c212 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-23     Neale Ferguson <neale@sinenomine.net>
+       
+       * s390x-codegen.h: Remove duplicate
+
 2009-06-24     Neale Ferguson <neale@sinenomine.net>
        
        * s390x-codegen.h: Add some new instructions.
index 6af46dbf2405c182b05972cd68cc0c580d9bebb5..7a2e069bfc26a6934609ac6977887cb42f8adfcd 100644 (file)
@@ -773,7 +773,6 @@ typedef struct {
 #define s390_stey(c, r, x, b, d)       S390_RXY(c, 0xed66, r, x, b, d)
 #define s390_stfpc(c, b, d)            S390_S(c, 0xb29c, b, d)
 #define s390_stg(c, r, x, b, d)                S390_RXY(c, 0xe324, r, x, b, d)
-#define s390_stg(c, r, x, b, d)                S390_RXY(c, 0xe324, r, x, b, d)
 #define s390_sth(c, r, x, b, d)                S390_RX(c, 0x40, r, x, b, d)
 #define s390_sthy(c, r, x, b, d)       S390_RXY(c, 0xe370, r, x, b, d)
 #define s390_stm(c, r1, r2, b, d)      S390_RS_1(c, 0x90, r1, r2, b, d)
index 67cd07cd67863c91f68bd4c44aff01ffa40eb620..8783e9ab7b857baf7912d9c03198c582a1bf4c94 100644 (file)
@@ -1,3 +1,25 @@
+2010-03-26  Zoltan Varga  <vargaz@gmail.com>
+
+       * sockets.c: Apply some openbsd changes from openbsd ports.
+
+2010-03-26  Zoltan Varga  <vargaz@gmail.com>
+
+       * shared.c: Disable shared supported by default, it can be enabled by setting
+       the MONO_ENABLE_SHM env variable.
+
+2009-03-22 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * threads.h: Add wapi_self_interrupt.
+
+       * wthreads.c: Add wapi_self_interrupt which puts the current
+       thread in interrupted state.
+
+       * wthreads.c (wapi_thread_clear_wait_handle): Previous handle
+       can possibly be NULL if an async interrupt cleared it.
+
+       This is safe because it is only async cleared if running inside a
+       handler block.
+
 2010-03-06 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * processes.c: made ShellExecuteEx actually work when the file name to
index c36f360b14bae1dd96d3a7603db3e6e43612e69d..bf966d202c3c01f1a37590693c7e8bb104c465d0 100644 (file)
 
 static mono_mutex_t noshm_sems[_WAPI_SHARED_SEM_COUNT];
 
-#ifdef DISABLE_SHARED_HANDLES
 gboolean _wapi_shm_disabled = TRUE;
-#else
-gboolean _wapi_shm_disabled = FALSE;
-#endif
 
 static void
 noshm_semaphores_init (void)
@@ -391,11 +387,12 @@ try_again:
 static gboolean
 check_disabled (void)
 {
-       if (_wapi_shm_disabled || g_getenv ("MONO_DISABLE_SHM")) {
-               const char* val = g_getenv ("MONO_DISABLE_SHM");
-               if (val == NULL || *val == '1' || *val == 'y' || *val == 'Y') {
-                       _wapi_shm_disabled = TRUE;
-               }
+       static gboolean env_checked;
+
+       if (!env_checked) {
+               if (g_getenv ("MONO_ENABLE_SHM"))
+                       _wapi_shm_disabled = FALSE;
+               env_checked = TRUE;
        }
 
        return _wapi_shm_disabled;
index 16dcb16892f85e5b97427f34e3ca2abdbed4b01c..8e787209be10189c79fd70f444d22821c7a3a076 100644 (file)
@@ -14,6 +14,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#ifdef HAVE_SYS_UIO_H
+#  include <sys/uio.h>
+#endif
 #ifdef HAVE_SYS_IOCTL_H
 #  include <sys/ioctl.h>
 #endif
index 700e77b55832c23a776250a8874a25183b262464..b61f26113517d6e76d9675d434545e44bafede6d 100644 (file)
@@ -74,6 +74,8 @@ void wapi_interrupt_thread (gpointer handle);
 void wapi_clear_interruption (void);
 gboolean wapi_thread_set_wait_handle (gpointer handle);
 void wapi_thread_clear_wait_handle (gpointer handle);
+void wapi_self_interrupt (void);
+
 char* wapi_current_thread_desc (void);
 
 G_END_DECLS
index 480db8cabf7004442377c07d2f4ede415eb35a12..5eef4bc3a31060c2792ba35def890830538d312d 100644 (file)
@@ -1198,11 +1198,59 @@ void wapi_interrupt_thread (gpointer thread_handle)
        _wapi_handle_unref (wait_handle);
 }
 
+/*
+ * wapi_self_interrupt:
+ *
+ *   This is not part of the WIN32 API.
+ * Set the 'interrupted' state of the calling thread if it's NULL.
+ */
+void wapi_self_interrupt (void)
+{
+       struct _WapiHandle_thread *thread;
+       gboolean ok;
+       gpointer prev_handle, wait_handle;
+       gpointer thread_handle;
+
+
+       thread_handle = OpenThread (0, 0, GetCurrentThreadId ());
+       ok = _wapi_lookup_handle (thread_handle, WAPI_HANDLE_THREAD,
+                                                         (gpointer *)&thread);
+       g_assert (ok);
+
+       while (TRUE) {
+               wait_handle = thread->wait_handle;
+
+               /*
+                * Atomically obtain the handle the thread is waiting on, and
+                * change it to a flag value.
+                */
+               prev_handle = InterlockedCompareExchangePointer (&thread->wait_handle,
+                                                                                                                INTERRUPTION_REQUESTED_HANDLE, wait_handle);
+               if (prev_handle == INTERRUPTION_REQUESTED_HANDLE)
+                       /* Already interrupted */
+                       goto cleanup;
+               /*We did not get interrupted*/
+               if (prev_handle == wait_handle)
+                       break;
+
+               /* Try again */
+       }
+
+       if (wait_handle) {
+               /* ref added by set_wait_handle */
+               _wapi_handle_unref (wait_handle);
+       }
+
+cleanup:
+       _wapi_handle_unref (thread_handle);
+}
+
 /*
  * wapi_clear_interruption:
  *
  *   This is not part of the WIN32 API. 
  * Clear the 'interrupted' state of the calling thread.
+ * This function is signal safe
  */
 void wapi_clear_interruption (void)
 {
@@ -1324,7 +1372,8 @@ void wapi_thread_clear_wait_handle (gpointer handle)
                _wapi_handle_unref (handle);
                WAIT_DEBUG (printf ("%p: state -> NORMAL.\n", GetCurrentThreadId ()););
        } else {
-               g_assert (prev_handle == INTERRUPTION_REQUESTED_HANDLE);
+               /*It can be NULL if it was asynchronously cleared*/
+               g_assert (prev_handle == INTERRUPTION_REQUESTED_HANDLE || prev_handle == NULL);
                WAIT_DEBUG (printf ("%p: finished waiting.\n", GetCurrentThreadId ()););
        }
 
index cba5effa4ee2afe9f02606fb6fe5476efbe0939c..703b1f1e03021246a4eed64e9b0bf56f476228fc 100644 (file)
@@ -1,3 +1,203 @@
+2010-03-26  Andreas Färber  <andreas.faerber@web.de>
+
+       * null-gc.c (mono_gc_invoke_with_gc_lock): Fix function name.
+
+       Code is contributed under MIT/X11 license.
+
+Fri Mar 26 11:33:17 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * object.c, threads.c, threads-types.h, threads.h: make the
+       managed thread local storage references precisely tracked.
+
+2010-03-25 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * threadpool.[ch]: reworked the threadpool:
+               -Threadpool threads use a work-stealing queue. Adding a work
+               item from a threadpool thread will queue it in the thread
+               local queue without locking (in most cases).
+               -epoll events are coalesced before being added to the IO
+               queue.
+               -Dynamically change the number of active threads
+               -Changed the global queue to be more GC friendly
+
+       * class-internals.h: add 2 new performance counters for the number of
+       threads in the threadpool and the IO threadpool.
+
+       * object-internals.h: new field in MonoAsyncResult.
+       * icall-def.h: new internal call for queueing work items.
+
+       * Makefile.am: add 2 new files.
+
+       * appdomain.c: bump up corlib version.
+
+       * mono-wsq.[ch]: an implementation of a work-stealing queue.
+
+       * mono-perfcounters-def.h:
+       * mono-perfcounters.c: added 2 new performance counters.
+
+2010-03-26  Mark Probst  <mark.probst@gmail.com>
+
+       * sgen-gc.c: More FIXME/TODO updates.
+
+2010-03-25  Mark Probst  <mark.probst@gmail.com>
+
+       * gc-internal.h, sgen-gc.c, sgen-gc.h, boehm-gc.c, null-gc.c: New
+       function mono_gc_invoke_with_gc_lock() which invokes a function
+       with the guarantee that no collection will occur during its execution.
+
+2010-03-25  Mark Probst  <mark.probst@gmail.com>
+
+       * sgen-gc.c: Update a few comments.
+
+2010-03-24 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * reflection.c: Add support for new v4 type
+       System.Reflection.MonoAssembly that is the concrete version
+       of Assembly which is abstract unver v4.
+
+2010-03-24  U-anarquia\miguel  <miguel@anarquia>
+
+       * reflection.c (mono_reflection_get_custom_attrs_info): Protect
+       code that uses System.Reflection.Emit in DISABLE_REFLECTION_EMIT.
+
+       Expose a few macros that are needed for SR but not SRE to the
+       world (previous inside the SRE ifdef)
+
+2010-03-24  Mark Probst  <mark.probst@gmail.com>
+
+       * sgen-gc.c (gc_register_current_thread): We need
+       stack_start_limit as well in the non-attribute pthread case.
+
+2010-03-23 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * threads.c: Fix windows build.
+
+2010-03-22 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * thread-types.h: Add mono_thread_resume_interruption.
+
+       * threads.c: Add mono_thread_resume_interruption, this
+       function should be called after the last protected handler
+       found at interruption time has finished.
+
+2010-03-22 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * threads.c (ves_icall_System_Threading_Thread_ResetAbort):
+       Check MonoInternalThread's ::state instead of ::abort_exc
+       since the later can be lazily created.
+
+       This is specially problematic when running a finally block
+       under AbortRequested state. ResetAbort must work, but the
+       abort_exc object has not been created because interruption
+       has not began.
+
+2010-03-22  Geoff Norton  <gnorton@novell.com>
+
+       * locales.c: Its possible for CFStringGetCStringPtr
+       to return null and not convert encodings.  Use
+       CFStringGetCString instead.
+
+Mon Mar 22 18:06:38 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * class-internals.h, class.c, object.c: introduce compressed
+       interface bitmaps (for now only under small config): this saves
+       about 600 KB of runtime memory on gmcs bootstraps or monodevelop
+       startups.
+
+Mon Mar 22 16:03:34 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * mono-debug.c: don't try to get the method header, it causes a
+       deadlock and it is not used for anything anymore.
+
+2010-03-22  Zoltan Varga  <vargaz@gmail.com>
+
+       * loader.c (mono_method_get_marshal_info): Fix the handling of dynamic methods
+       broken by the last change.
+
+2010-03-21  Andreas Färber  <andreas.faerber@web.de>
+
+       * socket-io.c: Don't depend on AF_SNA, AF_DECnet,
+       SOCK_RDM.
+       
+       Code is contributed under MIT/X11 license.
+
+2010-03-20  Sanjoy Das <sanjoy@playingwithpointers.com>
+
+       * sgen-gc.c (mono_gc_get_write_barrier): Handle non-aligned
+       nursery.
+
+       Code is contributed under MIT/X11 license.
+
+2010-03-19  Martin Baulig  <martin@ximian.com>
+
+       * mono-debug.c (MonoDebugWrapperData): Replace `cil_code' with a
+       dummy field, containing an empty string.
+       (mono_debug_add_method): Don't call mono_disasm_code() for wrappers.
+
+
+Fri Mar 19 17:26:43 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * class.c: setup_interface_offsets() refactor to not call
+       mono_class_get_implemented_interfaces () more times than needed and
+       to reduce the runtime memory requirements to be O(num_interfaces)
+       instead of O(max_interface_id).
+
+2010-03-18 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * mono-mlist.[ch]: add mono_mlist_set_next ().
+
+2010-03-16 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * domain-internals.h: Add MonoTryBlockHoleJitInfo struct and
+       associated changes to support holes in the protected range of a
+       try block.
+
+       * domain.c: Add mono_jit_info_get_try_block_hole_table_info, which
+       retrieves the holes table from a given MonoJitInfo.
+
+Tue Mar 16 13:11:15 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * object.h, object-internals.h, object.c, icall.c, gc-internal.h,
+       debug-helpers.c, cominterop.c, process.c, sgen-gc.c, socket-io.c:
+       hide the contents of the MonoString and MonoArray structs from the
+       public API. Change the accessor macros to accessors functions where
+       needed. Adjusted the array API to allow for pointer-sized lengths and
+       starting positions, so 64 bit arrays can be optionally provided in an
+       API compatible way if needed on 64 bit systems.
+
+Tue Mar 16 10:18:07 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * class-internals.h, class.c, loader.c, marshal.c, metadata.c,
+       reflection.c: the MonoMethodNormal struct is now unused, so remove it.
+
+Mon Mar 15 18:28:00 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * class-internals.h: remove the method header from MonoMethod since
+       from now on it will be transient. We have a header pointer for method
+       wrappers, since in that case we need to keep track of it. For this
+       reason, all the Reflection.Emit generated methods use MonoMethodWrapper
+       structs now. The same happens with MonoMethodInflated.
+       * class.c: reset the sre_method flag for inflated method structures:
+       this makes the code that cares look at the header in the MonoMethodInflated
+       structure.
+       * loader.c: lookup the method header in the appropriate field now that
+       it is removed from MonoMethod.
+       * metadata-internals.h: add a flag to the method header to know if it
+       can be freed inside mono_metadata_free_mh ().
+       * method-builder.c: updates after moving the header field from
+       MonoMethod to MonoMethodWrapper.
+       * reflection.c: MonoMethods generated from Reflection.Emit use
+       MonoMethodWrapper structs if they need a method header now (later take
+       advantage of this and remove all the current unsafe uses of method_aux_hash).
+       * metadata.c: make method header parsing not leak when verification
+       fails. Alloc it with g_malloc() and free it in mono_metadata_free_mh().
+       These changes save a few hundred KB of runtime memory in a mcs
+       bootstrap or a monodevelop startup.
+
+2010-03-12 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * verify.c: Improve error message.
+
 2010-03-12  Jb Evain  <jbevain@novell.com>
 
        * reflection.c (add_exported_type): populate the exported
index 7a1e5cfed45637082c99bd28ade1999782630ace..27058e49af89f17ecc8ffe8b6c8e2ee3a477c503 100644 (file)
@@ -128,6 +128,8 @@ libmonoruntime_la_SOURCES = \
        mono-perfcounters.c     \
        mono-perfcounters.h     \
        mono-perfcounters-def.h \
+       mono-wsq.c              \
+       mono-wsq.h              \
        monitor.c               \
        monitor.h               \
        normalization-tables.h  \
index d922fb71b2e485b70264ed5690e3ebbc6bac3c7a..abde1a7933f5f593b292c38c79ee8510fccf8f07 100644 (file)
@@ -73,7 +73,7 @@
  * Changes which are already detected at runtime, like the addition
  * of icalls, do not require an increment.
  */
-#define MONO_CORLIB_VERSION 89
+#define MONO_CORLIB_VERSION 90
 
 typedef struct
 {
index 4f1fd91227fd05c8333e85fb643606d21811ba16..711343f3ecc8f75a39e0b12f6c727becc2a236b4 100644 (file)
@@ -932,5 +932,11 @@ mono_gc_get_write_barrier (void)
 
 #endif
 
+void*
+mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data)
+{
+       return GC_call_with_alloc_lock (func, data);
+}
+
 #endif /* no Boehm GC */
 
index 114c8ccbc41966f9fc296db124ccebfe5f449e8f..b6e0197afdd6262635d95833356d779762c40b4a 100644 (file)
@@ -19,7 +19,6 @@ extern gboolean mono_print_vtable;
 
 typedef void     (*MonoStackWalkImpl) (MonoStackWalk func, gboolean do_il_offset, gpointer user_data);
 
-typedef struct _MonoMethodNormal MonoMethodNormal;
 typedef struct _MonoMethodWrapper MonoMethodWrapper;
 typedef struct _MonoMethodInflated MonoMethodInflated;
 typedef struct _MonoMethodPInvoke MonoMethodPInvoke;
@@ -68,13 +67,14 @@ struct _MonoMethod {
        unsigned int string_ctor:1;
        unsigned int save_lmf:1;
        unsigned int dynamic:1; /* created & destroyed during runtime */
+       unsigned int sre_method:1; /* created at runtime using Reflection.Emit */
        unsigned int is_generic:1; /* whenever this is a generic method definition */
        unsigned int is_inflated:1; /* whether we're a MonoMethodInflated */
        unsigned int skip_visibility:1; /* whenever to skip JIT visibility checks */
        unsigned int verification_success:1; /* whether this method has been verified successfully.*/
        /* TODO we MUST get rid of this field, it's an ugly hack nobody is proud of. */
        unsigned int is_mb_open : 1;            /* This is the fully open instantiation of a generic method_builder. Worse than is_tb_open, but it's temporary */
-       signed int slot : 17;
+       signed int slot : 16;
 
        /*
         * If is_generic is TRUE, the generic_container is stored in image->property_hash, 
@@ -82,13 +82,9 @@ struct _MonoMethod {
         */
 };
 
-struct _MonoMethodNormal {
+struct _MonoMethodWrapper {
        MonoMethod method;
        MonoMethodHeader *header;
-};
-
-struct _MonoMethodWrapper {
-       MonoMethodNormal method;
        void *method_data;
 };
 
@@ -370,8 +366,12 @@ struct _MonoClass {
        guint16     interface_offsets_count;
        MonoClass **interfaces_packed;
        guint16    *interface_offsets_packed;
+/* enabled only with small config for now: we might want to do it unconditionally */
+#ifdef MONO_SMALL_CONFIG
+#define COMPRESSED_INTERFACE_BITMAP 1
+#endif
        guint8     *interface_bitmap;
-       
+
        MonoClass **interfaces;
 
        union {
@@ -426,7 +426,16 @@ struct _MonoClass {
        MonoClassExt *ext;
 };
 
-#define MONO_CLASS_IMPLEMENTS_INTERFACE(k,uiid) (((uiid) <= (k)->max_interface_id) && ((k)->interface_bitmap [(uiid) >> 3] & (1 << ((uiid)&7))))
+#ifdef COMPRESSED_INTERFACE_BITMAP
+int mono_compress_bitmap (uint8_t *dest, const uint8_t *bitmap, int size) MONO_INTERNAL;
+int mono_class_interface_match (const uint8_t *bitmap, int id) MONO_INTERNAL;
+#else
+#define mono_class_interface_match(bmap,uiid) ((bmap) [(uiid) >> 3] & (1 << ((uiid)&7)))
+#endif
+
+#define MONO_CLASS_IMPLEMENTS_INTERFACE(k,uiid) (((uiid) <= (k)->max_interface_id) && mono_class_interface_match ((k)->interface_bitmap, (uiid)))
+
+
 int mono_class_interface_offset (MonoClass *klass, MonoClass *itf);
 int mono_class_interface_offset_with_variance (MonoClass *klass, MonoClass *itf, gboolean *non_exact_match) MONO_INTERNAL;
 
@@ -457,7 +466,7 @@ struct MonoVTable {
 
 #define MONO_SIZEOF_VTABLE (sizeof (MonoVTable) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
 
-#define MONO_VTABLE_IMPLEMENTS_INTERFACE(vt,uiid) (((uiid) <= (vt)->max_interface_id) && ((vt)->interface_bitmap [(uiid) >> 3] & (1 << ((uiid)&7))))
+#define MONO_VTABLE_IMPLEMENTS_INTERFACE(vt,uiid) (((uiid) <= (vt)->max_interface_id) && mono_class_interface_match ((vt)->interface_bitmap, (uiid)))
 
 /*
  * Generic instantiation data type encoding.
@@ -499,9 +508,9 @@ struct _MonoGenericContext {
 struct _MonoMethodInflated {
        union {
                MonoMethod method;
-               MonoMethodNormal normal;
                MonoMethodPInvoke pinvoke;
        } method;
+       MonoMethodHeader *header;
        MonoMethod *declaring;          /* the generic method definition. */
        MonoGenericContext context;     /* The current instantiation */
 };
@@ -781,6 +790,8 @@ typedef struct {
        /* Threadpool */
        guint64 threadpool_workitems;
        guint64 threadpool_ioworkitems;
+       guint threadpool_threads;
+       guint threadpool_iothreads;
 } MonoPerfCounters;
 
 extern MonoPerfCounters *mono_perfcounters MONO_INTERNAL;
index ff39c9a6233f75fd0fa4aa6ae843f79c8cab6966..cf74f3a278ac1f94e163a84ceda796e3070f93da 100644 (file)
@@ -964,13 +964,13 @@ mono_class_inflate_generic_method_full_checked (MonoMethod *method, MonoClass *k
        if (sig->pinvoke) {
                memcpy (&iresult->method.pinvoke, method, sizeof (MonoMethodPInvoke));
        } else {
-               memcpy (&iresult->method.normal, method, sizeof (MonoMethodNormal));
-               iresult->method.normal.header = NULL;
+               memcpy (&iresult->method.method, method, sizeof (MonoMethod));
        }
 
        result = (MonoMethod *) iresult;
        result->is_inflated = TRUE;
        result->is_generic = FALSE;
+       result->sre_method = FALSE;
        result->signature = NULL;
        result->is_mb_open = is_mb_open;
 
@@ -2468,8 +2468,20 @@ print_implemented_interfaces (MonoClass *klass) {
                        printf ("(%d,F)", i);
        printf ("\n");
        printf ("Dump interface flags:");
+#ifdef COMPRESSED_INTERFACE_BITMAP
+       {
+               const uint8_t* p = klass->interface_bitmap;
+               i = klass->max_interface_id;
+               while (i > 0) {
+                       printf (" %d x 00 %02X", p [0], p [1]);
+                       i -= p [0] * 8;
+                       i -= 8;
+               }
+       }
+#else
        for (i = 0; i < ((((klass->max_interface_id + 1) >> 3)) + (((klass->max_interface_id + 1) & 7)? 1 :0)); i++)
                printf (" %02X", klass->interface_bitmap [i]);
+#endif
        printf ("\n");
        while (klass != NULL) {
                printf ("[LEVEL %d] Implemented interfaces by class %s:\n", ancestor_level, klass->name);
@@ -2782,6 +2794,170 @@ count_virtual_methods (MonoClass *class)
        return count;
 }
 
+static int
+find_interface (int num_ifaces, MonoClass **interfaces_full, MonoClass *ic)
+{
+       int m, l = 0;
+       if (!num_ifaces)
+               return -1;
+       while (1) {
+               if (l > num_ifaces)
+                       return -1;
+               m = (l + num_ifaces) / 2;
+               if (interfaces_full [m] == ic)
+                       return m;
+               if (l == num_ifaces)
+                       return -1;
+               if (!interfaces_full [m] || interfaces_full [m]->interface_id > ic->interface_id) {
+                       num_ifaces = m - 1;
+               } else {
+                       l =  m + 1;
+               }
+       }
+}
+
+static int
+find_interface_offset (int num_ifaces, MonoClass **interfaces_full, int *interface_offsets_full, MonoClass *ic)
+{
+       int i = find_interface (num_ifaces, interfaces_full, ic);
+       if (ic >= 0)
+               return interface_offsets_full [i];
+       return -1;
+}
+
+static mono_bool
+set_interface_and_offset (int num_ifaces, MonoClass **interfaces_full, int *interface_offsets_full, MonoClass *ic, int offset, mono_bool force_set)
+{
+       int i = find_interface (num_ifaces, interfaces_full, ic);
+       if (i >= 0) {
+               if (!force_set)
+                       return TRUE;
+               interface_offsets_full [i] = offset;
+               return FALSE;
+       }
+       for (i = 0; i < num_ifaces; ++i) {
+               if (interfaces_full [i]) {
+                       int end;
+                       if (interfaces_full [i]->interface_id < ic->interface_id)
+                               continue;
+                       end = i + 1;
+                       while (end < num_ifaces && interfaces_full [end]) end++;
+                       memmove (interfaces_full + i + 1, interfaces_full + i, sizeof (MonoClass*) * (end - i));
+                       memmove (interface_offsets_full + i + 1, interface_offsets_full + i, sizeof (int) * (end - i));
+               }
+               interfaces_full [i] = ic;
+               interface_offsets_full [i] = offset;
+               break;
+       }
+       return FALSE;
+}
+
+#ifdef COMPRESSED_INTERFACE_BITMAP
+
+/*
+ * Compressed interface bitmap design.
+ *
+ * Interface bitmaps take a large amount of memory, because their size is
+ * linear with the maximum interface id assigned in the process (each interface
+ * is assigned a unique id as it is loaded). The number of interface classes
+ * is high because of the many implicit interfaces implemented by arrays (we'll
+ * need to lazy-load them in the future).
+ * Most classes implement a very small number of interfaces, so the bitmap is
+ * sparse. This bitmap needs to be checked by interface casts, so access to the
+ * needed bit must be fast and doable with few jit instructions.
+ *
+ * The current compression format is as follows:
+ * *) it is a sequence of one or more two-byte elements
+ * *) the first byte in the element is the count of empty bitmap bytes
+ * at the current bitmap position
+ * *) the second byte in the element is an actual bitmap byte at the current
+ * bitmap position
+ *
+ * As an example, the following compressed bitmap bytes:
+ *     0x07 0x01 0x00 0x7
+ * correspond to the following bitmap:
+ *     0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x07
+ *
+ * Each two-byte element can represent up to 2048 bitmap bits, but as few as a single
+ * bitmap byte for non-sparse sequences. In practice the interface bitmaps created
+ * during a gmcs bootstrap are reduced to less tha 5% of the original size.
+ */
+
+/**
+ * mono_compress_bitmap:
+ * @dest: destination buffer
+ * @bitmap: bitmap buffer
+ * @size: size of @bitmap in bytes
+ *
+ * This is a mono internal function.
+ * The @bitmap data is compressed into a format that is small but
+ * still searchable in few instructions by the JIT and runtime.
+ * The compressed data is stored in the buffer pointed to by the
+ * @dest array. Passing a #NULL value for @dest allows to just compute
+ * the size of the buffer.
+ * This compression algorithm assumes the bits set in the bitmap are
+ * few and far between, like in interface bitmaps.
+ * Returns: the size of the compressed bitmap in bytes.
+ */
+int
+mono_compress_bitmap (uint8_t *dest, const uint8_t *bitmap, int size)
+{
+       int numz = 0;
+       int res = 0;
+       const uint8_t *end = bitmap + size;
+       while (bitmap < end) {
+               if (*bitmap || numz == 255) {
+                       if (dest) {
+                               *dest++ = numz;
+                               *dest++ = *bitmap;
+                       }
+                       res += 2;
+                       numz = 0;
+                       bitmap++;
+                       continue;
+               }
+               bitmap++;
+               numz++;
+       }
+       if (numz) {
+               res += 2;
+               if (dest) {
+                       *dest++ = numz;
+                       *dest++ = 0;
+               }
+       }
+       return res;
+}
+
+/**
+ * mono_class_interface_match:
+ * @bitmap: a compressed bitmap buffer
+ * @id: the index to check in the bitmap
+ *
+ * This is a mono internal function.
+ * Checks if a bit is set in a compressed interface bitmap. @id must
+ * be already checked for being smaller than the maximum id encoded in the
+ * bitmap.
+ *
+ * Returns: a non-zero value if bit @id is set in the bitmap @bitmap,
+ * #FALSE otherwise.
+ */
+int
+mono_class_interface_match (const uint8_t *bitmap, int id)
+{
+       while (TRUE) {
+               id -= bitmap [0] * 8;
+               if (id < 8) {
+                       if (id < 0)
+                               return 0;
+                       return bitmap [1] & (1 << id);
+               }
+               bitmap += 2;
+               id -= 8;
+       }
+}
+#endif
+
 /*
  * LOCKING: this is supposed to be called with the loader lock held.
  * Return -1 on failure and set exception_type
@@ -2791,15 +2967,17 @@ setup_interface_offsets (MonoClass *class, int cur_slot)
 {
        MonoError error;
        MonoClass *k, *ic;
-       int i, max_iid;
+       int i, j, max_iid, num_ifaces;
        MonoClass **interfaces_full = NULL;
        int *interface_offsets_full = NULL;
        GPtrArray *ifaces;
+       GPtrArray **ifaces_array = NULL;
        int interface_offsets_count;
        MonoClass **array_interfaces = NULL;
        int num_array_interfaces;
        int is_enumerator = FALSE;
 
+       mono_class_setup_supertypes (class);
        /* 
         * get the implicit generic interfaces for either the arrays or for System.Array/InternalEnumerator<T>
         * implicit interfaces have the property that they are assigned the same slot in the
@@ -2809,7 +2987,11 @@ setup_interface_offsets (MonoClass *class, int cur_slot)
 
        /* compute maximum number of slots and maximum interface id */
        max_iid = 0;
-       for (k = class; k ; k = k->parent) {
+       num_ifaces = num_array_interfaces; /* this can include duplicated ones */
+       ifaces_array = g_new0 (GPtrArray *, class->idepth);
+       for (j = 0; j < class->idepth; j++) {
+               k = class->supertypes [j];
+               num_ifaces += k->interface_count;
                for (i = 0; i < k->interface_count; i++) {
                        ic = k->interfaces [i];
 
@@ -2825,17 +3007,20 @@ setup_interface_offsets (MonoClass *class, int cur_slot)
                        mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error getting the interfaces of %s due to %s", name, mono_error_get_message (&error)));
                        g_free (name);
                        mono_error_cleanup (&error);
-                       goto fail;
+                       cur_slot = -1;
+                       goto end;
                }
                if (ifaces) {
+                       num_ifaces += ifaces->len;
                        for (i = 0; i < ifaces->len; ++i) {
                                ic = g_ptr_array_index (ifaces, i);
                                if (max_iid < ic->interface_id)
                                        max_iid = ic->interface_id;
                        }
-                       g_ptr_array_free (ifaces, TRUE);
+                       ifaces_array [j] = ifaces;
                }
        }
+
        for (i = 0; i < num_array_interfaces; ++i) {
                ic = array_interfaces [i];
                mono_class_init (ic);
@@ -2844,22 +3029,23 @@ setup_interface_offsets (MonoClass *class, int cur_slot)
        }
 
        if (MONO_CLASS_IS_INTERFACE (class)) {
+               num_ifaces++;
                if (max_iid < class->interface_id)
                        max_iid = class->interface_id;
        }
        class->max_interface_id = max_iid;
        /* compute vtable offset for interfaces */
-       interfaces_full = g_malloc (sizeof (MonoClass*) * (max_iid + 1));
-       interface_offsets_full = g_malloc (sizeof (int) * (max_iid + 1));
+       interfaces_full = g_malloc0 (sizeof (MonoClass*) * num_ifaces);
+       interface_offsets_full = g_malloc (sizeof (int) * num_ifaces);
 
-       for (i = 0; i <= max_iid; i++) {
-               interfaces_full [i] = NULL;
+       for (i = 0; i < num_ifaces; i++) {
                interface_offsets_full [i] = -1;
        }
 
-       for (k = class->parent; k ; k = k->parent) {
-               ifaces = mono_class_get_implemented_interfaces (k, &error);
-               g_assert (mono_error_ok (&error));/*FIXME we perform the same thing above, so not failing there but here is VERY wrong.*/
+       /* skip the current class */
+       for (j = 0; j < class->idepth - 1; j++) {
+               k = class->supertypes [j];
+               ifaces = ifaces_array [j];
 
                if (ifaces) {
                        for (i = 0; i < ifaces->len; ++i) {
@@ -2869,56 +3055,43 @@ setup_interface_offsets (MonoClass *class, int cur_slot)
                                /*Force the sharing of interface offsets between parent and subtypes.*/
                                io = mono_class_interface_offset (k, ic);
                                g_assert (io >= 0);
-                               interfaces_full [ic->interface_id] = ic;
-                               interface_offsets_full [ic->interface_id] = io;
+                               set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, ic, io, TRUE);
                        }
-                       g_ptr_array_free (ifaces, TRUE);
                }
        }
 
-
-       ifaces = mono_class_get_implemented_interfaces (class, &error);
-       if (!mono_error_ok (&error)) {
-               char *name = mono_type_get_full_name (class);
-               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error getting the interfaces of %s due to %s", name, mono_error_get_message (&error)));
-               g_free (name);
-               mono_error_cleanup (&error);
-               goto fail;
-       } else if (ifaces) {
+       g_assert (class == class->supertypes [class->idepth - 1]);
+       ifaces = ifaces_array [class->idepth - 1];
+       if (ifaces) {
                for (i = 0; i < ifaces->len; ++i) {
                        int count;
                        ic = g_ptr_array_index (ifaces, i);
-                       if (interfaces_full [ic->interface_id] != NULL)
+                       if (set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, ic, cur_slot, FALSE))
                                continue;
-                       interfaces_full [ic->interface_id] = ic;
-                       interface_offsets_full [ic->interface_id] = cur_slot;
                        count = count_virtual_methods (ic);
                        if (count == -1) {
                                char *name = mono_type_get_full_name (ic);
                                mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error calculating interface offset of %s", name));
                                g_free (name);
-                               goto fail;
+                               cur_slot = -1;
+                               goto end;
                        }
                        cur_slot += count;
                }
-               g_ptr_array_free (ifaces, TRUE);
        }
 
-       if (MONO_CLASS_IS_INTERFACE (class)) {
-               interfaces_full [class->interface_id] = class;
-               interface_offsets_full [class->interface_id] = cur_slot;
-       }
+       if (MONO_CLASS_IS_INTERFACE (class))
+               set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, class, cur_slot, TRUE);
 
        if (num_array_interfaces) {
                if (is_enumerator) {
-                       int ienumerator_offset;
                        int ienumerator_idx = find_array_interface (class, "IEnumerator`1");
-                       ienumerator_offset = interface_offsets_full [class->interfaces [ienumerator_idx]->interface_id];
+                       int ienumerator_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, class->interfaces [ienumerator_idx]);
+                       g_assert (ienumerator_offset >= 0);
                        for (i = 0; i < num_array_interfaces; ++i) {
                                ic = array_interfaces [i];
-                               interfaces_full [ic->interface_id] = ic;
                                if (strcmp (ic->name, "IEnumerator`1") == 0)
-                                       interface_offsets_full [ic->interface_id] = ienumerator_offset;
+                                       set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, ic, ienumerator_offset, TRUE);
                                else
                                        g_assert_not_reached ();
                                /*g_print ("type %s has %s offset at %d (%s)\n", class->name, ic->name, interface_offsets_full [ic->interface_id], class->interfaces [0]->name);*/
@@ -2926,29 +3099,31 @@ setup_interface_offsets (MonoClass *class, int cur_slot)
                } else {
                        int ilist_offset, icollection_offset, ienumerable_offset;
                        int ilist_iface_idx = find_array_interface (class, "IList`1");
-                       int icollection_iface_idx = find_array_interface (class->interfaces [ilist_iface_idx], "ICollection`1");
-                       int ienumerable_iface_idx = find_array_interface (class->interfaces [ilist_iface_idx], "IEnumerable`1");
-                       ilist_offset = interface_offsets_full [class->interfaces [ilist_iface_idx]->interface_id];
-                       icollection_offset = interface_offsets_full [class->interfaces [ilist_iface_idx]->interfaces [icollection_iface_idx]->interface_id];
-                       ienumerable_offset = interface_offsets_full [class->interfaces [ilist_iface_idx]->interfaces [ienumerable_iface_idx]->interface_id];
+                       MonoClass* ilist_class = class->interfaces [ilist_iface_idx];
+                       int icollection_iface_idx = find_array_interface (ilist_class, "ICollection`1");
+                       int ienumerable_iface_idx = find_array_interface (ilist_class, "IEnumerable`1");
+                       ilist_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, class->interfaces [ilist_iface_idx]);
+                       icollection_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, ilist_class->interfaces [icollection_iface_idx]);
+                       ienumerable_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, ilist_class->interfaces [ienumerable_iface_idx]);
                        g_assert (ilist_offset >= 0 && icollection_offset >= 0 && ienumerable_offset >= 0);
                        for (i = 0; i < num_array_interfaces; ++i) {
+                               int offset;
                                ic = array_interfaces [i];
-                               interfaces_full [ic->interface_id] = ic;
                                if (ic->generic_class->container_class == mono_defaults.generic_ilist_class)
-                                       interface_offsets_full [ic->interface_id] = ilist_offset;
+                                       offset = ilist_offset;
                                else if (strcmp (ic->name, "ICollection`1") == 0)
-                                       interface_offsets_full [ic->interface_id] = icollection_offset;
+                                       offset = icollection_offset;
                                else if (strcmp (ic->name, "IEnumerable`1") == 0)
-                                       interface_offsets_full [ic->interface_id] = ienumerable_offset;
+                                       offset = ienumerable_offset;
                                else
                                        g_assert_not_reached ();
-                               /*g_print ("type %s has %s offset at %d (%s)\n", class->name, ic->name, interface_offsets_full [ic->interface_id], class->interfaces [0]->name);*/
+                               set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, ic, offset, TRUE);
+                               /*g_print ("type %s has %s offset at %d (%s)\n", class->name, ic->name, offset, class->interfaces [0]->name);*/
                        }
                }
        }
 
-       for (interface_offsets_count = 0, i = 0; i <= max_iid; i++) {
+       for (interface_offsets_count = 0, i = 0; i < num_ifaces; i++) {
                if (interface_offsets_full [i] != -1) {
                        interface_offsets_count ++;
                }
@@ -2961,35 +3136,50 @@ setup_interface_offsets (MonoClass *class, int cur_slot)
        if (class->interfaces_packed) {
                g_assert (class->interface_offsets_count == interface_offsets_count);
        } else {
+               uint8_t *bitmap;
+               int bsize;
                class->interface_offsets_count = interface_offsets_count;
                class->interfaces_packed = mono_image_alloc (class->image, sizeof (MonoClass*) * interface_offsets_count);
                class->interface_offsets_packed = mono_image_alloc (class->image, sizeof (guint16) * interface_offsets_count);
-               class->interface_bitmap = mono_image_alloc0 (class->image, (sizeof (guint8) * ((max_iid + 1) >> 3)) + (((max_iid + 1) & 7)? 1 :0));
-               for (interface_offsets_count = 0, i = 0; i <= max_iid; i++) {
-                       if (interface_offsets_full [i] != -1) {
-                               class->interface_bitmap [i >> 3] |= (1 << (i & 7));
-                               class->interfaces_packed [interface_offsets_count] = interfaces_full [i];
-                               class->interface_offsets_packed [interface_offsets_count] = interface_offsets_full [i];
-                               /*if (num_array_interfaces)
-                                 g_print ("type %s has %s offset at %d\n", mono_type_get_name_full (&class->byval_arg, 0), mono_type_get_name_full (&interfaces_full [i]->byval_arg, 0), interface_offsets_full [i]);*/
-                               interface_offsets_count ++;
-                       }
-               }
+               bsize = (sizeof (guint8) * ((max_iid + 1) >> 3)) + (((max_iid + 1) & 7)? 1 :0);
+#ifdef COMPRESSED_INTERFACE_BITMAP
+               bitmap = g_malloc0 (bsize);
+#else
+               bitmap = mono_image_alloc0 (class->image, bsize);
+#endif
+               for (i = 0; i < interface_offsets_count; i++) {
+                       int id = interfaces_full [i]->interface_id;
+                       bitmap [id >> 3] |= (1 << (id & 7));
+                       class->interfaces_packed [i] = interfaces_full [i];
+                       class->interface_offsets_packed [i] = interface_offsets_full [i];
+                       /*if (num_array_interfaces)
+                         g_print ("type %s has %s offset at %d\n", mono_type_get_name_full (&class->byval_arg, 0), mono_type_get_name_full (&interfaces_full [i]->byval_arg, 0), interface_offsets_full [i]);*/
+               }
+#ifdef COMPRESSED_INTERFACE_BITMAP
+               i = mono_compress_bitmap (NULL, bitmap, bsize);
+               class->interface_bitmap = mono_image_alloc0 (class->image, i);
+               mono_compress_bitmap (class->interface_bitmap, bitmap, bsize);
+               g_free (bitmap);
+#else
+               class->interface_bitmap = bitmap;
+#endif
        }
-       
+
+end:
        g_free (interfaces_full);
        g_free (interface_offsets_full);
        g_free (array_interfaces);
+       for (i = 0; i < class->idepth; i++) {
+               ifaces = ifaces_array [i];
+               if (ifaces)
+                       g_ptr_array_free (ifaces, TRUE);
+       }
+       g_free (ifaces_array);
        
        //printf ("JUST DONE: ");
        //print_implemented_interfaces (class);
  
        return cur_slot;
-fail:
-       g_free (interfaces_full);
-       g_free (interface_offsets_full);
-       g_free (array_interfaces);
-       return -1;
 }
 
 /*
index e1a2fe3e2acb6155e12da48f60d72a15a88d6a4a..6d9fe24c3c1ddb829b7cc7dbf74e1329b46cfdab 100644 (file)
@@ -358,7 +358,7 @@ cominterop_get_com_slot_for_method (MonoMethod* method)
 
 
 static void
-cominterop_mono_string_to_guid (const MonoString* string, guint8 *guid);
+cominterop_mono_string_to_guid (MonoString* string, guint8 *guid);
 
 static gboolean
 cominterop_class_guid (MonoClass* klass, guint8* guid)
@@ -2241,7 +2241,7 @@ cominterop_get_managed_wrapper_adjusted (MonoMethod *method)
  * to a 16 byte Microsoft GUID.
  */
 static void
-cominterop_mono_string_to_guid (const MonoString* string, guint8 *guid) {
+cominterop_mono_string_to_guid (MonoString* string, guint8 *guid) {
        gunichar2 * chars = mono_string_chars (string);
        int i = 0;
        static guint8 indexes[16] = {7, 5, 3, 1, 12, 10, 17, 15, 20, 22, 25, 27, 29, 31, 33, 35};
@@ -2946,8 +2946,8 @@ static gboolean
 mono_marshal_safearray_begin (gpointer safearray, MonoArray **result, gpointer *indices, gpointer empty, gpointer parameter, gboolean allocateNewArray)
 {
        int dim;
-       mono_array_size_t *sizes;
-       mono_array_size_t *bounds;
+       uintptr_t *sizes;
+       intptr_t *bounds;
        MonoClass *aklass;
        int i;
        gboolean bounded = FALSE;
@@ -2973,8 +2973,8 @@ mono_marshal_safearray_begin (gpointer safearray, MonoArray **result, gpointer *
 
                        *indices = g_malloc (dim * sizeof(int));
 
-                       sizes = alloca (dim * sizeof(mono_array_size_t));
-                       bounds = alloca (dim * sizeof(mono_array_size_t));
+                       sizes = alloca (dim * sizeof(uintptr_t));
+                       bounds = alloca (dim * sizeof(intptr_t));
 
                        for (i=0; i<dim; ++i) {
                                glong lbound, ubound;
index 961c80830d690f1bd7d63a837e218c4bce0cad52..ee61167991ac8214af79fef7bb66679068204adf 100644 (file)
@@ -14,166 +14,166 @@ static const DateTimeFormatEntry datetime_format_entries [] = {
        {853, 876, 888, 376, 370, 447, 457, 465, 468, {897, 906, 914, 922, 931, 938, 948}, {957, 961, 965, 969, 973, 977, 981}, {985, 991, 998, 1004, 1010, 1015, 1020, 1027, 1033, 1042, 1050, 1059, 343}, {1068, 1073, 998, 1078, 1010, 1015, 1083, 1088, 1092, 1097, 1102, 1107, 343}, 0, 0, 344, 346, {348,888},{357,876},{370},{376}},
        {1112, 357, 348, 376, 370, 1136, 1146, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
        {1356, 1379, 1392, 1399, 1409, 447, 1414, 1422, 1427, {1432, 1440, 1450, 1458, 1466, 1475, 1482}, {1489, 1492, 1495, 1499, 1502, 1506, 1510}, {1513, 1519, 1525, 1533, 1539, 1547, 1555, 1565, 1571, 1579, 1587, 1596, 343}, {1605, 1607, 1610, 1614, 1617, 1619, 1622, 1626, 1631, 1634, 1636, 1639, 343}, 0, 1, 344, 346, {348,1392},{357,1379},{370,1409},{376,1399}},
-       {1643, 1664, 1676, 438, 370, 447, 457, 465, 468, {1687, 1695, 1702, 1710, 1717, 1725, 1732}, {1740, 1745, 1749, 1753, 1757, 1761, 1765}, {1770, 1777, 1785, 1791, 1797, 1801, 1806, 1811, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 1862, 1866, 1797, 1870, 1874, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,1898,1676},{357,1664},{370},{376,438}},
-       {1907, 1379, 1929, 438, 370, 447, 1414, 1940, 1946, {1953, 1961, 1968, 1977, 1986, 1997, 2005}, {2013, 2016, 2019, 2022, 2025, 2028, 2031}, {2034, 2041, 2049, 2055, 2061, 2065, 2070, 2075, 2082, 2092, 2100, 2109, 343}, {2118, 2122, 2126, 2130, 2061, 2134, 2138, 2142, 2146, 2150, 2154, 2158, 343}, 0, 1, 344, 346, {348,844,1929},{357,1379},{370},{376,438}},
-       {2162, 409, 37, 2186, 56, 447, 457, 2197, 2202, {2207, 2222, 2237, 2248, 2263, 2276, 2295}, {2310, 2317, 2324, 2331, 2338, 2345, 2352}, {2359, 2380, 2403, 2418, 2435, 2446, 2461, 2476, 2495, 2518, 2537, 2556, 343}, {2577, 2584, 2591, 2598, 2605, 2612, 2621, 2630, 2637, 2644, 2651, 2658, 343}, 0, 1, 344, 346, {348,2665,37},{357,409},{370,56},{376,2676,2186}},
-       {2688, 2719, 2739, 2186, 2746, 447, 2754, 465, 468, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 0, 344, 346, {348,2739},{2719,2719,2912,2926,2946},{2746,2746,2961,1409,370},{2186,2186,2970,2982,438}},
-       {2990, 3024, 3046, 2970, 370, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046},{357,3024},{370},{376,2970}},
-       {3272, 3297, 3314, 2982, 370, 3323, 3336, 465, 468, {3348, 3358, 3368, 3376, 3388, 3396, 3406}, {3415, 3418, 3421, 3424, 3427, 3430, 3433}, {3436, 3445, 3454, 3464, 3473, 3482, 3491, 3501, 3508, 3516, 3524, 3534, 343}, {3543, 3549, 3555, 3562, 3568, 3574, 3580, 3587, 3591, 3596, 3601, 3608, 343}, 0, 1, 344, 346, {348,3314},{357,3297},{370},{376,2982}},
-       {3614, 3640, 888, 438, 370, 447, 74, 465, 468, {3657, 3666, 3672, 3678, 3687, 3693, 3702}, {3709, 3714, 3719, 3724, 3729, 3734, 3739}, {3744, 3752, 3761, 3766, 3772, 3776, 3781, 3789, 3795, 3805, 1050, 3813, 343}, {3823, 3829, 3761, 3836, 3772, 3776, 3841, 3789, 3847, 1097, 1102, 3853, 343}, 0, 0, 344, 346, {888,3859,3264},{357,876,3640},{370},{376,438}},
-       {3869, 876, 2665, 438, 370, 447, 74, 465, 468, {3890, 3908, 3922, 3940, 3958, 3976, 3992}, {3999, 4002, 4005, 4008, 4011, 4014, 4017}, {4020, 4031, 4044, 4051, 4062, 4069, 4078, 4087, 4100, 4113, 4128, 4141, 343}, {4152, 4159, 4044, 4166, 4062, 4173, 4180, 4187, 4194, 4201, 4208, 4215, 343}, 0, 0, 344, 346, {348,888,2665},{357,876},{370},{376,438}},
-       {4222, 4244, 4258, 2982, 1409, 4272, 4283, 4291, 4294, {4297, 4307, 4315, 4320, 4327, 4340, 4348}, {1617, 4356, 4358, 4360, 4364, 4367, 4369}, {4373, 4381, 4390, 4399, 4408, 4415, 4423, 4431, 4441, 4452, 1836, 1845, 343}, {4461, 4466, 4472, 4479, 4485, 4491, 4497, 4503, 4508, 4515, 1102, 4520, 343}, 0, 1, 344, 346, {348,4525,4258},{357,4244},{370,1409},{376,1399,2982}},
-       {1907, 1379, 3314, 438, 370, 447, 1414, 465, 468, {4537, 4548, 4559, 4573, 4587, 4599, 4611}, {4623, 4627, 4632, 4637, 4642, 4646, 4651}, {4655, 4663, 3761, 4672, 4679, 4684, 4691, 4698, 1818, 4452, 4706, 4716, 343}, {1854, 1858, 1862, 1866, 4679, 4725, 4730, 4735, 1882, 1886, 4741, 4746, 343}, 0, 0, 344, 346, {348,3314},{357,1379},{370},{376,438}},
-       {4750, 409, 888, 376, 370, 447, 74, 4774, 4777, {4780, 4789, 4797, 4806, 4817, 4826, 4835}, {3139, 3143, 1862, 4842, 4846, 4850, 4854}, {4858, 4866, 3179, 4875, 4882, 4889, 4896, 3202, 4903, 4913, 1050, 4921, 343}, {4930, 1858, 1862, 1866, 4934, 4938, 4942, 3252, 4946, 4950, 1890, 3260, 343}, 0, 1, 344, 346, {348,888},{357,409},{370},{376}},
-       {4954, 4984, 5006, 2982, 1409, 5017, 5033, 5046, 5053, {5060, 5070, 5080, 5090, 5100, 5110, 5120}, {1238, 5130, 5134, 5138, 5142, 5146, 5150}, {5154, 5159, 5164, 5169, 5174, 5179, 5184, 5189, 5194, 5199, 5205, 5211, 343}, {5217, 5219, 5221, 5223, 5225, 5227, 5229, 5231, 5233, 5235, 5238, 5241, 343}, 0, 0, 344, 346, {5006,5006,348,5244,5251,5260,5279,5296},{4984,4984,5315,5339,5366},{1409,1409,370,5395,5403},{2982,438,5412,5423}},
-       {5435, 5488, 5515, 5524, 5550, 5568, 5585, 5599, 5606, {5613, 5623, 5633, 5643, 5653, 5663, 5673}, {5683, 5687, 5691, 5695, 5699, 5703, 5707}, {5711, 5716, 5721, 5726, 5731, 5736, 5741, 5746, 5751, 5756, 5762, 5768, 343}, {5711, 5716, 5721, 5726, 5731, 5736, 5741, 5746, 5751, 5756, 5762, 5768, 343}, 0, 0, 344, 346, {348,5515},{357,5488},{370,5550},{376,5524}},
-       {5774, 876, 5796, 1399, 1409, 447, 74, 465, 468, {5803, 5810, 5818, 5826, 5835, 5845, 5853}, {5862, 3418, 5865, 5868, 5871, 5874, 5877}, {5880, 5888, 5897, 1791, 5903, 1801, 1806, 5907, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 5916, 1866, 5903, 1870, 1874, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,5796},{357,876},{370,1409},{376,1399}},
-       {5920, 1379, 844, 5944, 5955, 447, 1414, 465, 468, {1687, 1695, 1702, 1710, 1717, 1725, 1732}, {5961, 3418, 3421, 5965, 3427, 5968, 5971}, {1770, 1777, 3761, 1791, 3772, 1801, 1806, 1811, 1818, 1828, 1836, 4716, 343}, {1854, 1858, 1862, 1866, 3772, 1870, 1874, 1878, 1882, 1886, 1890, 4746, 343}, 0, 1, 344, 346, {348,844},{357,1379},{370,5955},{376,5944}},
-       {5975, 876, 5996, 438, 370, 447, 74, 465, 468, {6007, 6017, 6031, 6038, 6045, 6054, 1482}, {6062, 6064, 6067, 6070, 6074, 6077, 2013}, {6080, 6089, 6094, 6101, 1797, 6111, 6120, 6127, 6137, 6147, 1587, 6160, 343}, {6170, 6174, 1862, 6178, 1797, 6182, 6186, 6190, 6194, 6198, 6203, 6207, 343}, 0, 1, 344, 346, {348,5515,5996},{357,876},{370},{376,438}},
-       {6211, 3024, 1676, 376, 370, 3057, 3062, 465, 468, {3084, 6244, 6258, 6271, 6284, 6297, 3131}, {3139, 6309, 6313, 6317, 6321, 6325, 3160}, {6329, 6337, 6347, 1004, 6354, 6359, 6365, 3202, 6371, 6380, 6388, 6397, 343}, {1854, 6406, 1862, 3244, 3772, 1870, 1874, 3252, 4946, 6410, 1890, 6414, 343}, 0, 0, 344, 346, {348,1676},{357,3024},{370},{376}},
-       {5975, 876, 1929, 438, 370, 447, 74, 465, 468, {6418, 6428, 6433, 6440, 6449, 6453, 6460}, {6471, 6473, 6475, 2022, 6478, 1617, 6480}, {6482, 6491, 6501, 6508, 3772, 6516, 6522, 1811, 6528, 6539, 6549, 6559, 343}, {6569, 2122, 2900, 2130, 2061, 6573, 6577, 2142, 2146, 2904, 2154, 2908, 343}, 0, 1, 344, 346, {348,1929},{357,876},{370},{376,438}},
-       {6581, 6607, 1929, 2982, 1409, 6625, 74, 465, 468, {6641, 6664, 505, 6687, 6698, 6713, 6728}, {6743, 6748, 6753, 6758, 6763, 6768, 6773}, {6778, 6791, 6806, 6815, 6828, 6835, 6844, 6853, 6866, 6883, 6898, 6911, 343}, {6926, 6933, 6940, 6947, 678, 6954, 6961, 6968, 6975, 6982, 6989, 6996, 343}, 0, 1, 344, 346, {348,844,1929},{357,6607},{370,1409},{376,1399,2982}},
-       {7003, 7025, 3314, 2982, 370, 4272, 1146, 465, 468, {7039, 7048, 7060, 7067, 7075, 7085, 7091}, {7098, 7102, 7106, 7110, 7114, 7119, 7123}, {7127, 7137, 7146, 7154, 7162, 7170, 7177, 7184, 7192, 1587, 7198, 7206, 343}, {7215, 7219, 7223, 7228, 7232, 6186, 7236, 7240, 7244, 6203, 7248, 7252, 343}, 0, 1, 344, 346, {348,7256,3314},{357,7025},{370},{376,2982}},
-       {7267, 1379, 7288, 2982, 1409, 447, 1414, 465, 468, {7299, 7307, 7316, 7323, 7330, 7339, 7346}, {7353, 7356, 7359, 7362, 7365, 7369, 2013}, {4373, 4381, 7372, 4672, 7378, 4725, 4730, 1811, 1818, 4452, 1836, 1845, 343}, {1854, 1858, 1862, 1866, 7378, 4725, 4730, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,3314,7288},{357,1379},{370,1409},{376,1399,2982}},
-       {7383, 409, 5996, 7407, 7418, 447, 457, 7425, 7428, {7431, 7438, 7447, 7456, 7468, 7476, 7485}, {7495, 7499, 2900, 7504, 7509, 7513, 7517}, {7521, 7527, 3761, 7534, 1797, 7540, 7548, 7555, 7561, 7569, 7575, 7583, 343}, {2118, 7591, 2900, 7595, 7599, 7603, 7607, 7611, 7517, 7615, 7619, 7624, 343}, 0, 1, 344, 346, {348,5515,5996},{357,409},{370,7418},{376,7628,7407}},
-       {7640, 7668, 5996, 5944, 5955, 447, 74, 7685, 7688, {7691, 7699, 7707, 1710, 1717, 1725, 7714}, {7722, 7726, 3421, 5965, 3427, 5968, 7730}, {5880, 5888, 3761, 1791, 1797, 1801, 1806, 7734, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 1862, 1866, 1797, 1870, 1874, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,5996},{357,7668},{370,5955},{376,5944}},
-       {7742, 876, 37, 2982, 1409, 447, 74, 7763, 7794, {7825, 7856, 7884, 7912, 7931, 7965, 7990}, {8015, 8023, 8028, 8033, 8038, 8046, 8051}, {8056, 8075, 8106, 8125, 8144, 8166, 8191, 8213, 8235, 8257, 8276, 8304, 343}, {8326, 8335, 8344, 8356, 8368, 8377, 8389, 8398, 8407, 8416, 8425, 8434, 343}, 0, 0, 344, 346, {348,37},{357,876},{370,1409},{376,8443,2982}},
-       {8483, 8510, 1929, 438, 370, 447, 457, 465, 468, {8528, 8534, 8544, 8550, 8561, 8571, 8576}, {8586, 8590, 8594, 8598, 8603, 8607, 8611}, {8615, 8620, 8627, 8632, 8638, 8645, 8653, 8660, 8669, 8676, 8681, 8688, 343}, {8696, 8700, 2900, 8705, 2869, 8709, 8713, 8717, 8722, 8726, 8730, 8734, 343}, 0, 1, 344, 346, {348,1929},{357,8510},{370},{376,438}},
-       {1112, 357, 348, 376, 370, 1136, 1146, 465, 468, {8738, 8745, 8751, 8758, 8763, 8769, 8775}, {8781, 8785, 8789, 8793, 8797, 8801, 8805}, {8809, 8817, 8826, 2055, 8832, 2065, 2070, 8836, 2082, 2092, 2100, 8844, 343}, {2118, 2122, 2900, 2130, 8832, 2134, 2138, 8853, 2146, 2150, 2154, 8857, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
-       {8861, 876, 1929, 2982, 370, 8881, 74, 465, 468, {8897, 8910, 8929, 8946, 8959, 8972, 8988}, {9001, 6748, 6753, 6758, 6763, 6768, 6773}, {9006, 9017, 9030, 9045, 9058, 9071, 9084, 9095, 9108, 9123, 9136, 9155, 343}, {9168, 9175, 9182, 9189, 9198, 9207, 9216, 9223, 9232, 9239, 9248, 9257, 343}, 0, 1, 344, 346, {348,844,1929},{357,876},{370},{376,2982}},
-       {9266, 876, 1392, 5944, 5955, 447, 74, 465, 468, {9289, 9304, 9325, 9340, 9353, 9366, 9381}, {9394, 9399, 9404, 9409, 9414, 9419, 9424}, {9429, 9446, 9455, 9470, 678, 9487, 9502, 9515, 9530, 9547, 9568, 9585, 343}, {9600, 9175, 9607, 9614, 678, 9621, 9628, 9635, 9232, 9642, 9649, 9656, 343}, 0, 1, 344, 346, {348,1392},{357,876},{370,5955},{376,5944}},
-       {9663, 9685, 3314, 2982, 1409, 447, 9699, 465, 468, {9708, 9716, 9727, 9733, 9739, 9748, 1482}, {7098, 7102, 1757, 9754, 7114, 7119, 9758}, {1770, 1777, 7372, 1791, 1797, 9762, 9768, 9774, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 1862, 1866, 1797, 1870, 1874, 9781, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,9785,3314},{357,9685},{370,1409},{376,1399,2982}},
-       {8861, 876, 9792, 2982, 1409, 447, 9802, 465, 468, {9810, 9821, 9832, 9843, 9854, 9865, 9871}, {4367, 9880, 9882, 4358, 6062, 9884, 6473}, {9886, 9894, 9903, 9910, 3772, 9917, 9923, 1811, 1818, 9929, 1836, 9938, 343}, {9948, 9953, 9903, 1866, 3772, 9917, 9923, 1878, 9959, 1886, 1890, 9964, 343}, 0, 1, 344, 346, {348,844,9792},{357,876},{370,1409},{376,1399,2982}},
-       {9969, 9998, 4525, 2982, 370, 10019, 1414, 465, 468, {10037, 10048, 10058, 10067, 10078, 10090, 10101}, {10111, 4367, 10114, 9882, 10116, 10118, 6480}, {10121, 10131, 1785, 10142, 10151, 10157, 10165, 10173, 10181, 10192, 10201, 10211, 343}, {2118, 2122, 2900, 2130, 2061, 10221, 10226, 2142, 2146, 2150, 2154, 2908, 343}, 0, 1, 344, 346, {348,10231,4525},{357,9998},{370},{376,2982}},
-       {10238, 10271, 7256, 376, 370, 10293, 10308, 465, 468, {10320, 10332, 10344, 10356, 10370, 10385, 10398}, {10412, 10415, 10418, 10421, 10424, 6064, 7365}, {10427, 10434, 10442, 10447, 10458, 10468, 10478, 10485, 10497, 10506, 10513, 10524, 343}, {10534, 10538, 10542, 10546, 10550, 10554, 10558, 10562, 10566, 10570, 10574, 10578, 343}, 0, 1, 344, 346, {348,7256},{357,10271},{370},{376}},
-       {10582, 876, 10606, 2970, 370, 447, 74, 10615, 10622, {10629, 10645, 10658, 10674, 10691, 10709, 10718}, {10727, 10731, 10735, 10739, 10743, 10747, 10751}, {10755, 10768, 229, 10779, 10790, 10795, 10804, 10815, 10822, 10837, 10848, 10861, 343}, {10874, 10881, 10888, 10895, 10902, 10909, 10916, 10815, 10923, 10930, 10937, 10944, 343}, 0, 0, 344, 346, {348,10951,10606},{357,876},{370},{376,10961,2970}},
-       {10974, 409, 2665, 2186, 370, 447, 457, 10998, 11001, {11004, 11017, 11027, 11036, 11046, 11057, 11068}, {11080, 11083, 11088, 11093, 11098, 11103, 11108}, {11113, 11126, 11137, 11147, 11158, 11170, 11182, 11195, 11207, 11220, 11235, 11256, 343}, {11275, 11281, 11287, 11293, 11299, 11305, 11311, 11317, 11323, 11329, 11336, 11343, 343}, 0, 1, 344, 346, {348,2665},{357,409},{370},{376,2186}},
-       {11350, 2912, 1929, 2982, 370, 447, 2754, 11372, 11380, {11388, 11401, 11422, 11441, 11462, 11481, 11494}, {11505, 11512, 11519, 11526, 11533, 11540, 11547}, {11554, 11571, 11588, 11597, 11608, 11619, 11632, 11645, 11660, 11679, 11698, 11715, 343}, {11734, 11741, 11748, 11755, 11762, 11769, 11776, 11783, 11790, 11797, 11804, 11811, 343}, 0, 1, 344, 346, {348,11818,1929},{357,2912},{370},{376,2982}},
-       {1112, 357, 348, 376, 370, 1136, 1146, 465, 468, {11827, 11835, 11846, 11856, 11867, 11876, 11885}, {11895, 11898, 11901, 11904, 11907, 11910, 11913}, {11916, 11926, 11934, 11942, 11950, 11958, 11965, 11973, 11981, 11988, 11994, 12001, 343}, {12009, 12013, 1862, 12017, 3772, 12021, 12025, 12029, 12033, 12037, 12041, 12045, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
-       {387, 409, 1929, 438, 370, 447, 457, 465, 468, {12049, 484, 505, 6687, 12062, 12079, 12090}, {574, 582, 590, 12103, 12111, 612, 12119}, {12127, 641, 658, 667, 12142, 12149, 12158, 699, 712, 731, 748, 763, 343}, {12167, 786, 12175, 794, 12183, 12191, 12199, 802, 12207, 818, 826, 12217, 343}, 0, 1, 344, 346, {348,12229,1929},{357,409},{370},{376,438}},
-       {1112, 357, 348, 376, 370, 1136, 1146, 12237, 12240, {12243, 12250, 12258, 12266, 12275, 12285, 12292}, {2013, 6475, 2019, 12301, 2025, 12304, 2031}, {12307, 12316, 12326, 2055, 8832, 12332, 12338, 12344, 2082, 2092, 2100, 8844, 343}, {2118, 2122, 2900, 2130, 8832, 2134, 2138, 2142, 2146, 2150, 2154, 8857, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
-       {12353, 12373, 348, 376, 370, 12382, 1146, 12389, 12405, {5217, 5219, 5221, 5223, 5225, 5227, 5229}, {5217, 5219, 5221, 5223, 5225, 5227, 5229}, {5217, 5219, 5221, 5223, 5225, 5227, 5229, 5231, 5233, 5235, 5238, 5241, 343}, {5217, 5219, 5221, 5223, 5225, 5227, 5229, 5231, 5233, 5235, 5238, 5241, 343}, 0, 0, 344, 346, {348},{357,12373},{370},{376}},
-       {12427, 1664, 1898, 376, 370, 447, 457, 465, 468, {4537, 12450, 12461, 12471, 12481, 12491, 12505}, {4623, 4627, 12517, 12522, 12526, 12531, 12536}, {1770, 1777, 3761, 4672, 3772, 1801, 1806, 1811, 1818, 1828, 1836, 4716, 343}, {1854, 1858, 1862, 1866, 3772, 1870, 1874, 1878, 1882, 1886, 1890, 4746, 343}, 0, 0, 344, 346, {348,1898},{357,1664},{370},{376}},
+       {1643, 1664, 1676, 438, 370, 447, 1687, 465, 468, {1696, 1704, 1711, 1719, 1726, 1734, 1741}, {1749, 1754, 1758, 1762, 1766, 1770, 1774}, {1779, 1786, 1794, 1800, 1806, 1810, 1815, 1820, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 1871, 1875, 1806, 1879, 1883, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,1907,1676},{357,1664},{370},{376,438}},
+       {1916, 1379, 1938, 438, 370, 447, 1414, 1949, 1955, {1962, 1970, 1977, 1986, 1995, 2006, 2014}, {2022, 2025, 2028, 2031, 2034, 2037, 2040}, {2043, 2050, 2058, 2064, 2070, 2074, 2079, 2084, 2091, 2101, 2109, 2118, 343}, {2127, 2131, 2135, 2139, 2070, 2143, 2147, 2151, 2155, 2159, 2163, 2167, 343}, 0, 1, 344, 346, {348,844,1938},{357,1379},{370},{376,438}},
+       {2171, 409, 37, 2195, 56, 447, 457, 2206, 2211, {2216, 2231, 2246, 2257, 2272, 2285, 2304}, {2319, 2326, 2333, 2340, 2347, 2354, 2361}, {2368, 2389, 2412, 2427, 2444, 2455, 2470, 2485, 2504, 2527, 2546, 2565, 343}, {2586, 2593, 2600, 2607, 2614, 2621, 2630, 2639, 2646, 2653, 2660, 2667, 343}, 0, 1, 344, 346, {348,2674,37},{357,409},{370,56},{376,2685,2195}},
+       {2697, 2728, 2748, 2195, 2755, 447, 2763, 465, 468, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 0, 344, 346, {348,2748},{2728,2728,2921,2935,2955},{2755,2755,2970,1409,370},{2195,2195,2979,2991,438}},
+       {2999, 3033, 3055, 2979, 370, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055},{357,3033},{370},{376,2979}},
+       {3281, 3306, 3323, 2991, 370, 3332, 3345, 465, 468, {3357, 3367, 3377, 3385, 3397, 3405, 3415}, {3424, 3427, 3430, 3433, 3436, 3439, 3442}, {3445, 3454, 3463, 3473, 3482, 3491, 3500, 3510, 3517, 3525, 3533, 3543, 343}, {3552, 3558, 3564, 3571, 3577, 3583, 3589, 3596, 3600, 3605, 3610, 3617, 343}, 0, 1, 344, 346, {348,3323},{357,3306},{370},{376,2991}},
+       {3623, 3649, 888, 438, 370, 447, 74, 465, 468, {3666, 3675, 3681, 3687, 3696, 3702, 3711}, {3718, 3723, 3728, 3733, 3738, 3743, 3748}, {3753, 3761, 3770, 3775, 3781, 3785, 3790, 3798, 3804, 3814, 1050, 3822, 343}, {3832, 3838, 3770, 3845, 3781, 3785, 3850, 3798, 3856, 1097, 1102, 3862, 343}, 0, 0, 344, 346, {888,3868,3273},{357,876,3649},{370},{376,438}},
+       {3878, 876, 2674, 438, 370, 447, 74, 465, 468, {3899, 3917, 3931, 3949, 3967, 3985, 4001}, {4008, 4011, 4014, 4017, 4020, 4023, 4026}, {4029, 4040, 4053, 4060, 4071, 4078, 4087, 4096, 4109, 4122, 4137, 4150, 343}, {4161, 4168, 4053, 4175, 4071, 4182, 4189, 4196, 4203, 4210, 4217, 4224, 343}, 0, 0, 344, 346, {348,888,2674},{357,876},{370},{376,438}},
+       {4231, 4253, 4267, 2991, 1409, 4281, 4292, 4300, 4303, {4306, 4316, 4324, 4329, 4336, 4349, 4357}, {1617, 4365, 4367, 4369, 4373, 4376, 4378}, {4382, 4390, 4399, 4408, 4417, 4424, 4432, 4440, 4450, 4461, 1845, 1854, 343}, {4470, 4475, 4481, 4488, 4494, 4500, 4506, 4512, 4517, 4524, 1102, 4529, 343}, 0, 1, 344, 346, {348,4534,4267},{357,4253},{370,1409},{376,1399,2991}},
+       {1916, 1379, 3323, 438, 370, 447, 1414, 465, 468, {4546, 4557, 4568, 4582, 4596, 4608, 4620}, {4632, 4636, 4641, 4646, 4651, 4655, 4660}, {4664, 4672, 3770, 4681, 4688, 4693, 4700, 4707, 1827, 4461, 4715, 4725, 343}, {1863, 1867, 1871, 1875, 4688, 4734, 4739, 4744, 1891, 1895, 4750, 4755, 343}, 0, 0, 344, 346, {348,3323},{357,1379},{370},{376,438}},
+       {4759, 409, 888, 376, 370, 447, 74, 4783, 4786, {4789, 4798, 4806, 4815, 4826, 4835, 4844}, {3148, 3152, 1871, 4851, 4855, 4859, 4863}, {4867, 4875, 3188, 4884, 4891, 4898, 4905, 3211, 4912, 4922, 1050, 4930, 343}, {4939, 1867, 1871, 1875, 4943, 4947, 4951, 3261, 4955, 4959, 1899, 3269, 343}, 0, 1, 344, 346, {348,888},{357,409},{370},{376}},
+       {4963, 4993, 5015, 2991, 1409, 5026, 5042, 5055, 5062, {5069, 5079, 5089, 5099, 5109, 5119, 5129}, {1238, 5139, 5143, 5147, 5151, 5155, 5159}, {5163, 5168, 5173, 5178, 5183, 5188, 5193, 5198, 5203, 5208, 5214, 5220, 343}, {5226, 5228, 5230, 5232, 5234, 5236, 5238, 5240, 5242, 5244, 5247, 5250, 343}, 0, 0, 344, 346, {5015,5015,348,5253,5260,5269,5288,5305},{4993,4993,5324,5348,5375},{1409,1409,370,5404,5412},{2991,438,5421,5432}},
+       {5444, 5497, 5524, 5533, 5559, 5577, 5594, 5608, 5615, {5622, 5632, 5642, 5652, 5662, 5672, 5682}, {5692, 5696, 5700, 5704, 5708, 5712, 5716}, {5720, 5725, 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5771, 5777, 343}, {5720, 5725, 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5771, 5777, 343}, 0, 0, 344, 346, {348,5524},{357,5497},{370,5559},{376,5533}},
+       {5783, 876, 5805, 1399, 1409, 447, 74, 465, 468, {5812, 5819, 5827, 5835, 5844, 5854, 5862}, {5871, 3427, 5874, 5877, 5880, 5883, 5886}, {5889, 5897, 5906, 1800, 5912, 1810, 1815, 5916, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 5925, 1875, 5912, 1879, 1883, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,5805},{357,876},{370,1409},{376,1399}},
+       {5929, 1379, 844, 5953, 5964, 447, 1414, 465, 468, {1696, 1704, 1711, 1719, 1726, 1734, 1741}, {5970, 3427, 3430, 5974, 3436, 5977, 5980}, {1779, 1786, 3770, 1800, 3781, 1810, 1815, 1820, 1827, 1837, 1845, 4725, 343}, {1863, 1867, 1871, 1875, 3781, 1879, 1883, 1887, 1891, 1895, 1899, 4755, 343}, 0, 1, 344, 346, {348,844},{357,1379},{370,5964},{376,5953}},
+       {5984, 876, 6005, 438, 370, 447, 74, 465, 468, {6016, 6026, 6040, 6047, 6054, 6063, 1482}, {6071, 6073, 6076, 6079, 6083, 6086, 2022}, {6089, 6098, 6103, 6110, 1806, 6120, 6129, 6136, 6146, 6156, 1587, 6169, 343}, {6179, 6183, 1871, 6187, 1806, 6191, 6195, 6199, 6203, 6207, 6212, 6216, 343}, 0, 1, 344, 346, {348,5524,6005},{357,876},{370},{376,438}},
+       {6220, 3033, 1676, 376, 370, 3066, 3071, 465, 468, {3093, 6253, 6267, 6280, 6293, 6306, 3140}, {3148, 6318, 6322, 6326, 6330, 6334, 3169}, {6338, 6346, 6356, 1004, 6363, 6368, 6374, 3211, 6380, 6389, 6397, 6406, 343}, {1863, 6415, 1871, 3253, 3781, 1879, 1883, 3261, 4955, 6419, 1899, 6423, 343}, 0, 0, 344, 346, {348,1676},{357,3033},{370},{376}},
+       {5984, 876, 1938, 438, 370, 447, 74, 465, 468, {6427, 6437, 6442, 6449, 6458, 6462, 6469}, {6480, 6482, 6484, 2031, 6487, 1617, 6489}, {6491, 6500, 6510, 6517, 3781, 6525, 6531, 1820, 6537, 6548, 6558, 6568, 343}, {6578, 2131, 2909, 2139, 2070, 6582, 6586, 2151, 2155, 2913, 2163, 2917, 343}, 0, 1, 344, 346, {348,1938},{357,876},{370},{376,438}},
+       {6590, 6616, 1938, 2991, 1409, 6634, 74, 465, 468, {6650, 6673, 505, 6696, 6707, 6722, 6737}, {6752, 6757, 6762, 6767, 6772, 6777, 6782}, {6787, 6800, 6815, 6824, 6837, 6844, 6853, 6862, 6875, 6892, 6907, 6920, 343}, {6935, 6942, 6949, 6956, 678, 6963, 6970, 6977, 6984, 6991, 6998, 7005, 343}, 0, 1, 344, 346, {348,844,1938},{357,6616},{370,1409},{376,1399,2991}},
+       {7012, 7034, 3323, 2991, 370, 4281, 1146, 465, 468, {7048, 7057, 7069, 7076, 7084, 7094, 7100}, {7107, 7111, 7115, 7119, 7123, 7128, 7132}, {7136, 7146, 7155, 7163, 7171, 7179, 7186, 7193, 7201, 1587, 7207, 7215, 343}, {7224, 7228, 7232, 7237, 7241, 6195, 7245, 7249, 7253, 6212, 7257, 7261, 343}, 0, 1, 344, 346, {348,7265,3323},{357,7034},{370},{376,2991}},
+       {7276, 1379, 7297, 2991, 1409, 447, 1414, 465, 468, {7308, 7316, 7325, 7332, 7339, 7348, 7355}, {7362, 7365, 7368, 7371, 7374, 7378, 2022}, {4382, 4390, 7381, 4681, 7387, 4734, 4739, 1820, 1827, 4461, 1845, 1854, 343}, {1863, 1867, 1871, 1875, 7387, 4734, 4739, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,3323,7297},{357,1379},{370,1409},{376,1399,2991}},
+       {7392, 409, 6005, 7416, 7427, 447, 457, 7434, 7437, {7440, 7447, 7456, 7465, 7477, 7485, 7494}, {7504, 7508, 2909, 7513, 7518, 7522, 7526}, {7530, 7536, 3770, 7543, 1806, 7549, 7557, 7564, 7570, 7578, 7584, 7592, 343}, {2127, 7600, 2909, 7604, 7608, 7612, 7616, 7620, 7526, 7624, 7628, 7633, 343}, 0, 1, 344, 346, {348,5524,6005},{357,409},{370,7427},{376,7637,7416}},
+       {7649, 7677, 6005, 5953, 5964, 447, 74, 7694, 7697, {7700, 7708, 7716, 1719, 1726, 1734, 7723}, {7731, 7735, 3430, 5974, 3436, 5977, 7739}, {5889, 5897, 3770, 1800, 1806, 1810, 1815, 7743, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 1871, 1875, 1806, 1879, 1883, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,6005},{357,7677},{370,5964},{376,5953}},
+       {7751, 876, 37, 2991, 1409, 447, 74, 7772, 7803, {7834, 7865, 7893, 7921, 7940, 7974, 7999}, {8024, 8032, 8037, 8042, 8047, 8055, 8060}, {8065, 8084, 8115, 8134, 8153, 8175, 8200, 8222, 8244, 8266, 8285, 8313, 343}, {8335, 8344, 8353, 8365, 8377, 8386, 8398, 8407, 8416, 8425, 8434, 8443, 343}, 0, 0, 344, 346, {348,37},{357,876},{370,1409},{376,8452,2991}},
+       {8492, 8519, 1938, 438, 370, 447, 457, 465, 468, {8537, 8543, 8553, 8559, 8570, 8580, 8585}, {8595, 8599, 8603, 8607, 8612, 8616, 8620}, {8624, 8629, 8636, 8641, 8647, 8654, 8662, 8669, 8678, 8685, 8690, 8697, 343}, {8705, 8709, 2909, 8714, 2878, 8718, 8722, 8726, 8731, 8735, 8739, 8743, 343}, 0, 1, 344, 346, {348,1938},{357,8519},{370},{376,438}},
+       {1112, 357, 348, 376, 370, 1136, 1146, 465, 468, {8747, 8754, 8760, 8767, 8772, 8778, 8784}, {8790, 8794, 8798, 8802, 8806, 8810, 8814}, {8818, 8826, 8835, 2064, 8841, 2074, 2079, 8845, 2091, 2101, 2109, 8853, 343}, {2127, 2131, 2909, 2139, 8841, 2143, 2147, 8862, 2155, 2159, 2163, 8866, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
+       {8870, 876, 1938, 2991, 370, 8890, 74, 465, 468, {8906, 8919, 8938, 8955, 8968, 8981, 8997}, {9010, 6757, 6762, 6767, 6772, 6777, 6782}, {9015, 9026, 9039, 9054, 9067, 9080, 9093, 9104, 9117, 9132, 9145, 9164, 343}, {9177, 9184, 9191, 9198, 9207, 9216, 9225, 9232, 9241, 9248, 9257, 9266, 343}, 0, 1, 344, 346, {348,844,1938},{357,876},{370},{376,2991}},
+       {9275, 876, 1392, 5953, 5964, 447, 74, 465, 468, {9298, 9313, 9334, 9349, 9362, 9375, 9390}, {9403, 9408, 9413, 9418, 9423, 9428, 9433}, {9438, 9455, 9464, 9479, 678, 9496, 9511, 9524, 9539, 9556, 9577, 9594, 343}, {9609, 9184, 9616, 9623, 678, 9630, 9637, 9644, 9241, 9651, 9658, 9665, 343}, 0, 1, 344, 346, {348,1392},{357,876},{370,5964},{376,5953}},
+       {9672, 9694, 3323, 2991, 1409, 447, 1687, 465, 468, {9708, 9716, 9727, 9733, 9739, 9748, 1482}, {7107, 7111, 1766, 9754, 7123, 7128, 9758}, {1779, 1786, 7381, 1800, 1806, 9762, 9768, 9774, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 1871, 1875, 1806, 1879, 1883, 9781, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,9785,3323},{357,9694},{370,1409},{376,1399,2991}},
+       {8870, 876, 9792, 2991, 1409, 447, 9802, 465, 468, {9810, 9821, 9832, 9843, 9854, 9865, 9871}, {4376, 9880, 9882, 4367, 6071, 9884, 6482}, {9886, 9894, 9903, 9910, 3781, 9917, 9923, 1820, 1827, 9929, 1845, 9938, 343}, {9948, 9953, 9903, 1875, 3781, 9917, 9923, 1887, 9959, 1895, 1899, 9964, 343}, 0, 1, 344, 346, {348,844,9792},{357,876},{370,1409},{376,1399,2991}},
+       {9969, 9998, 4534, 2991, 370, 10019, 1414, 465, 468, {10037, 10048, 10058, 10067, 10078, 10090, 10101}, {10111, 4376, 10114, 9882, 10116, 10118, 6489}, {10121, 10131, 1794, 10142, 10151, 10157, 10165, 10173, 10181, 10192, 10201, 10211, 343}, {2127, 2131, 2909, 2139, 2070, 10221, 10226, 2151, 2155, 2159, 2163, 2917, 343}, 0, 1, 344, 346, {348,10231,4534},{357,9998},{370},{376,2991}},
+       {10238, 10271, 7265, 376, 370, 10293, 10308, 465, 468, {10320, 10332, 10344, 10356, 10370, 10385, 10398}, {10412, 10415, 10418, 10421, 10424, 6073, 7374}, {10427, 10434, 10442, 10447, 10458, 10468, 10478, 10485, 10497, 10506, 10513, 10524, 343}, {10534, 10538, 10542, 10546, 10550, 10554, 10558, 10562, 10566, 10570, 10574, 10578, 343}, 0, 1, 344, 346, {348,7265},{357,10271},{370},{376}},
+       {10582, 876, 10606, 2979, 370, 447, 74, 10615, 10622, {10629, 10645, 10658, 10674, 10691, 10709, 10718}, {10727, 10731, 10735, 10739, 10743, 10747, 10751}, {10755, 10768, 229, 10779, 10790, 10795, 10804, 10815, 10822, 10837, 10848, 10861, 343}, {10874, 10881, 10888, 10895, 10902, 10909, 10916, 10815, 10923, 10930, 10937, 10944, 343}, 0, 0, 344, 346, {348,10951,10606},{357,876},{370},{376,10961,2979}},
+       {10974, 409, 2674, 2195, 370, 447, 457, 10998, 11001, {11004, 11017, 11027, 11036, 11046, 11057, 11068}, {11080, 11083, 11088, 11093, 11098, 11103, 11108}, {11113, 11126, 11137, 11147, 11158, 11170, 11182, 11195, 11207, 11220, 11235, 11256, 343}, {11275, 11281, 11287, 11293, 11299, 11305, 11311, 11317, 11323, 11329, 11336, 11343, 343}, 0, 1, 344, 346, {348,2674},{357,409},{370},{376,2195}},
+       {11350, 2921, 1938, 2991, 370, 447, 2763, 11372, 11380, {11388, 11401, 11422, 11441, 11462, 11481, 11494}, {11505, 11512, 11519, 11526, 11533, 11540, 11547}, {11554, 11571, 11588, 11597, 11608, 11619, 11632, 11645, 11660, 11679, 11698, 11715, 343}, {11734, 11741, 11748, 11755, 11762, 11769, 11776, 11783, 11790, 11797, 11804, 11811, 343}, 0, 1, 344, 346, {348,11818,1938},{357,2921},{370},{376,2991}},
+       {1112, 357, 348, 376, 370, 1136, 1146, 465, 468, {11827, 11835, 11846, 11856, 11867, 11876, 11885}, {11895, 11898, 11901, 11904, 11907, 11910, 11913}, {11916, 11926, 11934, 11942, 11950, 11958, 11965, 11973, 11981, 11988, 11994, 12001, 343}, {12009, 12013, 1871, 12017, 3781, 12021, 12025, 12029, 12033, 12037, 12041, 12045, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
+       {387, 409, 1938, 438, 370, 447, 457, 465, 468, {12049, 484, 505, 6696, 12062, 12079, 12090}, {574, 582, 590, 12103, 12111, 612, 12119}, {12127, 641, 658, 667, 12142, 12149, 12158, 699, 712, 731, 748, 763, 343}, {12167, 786, 12175, 794, 12183, 12191, 12199, 802, 12207, 818, 826, 12217, 343}, 0, 1, 344, 346, {348,12229,1938},{357,409},{370},{376,438}},
+       {1112, 357, 348, 376, 370, 1136, 1146, 12237, 12240, {12243, 12250, 12258, 12266, 12275, 12285, 12292}, {2022, 6484, 2028, 12301, 2034, 12304, 2040}, {12307, 12316, 12326, 2064, 8841, 12332, 12338, 12344, 2091, 2101, 2109, 8853, 343}, {2127, 2131, 2909, 2139, 8841, 2143, 2147, 2151, 2155, 2159, 2163, 8866, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
+       {12353, 12373, 348, 376, 370, 12382, 1146, 12389, 12405, {5226, 5228, 5230, 5232, 5234, 5236, 5238}, {5226, 5228, 5230, 5232, 5234, 5236, 5238}, {5226, 5228, 5230, 5232, 5234, 5236, 5238, 5240, 5242, 5244, 5247, 5250, 343}, {5226, 5228, 5230, 5232, 5234, 5236, 5238, 5240, 5242, 5244, 5247, 5250, 343}, 0, 0, 344, 346, {348},{357,12373},{370},{376}},
+       {12427, 1664, 1907, 376, 370, 447, 457, 465, 468, {4546, 12450, 12461, 12471, 12481, 12491, 12505}, {4632, 4636, 12517, 12522, 12526, 12531, 12536}, {1779, 1786, 3770, 4681, 3781, 1810, 1815, 1820, 1827, 1837, 1845, 4725, 343}, {1863, 1867, 1871, 1875, 3781, 1879, 1883, 1887, 1891, 1895, 1899, 4755, 343}, 0, 0, 344, 346, {348,1907},{357,1664},{370},{376}},
        {1112, 357, 348, 376, 370, 1136, 1146, 12540, 12568, {12590, 12609, 12628, 12650, 12669, 12691, 12716}, {12735, 12745, 12755, 12768, 12778, 12791, 12807}, {12817, 12833, 12849, 12865, 12884, 12891, 12901, 12917, 12933, 12955, 12977, 12996, 343}, {12817, 12833, 12849, 12865, 12884, 12891, 12901, 12917, 12933, 12955, 12977, 12996, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
-       {1112, 357, 348, 376, 370, 1136, 1146, 465, 468, {13018, 13027, 13036, 13044, 13053, 13062, 13069}, {13078, 13082, 13086, 13090, 13094, 13098, 13102}, {8809, 8817, 13106, 13112, 8832, 2065, 13119, 13125, 13132, 13141, 13148, 13156, 343}, {2118, 2122, 2900, 2130, 8832, 2134, 2138, 13164, 2146, 2150, 2154, 8857, 343}, 0, 6, 344, 346, {348},{357},{370},{376}},
+       {1112, 357, 348, 376, 370, 1136, 1146, 465, 468, {13018, 13027, 13036, 13044, 13053, 13062, 13069}, {13078, 13082, 13086, 13090, 13094, 13098, 13102}, {8818, 8826, 13106, 13112, 8841, 2074, 13119, 13125, 13132, 13141, 13148, 13156, 343}, {2127, 2131, 2909, 2139, 8841, 2143, 2147, 13164, 2155, 2159, 2163, 8866, 343}, 0, 6, 344, 346, {348},{357},{370},{376}},
        {1112, 357, 348, 376, 370, 1136, 1146, 13168, 13210, {13252, 13271, 13290, 13312, 13331, 13353, 13378}, {13397, 13407, 13417, 13430, 13440, 13453, 13469}, {13479, 13507, 13535, 13551, 13570, 13577, 13587, 13603, 13619, 13647, 13669, 13691, 343}, {13716, 13735, 13535, 13551, 13570, 13577, 13587, 13603, 13754, 13770, 13786, 13796, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
        {1112, 357, 348, 376, 370, 1136, 1146, 13809, 13822, {13835, 13854, 13876, 13901, 13917, 13939, 13958}, {13968, 13975, 13982, 13989, 13996, 14003, 14010}, {14014, 14030, 14055, 14074, 14093, 14100, 14113, 14126, 14145, 14176, 14201, 14223, 343}, {14248, 14256, 14270, 14284, 14093, 14100, 14113, 14295, 14303, 14317, 14328, 14336, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
        {1112, 357, 348, 376, 370, 1136, 1146, 14347, 14375, {14397, 14419, 14441, 14466, 14488, 14513, 14541}, {14563, 14573, 14583, 14596, 14606, 14619, 14635}, {14645, 14661, 14686, 14705, 14727, 14734, 14747, 14760, 14779, 14810, 14835, 14854, 343}, {14645, 14661, 14686, 14705, 14727, 14734, 14747, 14760, 14779, 14810, 14835, 14854, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
        {1112, 357, 348, 376, 370, 1136, 1146, 14879, 14907, {14929, 14948, 14967, 14989, 15008, 15030, 15055}, {15074, 15079, 15087, 15095, 15103, 15111, 15119}, {15130, 15146, 15171, 15190, 15212, 15219, 15232, 15245, 15264, 15292, 15317, 15339, 343}, {15130, 15146, 15171, 15190, 15212, 15219, 15232, 15245, 15264, 15292, 15317, 15339, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
        {1112, 357, 348, 376, 370, 1136, 1146, 15364, 15376, {12590, 12609, 15388, 12650, 12669, 12691, 12716}, {12735, 12745, 15410, 12768, 12778, 12791, 12807}, {15423, 15448, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, {15423, 15448, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
-       {1112, 357, 348, 376, 370, 1136, 1146, 465, 468, {15628, 15636, 15641, 15648, 15658, 15664, 15671}, {15679, 15683, 2900, 15687, 15692, 15696, 15700}, {15705, 15713, 15722, 15728, 15734, 15739, 15745, 15751, 15758, 15767, 15775, 15784, 343}, {15793, 2122, 2900, 15797, 2061, 15801, 15806, 13164, 15810, 15814, 2154, 2908, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
+       {1112, 357, 348, 376, 370, 1136, 1146, 465, 468, {15628, 15636, 15641, 15648, 15658, 15664, 15671}, {15679, 15683, 2909, 15687, 15692, 15696, 15700}, {15705, 15713, 15722, 15728, 15734, 15739, 15745, 15751, 15758, 15767, 15775, 15784, 343}, {15793, 2131, 2909, 15797, 2070, 15801, 15806, 13164, 15810, 15814, 2163, 2917, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
        {1112, 357, 348, 376, 370, 1136, 1146, 15364, 15376, {15818, 12609, 15846, 12650, 12669, 12691, 12716}, {12735, 12745, 15410, 12768, 12778, 12791, 12807}, {15423, 15865, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, {15423, 15448, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, 0, 0, 344, 346, {348},{357},{370},{376}},
        {1, 24, 37, 46, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37},{357,24},{370,56},{376,46}},
        {387, 409, 422, 438, 370, 447, 457, 465, 468, {471, 484, 505, 520, 531, 550, 561}, {574, 582, 590, 596, 602, 612, 620}, {628, 641, 658, 667, 678, 685, 692, 699, 712, 731, 748, 763, 343}, {780, 786, 658, 794, 678, 685, 692, 802, 810, 818, 826, 836, 343}, 0, 1, 344, 346, {348,844,422},{357,409},{370},{376,438}},
-       {5975, 876, 2665, 438, 370, 447, 457, 465, 468, {897, 906, 914, 922, 931, 938, 948}, {957, 961, 965, 969, 973, 977, 981}, {985, 991, 998, 1004, 1010, 1015, 1020, 1027, 1033, 1042, 1050, 1059, 343}, {1068, 1073, 998, 1078, 1010, 1015, 1083, 1088, 1092, 1097, 1102, 1107, 343}, 0, 1, 344, 346, {348,888,2665},{357,876},{370},{376,438}},
-       {15896, 4984, 5251, 15941, 15964, 5017, 5033, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, 0, 0, 344, 346, {348,5251},{357,4984},{370,15964},{376,15941}},
-       {7267, 1379, 3314, 2982, 1409, 447, 1414, 1422, 1427, {1432, 1440, 1450, 1458, 1466, 1475, 1482}, {1489, 1492, 1495, 1499, 1502, 1506, 1510}, {1513, 1519, 1525, 1533, 1539, 1547, 1555, 1565, 1571, 1579, 1587, 1596, 343}, {1605, 1607, 1610, 1614, 1617, 1619, 1622, 1626, 1631, 1634, 1636, 1639, 343}, 0, 1, 344, 346, {348,1392,3314},{357,1379},{370,1409},{376,1399,2982}},
-       {1643, 1664, 1676, 438, 370, 447, 457, 465, 468, {1687, 1695, 1702, 1710, 1717, 1725, 1732}, {1740, 1745, 1749, 1753, 1757, 1761, 1765}, {1770, 1777, 1785, 1791, 1797, 1801, 1806, 1811, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 1862, 1866, 1797, 1870, 1874, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,1898,1676},{357,1664},{370},{376,438}},
-       {1907, 1379, 1929, 438, 370, 447, 1414, 1940, 1946, {1953, 1961, 1968, 1977, 1986, 1997, 2005}, {2013, 2016, 2019, 2022, 2025, 2028, 2031}, {2034, 2041, 2049, 2055, 2061, 2065, 2070, 2075, 2082, 2092, 2100, 2109, 343}, {2118, 2122, 2126, 2130, 2061, 2134, 2138, 2142, 2146, 2150, 2154, 2158, 343}, 0, 1, 344, 346, {348,844,1929},{357,1379},{370},{376,438}},
-       {2162, 409, 37, 2186, 56, 447, 457, 2197, 2202, {2207, 2222, 2237, 2248, 2263, 2276, 2295}, {2310, 2317, 2324, 2331, 2338, 2345, 2352}, {2359, 2380, 2403, 2418, 2435, 2446, 2461, 2476, 2495, 2518, 2537, 2556, 343}, {2577, 2584, 2591, 2598, 2605, 2612, 2621, 2630, 2637, 2644, 2651, 2658, 343}, 0, 1, 344, 346, {348,2665,37},{357,409},{370,56},{376,2676,2186}},
-       {2688, 2719, 10606, 2186, 2746, 63, 2754, 465, 468, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 0, 344, 346, {10606,10606,2739,2739,11818,3046,348,5996,15971},{2719,2719,2912,2926,2946},{2746,2746,2961,1409,370},{2186,2186,2970,2982,438}},
-       {3272, 3297, 3314, 2982, 370, 3323, 3336, 465, 468, {3348, 3358, 3368, 3376, 3388, 3396, 3406}, {3415, 3418, 3421, 3424, 3427, 3430, 3433}, {3436, 3445, 3454, 3464, 3473, 3482, 3491, 3501, 3508, 3516, 3524, 3534, 343}, {3543, 3549, 3555, 3562, 3568, 3574, 3580, 3587, 3591, 3596, 3601, 3608, 343}, 0, 1, 344, 346, {348,3314},{357,3297},{370},{376,2982}},
-       {3614, 3640, 2665, 438, 370, 447, 74, 465, 468, {3657, 3666, 3672, 3678, 3687, 3693, 3702}, {3709, 3714, 3719, 3724, 3729, 3734, 3739}, {3744, 3752, 3761, 3766, 3772, 3776, 3781, 3789, 3795, 3805, 1050, 3813, 343}, {3823, 3829, 3761, 3836, 3772, 3776, 3841, 3789, 3847, 1097, 1102, 3853, 343}, 0, 1, 344, 346, {888,3859,3264,2665},{357,876,3640},{370},{376,438}},
-       {3869, 876, 2665, 438, 370, 447, 74, 465, 468, {3890, 3908, 3922, 3940, 3958, 3976, 3992}, {3999, 4002, 4005, 4008, 4011, 4014, 4017}, {4020, 4031, 4044, 4051, 4062, 4069, 4078, 4087, 4100, 4113, 4128, 4141, 343}, {4152, 4159, 4044, 4166, 4062, 4173, 4180, 4187, 4194, 4201, 4208, 4215, 343}, 0, 0, 344, 346, {348,888,2665},{357,876},{370},{376,438}},
-       {4222, 4244, 4258, 2982, 1409, 4272, 4283, 4291, 4294, {4297, 4307, 4315, 4320, 4327, 4340, 4348}, {1617, 4356, 4358, 4360, 4364, 4367, 4369}, {4373, 4381, 4390, 4399, 4408, 4415, 4423, 4431, 4441, 4452, 1836, 1845, 343}, {4461, 4466, 4472, 4479, 4485, 4491, 4497, 4503, 4508, 4515, 1102, 4520, 343}, 0, 1, 344, 346, {348,4525,4258},{357,4244},{370,1409},{376,1399,2982}},
-       {1907, 1379, 3314, 438, 370, 447, 1414, 465, 468, {4537, 4548, 4559, 4573, 4587, 4599, 4611}, {4623, 4627, 4632, 4637, 4642, 4646, 4651}, {4655, 4663, 3761, 4672, 4679, 4684, 4691, 4698, 1818, 4452, 4706, 4716, 343}, {1854, 1858, 1862, 1866, 4679, 4725, 4730, 4735, 1882, 1886, 4741, 4746, 343}, 0, 0, 344, 346, {348,3314},{357,1379},{370},{376,438}},
-       {15981, 409, 2665, 16002, 370, 447, 74, 4774, 4777, {4780, 4789, 4797, 4806, 4817, 4826, 4835}, {3139, 3143, 1862, 4842, 4846, 4850, 4854}, {4858, 4866, 3179, 4875, 4882, 4889, 4896, 3202, 4903, 4913, 1050, 4921, 343}, {4930, 1858, 1862, 1866, 4934, 4938, 4942, 3252, 4946, 4950, 1890, 3260, 343}, 0, 1, 344, 346, {348,888,2665},{357,409},{370},{376,1399,16002}},
-       {4954, 4984, 5006, 2982, 1409, 5017, 5033, 5046, 5053, {5060, 5070, 5080, 5090, 5100, 5110, 5120}, {1238, 5130, 5134, 5138, 5142, 5146, 5150}, {5154, 5159, 5164, 5169, 5174, 5179, 5184, 5189, 5194, 5199, 5205, 5211, 343}, {5217, 5219, 5221, 5223, 5225, 5227, 5229, 5231, 5233, 5235, 5238, 5241, 343}, 0, 0, 344, 346, {5006,5006,348,5244,5251,5260,5279,5296},{4984,4984,5315,5339,5366},{1409,1409,370,5395,5403},{2982,438,5412,5423}},
-       {16010, 16060, 5006, 16084, 5395, 5568, 5585, 5599, 5606, {5613, 5623, 5633, 5643, 5653, 5663, 5673}, {5683, 5687, 5691, 5695, 5699, 5703, 5707}, {5711, 5716, 5721, 5726, 5731, 5736, 5741, 5746, 5751, 5756, 5762, 5768, 343}, {5711, 5716, 5721, 5726, 5731, 5736, 5741, 5746, 5751, 5756, 5762, 5768, 343}, 0, 0, 344, 346, {5006,5006,348,5244,5251,16110,16123},{16060,16060,16134,16160,16182},{5395,1409,370,16206,16220,16235,5395,5403,16251,16268,16286},{16084,16084,16305,16327,2982,438,16351,16376,5412,5423}},
-       {8861, 876, 16403, 2982, 1409, 447, 74, 465, 468, {5803, 5810, 5818, 5826, 5835, 5845, 5853}, {5862, 3418, 5865, 5868, 5871, 5874, 5877}, {5880, 5888, 5897, 1791, 5903, 1801, 1806, 5907, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 5916, 1866, 5903, 1870, 1874, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,5796,16403},{357,876},{370,1409},{376,1399,2982}},
-       {5920, 1379, 844, 5944, 5955, 447, 1414, 465, 468, {1687, 1695, 1702, 1710, 1717, 1725, 1732}, {5961, 3418, 3421, 5965, 3427, 5968, 5971}, {1770, 1777, 3761, 1791, 3772, 1801, 1806, 1811, 1818, 1828, 1836, 4716, 343}, {1854, 1858, 1862, 1866, 3772, 1870, 1874, 1878, 1882, 1886, 1890, 4746, 343}, 0, 1, 344, 346, {348,844},{357,1379},{370,5955},{376,5944}},
-       {5975, 876, 5996, 438, 370, 447, 74, 465, 468, {6007, 6017, 6031, 6038, 6045, 6054, 1482}, {6062, 6064, 6067, 6070, 6074, 6077, 2013}, {6080, 6089, 6094, 6101, 1797, 6111, 6120, 6127, 6137, 6147, 1587, 6160, 343}, {6170, 6174, 1862, 6178, 1797, 6182, 6186, 6190, 6194, 6198, 6203, 6207, 343}, 0, 1, 344, 346, {348,5515,5996},{357,876},{370},{376,438}},
-       {16412, 3024, 37, 438, 370, 3057, 3062, 465, 468, {3084, 6244, 6258, 6271, 6284, 6297, 3131}, {3139, 6309, 6313, 6317, 6321, 6325, 3160}, {6329, 6337, 6347, 1004, 6354, 6359, 6365, 3202, 6371, 6380, 6388, 6397, 343}, {1854, 6406, 1862, 3244, 3772, 1870, 1874, 3252, 4946, 6410, 1890, 6414, 343}, 0, 0, 344, 346, {348,1676,888,37},{357,3024},{370},{376,16443,438}},
-       {5975, 876, 1929, 438, 370, 447, 74, 465, 468, {6418, 6428, 6433, 6440, 6449, 6453, 6460}, {6471, 6473, 6475, 2022, 6478, 1617, 6480}, {6482, 6491, 6501, 6508, 3772, 6516, 6522, 1811, 6528, 6539, 6549, 6559, 343}, {6569, 2122, 2900, 2130, 2061, 6573, 6577, 2142, 2146, 2904, 2154, 2908, 343}, 0, 1, 344, 346, {348,1929},{357,876},{370},{376,438}},
-       {6581, 6607, 1929, 2982, 1409, 6625, 74, 465, 468, {6641, 6664, 505, 6687, 6698, 6713, 6728}, {6743, 6748, 6753, 6758, 6763, 6768, 6773}, {6778, 6791, 6806, 6815, 6828, 6835, 6844, 6853, 6866, 6883, 6898, 6911, 343}, {6926, 6933, 6940, 6947, 678, 6954, 6961, 6968, 6975, 6982, 6989, 6996, 343}, 0, 1, 344, 346, {348,844,1929},{357,6607},{370,1409},{376,1399,2982}},
-       {7003, 7025, 3314, 2982, 370, 4272, 1146, 465, 468, {7039, 7048, 7060, 7067, 7075, 7085, 7091}, {7098, 7102, 7106, 7110, 7114, 7119, 7123}, {7127, 7137, 7146, 7154, 7162, 7170, 7177, 7184, 7192, 1587, 7198, 7206, 343}, {7215, 7219, 7223, 7228, 7232, 6186, 7236, 7240, 7244, 6203, 7248, 7252, 343}, 0, 1, 344, 346, {348,7256,3314},{357,7025},{370},{376,2982}},
-       {7267, 1379, 7288, 2982, 1409, 447, 1414, 465, 468, {7299, 7307, 7316, 7323, 7330, 7339, 7346}, {7353, 7356, 7359, 7362, 7365, 7369, 2013}, {4373, 4381, 7372, 4672, 7378, 4725, 4730, 1811, 1818, 4452, 1836, 1845, 343}, {1854, 1858, 1862, 1866, 7378, 4725, 4730, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,3314,7288},{357,1379},{370,1409},{376,1399,2982}},
-       {7383, 409, 5996, 7407, 7418, 447, 457, 7425, 7428, {7431, 7438, 7447, 7456, 7468, 7476, 7485}, {7495, 7499, 2900, 7504, 7509, 7513, 7517}, {7521, 7527, 3761, 7534, 1797, 7540, 7548, 7555, 7561, 7569, 7575, 7583, 343}, {2118, 7591, 2900, 7595, 7599, 7603, 7607, 7611, 7517, 7615, 7619, 7624, 343}, 0, 1, 344, 346, {348,5515,5996},{357,409},{370,7418},{376,7628,7407}},
-       {16460, 7668, 5996, 438, 370, 447, 74, 7685, 7688, {7691, 7699, 7707, 1710, 1717, 1725, 7714}, {7722, 7726, 3421, 5965, 3427, 5968, 7730}, {5880, 5888, 3761, 1791, 1797, 1801, 1806, 7734, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 1862, 1866, 1797, 1870, 1874, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,5996},{357,7668},{370,5955},{376,5944,438}},
-       {7742, 876, 37, 2982, 1409, 447, 74, 7763, 7794, {7825, 7856, 7884, 7912, 7931, 7965, 7990}, {8015, 8023, 8028, 8033, 8038, 8046, 8051}, {8056, 8075, 8106, 8125, 8144, 8166, 8191, 8213, 8235, 8257, 8276, 8304, 343}, {8326, 8335, 8344, 8356, 8368, 8377, 8389, 8398, 8407, 8416, 8425, 8434, 343}, 0, 0, 344, 346, {348,37},{357,876},{370,1409},{376,8443,2982}},
-       {8483, 8510, 1929, 438, 370, 447, 457, 465, 468, {8528, 8534, 8544, 8550, 8561, 8571, 8576}, {8586, 8590, 8594, 8598, 8603, 8607, 8611}, {8615, 8620, 8627, 8632, 8638, 8645, 8653, 8660, 8669, 8676, 8681, 8688, 343}, {8696, 8700, 2900, 8705, 2869, 8709, 8713, 8717, 8722, 8726, 8730, 8734, 343}, 0, 1, 344, 346, {348,1929},{357,8510},{370},{376,438}},
-       {16486, 409, 2665, 2982, 1409, 447, 457, 465, 468, {8738, 8745, 8751, 8758, 8763, 8769, 8775}, {8781, 8785, 8789, 8793, 8797, 8801, 8805}, {8809, 8817, 8826, 2055, 8832, 2065, 2070, 8836, 2082, 2092, 2100, 8844, 343}, {2118, 2122, 2900, 2130, 8832, 2134, 2138, 8853, 2146, 2150, 2154, 8857, 343}, 0, 0, 344, 346, {348,888,2665},{357,409},{370,1409},{376,2982}},
-       {8861, 876, 1929, 2982, 370, 8881, 74, 465, 468, {8897, 8910, 8929, 8946, 8959, 8972, 8988}, {9001, 6748, 6753, 6758, 6763, 6768, 6773}, {9006, 9017, 9030, 9045, 9058, 9071, 9084, 9095, 9108, 9123, 9136, 9155, 343}, {9168, 9175, 9182, 9189, 9198, 9207, 9216, 9223, 9232, 9239, 9248, 9257, 343}, 0, 1, 344, 346, {348,844,1929},{357,876},{370},{376,2982}},
-       {8861, 876, 1929, 2982, 5955, 447, 74, 465, 468, {9289, 9304, 9325, 9340, 9353, 9366, 9381}, {9394, 9399, 9404, 9409, 9414, 9419, 9424}, {9429, 9446, 9455, 9470, 678, 9487, 9502, 9515, 9530, 9547, 9568, 9585, 343}, {9600, 9175, 9607, 9614, 678, 9621, 9628, 9635, 9232, 9642, 9649, 9656, 343}, 0, 1, 344, 346, {348,1392,1929},{357,876},{370,5955},{376,5944,2982}},
-       {9663, 9685, 3314, 2982, 1409, 447, 9699, 465, 468, {9708, 9716, 9727, 9733, 9739, 9748, 1482}, {7098, 7102, 1757, 9754, 7114, 7119, 9758}, {1770, 1777, 7372, 1791, 1797, 9762, 9768, 9774, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 1862, 1866, 1797, 1870, 1874, 9781, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,9785,3314},{357,9685},{370,1409},{376,1399,2982}},
-       {8861, 876, 9792, 2982, 1409, 447, 9802, 465, 468, {9810, 9821, 9832, 9843, 9854, 9865, 9871}, {4367, 9880, 9882, 4358, 6062, 9884, 6473}, {9886, 9894, 9903, 9910, 3772, 9917, 9923, 1811, 1818, 9929, 1836, 9938, 343}, {9948, 9953, 9903, 1866, 3772, 9917, 9923, 1878, 9959, 1886, 1890, 9964, 343}, 0, 1, 344, 346, {348,844,9792},{357,876},{370,1409},{376,1399,2982}},
-       {9969, 9998, 4525, 2982, 370, 10019, 1414, 465, 468, {10037, 10048, 10058, 10067, 10078, 10090, 10101}, {10111, 4367, 10114, 9882, 10116, 10118, 6480}, {10121, 10131, 1785, 10142, 10151, 10157, 10165, 10173, 10181, 10192, 10201, 10211, 343}, {2118, 2122, 2900, 2130, 2061, 10221, 10226, 2142, 2146, 2150, 2154, 2908, 343}, 0, 1, 344, 346, {348,10231,4525},{357,9998},{370},{376,2982}},
-       {16507, 10271, 7256, 438, 370, 10293, 10308, 465, 468, {10320, 10332, 10344, 10356, 10370, 10385, 10398}, {10412, 10415, 10418, 10421, 10424, 6064, 7365}, {10427, 10434, 10442, 10447, 10458, 10468, 10478, 10485, 10497, 10506, 10513, 10524, 343}, {10534, 10538, 10542, 10546, 10550, 10554, 10558, 10562, 10566, 10570, 10574, 10578, 343}, 0, 1, 344, 346, {348,7256},{357,10271},{370},{376,438}},
-       {10582, 876, 10606, 2970, 370, 447, 74, 10615, 10622, {10629, 10645, 10658, 10674, 10691, 10709, 10718}, {10727, 10731, 10735, 10739, 10743, 10747, 10751}, {10755, 10768, 229, 10779, 10790, 10795, 10804, 10815, 10822, 10837, 10848, 10861, 343}, {10874, 10881, 10888, 10895, 10902, 10909, 10916, 10815, 10923, 10930, 10937, 10944, 343}, 0, 6, 344, 346, {348,10951,10606},{357,876},{370},{376,10961,2970}},
-       {10974, 409, 2665, 2186, 370, 447, 457, 10998, 11001, {11004, 11017, 11027, 11036, 11046, 11057, 11068}, {11080, 11083, 11088, 11093, 11098, 11103, 11108}, {11113, 11126, 11137, 11147, 11158, 11170, 11182, 11195, 11207, 11220, 11235, 11256, 343}, {11275, 11281, 11287, 11293, 11299, 11305, 11311, 11317, 11323, 11329, 11336, 11343, 343}, 0, 1, 344, 346, {348,2665},{357,409},{370},{376,2186}},
-       {11350, 2912, 1929, 2982, 370, 447, 2754, 11372, 16538, {11388, 11401, 11422, 11441, 11462, 11481, 11494}, {11505, 11512, 11519, 11526, 11533, 11540, 11547}, {16546, 16561, 11588, 11597, 11608, 16576, 16589, 11645, 11660, 11679, 11698, 11715, 343}, {16602, 16609, 11748, 11755, 11762, 16616, 16623, 11783, 11790, 11797, 11804, 11811, 343}, 0, 1, 344, 346, {348,11818,1929},{357,2912},{370},{376,2982}},
-       {16630, 16669, 5006, 438, 370, 16699, 1146, 465, 468, {11827, 11835, 11846, 11856, 11867, 11876, 11885}, {11895, 11898, 11901, 11904, 11907, 11910, 11913}, {11916, 11926, 11934, 11942, 11950, 11958, 11965, 11973, 11981, 11988, 11994, 12001, 343}, {12009, 12013, 1862, 12017, 3772, 12021, 12025, 12029, 12033, 12037, 12041, 12045, 343}, 0, 1, 344, 346, {348,16714,5006},{357,16669},{370},{376,438}},
-       {387, 409, 1929, 438, 370, 447, 457, 465, 468, {12049, 484, 505, 6687, 12062, 12079, 12090}, {574, 582, 590, 12103, 12111, 612, 12119}, {12127, 641, 658, 667, 12142, 12149, 12158, 699, 712, 731, 748, 763, 343}, {12167, 786, 12175, 794, 12183, 12191, 12199, 802, 12207, 818, 826, 12217, 343}, 0, 1, 344, 346, {348,12229,1929},{357,409},{370},{376,438}},
-       {16727, 409, 5006, 2970, 56, 447, 457, 343, 343, {12243, 12250, 12258, 12266, 12275, 12285, 12292}, {2013, 6475, 2019, 12301, 2025, 12304, 2031}, {12307, 12316, 12326, 2055, 8832, 12332, 12338, 12344, 2082, 2092, 2100, 8844, 343}, {2118, 2122, 2900, 2130, 8832, 2134, 2138, 2142, 2146, 2150, 2154, 8857, 343}, 0, 0, 344, 346, {348,5006},{357,409},{370,56},{376,46,2970}},
-       {16752, 16792, 1929, 2982, 1409, 12382, 1146, 12389, 12405, {5217, 5219, 5221, 5223, 5225, 5227, 5229}, {5217, 5219, 5221, 5223, 5225, 5227, 5229}, {5217, 5219, 5221, 5223, 5225, 5227, 5229, 5231, 5233, 5235, 5238, 5241, 343}, {5217, 5219, 5221, 5223, 5225, 5227, 5229, 5231, 5233, 5235, 5238, 5241, 343}, 0, 0, 344, 346, {348,1929},{357,12373,16792},{370,1409},{376,2982}},
-       {16824, 1664, 1676, 16845, 370, 447, 457, 465, 468, {4537, 12450, 12461, 12471, 12481, 12491, 12505}, {4623, 4627, 12517, 12522, 12526, 12531, 12536}, {1770, 1777, 3761, 4672, 3772, 1801, 1806, 1811, 1818, 1828, 1836, 4716, 343}, {1854, 1858, 1862, 1866, 3772, 1870, 1874, 1878, 1882, 1886, 1890, 4746, 343}, 0, 0, 344, 346, {348,1898,1676},{357,1664},{370},{376,16845}},
-       {5975, 876, 1676, 438, 56, 447, 74, 12540, 12568, {12590, 12609, 12628, 12650, 12669, 12691, 12716}, {12735, 12745, 12755, 12768, 12778, 12791, 12807}, {12817, 12833, 12849, 12865, 12884, 12891, 12901, 12917, 12933, 12955, 12977, 12996, 343}, {12817, 12833, 12849, 12865, 12884, 12891, 12901, 12917, 12933, 12955, 12977, 12996, 343}, 0, 0, 344, 346, {348,5796,1676},{357,876},{370,56},{376,2676,438}},
-       {16854, 357, 10606, 16878, 370, 1136, 1146, 465, 468, {13018, 13027, 13036, 13044, 13053, 13062, 13069}, {13078, 13082, 13086, 13090, 13094, 13098, 13102}, {8809, 8817, 13106, 13112, 8832, 2065, 13119, 13125, 13132, 13141, 13148, 13156, 343}, {2118, 2122, 2900, 2130, 8832, 2134, 2138, 13164, 2146, 2150, 2154, 8857, 343}, 0, 6, 344, 346, {348,10606},{357},{370},{376,16878}},
+       {5984, 876, 2674, 438, 370, 447, 457, 465, 468, {897, 906, 914, 922, 931, 938, 948}, {957, 961, 965, 969, 973, 977, 981}, {985, 991, 998, 1004, 1010, 1015, 1020, 1027, 1033, 1042, 1050, 1059, 343}, {1068, 1073, 998, 1078, 1010, 1015, 1083, 1088, 1092, 1097, 1102, 1107, 343}, 0, 1, 344, 346, {348,888,2674},{357,876},{370},{376,438}},
+       {15896, 4993, 5260, 15941, 15964, 5026, 5042, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, 0, 0, 344, 346, {348,5260},{357,4993},{370,15964},{376,15941}},
+       {7276, 1379, 3323, 2991, 1409, 447, 1414, 1422, 1427, {1432, 1440, 1450, 1458, 1466, 1475, 1482}, {1489, 1492, 1495, 1499, 1502, 1506, 1510}, {1513, 1519, 1525, 1533, 1539, 1547, 1555, 1565, 1571, 1579, 1587, 1596, 343}, {1605, 1607, 1610, 1614, 1617, 1619, 1622, 1626, 1631, 1634, 1636, 1639, 343}, 0, 1, 344, 346, {348,1392,3323},{357,1379},{370,1409},{376,1399,2991}},
+       {1643, 1664, 1676, 438, 370, 447, 1687, 465, 468, {1696, 1704, 1711, 1719, 1726, 1734, 1741}, {1749, 1754, 1758, 1762, 1766, 1770, 1774}, {1779, 1786, 1794, 1800, 1806, 1810, 1815, 1820, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 1871, 1875, 1806, 1879, 1883, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,1907,1676},{357,1664},{370},{376,438}},
+       {1916, 1379, 1938, 438, 370, 447, 1414, 1949, 1955, {1962, 1970, 1977, 1986, 1995, 2006, 2014}, {2022, 2025, 2028, 2031, 2034, 2037, 2040}, {2043, 2050, 2058, 2064, 2070, 2074, 2079, 2084, 2091, 2101, 2109, 2118, 343}, {2127, 2131, 2135, 2139, 2070, 2143, 2147, 2151, 2155, 2159, 2163, 2167, 343}, 0, 1, 344, 346, {348,844,1938},{357,1379},{370},{376,438}},
+       {2171, 409, 37, 2195, 56, 447, 457, 2206, 2211, {2216, 2231, 2246, 2257, 2272, 2285, 2304}, {2319, 2326, 2333, 2340, 2347, 2354, 2361}, {2368, 2389, 2412, 2427, 2444, 2455, 2470, 2485, 2504, 2527, 2546, 2565, 343}, {2586, 2593, 2600, 2607, 2614, 2621, 2630, 2639, 2646, 2653, 2660, 2667, 343}, 0, 1, 344, 346, {348,2674,37},{357,409},{370,56},{376,2685,2195}},
+       {2697, 2728, 10606, 2195, 2755, 63, 2763, 465, 468, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 0, 344, 346, {10606,10606,2748,2748,11818,3055,348,6005,15971},{2728,2728,2921,2935,2955},{2755,2755,2970,1409,370},{2195,2195,2979,2991,438}},
+       {3281, 3306, 3323, 2991, 370, 3332, 3345, 465, 468, {3357, 3367, 3377, 3385, 3397, 3405, 3415}, {3424, 3427, 3430, 3433, 3436, 3439, 3442}, {3445, 3454, 3463, 3473, 3482, 3491, 3500, 3510, 3517, 3525, 3533, 3543, 343}, {3552, 3558, 3564, 3571, 3577, 3583, 3589, 3596, 3600, 3605, 3610, 3617, 343}, 0, 1, 344, 346, {348,3323},{357,3306},{370},{376,2991}},
+       {3623, 3649, 2674, 438, 370, 447, 74, 465, 468, {3666, 3675, 3681, 3687, 3696, 3702, 3711}, {3718, 3723, 3728, 3733, 3738, 3743, 3748}, {3753, 3761, 3770, 3775, 3781, 3785, 3790, 3798, 3804, 3814, 1050, 3822, 343}, {3832, 3838, 3770, 3845, 3781, 3785, 3850, 3798, 3856, 1097, 1102, 3862, 343}, 0, 1, 344, 346, {888,3868,3273,2674},{357,876,3649},{370},{376,438}},
+       {3878, 876, 2674, 438, 370, 447, 74, 465, 468, {3899, 3917, 3931, 3949, 3967, 3985, 4001}, {4008, 4011, 4014, 4017, 4020, 4023, 4026}, {4029, 4040, 4053, 4060, 4071, 4078, 4087, 4096, 4109, 4122, 4137, 4150, 343}, {4161, 4168, 4053, 4175, 4071, 4182, 4189, 4196, 4203, 4210, 4217, 4224, 343}, 0, 0, 344, 346, {348,888,2674},{357,876},{370},{376,438}},
+       {4231, 4253, 4267, 2991, 1409, 4281, 4292, 4300, 4303, {4306, 4316, 4324, 4329, 4336, 4349, 4357}, {1617, 4365, 4367, 4369, 4373, 4376, 4378}, {4382, 4390, 4399, 4408, 4417, 4424, 4432, 4440, 4450, 4461, 1845, 1854, 343}, {4470, 4475, 4481, 4488, 4494, 4500, 4506, 4512, 4517, 4524, 1102, 4529, 343}, 0, 1, 344, 346, {348,4534,4267},{357,4253},{370,1409},{376,1399,2991}},
+       {1916, 1379, 3323, 438, 370, 447, 1414, 465, 468, {4546, 4557, 4568, 4582, 4596, 4608, 4620}, {4632, 4636, 4641, 4646, 4651, 4655, 4660}, {4664, 4672, 3770, 4681, 4688, 4693, 4700, 4707, 1827, 4461, 4715, 4725, 343}, {1863, 1867, 1871, 1875, 4688, 4734, 4739, 4744, 1891, 1895, 4750, 4755, 343}, 0, 0, 344, 346, {348,3323},{357,1379},{370},{376,438}},
+       {15981, 409, 2674, 16002, 370, 447, 74, 4783, 4786, {4789, 4798, 4806, 4815, 4826, 4835, 4844}, {3148, 3152, 1871, 4851, 4855, 4859, 4863}, {4867, 4875, 3188, 4884, 4891, 4898, 4905, 3211, 4912, 4922, 1050, 4930, 343}, {4939, 1867, 1871, 1875, 4943, 4947, 4951, 3261, 4955, 4959, 1899, 3269, 343}, 0, 1, 344, 346, {348,888,2674},{357,409},{370},{376,1399,16002}},
+       {4963, 4993, 5015, 2991, 1409, 5026, 5042, 5055, 5062, {5069, 5079, 5089, 5099, 5109, 5119, 5129}, {1238, 5139, 5143, 5147, 5151, 5155, 5159}, {5163, 5168, 5173, 5178, 5183, 5188, 5193, 5198, 5203, 5208, 5214, 5220, 343}, {5226, 5228, 5230, 5232, 5234, 5236, 5238, 5240, 5242, 5244, 5247, 5250, 343}, 0, 0, 344, 346, {5015,5015,348,5253,5260,5269,5288,5305},{4993,4993,5324,5348,5375},{1409,1409,370,5404,5412},{2991,438,5421,5432}},
+       {16010, 16060, 5015, 16084, 5404, 5577, 5594, 5608, 5615, {5622, 5632, 5642, 5652, 5662, 5672, 5682}, {5692, 5696, 5700, 5704, 5708, 5712, 5716}, {5720, 5725, 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5771, 5777, 343}, {5720, 5725, 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5771, 5777, 343}, 0, 0, 344, 346, {5015,5015,348,5253,5260,16110,16123},{16060,16060,16134,16160,16182},{5404,1409,370,16206,16220,16235,5404,5412,16251,16268,16286},{16084,16084,16305,16327,2991,438,16351,16376,5421,5432}},
+       {8870, 876, 16403, 2991, 1409, 447, 74, 465, 468, {5812, 5819, 5827, 5835, 5844, 5854, 5862}, {5871, 3427, 5874, 5877, 5880, 5883, 5886}, {5889, 5897, 5906, 1800, 5912, 1810, 1815, 5916, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 5925, 1875, 5912, 1879, 1883, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,5805,16403},{357,876},{370,1409},{376,1399,2991}},
+       {5929, 1379, 844, 5953, 5964, 447, 1414, 465, 468, {1696, 1704, 1711, 1719, 1726, 1734, 1741}, {5970, 3427, 3430, 5974, 3436, 5977, 5980}, {1779, 1786, 3770, 1800, 3781, 1810, 1815, 1820, 1827, 1837, 1845, 4725, 343}, {1863, 1867, 1871, 1875, 3781, 1879, 1883, 1887, 1891, 1895, 1899, 4755, 343}, 0, 1, 344, 346, {348,844},{357,1379},{370,5964},{376,5953}},
+       {5984, 876, 6005, 438, 370, 447, 74, 465, 468, {6016, 6026, 6040, 6047, 6054, 6063, 1482}, {6071, 6073, 6076, 6079, 6083, 6086, 2022}, {6089, 6098, 6103, 6110, 1806, 6120, 6129, 6136, 6146, 6156, 1587, 6169, 343}, {6179, 6183, 1871, 6187, 1806, 6191, 6195, 6199, 6203, 6207, 6212, 6216, 343}, 0, 1, 344, 346, {348,5524,6005},{357,876},{370},{376,438}},
+       {16412, 3033, 37, 438, 370, 3066, 3071, 465, 468, {3093, 6253, 6267, 6280, 6293, 6306, 3140}, {3148, 6318, 6322, 6326, 6330, 6334, 3169}, {6338, 6346, 6356, 1004, 6363, 6368, 6374, 3211, 6380, 6389, 6397, 6406, 343}, {1863, 6415, 1871, 3253, 3781, 1879, 1883, 3261, 4955, 6419, 1899, 6423, 343}, 0, 0, 344, 346, {348,1676,888,37},{357,3033},{370},{376,16443,438}},
+       {5984, 876, 1938, 438, 370, 447, 74, 465, 468, {6427, 6437, 6442, 6449, 6458, 6462, 6469}, {6480, 6482, 6484, 2031, 6487, 1617, 6489}, {6491, 6500, 6510, 6517, 3781, 6525, 6531, 1820, 6537, 6548, 6558, 6568, 343}, {6578, 2131, 2909, 2139, 2070, 6582, 6586, 2151, 2155, 2913, 2163, 2917, 343}, 0, 1, 344, 346, {348,1938},{357,876},{370},{376,438}},
+       {6590, 6616, 1938, 2991, 1409, 6634, 74, 465, 468, {6650, 6673, 505, 6696, 6707, 6722, 6737}, {6752, 6757, 6762, 6767, 6772, 6777, 6782}, {6787, 6800, 6815, 6824, 6837, 6844, 6853, 6862, 6875, 6892, 6907, 6920, 343}, {6935, 6942, 6949, 6956, 678, 6963, 6970, 6977, 6984, 6991, 6998, 7005, 343}, 0, 1, 344, 346, {348,844,1938},{357,6616},{370,1409},{376,1399,2991}},
+       {7012, 7034, 3323, 2991, 370, 4281, 1146, 465, 468, {7048, 7057, 7069, 7076, 7084, 7094, 7100}, {7107, 7111, 7115, 7119, 7123, 7128, 7132}, {7136, 7146, 7155, 7163, 7171, 7179, 7186, 7193, 7201, 1587, 7207, 7215, 343}, {7224, 7228, 7232, 7237, 7241, 6195, 7245, 7249, 7253, 6212, 7257, 7261, 343}, 0, 1, 344, 346, {348,7265,3323},{357,7034},{370},{376,2991}},
+       {7276, 1379, 7297, 2991, 1409, 447, 1414, 465, 468, {7308, 7316, 7325, 7332, 7339, 7348, 7355}, {7362, 7365, 7368, 7371, 7374, 7378, 2022}, {4382, 4390, 7381, 4681, 7387, 4734, 4739, 1820, 1827, 4461, 1845, 1854, 343}, {1863, 1867, 1871, 1875, 7387, 4734, 4739, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,3323,7297},{357,1379},{370,1409},{376,1399,2991}},
+       {7392, 409, 6005, 7416, 7427, 447, 457, 7434, 7437, {7440, 7447, 7456, 7465, 7477, 7485, 7494}, {7504, 7508, 2909, 7513, 7518, 7522, 7526}, {7530, 7536, 3770, 7543, 1806, 7549, 7557, 7564, 7570, 7578, 7584, 7592, 343}, {2127, 7600, 2909, 7604, 7608, 7612, 7616, 7620, 7526, 7624, 7628, 7633, 343}, 0, 1, 344, 346, {348,5524,6005},{357,409},{370,7427},{376,7637,7416}},
+       {16460, 7677, 6005, 438, 370, 447, 74, 7694, 7697, {7700, 7708, 7716, 1719, 1726, 1734, 7723}, {7731, 7735, 3430, 5974, 3436, 5977, 7739}, {5889, 5897, 3770, 1800, 1806, 1810, 1815, 7743, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 1871, 1875, 1806, 1879, 1883, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,6005},{357,7677},{370,5964},{376,5953,438}},
+       {7751, 876, 37, 2991, 1409, 447, 74, 7772, 7803, {7834, 7865, 7893, 7921, 7940, 7974, 7999}, {8024, 8032, 8037, 8042, 8047, 8055, 8060}, {8065, 8084, 8115, 8134, 8153, 8175, 8200, 8222, 8244, 8266, 8285, 8313, 343}, {8335, 8344, 8353, 8365, 8377, 8386, 8398, 8407, 8416, 8425, 8434, 8443, 343}, 0, 0, 344, 346, {348,37},{357,876},{370,1409},{376,8452,2991}},
+       {8492, 8519, 1938, 438, 370, 447, 457, 465, 468, {8537, 8543, 8553, 8559, 8570, 8580, 8585}, {8595, 8599, 8603, 8607, 8612, 8616, 8620}, {8624, 8629, 8636, 8641, 8647, 8654, 8662, 8669, 8678, 8685, 8690, 8697, 343}, {8705, 8709, 2909, 8714, 2878, 8718, 8722, 8726, 8731, 8735, 8739, 8743, 343}, 0, 1, 344, 346, {348,1938},{357,8519},{370},{376,438}},
+       {16486, 409, 2674, 2991, 1409, 447, 457, 465, 468, {8747, 8754, 8760, 8767, 8772, 8778, 8784}, {8790, 8794, 8798, 8802, 8806, 8810, 8814}, {8818, 8826, 8835, 2064, 8841, 2074, 2079, 8845, 2091, 2101, 2109, 8853, 343}, {2127, 2131, 2909, 2139, 8841, 2143, 2147, 8862, 2155, 2159, 2163, 8866, 343}, 0, 0, 344, 346, {348,888,2674},{357,409},{370,1409},{376,2991}},
+       {8870, 876, 1938, 2991, 370, 8890, 74, 465, 468, {8906, 8919, 8938, 8955, 8968, 8981, 8997}, {9010, 6757, 6762, 6767, 6772, 6777, 6782}, {9015, 9026, 9039, 9054, 9067, 9080, 9093, 9104, 9117, 9132, 9145, 9164, 343}, {9177, 9184, 9191, 9198, 9207, 9216, 9225, 9232, 9241, 9248, 9257, 9266, 343}, 0, 1, 344, 346, {348,844,1938},{357,876},{370},{376,2991}},
+       {8870, 876, 1938, 2991, 5964, 447, 74, 465, 468, {9298, 9313, 9334, 9349, 9362, 9375, 9390}, {9403, 9408, 9413, 9418, 9423, 9428, 9433}, {9438, 9455, 9464, 9479, 678, 9496, 9511, 9524, 9539, 9556, 9577, 9594, 343}, {9609, 9184, 9616, 9623, 678, 9630, 9637, 9644, 9241, 9651, 9658, 9665, 343}, 0, 1, 344, 346, {348,1392,1938},{357,876},{370,5964},{376,5953,2991}},
+       {9672, 9694, 3323, 2991, 1409, 447, 1687, 465, 468, {9708, 9716, 9727, 9733, 9739, 9748, 1482}, {7107, 7111, 1766, 9754, 7123, 7128, 9758}, {1779, 1786, 7381, 1800, 1806, 9762, 9768, 9774, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 1871, 1875, 1806, 1879, 1883, 9781, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,9785,3323},{357,9694},{370,1409},{376,1399,2991}},
+       {8870, 876, 9792, 2991, 1409, 447, 9802, 465, 468, {9810, 9821, 9832, 9843, 9854, 9865, 9871}, {4376, 9880, 9882, 4367, 6071, 9884, 6482}, {9886, 9894, 9903, 9910, 3781, 9917, 9923, 1820, 1827, 9929, 1845, 9938, 343}, {9948, 9953, 9903, 1875, 3781, 9917, 9923, 1887, 9959, 1895, 1899, 9964, 343}, 0, 1, 344, 346, {348,844,9792},{357,876},{370,1409},{376,1399,2991}},
+       {9969, 9998, 4534, 2991, 370, 10019, 1414, 465, 468, {10037, 10048, 10058, 10067, 10078, 10090, 10101}, {10111, 4376, 10114, 9882, 10116, 10118, 6489}, {10121, 10131, 1794, 10142, 10151, 10157, 10165, 10173, 10181, 10192, 10201, 10211, 343}, {2127, 2131, 2909, 2139, 2070, 10221, 10226, 2151, 2155, 2159, 2163, 2917, 343}, 0, 1, 344, 346, {348,10231,4534},{357,9998},{370},{376,2991}},
+       {16507, 10271, 7265, 438, 370, 10293, 10308, 465, 468, {10320, 10332, 10344, 10356, 10370, 10385, 10398}, {10412, 10415, 10418, 10421, 10424, 6073, 7374}, {10427, 10434, 10442, 10447, 10458, 10468, 10478, 10485, 10497, 10506, 10513, 10524, 343}, {10534, 10538, 10542, 10546, 10550, 10554, 10558, 10562, 10566, 10570, 10574, 10578, 343}, 0, 1, 344, 346, {348,7265},{357,10271},{370},{376,438}},
+       {10582, 876, 10606, 2979, 370, 447, 74, 10615, 10622, {10629, 10645, 10658, 10674, 10691, 10709, 10718}, {10727, 10731, 10735, 10739, 10743, 10747, 10751}, {10755, 10768, 229, 10779, 10790, 10795, 10804, 10815, 10822, 10837, 10848, 10861, 343}, {10874, 10881, 10888, 10895, 10902, 10909, 10916, 10815, 10923, 10930, 10937, 10944, 343}, 0, 6, 344, 346, {348,10951,10606},{357,876},{370},{376,10961,2979}},
+       {10974, 409, 2674, 2195, 370, 447, 457, 10998, 11001, {11004, 11017, 11027, 11036, 11046, 11057, 11068}, {11080, 11083, 11088, 11093, 11098, 11103, 11108}, {11113, 11126, 11137, 11147, 11158, 11170, 11182, 11195, 11207, 11220, 11235, 11256, 343}, {11275, 11281, 11287, 11293, 11299, 11305, 11311, 11317, 11323, 11329, 11336, 11343, 343}, 0, 1, 344, 346, {348,2674},{357,409},{370},{376,2195}},
+       {11350, 2921, 1938, 2991, 370, 447, 2763, 11372, 16538, {11388, 11401, 11422, 11441, 11462, 11481, 11494}, {11505, 11512, 11519, 11526, 11533, 11540, 11547}, {16546, 16561, 11588, 11597, 11608, 16576, 16589, 11645, 11660, 11679, 11698, 11715, 343}, {16602, 16609, 11748, 11755, 11762, 16616, 16623, 11783, 11790, 11797, 11804, 11811, 343}, 0, 1, 344, 346, {348,11818,1938},{357,2921},{370},{376,2991}},
+       {16630, 16669, 5015, 438, 370, 16699, 1146, 465, 468, {11827, 11835, 11846, 11856, 11867, 11876, 11885}, {11895, 11898, 11901, 11904, 11907, 11910, 11913}, {11916, 11926, 11934, 11942, 11950, 11958, 11965, 11973, 11981, 11988, 11994, 12001, 343}, {12009, 12013, 1871, 12017, 3781, 12021, 12025, 12029, 12033, 12037, 12041, 12045, 343}, 0, 1, 344, 346, {348,16714,5015},{357,16669},{370},{376,438}},
+       {387, 409, 1938, 438, 370, 447, 457, 465, 468, {12049, 484, 505, 6696, 12062, 12079, 12090}, {574, 582, 590, 12103, 12111, 612, 12119}, {12127, 641, 658, 667, 12142, 12149, 12158, 699, 712, 731, 748, 763, 343}, {12167, 786, 12175, 794, 12183, 12191, 12199, 802, 12207, 818, 826, 12217, 343}, 0, 1, 344, 346, {348,12229,1938},{357,409},{370},{376,438}},
+       {16727, 409, 5015, 2979, 56, 447, 457, 343, 343, {12243, 12250, 12258, 12266, 12275, 12285, 12292}, {2022, 6484, 2028, 12301, 2034, 12304, 2040}, {12307, 12316, 12326, 2064, 8841, 12332, 12338, 12344, 2091, 2101, 2109, 8853, 343}, {2127, 2131, 2909, 2139, 8841, 2143, 2147, 2151, 2155, 2159, 2163, 8866, 343}, 0, 0, 344, 346, {348,5015},{357,409},{370,56},{376,46,2979}},
+       {16752, 16792, 1938, 2991, 1409, 12382, 1146, 12389, 12405, {5226, 5228, 5230, 5232, 5234, 5236, 5238}, {5226, 5228, 5230, 5232, 5234, 5236, 5238}, {5226, 5228, 5230, 5232, 5234, 5236, 5238, 5240, 5242, 5244, 5247, 5250, 343}, {5226, 5228, 5230, 5232, 5234, 5236, 5238, 5240, 5242, 5244, 5247, 5250, 343}, 0, 0, 344, 346, {348,1938},{357,12373,16792},{370,1409},{376,2991}},
+       {16824, 1664, 1676, 16845, 370, 447, 457, 465, 468, {4546, 12450, 12461, 12471, 12481, 12491, 12505}, {4632, 4636, 12517, 12522, 12526, 12531, 12536}, {1779, 1786, 3770, 4681, 3781, 1810, 1815, 1820, 1827, 1837, 1845, 4725, 343}, {1863, 1867, 1871, 1875, 3781, 1879, 1883, 1887, 1891, 1895, 1899, 4755, 343}, 0, 0, 344, 346, {348,1907,1676},{357,1664},{370},{376,16845}},
+       {5984, 876, 1676, 438, 56, 447, 74, 12540, 12568, {12590, 12609, 12628, 12650, 12669, 12691, 12716}, {12735, 12745, 12755, 12768, 12778, 12791, 12807}, {12817, 12833, 12849, 12865, 12884, 12891, 12901, 12917, 12933, 12955, 12977, 12996, 343}, {12817, 12833, 12849, 12865, 12884, 12891, 12901, 12917, 12933, 12955, 12977, 12996, 343}, 0, 0, 344, 346, {348,5805,1676},{357,876},{370,56},{376,2685,438}},
+       {16854, 357, 10606, 16878, 370, 1136, 1146, 465, 468, {13018, 13027, 13036, 13044, 13053, 13062, 13069}, {13078, 13082, 13086, 13090, 13094, 13098, 13102}, {8818, 8826, 13106, 13112, 8841, 2074, 13119, 13125, 13132, 13141, 13148, 13156, 343}, {2127, 2131, 2909, 2139, 8841, 2143, 2147, 13164, 2155, 2159, 2163, 8866, 343}, 0, 6, 344, 346, {348,10606},{357},{370},{376,16878}},
        {16889, 876, 16914, 16922, 16935, 447, 74, 13168, 13210, {13252, 13271, 13290, 13312, 13331, 13353, 13378}, {13397, 13407, 13417, 13430, 13440, 13453, 13469}, {13479, 13507, 13535, 13551, 13570, 13577, 13587, 13603, 13619, 13647, 13669, 13691, 343}, {13716, 13735, 13535, 13551, 13570, 13577, 13587, 13603, 13754, 13770, 13786, 13796, 343}, 0, 0, 344, 346, {348,16914},{357,876},{370,16935},{376,16922}},
-       {16943, 876, 5796, 2676, 56, 447, 74, 13809, 13822, {13835, 13854, 13876, 13901, 13917, 13939, 13958}, {13968, 13975, 13982, 13989, 13996, 14003, 14010}, {14014, 14030, 14055, 14074, 14093, 14100, 14113, 14126, 14145, 14176, 14201, 14223, 343}, {14248, 14256, 14270, 14284, 14093, 14100, 14113, 14295, 14303, 14317, 14328, 14336, 343}, 0, 0, 344, 346, {348,5796},{357,876},{370,56},{376,2676}},
-       {16943, 876, 1898, 2676, 56, 447, 74, 14347, 14375, {14397, 14419, 14441, 14466, 14488, 14513, 14541}, {14563, 14573, 14583, 14596, 14606, 14619, 14635}, {14645, 14661, 14686, 14705, 14727, 14734, 14747, 14760, 14779, 14810, 14835, 14854, 343}, {14645, 14661, 14686, 14705, 14727, 14734, 14747, 14760, 14779, 14810, 14835, 14854, 343}, 0, 0, 344, 346, {348,1898},{357,876},{370,56},{376,2676}},
-       {16889, 876, 5796, 16922, 16935, 447, 74, 14879, 14907, {14929, 14948, 14967, 14989, 15008, 15030, 15055}, {15074, 15079, 15087, 15095, 15103, 15111, 15119}, {15130, 15146, 15171, 15190, 15212, 15219, 15232, 15245, 15264, 15292, 15317, 15339, 343}, {15130, 15146, 15171, 15190, 15212, 15219, 15232, 15245, 15264, 15292, 15317, 15339, 343}, 0, 0, 344, 346, {348,5796},{357,876},{370,16935},{376,16922}},
-       {16943, 876, 5796, 2676, 56, 447, 74, 15364, 15376, {12590, 12609, 15388, 12650, 12669, 12691, 12716}, {12735, 12745, 15410, 12768, 12778, 12791, 12807}, {15423, 15448, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, {15423, 15448, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, 0, 0, 344, 346, {348,5796},{357,876},{370,56},{376,2676}},
-       {4750, 409, 888, 376, 370, 447, 457, 465, 468, {15628, 15636, 15641, 15648, 15658, 15664, 15671}, {15679, 15683, 2900, 15687, 15692, 15696, 15700}, {15705, 15713, 15722, 15728, 15734, 15739, 15745, 15751, 15758, 15767, 15775, 15784, 343}, {15793, 2122, 2900, 15797, 2061, 15801, 15806, 13164, 15810, 15814, 2154, 2908, 343}, 0, 1, 344, 346, {348,888},{357,409},{370},{376}},
-       {16943, 876, 5796, 2676, 56, 447, 74, 15364, 15376, {15818, 12609, 15846, 12650, 12669, 12691, 12716}, {12735, 12745, 15410, 12768, 12778, 12791, 12807}, {15423, 15865, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, {15423, 15448, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, 0, 0, 344, 346, {348,5796},{357,876},{370,56},{376,2676}},
+       {16943, 876, 5805, 2685, 56, 447, 74, 13809, 13822, {13835, 13854, 13876, 13901, 13917, 13939, 13958}, {13968, 13975, 13982, 13989, 13996, 14003, 14010}, {14014, 14030, 14055, 14074, 14093, 14100, 14113, 14126, 14145, 14176, 14201, 14223, 343}, {14248, 14256, 14270, 14284, 14093, 14100, 14113, 14295, 14303, 14317, 14328, 14336, 343}, 0, 0, 344, 346, {348,5805},{357,876},{370,56},{376,2685}},
+       {16943, 876, 1907, 2685, 56, 447, 74, 14347, 14375, {14397, 14419, 14441, 14466, 14488, 14513, 14541}, {14563, 14573, 14583, 14596, 14606, 14619, 14635}, {14645, 14661, 14686, 14705, 14727, 14734, 14747, 14760, 14779, 14810, 14835, 14854, 343}, {14645, 14661, 14686, 14705, 14727, 14734, 14747, 14760, 14779, 14810, 14835, 14854, 343}, 0, 0, 344, 346, {348,1907},{357,876},{370,56},{376,2685}},
+       {16889, 876, 5805, 16922, 16935, 447, 74, 14879, 14907, {14929, 14948, 14967, 14989, 15008, 15030, 15055}, {15074, 15079, 15087, 15095, 15103, 15111, 15119}, {15130, 15146, 15171, 15190, 15212, 15219, 15232, 15245, 15264, 15292, 15317, 15339, 343}, {15130, 15146, 15171, 15190, 15212, 15219, 15232, 15245, 15264, 15292, 15317, 15339, 343}, 0, 0, 344, 346, {348,5805},{357,876},{370,16935},{376,16922}},
+       {16943, 876, 5805, 2685, 56, 447, 74, 15364, 15376, {12590, 12609, 15388, 12650, 12669, 12691, 12716}, {12735, 12745, 15410, 12768, 12778, 12791, 12807}, {15423, 15448, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, {15423, 15448, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, 0, 0, 344, 346, {348,5805},{357,876},{370,56},{376,2685}},
+       {4759, 409, 888, 376, 370, 447, 457, 465, 468, {15628, 15636, 15641, 15648, 15658, 15664, 15671}, {15679, 15683, 2909, 15687, 15692, 15696, 15700}, {15705, 15713, 15722, 15728, 15734, 15739, 15745, 15751, 15758, 15767, 15775, 15784, 343}, {15793, 2131, 2909, 15797, 2070, 15801, 15806, 13164, 15810, 15814, 2163, 2917, 343}, 0, 1, 344, 346, {348,888},{357,409},{370},{376}},
+       {16943, 876, 5805, 2685, 56, 447, 74, 15364, 15376, {15818, 12609, 15846, 12650, 12669, 12691, 12716}, {12735, 12745, 15410, 12768, 12778, 12791, 12807}, {15423, 15865, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, {15423, 15448, 12849, 15473, 15492, 12891, 15499, 15512, 15528, 15556, 15578, 15606, 343}, 0, 0, 344, 346, {348,5805},{357,876},{370,56},{376,2685}},
        {1, 24, 37, 46, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37},{357,24},{370,56},{376,46}},
-       {16967, 4984, 17012, 17019, 17042, 5017, 5033, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, 0, 0, 344, 346, {348,17012},{357,4984},{370,17042},{376,17019}},
-       {1907, 1379, 1929, 438, 370, 447, 1414, 1940, 1946, {1953, 1961, 1968, 1977, 1986, 1997, 2005}, {2013, 2016, 2019, 2022, 2025, 2028, 2031}, {2034, 2041, 2049, 2055, 2061, 2065, 2070, 2075, 2082, 2092, 2100, 2109, 343}, {2118, 2122, 2126, 2130, 2061, 2134, 2138, 2142, 2146, 2150, 2154, 2158, 343}, 0, 1, 344, 346, {348,844,1929},{357,1379},{370},{376,438}},
-       {5975, 876, 2665, 438, 370, 447, 74, 465, 468, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 1, 344, 346, {348,2739,2665},{2719,2719,2912,2926,2946,876},{2746,2746,2961,1409,370},{2186,2186,2970,2982,438,376}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {8861, 876, 3859, 2982, 370, 447, 74, 465, 468, {3657, 3666, 3672, 3678, 3687, 3693, 3702}, {3709, 3714, 3719, 3724, 3729, 3734, 3739}, {3744, 3752, 3761, 3766, 3772, 3776, 3781, 3789, 3795, 3805, 1050, 3813, 343}, {3823, 3829, 3761, 3836, 3772, 3776, 3841, 3789, 3847, 1097, 1102, 3853, 343}, 0, 1, 344, 346, {888,3859,3264},{357,876,3640},{370},{376,438,2982}},
-       {5975, 876, 1929, 438, 370, 447, 74, 4774, 4777, {4780, 4789, 4797, 4806, 4817, 4826, 4835}, {3139, 3143, 1862, 4842, 4846, 4850, 4854}, {4858, 4866, 3179, 4875, 4882, 4889, 4896, 3202, 4903, 4913, 1050, 4921, 343}, {4930, 1858, 1862, 1866, 4934, 4938, 4942, 3252, 4946, 4950, 1890, 3260, 343}, 0, 1, 344, 346, {348,888,844,1929},{357,409,876},{370},{376,438}},
-       {8861, 876, 3859, 2982, 370, 447, 74, 465, 468, {5803, 5810, 5818, 5826, 5835, 5845, 5853}, {5862, 3418, 5865, 5868, 5871, 5874, 5877}, {5880, 5888, 5897, 1791, 5903, 1801, 1806, 5907, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 5916, 1866, 5903, 1870, 1874, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,5796,3264,3859},{357,876},{370,1409},{376,1399,2982}},
-       {5920, 1379, 844, 5944, 5955, 447, 1414, 465, 468, {1687, 1695, 1702, 1710, 1717, 1725, 1732}, {5961, 3418, 3421, 5965, 3427, 5968, 5971}, {1770, 1777, 3761, 1791, 3772, 1801, 1806, 1811, 1818, 1828, 1836, 4716, 343}, {1854, 1858, 1862, 1866, 3772, 1870, 1874, 1878, 1882, 1886, 1890, 4746, 343}, 0, 1, 344, 346, {348,844},{357,1379},{370,5955},{376,5944}},
-       {17048, 3024, 1676, 2982, 370, 3057, 3062, 465, 468, {3084, 6244, 6258, 6271, 6284, 6297, 3131}, {3139, 6309, 6313, 6317, 6321, 6325, 3160}, {6329, 6337, 6347, 1004, 6354, 6359, 6365, 3202, 6371, 6380, 6388, 6397, 343}, {1854, 6406, 1862, 3244, 3772, 1870, 1874, 3252, 4946, 6410, 1890, 6414, 343}, 0, 1, 344, 346, {348,1676},{357,3024},{370},{376,2982}},
-       {16460, 7668, 3314, 438, 5955, 447, 74, 7685, 7688, {7691, 7699, 7707, 1710, 1717, 1725, 7714}, {7722, 7726, 3421, 5965, 3427, 5968, 7730}, {5880, 5888, 3761, 1791, 1797, 1801, 1806, 7734, 1818, 1828, 1836, 1845, 343}, {1854, 1858, 1862, 1866, 1797, 1870, 1874, 1878, 1882, 1886, 1890, 1894, 343}, 0, 1, 344, 346, {348,5996,3314},{357,7668},{370,5955},{376,5944,438}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {17103, 5315, 17150, 15941, 17042, 17170, 17187, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {5154, 5159, 5164, 5169, 5174, 5179, 5184, 5189, 5194, 5199, 5205, 5211, 343}, 0, 0, 344, 346, {348,17150},{357,5315},{370,17042},{376,15941}},
-       {17202, 9685, 1929, 438, 370, 447, 9699, 1940, 1946, {1953, 1961, 1968, 1977, 1986, 1997, 2005}, {2013, 2016, 2019, 2022, 2025, 2028, 2031}, {17225, 2041, 2049, 2055, 2061, 2065, 2070, 2075, 2082, 2092, 2100, 2109, 343}, {17233, 2122, 17238, 2130, 2061, 2134, 2138, 2142, 2146, 2150, 2154, 2158, 343}, 0, 1, 344, 346, {348,844,1929},{357,1379,9685},{370},{376,438}},
-       {17243, 876, 3859, 2186, 56, 447, 74, 465, 468, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 0, 344, 346, {348,2739,3264,3859},{2719,2719,2912,2926,2946,876},{2746,2746,2961,1409,370,56},{2186,2186,2970,2982,438,46}},
-       {17266, 17303, 2665, 2982, 1409, 17332, 457, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024,17303},{370,1409},{376,2970,2982}},
-       {5975, 876, 5996, 438, 370, 447, 74, 465, 468, {3657, 3666, 3672, 3678, 3687, 3693, 3702}, {3709, 3714, 3719, 3724, 3729, 3734, 3739}, {3744, 3752, 3761, 3766, 3772, 3776, 3781, 3789, 3795, 3805, 1050, 3813, 343}, {3823, 3829, 3761, 3836, 3772, 3776, 3841, 3789, 3847, 1097, 1102, 3853, 343}, 0, 0, 344, 346, {888,3859,3264,5515,5996},{357,876,3640},{370},{376,438}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
+       {16967, 4993, 17012, 17019, 17042, 5026, 5042, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, 0, 0, 344, 346, {348,17012},{357,4993},{370,17042},{376,17019}},
+       {1916, 1379, 1938, 438, 370, 447, 1414, 1949, 1955, {1962, 1970, 1977, 1986, 1995, 2006, 2014}, {2022, 2025, 2028, 2031, 2034, 2037, 2040}, {2043, 2050, 2058, 2064, 2070, 2074, 2079, 2084, 2091, 2101, 2109, 2118, 343}, {2127, 2131, 2135, 2139, 2070, 2143, 2147, 2151, 2155, 2159, 2163, 2167, 343}, 0, 1, 344, 346, {348,844,1938},{357,1379},{370},{376,438}},
+       {5984, 876, 2674, 438, 370, 447, 74, 465, 468, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 1, 344, 346, {348,2748,2674},{2728,2728,2921,2935,2955,876},{2755,2755,2970,1409,370},{2195,2195,2979,2991,438,376}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {8870, 876, 3868, 2991, 370, 447, 74, 465, 468, {3666, 3675, 3681, 3687, 3696, 3702, 3711}, {3718, 3723, 3728, 3733, 3738, 3743, 3748}, {3753, 3761, 3770, 3775, 3781, 3785, 3790, 3798, 3804, 3814, 1050, 3822, 343}, {3832, 3838, 3770, 3845, 3781, 3785, 3850, 3798, 3856, 1097, 1102, 3862, 343}, 0, 1, 344, 346, {888,3868,3273},{357,876,3649},{370},{376,438,2991}},
+       {5984, 876, 1938, 438, 370, 447, 74, 4783, 4786, {4789, 4798, 4806, 4815, 4826, 4835, 4844}, {3148, 3152, 1871, 4851, 4855, 4859, 4863}, {4867, 4875, 3188, 4884, 4891, 4898, 4905, 3211, 4912, 4922, 1050, 4930, 343}, {4939, 1867, 1871, 1875, 4943, 4947, 4951, 3261, 4955, 4959, 1899, 3269, 343}, 0, 1, 344, 346, {348,888,844,1938},{357,409,876},{370},{376,438}},
+       {8870, 876, 3868, 2991, 370, 447, 74, 465, 468, {5812, 5819, 5827, 5835, 5844, 5854, 5862}, {5871, 3427, 5874, 5877, 5880, 5883, 5886}, {5889, 5897, 5906, 1800, 5912, 1810, 1815, 5916, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 5925, 1875, 5912, 1879, 1883, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,5805,3273,3868},{357,876},{370,1409},{376,1399,2991}},
+       {5929, 1379, 844, 5953, 5964, 447, 1414, 465, 468, {1696, 1704, 1711, 1719, 1726, 1734, 1741}, {5970, 3427, 3430, 5974, 3436, 5977, 5980}, {1779, 1786, 3770, 1800, 3781, 1810, 1815, 1820, 1827, 1837, 1845, 4725, 343}, {1863, 1867, 1871, 1875, 3781, 1879, 1883, 1887, 1891, 1895, 1899, 4755, 343}, 0, 1, 344, 346, {348,844},{357,1379},{370,5964},{376,5953}},
+       {17048, 3033, 1676, 2991, 370, 3066, 3071, 465, 468, {3093, 6253, 6267, 6280, 6293, 6306, 3140}, {3148, 6318, 6322, 6326, 6330, 6334, 3169}, {6338, 6346, 6356, 1004, 6363, 6368, 6374, 3211, 6380, 6389, 6397, 6406, 343}, {1863, 6415, 1871, 3253, 3781, 1879, 1883, 3261, 4955, 6419, 1899, 6423, 343}, 0, 1, 344, 346, {348,1676},{357,3033},{370},{376,2991}},
+       {16460, 7677, 3323, 438, 5964, 447, 74, 7694, 7697, {7700, 7708, 7716, 1719, 1726, 1734, 7723}, {7731, 7735, 3430, 5974, 3436, 5977, 7739}, {5889, 5897, 3770, 1800, 1806, 1810, 1815, 7743, 1827, 1837, 1845, 1854, 343}, {1863, 1867, 1871, 1875, 1806, 1879, 1883, 1887, 1891, 1895, 1899, 1903, 343}, 0, 1, 344, 346, {348,6005,3323},{357,7677},{370,5964},{376,5953,438}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {17103, 5324, 17150, 15941, 17042, 17170, 17187, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {5163, 5168, 5173, 5178, 5183, 5188, 5193, 5198, 5203, 5208, 5214, 5220, 343}, 0, 0, 344, 346, {348,17150},{357,5324},{370,17042},{376,15941}},
+       {17202, 9694, 1938, 438, 370, 447, 1687, 1949, 1955, {1962, 1970, 1977, 1986, 1995, 2006, 2014}, {2022, 2025, 2028, 2031, 2034, 2037, 2040}, {17225, 2050, 2058, 2064, 2070, 2074, 2079, 2084, 2091, 2101, 2109, 2118, 343}, {17233, 2131, 17238, 2139, 2070, 2143, 2147, 2151, 2155, 2159, 2163, 2167, 343}, 0, 1, 344, 346, {348,844,1938},{357,1379,9694},{370},{376,438}},
+       {17243, 876, 3868, 2195, 56, 447, 74, 465, 468, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 0, 344, 346, {348,2748,3273,3868},{2728,2728,2921,2935,2955,876},{2755,2755,2970,1409,370,56},{2195,2195,2979,2991,438,46}},
+       {17266, 17303, 2674, 2991, 1409, 17332, 457, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033,17303},{370,1409},{376,2979,2991}},
+       {5984, 876, 6005, 438, 370, 447, 74, 465, 468, {3666, 3675, 3681, 3687, 3696, 3702, 3711}, {3718, 3723, 3728, 3733, 3738, 3743, 3748}, {3753, 3761, 3770, 3775, 3781, 3785, 3790, 3798, 3804, 3814, 1050, 3822, 343}, {3832, 3838, 3770, 3845, 3781, 3785, 3850, 3798, 3856, 1097, 1102, 3862, 343}, 0, 0, 344, 346, {888,3868,3273,5524,6005},{357,876,3649},{370},{376,438}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
        {17347, 17370, 888, 17382, 17393, 447, 457, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, 0, 0, 344, 346, {348,888},{357,17370},{370,17393},{376,17382}},
-       {1907, 1379, 1929, 438, 370, 447, 1414, 1940, 1946, {1953, 1961, 1968, 1977, 1986, 1997, 2005}, {2013, 2016, 2019, 2022, 2025, 2028, 2031}, {2034, 2041, 2049, 2055, 2061, 2065, 2070, 2075, 2082, 2092, 2100, 2109, 343}, {2118, 2122, 2126, 2130, 2061, 2134, 2138, 2142, 2146, 2150, 2154, 2158, 343}, 0, 1, 344, 346, {348,844,1929},{357,1379},{370},{376,438}},
-       {17401, 17425, 2665, 2186, 56, 447, 2754, 465, 468, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 0, 344, 346, {348,2739,888,2665},{2719,2719,2912,2926,2946,17425},{2746,2746,2961,1409,370,56},{2186,2186,2970,2982,438,2676}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {5975, 876, 1929, 438, 370, 447, 74, 465, 468, {3657, 3666, 3672, 3678, 3687, 3693, 3702}, {3709, 3714, 3719, 3724, 3729, 3734, 3739}, {3744, 3752, 3761, 3766, 3772, 3776, 3781, 3789, 3795, 3805, 1050, 3813, 343}, {3823, 3829, 3761, 3836, 3772, 3776, 3841, 3789, 3847, 1097, 1102, 3853, 343}, 0, 1, 344, 346, {888,3859,3264,844,1929},{357,876,3640},{370},{376,438}},
-       {17438, 24, 1676, 2982, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,1676},{357,24},{370,56},{376,46,2982}},
-       {17103, 5315, 17150, 15941, 17042, 17170, 17187, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {5154, 5159, 5164, 5169, 5174, 5179, 5184, 5189, 5194, 5199, 5205, 5211, 343}, 0, 0, 344, 346, {348,17150},{357,5315},{370,17042},{376,15941}},
-       {17243, 876, 3859, 2186, 56, 447, 74, 3074, 3079, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 0, 344, 346, {348,2739,3264,3859},{2719,2719,2912,2926,2946,876},{2746,2746,2961,1409,370,56},{2186,2186,2970,2982,438,46}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {3614, 3640, 2665, 438, 370, 447, 74, 465, 468, {3657, 3666, 3672, 3678, 3687, 3693, 3702}, {3709, 3714, 3719, 3724, 3729, 3734, 3739}, {3744, 3752, 3761, 3766, 3772, 3776, 3781, 3789, 3795, 3805, 1050, 3813, 343}, {3823, 3829, 3761, 3836, 3772, 3776, 3841, 3789, 3847, 1097, 1102, 3853, 343}, 0, 1, 344, 346, {888,3859,3264,2665},{357,876,3640},{370},{376,438}},
-       {17438, 24, 1676, 2982, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,1676},{357,24},{370,56},{376,46,2982}},
-       {5975, 876, 2665, 438, 370, 447, 74, 3074, 3079, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 0, 344, 346, {348,2739,2665},{2719,2719,2912,2926,2946,876},{2746,2746,2961,1409,370},{2186,2186,2970,2982,438,376}},
-       {2990, 3024, 3046, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,11818},{357,3024},{370,16935},{376,2970,16922}},
-       {17438, 24, 1676, 2982, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,1676},{357,24},{370,56},{376,46,2982}},
-       {16727, 409, 5006, 2970, 56, 447, 457, 465, 468, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 0, 344, 346, {348,2739,5006},{2719,2719,2912,2926,2946,409},{2746,2746,2961,1409,370,56},{2186,2186,2970,2982,438,46}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {2990, 3024, 2665, 2970, 1409, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,2665},{357,3024},{370,1409},{376,2970,1399}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {17459, 17483, 17492, 17501, 17512, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, {17459, 17483, 17492, 17501, 17512, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, 0, 4, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {17459, 17483, 17492, 17501, 17627, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, {17459, 17483, 17492, 17501, 17627, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {2990, 3024, 2665, 2970, 370, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370},{376,2970,1399}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {17459, 17483, 17492, 17501, 17512, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, {17459, 17483, 17492, 17501, 17512, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {2162, 409, 10606, 2186, 56, 447, 457, 465, 468, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 0, 344, 346, {348,2739,37,10606},{2719,2719,2912,2926,2946,409},{2746,2746,2961,1409,370,56},{2186,2186,2970,2982,438,46}},
-       {17048, 3024, 2665, 2982, 1409, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,1409},{376,2970,1399,2982}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {17401, 17425, 10606, 2186, 56, 447, 2754, 465, 468, {2761, 2768, 2775, 2783, 2793, 2802, 2809}, {2818, 2822, 2826, 2830, 2834, 2838, 2842}, {2846, 2854, 2863, 2055, 2869, 2873, 2878, 2075, 2082, 2883, 2100, 2891, 343}, {2118, 2122, 2900, 2130, 2869, 2134, 2138, 2142, 2146, 2904, 2154, 2908, 343}, 0, 0, 344, 346, {348,2739,10606},{2719,2719,2912,2926,2946,17425},{2746,2746,2961,1409,370,56},{2186,2186,2970,2982,438,2676}},
-       {17048, 3024, 1676, 2982, 1409, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,1898,1676},{357,3024},{370,1409},{376,2970,1399,2982}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {17078, 24, 2665, 2970, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2665},{357,24},{370,56},{376,46,2970}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {17636, 17671, 2665, 2970, 16935, 3057, 17694, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024,17671},{370,16935},{376,2970,16922}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,888,2665},{357,3024},{370,16935},{376,2970,16922}},
-       {2990, 3024, 2665, 2970, 16935, 3057, 3062, 3074, 3079, {3084, 3092, 3098, 3105, 3116, 3123, 3131}, {3139, 3143, 1862, 3147, 3152, 3156, 3160}, {3165, 3171, 3179, 1004, 3185, 3190, 3196, 3202, 3209, 1042, 3220, 3230, 343}, {3240, 1858, 1862, 3244, 3248, 1870, 1874, 3252, 1882, 3256, 1890, 3260, 343}, 0, 1, 344, 346, {348,3264,3046,11818,2665},{357,3024},{370,16935},{376,2970,16922}},
+       {1916, 1379, 1938, 438, 370, 447, 1414, 1949, 1955, {1962, 1970, 1977, 1986, 1995, 2006, 2014}, {2022, 2025, 2028, 2031, 2034, 2037, 2040}, {2043, 2050, 2058, 2064, 2070, 2074, 2079, 2084, 2091, 2101, 2109, 2118, 343}, {2127, 2131, 2135, 2139, 2070, 2143, 2147, 2151, 2155, 2159, 2163, 2167, 343}, 0, 1, 344, 346, {348,844,1938},{357,1379},{370},{376,438}},
+       {17401, 17425, 2674, 2195, 56, 447, 2763, 465, 468, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 0, 344, 346, {348,2748,888,2674},{2728,2728,2921,2935,2955,17425},{2755,2755,2970,1409,370,56},{2195,2195,2979,2991,438,2685}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {5984, 876, 1938, 438, 370, 447, 74, 465, 468, {3666, 3675, 3681, 3687, 3696, 3702, 3711}, {3718, 3723, 3728, 3733, 3738, 3743, 3748}, {3753, 3761, 3770, 3775, 3781, 3785, 3790, 3798, 3804, 3814, 1050, 3822, 343}, {3832, 3838, 3770, 3845, 3781, 3785, 3850, 3798, 3856, 1097, 1102, 3862, 343}, 0, 1, 344, 346, {888,3868,3273,844,1938},{357,876,3649},{370},{376,438}},
+       {17438, 24, 1676, 2991, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,1676},{357,24},{370,56},{376,46,2991}},
+       {17103, 5324, 17150, 15941, 17042, 17170, 17187, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {5163, 5168, 5173, 5178, 5183, 5188, 5193, 5198, 5203, 5208, 5214, 5220, 343}, 0, 0, 344, 346, {348,17150},{357,5324},{370,17042},{376,15941}},
+       {17243, 876, 3868, 2195, 56, 447, 74, 3083, 3088, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 0, 344, 346, {348,2748,3273,3868},{2728,2728,2921,2935,2955,876},{2755,2755,2970,1409,370,56},{2195,2195,2979,2991,438,46}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {3623, 3649, 2674, 438, 370, 447, 74, 465, 468, {3666, 3675, 3681, 3687, 3696, 3702, 3711}, {3718, 3723, 3728, 3733, 3738, 3743, 3748}, {3753, 3761, 3770, 3775, 3781, 3785, 3790, 3798, 3804, 3814, 1050, 3822, 343}, {3832, 3838, 3770, 3845, 3781, 3785, 3850, 3798, 3856, 1097, 1102, 3862, 343}, 0, 1, 344, 346, {888,3868,3273,2674},{357,876,3649},{370},{376,438}},
+       {17438, 24, 1676, 2991, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,1676},{357,24},{370,56},{376,46,2991}},
+       {5984, 876, 2674, 438, 370, 447, 74, 3083, 3088, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 0, 344, 346, {348,2748,2674},{2728,2728,2921,2935,2955,876},{2755,2755,2970,1409,370},{2195,2195,2979,2991,438,376}},
+       {2999, 3033, 3055, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,11818},{357,3033},{370,16935},{376,2979,16922}},
+       {17438, 24, 1676, 2991, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,1676},{357,24},{370,56},{376,46,2991}},
+       {16727, 409, 5015, 2979, 56, 447, 457, 465, 468, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 0, 344, 346, {348,2748,5015},{2728,2728,2921,2935,2955,409},{2755,2755,2970,1409,370,56},{2195,2195,2979,2991,438,46}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {2999, 3033, 2674, 2979, 1409, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,2674},{357,3033},{370,1409},{376,2979,1399}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {17459, 17483, 17492, 17501, 17512, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, {17459, 17483, 17492, 17501, 17512, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, 0, 4, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {17459, 17483, 17492, 17501, 17627, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, {17459, 17483, 17492, 17501, 17627, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {2999, 3033, 2674, 2979, 370, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370},{376,2979,1399}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {17459, 17483, 17492, 17501, 17512, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, {17459, 17483, 17492, 17501, 17512, 17521, 17534, 17543, 17548, 17559, 17581, 17605, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {2171, 409, 10606, 2195, 56, 447, 457, 465, 468, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 0, 344, 346, {348,2748,37,10606},{2728,2728,2921,2935,2955,409},{2755,2755,2970,1409,370,56},{2195,2195,2979,2991,438,46}},
+       {17048, 3033, 2674, 2991, 1409, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,1409},{376,2979,1399,2991}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {17401, 17425, 10606, 2195, 56, 447, 2763, 465, 468, {2770, 2777, 2784, 2792, 2802, 2811, 2818}, {2827, 2831, 2835, 2839, 2843, 2847, 2851}, {2855, 2863, 2872, 2064, 2878, 2882, 2887, 2084, 2091, 2892, 2109, 2900, 343}, {2127, 2131, 2909, 2139, 2878, 2143, 2147, 2151, 2155, 2913, 2163, 2917, 343}, 0, 0, 344, 346, {348,2748,10606},{2728,2728,2921,2935,2955,17425},{2755,2755,2970,1409,370,56},{2195,2195,2979,2991,438,2685}},
+       {17048, 3033, 1676, 2991, 1409, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,1907,1676},{357,3033},{370,1409},{376,2979,1399,2991}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {184, 187, 190, 193, 196, 199, 202}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {17078, 24, 2674, 2979, 56, 63, 74, 81, 84, {87, 98, 113, 130, 147, 160, 173}, {87, 98, 113, 130, 147, 160, 173}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, {205, 216, 229, 238, 249, 258, 269, 280, 291, 304, 317, 330, 343}, 0, 6, 344, 346, {348,37,2674},{357,24},{370,56},{376,46,2979}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {17636, 17671, 2674, 2979, 16935, 3066, 17694, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033,17671},{370,16935},{376,2979,16922}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,888,2674},{357,3033},{370,16935},{376,2979,16922}},
+       {2999, 3033, 2674, 2979, 16935, 3066, 3071, 3083, 3088, {3093, 3101, 3107, 3114, 3125, 3132, 3140}, {3148, 3152, 1871, 3156, 3161, 3165, 3169}, {3174, 3180, 3188, 1004, 3194, 3199, 3205, 3211, 3218, 1042, 3229, 3239, 343}, {3249, 1867, 1871, 3253, 3257, 1879, 1883, 3261, 1891, 3265, 1899, 3269, 343}, 0, 1, 344, 346, {348,3273,3055,11818,2674},{357,3033},{370,16935},{376,2979,16922}},
        {1112, 357, 348, 376, 370, 1136, 1146, 1154, 1161, {1168, 1178, 1188, 1198, 1208, 1218, 1228}, {1238, 1242, 1246, 1250, 1254, 1258, 1262}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, {1266, 1273, 1280, 1287, 1294, 1301, 1308, 1315, 1322, 1329, 1336, 1346, 343}, 0, 0, 344, 346, {348},{357},{370},{376}}
 };
 
@@ -310,7 +310,7 @@ static const NumberFormatEntry number_format_entries [] = {
        {17744, 17737, 17744, 17737, 17744, 17737, 17965, 17742, 17746, 17720, 17750, 17760, 17733, 17735, 0, 0, 1, 1, 1, 2, 2, 2, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}},
        {17744, 17928, 17744, 17928, 17744, 17928, 17967, 17742, 17716, 17720, 17724, 17729, 17733, 17735, 2, 2, 1, 1, 1, 2, 2, 2, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}},
        {17707, 17710, 17707, 17710, 17707, 17710, 17972, 17713, 17716, 17720, 17724, 17729, 17733, 17735, 11, 2, 1, 1, 3, 2, 2, 2, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}},
-       {17744, 17737, 17744, 17737, 17744, 17737, 4367, 17742, 17746, 17720, 17750, 17760, 17733, 17735, 0, 0, 1, 1, 1, 2, 2, 2, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}},
+       {17744, 17737, 17744, 17737, 17744, 17737, 4376, 17742, 17746, 17720, 17750, 17760, 17733, 17735, 0, 0, 1, 1, 1, 2, 2, 2, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}},
        {17744, 17737, 17744, 17737, 17744, 17737, 17800, 17742, 17746, 17720, 17750, 17760, 17733, 17735, 1, 0, 1, 1, 1, 2, 2, 2, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}},
        {17737, 17744, 17737, 17744, 17737, 17744, 17982, 17742, 17716, 17720, 17724, 17729, 17733, 17735, 0, 0, 1, 1, 1, 2, 2, 2, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}},
        {17737, 17744, 17737, 17744, 17737, 17744, 17785, 17742, 17716, 17720, 17724, 17729, 17733, 17735, 8, 3, 1, 1, 1, 2, 2, 2, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}, {3, -1, -1, -1, -1}},
@@ -360,7 +360,7 @@ static const CultureInfoEntry culture_entries [] = {
        {0x0009, 0x007F, 0x0409, -1,18384, 18387, 18387, 18387, 18387, 18395, 18399, 18384, 0, {0, 0, 0, 0, 0}, 8, 8, { 1252, 37, 10000, 437, ',' }},
        {0x000A, 0x007F, 0x0C0A, -1,18403, 18406, 18406, 18406, 18414, 18423, 18427, 18403, 0, {0, 0, 0, 0, 0}, 9, 9, { 1252, 20284, 10000, 850, ';' }},
        {0x000B, 0x007F, 0x040B, -1,18431, 18434, 18434, 18434, 18442, 18448, 18452, 18431, 0, {0, 0, 0, 0, 0}, 10, 10, { 1252, 20278, 10000, 850, ';' }},
-       {0x000C, 0x007F, 0x040C, -1,5968, 18456, 18456, 18456, 18463, 18473, 18477, 5968, 0, {0, 0, 0, 0, 0}, 11, 11, { 1252, 20297, 10000, 850, ';' }},
+       {0x000C, 0x007F, 0x040C, -1,5977, 18456, 18456, 18456, 18463, 18473, 18477, 5977, 0, {0, 0, 0, 0, 0}, 11, 11, { 1252, 20297, 10000, 850, ';' }},
        {0x000D, 0x007F, 0x040D, -1,18481, 18484, 18484, 18484, 18491, 18502, 18506, 18481, 0, {0, 0, 0, 0, 0}, 12, 12, { 1255, 500, 10005, 862, ',' }},
        {0x000E, 0x007F, 0x040E, -1,18510, 18513, 18513, 18513, 18523, 18530, 18534, 18510, 0, {0, 0, 0, 0, 0}, 13, 13, { 1250, 500, 10029, 852, ';' }},
        {0x000F, 0x007F, 0x040F, -1,18538, 18541, 18541, 18541, 18551, 18561, 18565, 18538, 0, {0, 0, 0, 0, 0}, 14, 14, { 1252, 20871, 10079, 850, ';' }},
@@ -387,7 +387,7 @@ static const CultureInfoEntry culture_entries [] = {
        {0x0026, 0x007F, 0x0426, -1,19180, 19183, 19183, 19183, 19191, 19201, 19205, 19180, 0, {0, 0, 0, 0, 0}, 35, 35, { 1257, 500, 10029, 775, ';' }},
        {0x0027, 0x007F, 0x0427, -1,19209, 19212, 19212, 19212, 19223, 19233, 19237, 19209, 0, {0, 0, 0, 0, 0}, 36, 36, { 1257, 500, 10029, 775, ';' }},
        {0x0029, 0x007F, 0x0429, -1,19241, 19244, 19244, 19244, 19252, 19263, 19267, 19241, 0, {0, 0, 0, 0, 0}, 37, 37, { 1256, 20420, 10004, 720, ';' }},
-       {0x002A, 0x007F, 0x042A, -1,19271, 19274, 19274, 19274, 19285, 19300, 3156, 19271, 0, {0, 0, 0, 0, 0}, 38, 38, { 1258, 500, 10000, 1258, ',' }},
+       {0x002A, 0x007F, 0x042A, -1,19271, 19274, 19274, 19274, 19285, 19300, 3165, 19271, 0, {0, 0, 0, 0, 0}, 38, 38, { 1258, 500, 10000, 1258, ',' }},
        {0x002B, 0x007F, 0x042B, -1,19304, 19307, 19307, 19307, 19316, 19331, 19335, 19304, 0, {0, 0, 0, 0, 0}, 39, 39, { 0, 500, 2, 1, ',' }},
        {0x002D, 0x007F, 0x042D, -1,19339, 19342, 19342, 19342, 19349, 19357, 19361, 19339, 0, {0, 0, 0, 0, 0}, 40, 40, { 1252, 500, 10000, 850, ';' }},
        {0x002F, 0x007F, 0x042F, -1,19365, 19368, 19368, 19368, 19379, 19400, 19404, 19365, 0, {0, 0, 0, 0, 0}, 41, 41, { 1251, 500, 10007, 866, ';' }},
@@ -400,7 +400,7 @@ static const CultureInfoEntry culture_entries [] = {
        {0x0049, 0x007F, 0x0449, -1,19615, 19618, 19618, 19618, 19624, 19640, 19644, 19615, 0, {0, 0, 0, 0, 0}, 48, 48, { 0, 500, 2, 1, ',' }},
        {0x004A, 0x007F, 0x044A, -1,19648, 19651, 19651, 19651, 19658, 19677, 19681, 19648, 0, {0, 0, 0, 0, 0}, 49, 49, { 0, 500, 2, 1, ',' }},
        {0x004B, 0x007F, 0x044B, -1,19685, 19688, 19688, 19688, 19696, 19712, 19716, 19685, 0, {0, 0, 0, 0, 0}, 50, 50, { 0, 500, 2, 1, ',' }},
-       {0x004E, 0x007F, 0x044E, -1,19720, 19723, 19723, 19723, 19731, 19747, 1862, 19720, 0, {0, 0, 0, 0, 0}, 51, 51, { 0, 500, 2, 1, ',' }},
+       {0x004E, 0x007F, 0x044E, -1,19720, 19723, 19723, 19723, 19731, 19747, 1871, 19720, 0, {0, 0, 0, 0, 0}, 51, 51, { 0, 500, 2, 1, ',' }},
        {0x0056, 0x007F, 0x0456, -1,19751, 19754, 19754, 19754, 19763, 19770, 19774, 19751, 0, {0, 0, 0, 0, 0}, 52, 52, { 1252, 500, 10000, 850, ',' }},
        {0x0057, 0x007F, 0x0457, -1,19778, 19782, 19782, 19782, 19790, 19809, 19778, 19511, 0, {0, 0, 0, 0, 0}, 53, 53, { 0, 500, 2, 1, ',' }},
        {0x0401, 0x0001, 0x0401, 174,19813, 19819, 19819, 19819, 19841, 18165, 18169, 18140, 10998, {16777216, 0, 0, 0, 0}, 54, 54, { 1256, 20420, 10004, 720, ';' }},
@@ -409,11 +409,11 @@ static const CultureInfoEntry culture_entries [] = {
        {0x0404, 0x7C04, 0x0404, 207,20001, 20007, 20007, 20007, 20024, 20040, 18266, 18270, 20044, {0, 0, 0, 0, 0}, 57, 57, { 950, 500, 10002, 950, ',' }},
        {0x0405, 0x0005, 0x0405, 49,20047, 20053, 20053, 20053, 20076, 18292, 18296, 18273, 20106, {0, 0, 0, 0, 0}, 58, 58, { 1250, 500, 10029, 852, ';' }},
        {0x0406, 0x0006, 0x0406, 52,20109, 20115, 20115, 20115, 20132, 18316, 18320, 18300, 20148, {0, 0, 0, 0, 0}, 59, 59, { 1252, 20277, 10000, 850, ';' }},
-       {0x0407, 0x0007, 0x0407, 50,20151, 20157, 20157, 20157, 20174, 18342, 18346, 18324, 4291, {0, 0, 0, 0, 0}, 60, 60, { 1252, 20273, 10000, 850, ';' }},
+       {0x0407, 0x0007, 0x0407, 50,20151, 20157, 20157, 20157, 20174, 18342, 18346, 18324, 4300, {0, 0, 0, 0, 0}, 60, 60, { 1252, 20273, 10000, 850, ';' }},
        {0x0408, 0x0008, 0x0408, 81,20196, 20202, 20202, 20202, 20217, 18376, 18380, 18350, 20249, {0, 0, 0, 0, 0}, 61, 61, { 1253, 20273, 10006, 737, ';' }},
        {0x0409, 0x0009, 0x0409, 212,20252, 20258, 20258, 20258, 20258, 18395, 18399, 18384, 20282, {0, 0, 0, 0, 0}, 62, 62, { 1252, 37, 10000, 437, ',' }},
        {0x040B, 0x000B, 0x040B, 63,20285, 20291, 20291, 20291, 20309, 18448, 18452, 18431, 20323, {0, 0, 0, 0, 0}, 63, 63, { 1252, 20278, 10000, 850, ';' }},
-       {0x040C, 0x000C, 0x040C, 68,20326, 20332, 20332, 20332, 20348, 18473, 18477, 5968, 20367, {0, 0, 0, 0, 0}, 64, 64, { 1252, 20297, 10000, 850, ';' }},
+       {0x040C, 0x000C, 0x040C, 68,20326, 20332, 20332, 20332, 20348, 18473, 18477, 5977, 20367, {0, 0, 0, 0, 0}, 64, 64, { 1252, 20297, 10000, 850, ';' }},
        {0x040D, 0x000D, 0x040D, 92,20370, 20376, 20376, 20376, 20392, 18502, 18506, 18481, 20416, {0, 0, 0, 0, 0}, 65, 65, { 1255, 500, 10005, 862, ',' }},
        {0x040E, 0x000E, 0x040E, 89,20419, 20425, 20425, 20425, 20445, 18530, 18534, 18510, 20468, {0, 0, 0, 0, 0}, 66, 66, { 1250, 500, 10029, 852, ';' }},
        {0x040F, 0x000F, 0x040F, 97,20471, 20477, 20477, 20477, 20497, 18561, 18565, 18538, 20517, {0, 0, 0, 0, 0}, 67, 67, { 1252, 20871, 10079, 850, ';' }},
@@ -440,7 +440,7 @@ static const CultureInfoEntry culture_entries [] = {
        {0x0426, 0x0026, 0x0426, 121,21606, 21612, 21612, 21612, 21629, 19201, 19205, 19180, 21649, {0, 0, 0, 0, 0}, 88, 88, { 1257, 500, 10029, 775, ';' }},
        {0x0427, 0x0027, 0x0427, 119,21652, 21658, 21658, 21658, 21681, 19233, 19237, 19209, 21701, {0, 0, 0, 0, 0}, 89, 89, { 1257, 500, 10029, 775, ';' }},
        {0x0429, 0x0029, 0x0429, 96,21704, 21710, 21710, 21710, 21725, 19263, 19267, 19241, 21749, {0, 0, 0, 0, 0}, 90, 90, { 1256, 20420, 10004, 720, ';' }},
-       {0x042A, 0x002A, 0x042A, 220,21752, 21758, 21758, 21758, 21779, 19300, 3156, 19271, 21807, {0, 0, 0, 0, 0}, 91, 91, { 1258, 500, 10000, 1258, ',' }},
+       {0x042A, 0x002A, 0x042A, 220,21752, 21758, 21758, 21758, 21779, 19300, 3165, 19271, 21807, {0, 0, 0, 0, 0}, 91, 91, { 1258, 500, 10000, 1258, ',' }},
        {0x042B, 0x002B, 0x042B, 5,21810, 21816, 21816, 21816, 21835, 19331, 19335, 19304, 465, {0, 0, 0, 0, 0}, 92, 92, { 0, 500, 2, 1, ',' }},
        {0x042D, 0x002D, 0x042D, 61,21900, 21906, 21906, 21906, 21921, 19357, 19361, 19339, 19998, {0, 0, 0, 0, 0}, 93, 93, { 1252, 500, 10000, 850, ';' }},
        {0x042F, 0x002F, 0x042F, 128,21940, 21946, 21946, 21946, 21969, 19400, 19404, 19365, 22013, {0, 0, 0, 0, 0}, 94, 94, { 1251, 500, 10007, 866, ';' }},
@@ -453,7 +453,7 @@ static const CultureInfoEntry culture_entries [] = {
        {0x0449, 0x0049, 0x0449, 93,22369, 22375, 22375, 22375, 22389, 19640, 19644, 19615, 22263, {0, 0, 0, 0, 0}, 101, 101, { 0, 500, 2, 1, ',' }},
        {0x044A, 0x004A, 0x044A, 93,22429, 22435, 22435, 22435, 22450, 19677, 19681, 19648, 22263, {0, 0, 0, 0, 0}, 102, 102, { 0, 500, 2, 1, ',' }},
        {0x044B, 0x004B, 0x044B, 93,22497, 22503, 22503, 22503, 22519, 19712, 19716, 19685, 22263, {0, 0, 0, 0, 0}, 103, 103, { 0, 500, 2, 1, ',' }},
-       {0x044E, 0x004E, 0x044E, 93,22550, 22556, 22556, 22556, 22572, 19747, 1862, 19720, 22263, {0, 0, 0, 0, 0}, 104, 104, { 0, 500, 2, 1, ',' }},
+       {0x044E, 0x004E, 0x044E, 93,22550, 22556, 22556, 22556, 22572, 19747, 1871, 19720, 22263, {0, 0, 0, 0, 0}, 104, 104, { 0, 500, 2, 1, ',' }},
        {0x0456, 0x0056, 0x0456, 61,22603, 22609, 22609, 22609, 22626, 19770, 19774, 19751, 19998, {0, 0, 0, 0, 0}, 105, 105, { 1252, 500, 10000, 850, ',' }},
        {0x0457, 0x0057, 0x0457, 93,22643, 22650, 22650, 22650, 22666, 19809, 19778, 19778, 22263, {0, 0, 0, 0, 0}, 106, 106, { 0, 500, 2, 1, ',' }},
        {0x0801, 0x0001, 0x0801, 95,22700, 22706, 22706, 22706, 22720, 22750, 18169, 18140, 22754, {2, 1, 0, 0, 0}, 107, 107, { 1256, 20420, 10004, 720, ';' }},
@@ -461,7 +461,7 @@ static const CultureInfoEntry culture_entries [] = {
        {0x0807, 0x0007, 0x0807, 37,22795, 22801, 22801, 22801, 22822, 22840, 18346, 18324, 11001, {0, 0, 0, 0, 0}, 109, 109, { 1252, 20273, 10000, 850, ';' }},
        {0x0809, 0x0009, 0x0809, 70,22844, 22850, 22850, 22850, 22850, 22875, 18399, 18384, 22879, {0, 0, 0, 0, 0}, 110, 110, { 1252, 20285, 10000, 850, ',' }},
        {0x080A, 0x000A, 0x080A, 141,22882, 22888, 22888, 22888, 22905, 22924, 18427, 18403, 22928, {0, 0, 0, 0, 0}, 111, 111, { 1252, 20284, 10000, 850, ',' }},
-       {0x080C, 0x000C, 0x080C, 17,22931, 22937, 22937, 22937, 22954, 22975, 18477, 5968, 22979, {0, 0, 0, 0, 0}, 112, 112, { 1252, 20297, 10000, 850, ';' }},
+       {0x080C, 0x000C, 0x080C, 17,22931, 22937, 22937, 22937, 22954, 22975, 18477, 5977, 22979, {0, 0, 0, 0, 0}, 112, 112, { 1252, 20297, 10000, 850, ';' }},
        {0x0810, 0x0010, 0x0810, 37,22982, 22988, 22988, 22988, 23010, 23030, 18593, 18569, 11001, {0, 0, 0, 0, 0}, 113, 113, { 1252, 500, 10000, 850, ';' }},
        {0x0813, 0x0013, 0x0813, 17,23034, 23040, 23040, 23040, 23056, 23077, 18679, 18655, 22979, {0, 0, 0, 0, 0}, 114, 114, { 1252, 500, 10000, 850, ';' }},
        {0x0814, 0x0014, 0x0814, 150,23081, 23087, 23087, 23087, 23114, 23136, 23140, 23144, 20803, {0, 0, 0, 0, 0}, 115, 115, { 1252, 20277, 10000, 850, ';' }},
@@ -472,18 +472,18 @@ static const CultureInfoEntry culture_entries [] = {
        {0x0C07, 0x0007, 0x0C07, 10,23386, 23392, 23392, 23392, 23409, 23431, 18346, 18324, 23435, {0, 0, 0, 0, 0}, 120, 120, { 1252, 20273, 10000, 850, ';' }},
        {0x0C09, 0x0009, 0x0C09, 11,23438, 23444, 23444, 23444, 23444, 23464, 18399, 18384, 23468, {0, 0, 0, 0, 0}, 121, 121, { 1252, 500, 10000, 850, ',' }},
        {0x0C0A, 0x000A, 0x0C0A, 61,23471, 23477, 23477, 23477, 23493, 23512, 18427, 18403, 19998, {0, 0, 0, 0, 0}, 122, 122, { 1252, 20284, 10000, 850, ';' }},
-       {0x0C0C, 0x000C, 0x0C0C, 32,23516, 23522, 23522, 23522, 23538, 23557, 18477, 5968, 23561, {0, 0, 0, 0, 0}, 123, 123, { 1252, 20297, 10000, 850, ';' }},
+       {0x0C0C, 0x000C, 0x0C0C, 32,23516, 23522, 23522, 23522, 23538, 23557, 18477, 5977, 23561, {0, 0, 0, 0, 0}, 123, 123, { 1252, 20297, 10000, 850, ';' }},
        {0x1001, 0x0001, 0x1001, 122,23564, 23570, 23570, 23570, 23585, 23613, 18169, 18140, 23617, {16777216, 0, 0, 0, 0}, 124, 124, { 1256, 20420, 10004, 720, ';' }},
        {0x1004, 0x0004, 0x1004, 179,23620, 23626, 23626, 23626, 23646, 23665, 18266, 18270, 23669, {0, 0, 0, 0, 0}, 125, 125, { 936, 500, 10008, 936, ',' }},
        {0x1007, 0x0007, 0x1007, 120,23672, 23678, 23678, 23678, 23698, 23718, 18346, 18324, 23722, {0, 0, 0, 0, 0}, 126, 126, { 1252, 20273, 10000, 850, ';' }},
        {0x1009, 0x0009, 0x1009, 32,23725, 23731, 23731, 23731, 23731, 23748, 18399, 18384, 23561, {0, 0, 0, 0, 0}, 127, 127, { 1252, 37, 10000, 850, ',' }},
        {0x100A, 0x000A, 0x100A, 82,23752, 23758, 23758, 23758, 23778, 23799, 18427, 18403, 23803, {0, 0, 0, 0, 0}, 128, 128, { 1252, 20284, 10000, 850, ',' }},
-       {0x100C, 0x000C, 0x100C, 37,23806, 23812, 23812, 23812, 23833, 23852, 18477, 5968, 11001, {0, 0, 0, 0, 0}, 129, 129, { 1252, 20297, 10000, 850, ';' }},
+       {0x100C, 0x000C, 0x100C, 37,23806, 23812, 23812, 23812, 23833, 23852, 18477, 5977, 11001, {0, 0, 0, 0, 0}, 129, 129, { 1252, 20297, 10000, 850, ';' }},
        {0x1401, 0x0001, 0x1401, 55,23856, 23862, 23862, 23862, 23879, 23911, 18169, 18140, 23915, {16777216, 0, 0, 0, 0}, 130, 130, { 1256, 20420, 10004, 720, ';' }},
        {0x1404, 0x0004, 0x1404, 132,23918, 23924, 23924, 23924, 23953, 23990, 18266, 18270, 23994, {0, 0, 0, 0, 0}, 131, 131, { 950, 500, 10002, 950, ',' }},
        {0x1409, 0x0009, 0x1409, 154,23997, 24003, 24003, 24003, 24003, 24025, 18399, 18384, 24029, {0, 0, 0, 0, 0}, 132, 132, { 1252, 500, 10000, 850, ',' }},
        {0x140A, 0x000A, 0x140A, 44,24032, 24038, 24038, 24038, 24059, 24081, 18427, 18403, 24085, {0, 0, 0, 0, 0}, 133, 133, { 1252, 20284, 10000, 850, ',' }},
-       {0x140C, 0x000C, 0x140C, 120,24088, 24094, 24094, 24094, 24114, 24137, 18477, 5968, 23722, {0, 0, 0, 0, 0}, 134, 134, { 1252, 20297, 10000, 850, ';' }},
+       {0x140C, 0x000C, 0x140C, 120,24088, 24094, 24094, 24094, 24114, 24137, 18477, 5977, 23722, {0, 0, 0, 0, 0}, 134, 134, { 1252, 20297, 10000, 850, ';' }},
        {0x1801, 0x0001, 0x1801, 123,24141, 24147, 24147, 24147, 24164, 24194, 18169, 18140, 24198, {16777216, 0, 0, 0, 0}, 135, 135, { 1256, 20420, 10004, 720, ';' }},
        {0x1809, 0x0009, 0x1809, 91,24201, 24207, 24207, 24207, 24207, 24225, 18399, 18384, 24229, {0, 0, 0, 0, 0}, 136, 136, { 1252, 500, 10000, 850, ',' }},
        {0x180A, 0x000A, 0x180A, 156,24232, 24238, 24238, 24238, 24255, 24274, 18427, 18403, 24278, {0, 0, 0, 0, 0}, 137, 137, { 1252, 20284, 10000, 850, ',' }},
@@ -595,7 +595,7 @@ static const CultureInfoNameEntry culture_name_entries [] = {
        {26104, 63},
        {19482, 44},
        {26110, 97},
-       {5968, 11},
+       {5977, 11},
        {26116, 112},
        {26122, 123},
        {26128, 129},
@@ -739,7 +739,7 @@ static const RegionInfoEntry region_entries [] = {
        { 0, 47,27857,343,343,27860,343,26799,26803},
        { 0, 48,27877,343,343,27880,343,27887,27891},
        { 0, 49,20106,343,343,27904,343,27919,27923},
-       { 0, 50,4291,343,343,27945,343,26780,26784},
+       { 0, 50,4300,343,343,27945,343,26780,26784},
        { 0, 51,27953,343,343,27956,343,27965,27969},
        { 0, 52,20148,343,343,27984,343,27992,27996},
        { 0, 53,28009,343,343,28012,343,26540,26544},
@@ -814,7 +814,7 @@ static const RegionInfoEntry region_entries [] = {
        { 0, 122,23617,343,343,29713,343,29719,29723},
        { 0, 123,24198,343,343,29736,343,28182,28186},
        { 0, 124,29744,343,343,29747,343,26780,26784},
-       { 0, 125,7428,343,343,29754,343,29762,29766},
+       { 0, 125,7437,343,343,29754,343,29762,29766},
        { 0, 126,29779,343,343,29782,343,29793,29797},
        { 0, 127,29814,343,343,29817,343,26758,26762},
        { 0, 128,22013,343,343,29834,343,29844,29848},
@@ -973,7 +973,7 @@ static const RegionInfoNameEntry region_name_entries [] = {
        {27857, 47},
        {27877, 48},
        {20106, 49},
-       {4291, 50},
+       {4300, 50},
        {27953, 51},
        {20148, 52},
        {28009, 53},
@@ -1048,7 +1048,7 @@ static const RegionInfoNameEntry region_name_entries [] = {
        {23617, 122},
        {24198, 123},
        {29744, 124},
-       {7428, 125},
+       {7437, 125},
        {29779, 126},
        {29814, 127},
        {22013, 128},
@@ -1361,6 +1361,7 @@ static const char locale_strings [] = {
        "d. MMM yyyy HH:mm:ss\0"
        "d. MMM yyyy\0"
        "dd-MM-yyyy\0"
+       "dd. MMMM\0"
        "s\xc3\xb8ndag\0"
        "mandag\0"
        "tirsdag\0"
@@ -2289,7 +2290,6 @@ static const char locale_strings [] = {
        "\xd1\x81\xd0\xbd\xd0\xb5\0"
        "dd. MMMM yyyy H:mm:ss\0"
        "dd. MMMM yyyy\0"
-       "dd. MMMM\0"
        "nedelja\0"
        "ponedeljek\0"
        "torek\0"
index e3cfd09b61ed439605aadb0db8bd7383c2d1d2f9..1cf21e31b702c20ca165a913ad217e7c8ce2a745 100644 (file)
@@ -12,6 +12,7 @@
 #include "mono/metadata/opcodes.h"
 #include "mono/metadata/metadata-internals.h"
 #include "mono/metadata/class-internals.h"
+#include "mono/metadata/object-internals.h"
 #include "mono/metadata/mono-endian.h"
 #include "mono/metadata/debug-helpers.h"
 #include "mono/metadata/tabledefs.h"
@@ -843,7 +844,7 @@ mono_object_describe (MonoObject *obj)
                MonoArray *array = (MonoArray*)obj;
                sep = print_name_space (klass);
                g_print ("%s%s", sep, klass->name);
-               g_print (" at %p, rank: %d, length: %d\n", obj, klass->rank, mono_array_length (array));
+               g_print (" at %p, rank: %d, length: %d\n", obj, klass->rank, (int)mono_array_length (array));
        } else {
                sep = print_name_space (klass);
                g_print ("%s%s", sep, klass->name);
index 600873fa7fb608fd921234f4254f310b3f2198ab..56f7c697e29a41ca73d3d32129b8460e7592520a 100644 (file)
@@ -105,6 +105,42 @@ typedef struct
        gboolean this_in_reg:1;
 } MonoGenericJitInfo;
 
+/*
+A try block hole is used to represent a non-contiguous part of
+of a segment of native code protected by a given .try block.
+Usually, a try block is defined as a contiguous segment of code.
+But in some cases it's needed to have some parts of it to not be protected.
+For example, given "try {} finally {}", the code in the .try block to call
+the finally part looks like:
+
+try {
+    ...
+       call finally_block
+       adjust stack
+       jump outside try block
+       ...
+} finally {
+       ...
+}
+
+The instructions between the call and the jump should not be under the try block since they happen
+after the finally block executes, which means if an async exceptions happens at that point we would
+execute the finally clause twice. So, to avoid this, we introduce a hole in the try block to signal
+that those instructions are not protected.
+*/
+typedef struct
+{
+       guint32 offset;
+       guint16 clause;
+       guint16 length;
+} MonoTryBlockHoleJitInfo;
+
+typedef struct
+{
+       guint16 num_holes;
+       MonoTryBlockHoleJitInfo holes [MONO_ZERO_LEN_ARRAY];
+} MonoTryBlockHoleTableJitInfo;
+
 struct _MonoJitInfo {
        /* NOTE: These first two elements (method and
           next_jit_code_hash) must be in the same order and at the
@@ -127,6 +163,7 @@ struct _MonoJitInfo {
        gboolean    cas_method_deny:1;
        gboolean    cas_method_permitonly:1;
        gboolean    has_generic_jit_info:1;
+       gboolean    has_try_block_holes:1;
        gboolean    from_aot:1;
        gboolean    from_llvm:1;
 #ifdef HAVE_SGEN_GC
@@ -135,6 +172,7 @@ struct _MonoJitInfo {
 #endif
        MonoJitExceptionInfo clauses [MONO_ZERO_LEN_ARRAY];
        /* There is an optional MonoGenericJitInfo after the clauses */
+       /* There is an optional MonoTryBlockHoleTableJitInfo after MonoGenericJitInfo clauses*/
 };
 
 #define MONO_SIZEOF_JIT_INFO (offsetof (struct _MonoJitInfo, clauses))
@@ -372,6 +410,9 @@ mono_domain_unset (void) MONO_INTERNAL;
 void
 mono_domain_set_internal_with_options (MonoDomain *domain, gboolean migrate_exception) MONO_INTERNAL;
 
+MonoTryBlockHoleTableJitInfo*
+mono_jit_info_get_try_block_hole_table_info (MonoJitInfo *ji) MONO_INTERNAL;
+
 /* 
  * Installs a new function which is used to return a MonoJitInfo for a method inside
  * an AOT module.
index 12a21fa61aab330f9a0a2ad61bb92076823cbc4a..b6cf5c2289479417eb0380c93ea961c9e47a7aca 100644 (file)
@@ -1020,7 +1020,19 @@ mono_jit_info_set_generic_sharing_context (MonoJitInfo *ji, MonoGenericSharingCo
 
        gi->generic_sharing_context = gsctx;
 }
+
+MonoTryBlockHoleTableJitInfo*
+mono_jit_info_get_try_block_hole_table_info (MonoJitInfo *ji)
+{
+       if (ji->has_try_block_holes) {
+               char *ptr = (char*)&ji->clauses [ji->num_clauses];
+               if (ji->has_generic_jit_info)
+                       ptr += sizeof (MonoGenericJitInfo);
+               return (MonoTryBlockHoleTableJitInfo*)ptr;
+       } else {
+               return NULL;
+       }
+}
 void
 mono_install_create_domain_hook (MonoCreateDomainFunc func)
 {
index 10b94338ffabf3ad7c6473fb54fcf763072ee20a..2d17d7355929d24d2b32a46c973c2794e5402fa5 100644 (file)
@@ -112,8 +112,8 @@ void     mono_gc_finalize_notify    (void) MONO_INTERNAL;
 
 void* mono_gc_alloc_pinned_obj (MonoVTable *vtable, size_t size) MONO_INTERNAL;
 void* mono_gc_alloc_obj (MonoVTable *vtable, size_t size) MONO_INTERNAL;
-void* mono_gc_alloc_vector (MonoVTable *vtable, size_t size, mono_array_size_t max_length) MONO_INTERNAL;
-void* mono_gc_alloc_array (MonoVTable *vtable, size_t size, mono_array_size_t max_length, mono_array_size_t bounds_size) MONO_INTERNAL;
+void* mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length) MONO_INTERNAL;
+void* mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uintptr_t bounds_size) MONO_INTERNAL;
 void* mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len) MONO_INTERNAL;
 void* mono_gc_make_descr_for_string (gsize *bitmap, int numbits) MONO_INTERNAL;
 void* mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size) MONO_INTERNAL;
@@ -214,6 +214,10 @@ gsize* mono_gc_get_bitmap_for_descr (void *descr, int *numbits) MONO_INTERNAL;
    or -1 if not applicable. */
 int mono_gc_get_suspend_signal (void) MONO_INTERNAL;
 
+typedef void* (*MonoGCLockedCallbackFunc) (void *data);
+
+void* mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data) MONO_INTERNAL;
+
 #ifdef HAVE_SGEN_GC
 int mono_gc_get_los_limit (void) MONO_INTERNAL;
 #endif
index 55d304a1fddd921e1587abcb01467ee6d661707a..e6604f09522650fcc61be40553abc40e04f2389a 100644 (file)
@@ -915,6 +915,7 @@ ICALL(THREADP_2, "GetMaxThreads", ves_icall_System_Threading_ThreadPool_GetMaxTh
 ICALL(THREADP_3, "GetMinThreads", ves_icall_System_Threading_ThreadPool_GetMinThreads)
 ICALL(THREADP_35, "SetMaxThreads", ves_icall_System_Threading_ThreadPool_SetMaxThreads)
 ICALL(THREADP_4, "SetMinThreads", ves_icall_System_Threading_ThreadPool_SetMinThreads)
+ICALL(THREADP_5, "pool_queue", icall_append_job)
 
 ICALL_TYPE(WAITH, "System.Threading.WaitHandle", WAITH_1)
 ICALL(WAITH_1, "SignalAndWait_Internal", ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal)
index d1f2bb0806f481647c130c7795941c23bc48031d..59ee6946c4e7be1b6c81472501923606421b7c62 100644 (file)
@@ -559,7 +559,7 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
 {
        MonoClass *aklass;
        MonoArray *array;
-       mono_array_size_t *sizes, i;
+       uintptr_t *sizes, i;
        gboolean bounded = FALSE;
 
        MONO_ARCH_SAVE_REGS;
@@ -583,7 +583,7 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
 
        aklass = mono_bounded_array_class_get (mono_class_from_mono_type (type->type), mono_array_length (lengths), bounded);
 
-       sizes = alloca (aklass->rank * sizeof(mono_array_size_t) * 2);
+       sizes = alloca (aklass->rank * sizeof(intptr_t) * 2);
        for (i = 0; i < aklass->rank; ++i) {
                sizes [i] = mono_array_get (lengths, guint32, i);
                if (bounds)
@@ -592,7 +592,7 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
                        sizes [i + aklass->rank] = 0;
        }
 
-       array = mono_array_new_full (mono_object_domain (type), aklass, sizes, sizes + aklass->rank);
+       array = mono_array_new_full (mono_object_domain (type), aklass, sizes, (intptr_t*)sizes + aklass->rank);
 
        return array;
 }
@@ -602,7 +602,7 @@ ves_icall_System_Array_CreateInstanceImpl64 (MonoReflectionType *type, MonoArray
 {
        MonoClass *aklass;
        MonoArray *array;
-       mono_array_size_t *sizes, i;
+       uintptr_t *sizes, i;
        gboolean bounded = FALSE;
 
        MONO_ARCH_SAVE_REGS;
@@ -627,7 +627,7 @@ ves_icall_System_Array_CreateInstanceImpl64 (MonoReflectionType *type, MonoArray
 
        aklass = mono_bounded_array_class_get (mono_class_from_mono_type (type->type), mono_array_length (lengths), bounded);
 
-       sizes = alloca (aklass->rank * sizeof(mono_array_size_t) * 2);
+       sizes = alloca (aklass->rank * sizeof(intptr_t) * 2);
        for (i = 0; i < aklass->rank; ++i) {
                sizes [i] = mono_array_get (lengths, guint64, i);
                if (bounds)
@@ -636,7 +636,7 @@ ves_icall_System_Array_CreateInstanceImpl64 (MonoReflectionType *type, MonoArray
                        sizes [i + aklass->rank] = 0;
        }
 
-       array = mono_array_new_full (mono_object_domain (type), aklass, sizes, sizes + aklass->rank);
+       array = mono_array_new_full (mono_object_domain (type), aklass, sizes, (intptr_t*)sizes + aklass->rank);
 
        return array;
 }
@@ -653,7 +653,7 @@ static gint32
 ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension)
 {
        gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
-       mono_array_size_t length;
+       uintptr_t length;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -2854,12 +2854,13 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr
        
        if (m->klass->rank && !strcmp (m->name, ".ctor")) {
                int i;
-               mono_array_size_t *lengths;
-               mono_array_size_t *lower_bounds;
+               uintptr_t *lengths;
+               intptr_t *lower_bounds;
                pcount = mono_array_length (params);
-               lengths = alloca (sizeof (mono_array_size_t) * pcount);
+               lengths = alloca (sizeof (uintptr_t) * pcount);
+               /* Note: the synthetized array .ctors have int32 as argument type */
                for (i = 0; i < pcount; ++i)
-                       lengths [i] = *(mono_array_size_t*) ((char*)mono_array_get (params, gpointer, i) + sizeof (MonoObject));
+                       lengths [i] = *(int32_t*) ((char*)mono_array_get (params, gpointer, i) + sizeof (MonoObject));
 
                if (m->klass->rank == pcount) {
                        /* Only lengths provided. */
@@ -2867,7 +2868,7 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr
                } else {
                        g_assert (pcount == (m->klass->rank * 2));
                        /* lower bounds are first. */
-                       lower_bounds = lengths;
+                       lower_bounds = (intptr_t*)lengths;
                        lengths += m->klass->rank;
                }
 
index e08e19c81e2e2560fb33b73a11bcfd72a24d3525..5114695ab71b3ac27f5f743d8b72315b2a3e6983 100644 (file)
@@ -1508,7 +1508,7 @@ mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass,
            (cols [1] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
                result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke));
        else
-               result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodNormal));
+               result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod));
 
        mono_stats.method_count ++;
 
@@ -1737,12 +1737,12 @@ mono_free_method  (MonoMethod *method)
                mono_image_property_remove (method->klass->image, method);
 
                g_free ((char*)method->name);
-               if (mw->method.header) {
-                       g_free ((char*)mw->method.header->code);
-                       for (i = 0; i < mw->method.header->num_locals; ++i)
-                               g_free (mw->method.header->locals [i]);
-                       g_free (mw->method.header->clauses);
-                       g_free (mw->method.header);
+               if (mw->header) {
+                       g_free ((char*)mw->header->code);
+                       for (i = 0; i < mw->header->num_locals; ++i)
+                               g_free (mw->header->locals [i]);
+                       g_free (mw->header->clauses);
+                       g_free (mw->header);
                }
                g_free (mw->method_data);
                g_free (method->signature);
@@ -1867,6 +1867,7 @@ mono_method_get_marshal_info (MonoMethod *method, MonoMarshalSpec **mspecs)
                        for (i = 0; i < signature->param_count + 1; ++i)
                                if (dyn_specs [i]) {
                                        mspecs [i] = g_new0 (MonoMarshalSpec, 1);
+                                       memcpy (mspecs [i], dyn_specs [i], sizeof (MonoMarshalSpec));
                                        mspecs [i]->data.custom_data.custom_name = g_strdup (dyn_specs [i]->data.custom_data.custom_name);
                                        mspecs [i]->data.custom_data.cookie = g_strdup (dyn_specs [i]->data.custom_data.cookie);
                                }
@@ -2252,40 +2253,39 @@ mono_method_get_header (MonoMethod *method)
        guint32 rva;
        MonoImage* img;
        gpointer loc;
-       MonoMethodNormal* mn = (MonoMethodNormal*) method;
        MonoMethodHeader *header;
 
        if ((method->flags & METHOD_ATTRIBUTE_ABSTRACT) || (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) || (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) || (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
                return NULL;
 
-#ifdef G_LIKELY
-       if (G_LIKELY (mn->header))
-#else
-       if (mn->header)
-#endif
-               return mn->header;
+       if (method->wrapper_type != MONO_WRAPPER_NONE || method->sre_method) {
+               MonoMethodWrapper *mw = (MonoMethodWrapper *)method;
+               g_assert (mw->header);
+               return mw->header;
+       }
 
        if (method->is_inflated) {
                MonoMethodInflated *imethod = (MonoMethodInflated *) method;
                MonoMethodHeader *header;
 
-               header = mono_method_get_header (imethod->declaring);
-
                mono_loader_lock ();
 
-               if (mn->header) {
+               if (imethod->header) {
                        mono_loader_unlock ();
-                       return mn->header;
+                       return imethod->header;
                }
 
-               mn->header = inflate_generic_header (header, mono_method_get_context (method));
+               header = mono_method_get_header (imethod->declaring);
+
+               imethod->header = inflate_generic_header (header, mono_method_get_context (method));
                mono_loader_unlock ();
-               return mn->header;
+               mono_metadata_free_mh (header);
+               return imethod->header;
        }
 
        /* 
-        * Do most of the work outside the loader lock, to avoid assembly loader hook
-        * deadlocks.
+        * We don't need locks here: the new header is allocated from malloc memory
+        * and is not stored anywhere in the runtime, the user needs to free it.
         */
        g_assert (mono_metadata_token_table (method->token) == MONO_TABLE_METHOD);
        idx = mono_metadata_token_index (method->token);
@@ -2301,20 +2301,7 @@ mono_method_get_header (MonoMethod *method)
 
        header = mono_metadata_parse_mh_full (img, mono_method_get_generic_container (method), loc);
 
-       mono_loader_lock ();
-
-       if (mn->header) {
-               /* header is allocated from the image mempool, no need to free it */
-               mono_loader_unlock ();
-               return mn->header;
-       }
-
-       mono_memory_barrier ();
-
-       mn->header = header;
-
-       mono_loader_unlock ();
-       return mn->header;
+       return header;
 }
 
 guint32
index 928ce29026652761704311239dfa7c84fa1b7d43..ed18312270f3fbcd059675cced906686e738c8fc 100644 (file)
@@ -381,11 +381,14 @@ get_posix_locale (void)
 static gchar*
 get_darwin_locale (void)
 {
-       const gchar *darwin_locale = NULL;
-       gchar *cur_locale = NULL;
-       int i;
+       static gchar *darwin_locale = NULL;
        CFLocaleRef locale = NULL;
        CFStringRef locale_cfstr = NULL;
+       CFIndex len;
+       int i;
+
+       if (darwin_locale != NULL)
+               return g_strdup (darwin_locale);
 
        locale = CFLocaleCopyCurrent ();
 
@@ -393,20 +396,24 @@ get_darwin_locale (void)
                locale_cfstr = CFLocaleGetIdentifier (locale);
 
                if (locale_cfstr) {
-                       darwin_locale = CFStringGetCStringPtr (locale_cfstr, kCFStringEncodingMacRoman);
-
-                       cur_locale = g_strdup (darwin_locale);
+                       len = CFStringGetMaximumSizeForEncoding (CFStringGetLength (locale_cfstr), kCFStringEncodingMacRoman) + 1;
+                       darwin_locale = (char *) malloc (len);
+                       if (!CFStringGetCString (locale_cfstr, darwin_locale, len, kCFStringEncodingMacRoman)) {
+                               free (darwin_locale);
+                               CFRelease (locale);
+                               darwin_locale = NULL;
+                               return NULL;
+                       }
 
-                       for (i = 0; i < strlen (cur_locale); i++)
-                               if (cur_locale [i] == '_')
-                                       cur_locale [i] = '-';
+                       for (i = 0; i < strlen (darwin_locale); i++)
+                               if (darwin_locale [i] == '_')
+                                       darwin_locale [i] = '-';
                }
 
-
                CFRelease (locale);
        }
 
-       return cur_locale;
+       return g_strdup (darwin_locale);
 }
 #endif
 
@@ -416,7 +423,7 @@ get_current_locale_name (void)
        gchar *locale;
        gchar *corrected = NULL;
        const gchar *p;
-        gchar *c;
+       gchar *c;
 
 #ifdef HOST_WIN32
        locale = g_win32_getlocale ();
index ff3c8bf4c34550f782bb79a16c9aa687e1b859cd..0394014fe9c7dc711f94c8d6ad04d14b440a0a61 100644 (file)
@@ -8060,6 +8060,12 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
        mono_mb_emit_byte (mb, CEE_RET);
 }
 
+G_GNUC_UNUSED static void
+code_for (MonoMethod *method) {
+       MonoMethodHeader *header = mono_method_get_header (method);
+       printf ("CODE FOR %s: \n%s.\n", mono_method_full_name (method, TRUE), mono_disasm_code (0, method, header->code, header->code + header->code_size));
+}
+
 /**
  * mono_marshal_get_native_wrapper:
  * @method: The MonoMethod to wrap.
@@ -8247,7 +8253,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                        mono_metadata_free_marshal_spec (mspecs [i]);
        g_free (mspecs);
 
-       /* printf ("CODE FOR %s: \n%s.\n", mono_method_full_name (res, TRUE), mono_disasm_code (0, res, ((MonoMethodNormal*)res)->header->code, ((MonoMethodNormal*)res)->header->code + ((MonoMethodNormal*)res)->header->code_size)); */ 
+       /* code_for (res); */
 
        return res;
 }
@@ -8288,7 +8294,7 @@ mono_marshal_get_native_func_wrapper (MonoImage *image, MonoMethodSignature *sig
                                                                        mb, csig, csig->param_count + 16);
        mono_mb_free (mb);
 
-       /* printf ("CODE FOR %s: \n%s.\n", mono_method_full_name (res, TRUE), mono_disasm_code (0, res, ((MonoMethodNormal*)res)->header->code, ((MonoMethodNormal*)res)->header->code + ((MonoMethodNormal*)res)->header->code_size)); */ 
+       /* code_for (res); */
 
        return res;
 }
@@ -8661,7 +8667,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass,
                        mono_metadata_free_marshal_spec (mspecs [i]);
        g_free (mspecs);
 
-       /* printf ("CODE FOR %s: \n%s.\n", mono_method_full_name (res, TRUE), mono_disasm_code (0, res, ((MonoMethodNormal*)res)->header->code, ((MonoMethodNormal*)res)->header->code + ((MonoMethodNormal*)res)->header->code_size)); */
+       /* code_for (res); */
 
        return res;
 }
@@ -9296,7 +9302,7 @@ mono_marshal_get_unbox_wrapper (MonoMethod *method)
                                                                                 mb, sig, sig->param_count + 16);
        mono_mb_free (mb);
 
-       /* printf ("CODE FOR %s: \n%s.\n", mono_method_full_name (res, TRUE), mono_disasm_code (0, res, ((MonoMethodNormal*)res)->header->code, ((MonoMethodNormal*)res)->header->code + ((MonoMethodNormal*)res)->header->code_size)); */
+       /* code_for (res); */
 
        return res;     
 }
index e9a3df0dbf0521af37d1f6855184cdd07e7ca6f4..e6689514fc203f83f402769b69341983ccffd42c 100644 (file)
@@ -438,7 +438,8 @@ struct _MonoMethodHeader {
 #else
        guint32      code_size;
 #endif
-       guint16      max_stack;
+       guint16      max_stack   : 15;
+       unsigned int is_transient: 1; /* mono_metadata_free_mh () will actually free this header */
        unsigned int num_clauses : 15;
        /* if num_locals != 0, then the following apply: */
        unsigned int init_locals : 1;
index bdeda849b494732926e1a2fa9fabc06037ee1ff6..4f1cfaf04154bc596df2b0c9703b7516a08239ec 100644 (file)
@@ -1504,7 +1504,7 @@ mono_metadata_cleanup (void)
  *
  * To parse a generic type, `generic_container' points to the current class'es
  * (the `generic_container' field in the MonoClass) or the current generic method's
- * (the `generic_container' field in the MonoMethodNormal) generic container.
+ * (stored in image->property_hash) generic container.
  * When we encounter any MONO_TYPE_VAR or MONO_TYPE_MVAR's, they're looked up in
  * this MonoGenericContainer.
  * This is a Mono runtime internal function.
@@ -2589,8 +2589,7 @@ free_inflated_method (MonoMethodInflated *imethod)
                mono_metadata_free_inflated_signature (method->signature);
 
        if (!((method->flags & METHOD_ATTRIBUTE_ABSTRACT) || (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) || (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) || (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))) {
-               MonoMethodNormal* mn = (MonoMethodNormal*) method;
-               MonoMethodHeader *header = mn->header;
+               MonoMethodHeader *header = imethod->header;
 
                if (header) {
                        /* Allocated in inflate_generic_header () */
@@ -3008,7 +3007,7 @@ select_container (MonoGenericContainer *gc, MonoTypeEnum type)
 
 /* 
  * mono_metadata_parse_generic_param:
- * @generic_container: Our MonoClass's or MonoMethodNormal's MonoGenericContainer;
+ * @generic_container: Our MonoClass's or MonoMethod's MonoGenericContainer;
  *                     see mono_metadata_parse_type_full() for details.
  * Internal routine to parse a generic type parameter.
  * LOCKING: Acquires the loader lock
@@ -3233,16 +3232,16 @@ hex_dump (const char *buffer, int base, int count)
 #endif
 
 /** 
- * @mh: The Method header
  * @ptr: Points to the beginning of the Section Data (25.3)
  */
-static void
-parse_section_data (MonoImage *m, MonoMethodHeader *mh, const unsigned char *ptr)
+static MonoExceptionClause*
+parse_section_data (MonoImage *m, int *num_clauses, const unsigned char *ptr)
 {
        unsigned char sect_data_flags;
        const unsigned char *sptr;
        int is_fat;
        guint32 sect_data_len;
+       MonoExceptionClause* clauses = NULL;
        
        while (1) {
                /* align on 32-bit boundary */
@@ -3269,11 +3268,11 @@ parse_section_data (MonoImage *m, MonoMethodHeader *mh, const unsigned char *ptr
                if (sect_data_flags & METHOD_HEADER_SECTION_EHTABLE) {
                        const unsigned char *p = dword_align (ptr);
                        int i;
-                       mh->num_clauses = is_fat ? sect_data_len / 24: sect_data_len / 12;
+                       *num_clauses = is_fat ? sect_data_len / 24: sect_data_len / 12;
                        /* we could just store a pointer if we don't need to byteswap */
-                       mh->clauses = mono_image_alloc0 (m, sizeof (MonoExceptionClause) * mh->num_clauses);
-                       for (i = 0; i < mh->num_clauses; ++i) {
-                               MonoExceptionClause *ec = &mh->clauses [i];
+                       clauses = g_malloc0 (sizeof (MonoExceptionClause) * (*num_clauses));
+                       for (i = 0; i < *num_clauses; ++i) {
+                               MonoExceptionClause *ec = &clauses [i];
                                guint32 tof_value;
                                if (is_fat) {
                                        ec->flags = read32 (p);
@@ -3306,7 +3305,7 @@ parse_section_data (MonoImage *m, MonoMethodHeader *mh, const unsigned char *ptr
                if (sect_data_flags & METHOD_HEADER_SECTION_MORE_SECTS)
                        ptr += sect_data_len - 4; /* LAMESPEC: it seems the size includes the header */
                else
-                       return;
+                       return clauses;
        }
 }
 
@@ -3339,8 +3338,8 @@ mono_method_get_header_summary (MonoMethod *method, MonoMethodHeaderSummary *sum
        if ((method->flags & METHOD_ATTRIBUTE_ABSTRACT) || (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) || (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) || (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
                return FALSE;
 
-       if (method->klass->image->dynamic || ((MonoMethodNormal*) method)->header) {
-               MonoMethodHeader *header = mono_method_get_header (method);
+       if (method->wrapper_type != MONO_WRAPPER_NONE || method->sre_method) {
+               MonoMethodHeader *header =  ((MonoMethodWrapper *)method)->header;
                if (!header)
                        return FALSE;
                summary->code_size = header->code_size;
@@ -3404,15 +3403,19 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *container, cons
        guint16 fat_flags;
        guint32 local_var_sig_tok, max_stack, code_size, init_locals;
        const unsigned char *code;
-       int hsize;
-       
+       MonoExceptionClause* clauses = NULL;
+       int hsize, num_clauses = 0;
+       MonoTableInfo *t = &m->tables [MONO_TABLE_STANDALONESIG];
+       guint32 cols [MONO_STAND_ALONE_SIGNATURE_SIZE];
+
        g_return_val_if_fail (ptr != NULL, NULL);
 
        switch (format) {
        case METHOD_HEADER_TINY_FORMAT:
-               mh = mono_image_alloc0 (m, MONO_SIZEOF_METHOD_HEADER);
+               mh = g_malloc0 (MONO_SIZEOF_METHOD_HEADER);
                ptr++;
                mh->max_stack = 8;
+               mh->is_transient = TRUE;
                local_var_sig_tok = 0;
                mh->code_size = flags >> 2;
                mh->code = (unsigned char*)ptr;
@@ -3446,17 +3449,21 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *container, cons
        default:
                return NULL;
        }
-                      
-       if (local_var_sig_tok) {
-               MonoTableInfo *t = &m->tables [MONO_TABLE_STANDALONESIG];
-               const char *locals_ptr;
-               guint32 cols [MONO_STAND_ALONE_SIGNATURE_SIZE];
-               int len=0, i, bsize;
 
-               mono_metadata_decode_row (t, (local_var_sig_tok & 0xffffff)-1, cols, 1);
+       if (local_var_sig_tok) {
+               int idx = (local_var_sig_tok & 0xffffff)-1;
+               if (idx >= t->rows)
+                       return NULL;
+               mono_metadata_decode_row (t, idx, cols, 1);
 
                if (!mono_verifier_verify_standalone_signature (m, cols [MONO_STAND_ALONE_SIGNATURE], NULL))
                        return NULL;
+       }
+       if (fat_flags & METHOD_HEADER_MORE_SECTS)
+               clauses = parse_section_data (m, &num_clauses, (const unsigned char*)ptr);
+       if (local_var_sig_tok) {
+               const char *locals_ptr;
+               int len=0, i, bsize;
 
                locals_ptr = mono_metadata_blob_heap (m, cols [MONO_STAND_ALONE_SIGNATURE]);
                bsize = mono_metadata_decode_blob_size (locals_ptr, &locals_ptr);
@@ -3464,24 +3471,31 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *container, cons
                        g_warning ("wrong signature for locals blob");
                locals_ptr++;
                len = mono_metadata_decode_value (locals_ptr, &locals_ptr);
-               mh = mono_image_alloc0 (m, MONO_SIZEOF_METHOD_HEADER + len * sizeof (MonoType*));
+               mh = g_malloc0 (MONO_SIZEOF_METHOD_HEADER + len * sizeof (MonoType*) + num_clauses * sizeof (MonoExceptionClause));
                mh->num_locals = len;
                for (i = 0; i < len; ++i) {
                        mh->locals [i] = mono_metadata_parse_type_full (
                                m, container, MONO_PARSE_LOCAL, 0, locals_ptr, &locals_ptr);
                        if (!mh->locals [i]) {
+                               g_free (clauses);
                                return NULL;
                        }
                }
        } else {
-               mh = mono_image_alloc0 (m, MONO_SIZEOF_METHOD_HEADER);
+               mh = g_malloc0 (MONO_SIZEOF_METHOD_HEADER + num_clauses * sizeof (MonoExceptionClause));
        }
        mh->code = code;
        mh->code_size = code_size;
        mh->max_stack = max_stack;
+       mh->is_transient = TRUE;
        mh->init_locals = init_locals;
-       if (fat_flags & METHOD_HEADER_MORE_SECTS)
-               parse_section_data (m, mh, (const unsigned char*)ptr);
+       if (clauses) {
+               MonoExceptionClause* clausesp = (MonoExceptionClause*)&mh->locals [mh->num_locals];
+               memcpy (clausesp, clauses, num_clauses * sizeof (MonoExceptionClause));
+               g_free (clauses);
+               mh->clauses = clausesp;
+               mh->num_clauses = num_clauses;
+       }
        return mh;
 }
 
@@ -3515,12 +3529,16 @@ mono_metadata_parse_mh (MonoImage *m, const char *ptr)
  * @mh: a method header
  *
  * Free the memory allocated for the method header.
- * This is a Mono runtime internal function.
  */
 void
 mono_metadata_free_mh (MonoMethodHeader *mh)
 {
-       /* Allocated from the mempool */
+       /* If it is not transient it means it's part of a wrapper method,
+        * or a SRE-generated method, so the lifetime in that case is
+        * dictated by the method's own lifetime
+        */
+       if (mh->is_transient)
+               g_free (mh);
 }
 
 /*
index 74b42a204e0695da6718cc55b505a8e26c8e676d..247c749bdedad87bad1932fc978dea8bb7f81eb9 100644 (file)
@@ -142,11 +142,12 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
        mono_loader_lock (); /*FIXME I think this lock can go.*/
        if (mb->dynamic) {
                method = mb->method;
+               mw = (MonoMethodWrapper*)method;
 
                method->name = mb->name;
                method->dynamic = TRUE;
 
-               ((MonoMethodNormal *)method)->header = header = (MonoMethodHeader *) 
+               mw->header = header = (MonoMethodHeader *) 
                        g_malloc0 (MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *));
 
                header->code = mb->code;
@@ -159,13 +160,14 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
 
                method = mono_image_alloc0 (image, sizeof (MonoMethodWrapper));
                memcpy (method, mb->method, sizeof (MonoMethodWrapper));
+               mw = (MonoMethodWrapper*) method;
 
                if (mb->no_dup_name)
                        method->name = mb->name;
                else
                        method->name = mono_image_strdup (image, mb->name);
 
-               ((MonoMethodNormal *)method)->header = header = (MonoMethodHeader *) 
+               mw->header = header = (MonoMethodHeader *) 
                        mono_image_alloc0 (image, MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *));
 
                header->code = mono_image_alloc (image, mb->pos);
@@ -192,7 +194,6 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
 
        method->skip_visibility = mb->skip_visibility;
 
-       mw = (MonoMethodWrapper*) mb->method;
        i = g_list_length (mw->method_data);
        if (i) {
                GList *tmp;
@@ -210,7 +211,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
                }
                g_list_free (l);
 
-               ((MonoMethodWrapper*)method)->method_data = data;
+               mw->method_data = data;
        }
        /*{
                static int total_code = 0;
index 0b8f8063358dea16c0fa4361f6919b9204019deb..a1767f01076066a3011837438d5b5032d185ff2a 100644 (file)
@@ -72,7 +72,7 @@ struct _MonoDebugDataTable {
 
 typedef struct {
        const gchar *method_name;
-       const gchar *cil_code;
+       const gchar *obsolete_cil_code;
        guint32 wrapper_type;
 } MonoDebugWrapperData;
 
@@ -159,7 +159,6 @@ free_header_data (gpointer key, gpointer value, gpointer user_data)
 
        if (header->wrapper_data) {
                g_free ((gpointer)header->wrapper_data->method_name);
-               g_free ((gpointer)header->wrapper_data->cil_code);
                g_slist_free (header->address_list);
                g_free (header->wrapper_data);
        }
@@ -654,21 +653,13 @@ mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDoma
                g_hash_table_insert (table->method_hash, declaring, header);
 
                if (is_wrapper) {
-                       const unsigned char* il_code;
-                       MonoMethodHeader *mheader;
                        MonoDebugWrapperData *wrapper;
-                       guint32 il_codesize;
-
-                       mheader = mono_method_get_header (declaring);
-                       il_code = mono_method_header_get_code (mheader, &il_codesize, NULL);
 
                        header->wrapper_data = wrapper = g_new0 (MonoDebugWrapperData, 1);
 
                        wrapper->wrapper_type = method->wrapper_type;
                        wrapper->method_name = mono_method_full_name (declaring, TRUE);
-                       wrapper->cil_code = mono_disasm_code (
-                               NULL, declaring, il_code, il_code + il_codesize);
-                       mono_metadata_free_mh (mheader);
+                       wrapper->obsolete_cil_code = "";
                }
        } else {
                address->header.wrapper_data = header->wrapper_data;
index e0fda55dd9066797abaffa3644ce69ef4a2a45fd..a7543b50f851ec194734d38cd5c576bf9ad65d40 100644 (file)
@@ -11,7 +11,7 @@
 #include "mono/metadata/appdomain.h"
 #include "mono/metadata/class-internals.h"
 
-/* matches the System.MonoListItem objcet*/
+/* matches the System.MonoListItem object*/
 struct _MonoMList {
        MonoObject object;
        MonoMList *next;
@@ -72,6 +72,23 @@ mono_mlist_set_data (MonoMList* list, MonoObject *data)
        MONO_OBJECT_SETREF (list, data, data);
 }
 
+/**
+ * mono_mlist_set_next:
+ * @list: a managed list node
+ * @next: list node that will be next for the @list node.
+ *
+ * Set next node for @list to @next.
+ */
+MonoMList *
+mono_mlist_set_next (MonoMList* list, MonoMList *next)
+{
+       if (!list)
+               return next;
+
+       MONO_OBJECT_SETREF (list, next, next);
+       return list;
+}
+
 /**
  * mono_mlist_length:
  * @list: the managed list
@@ -175,7 +192,7 @@ find_prev (MonoMList* list, MonoMList *item)
 /**
  * mono_mlist_remove_item:
  * @list: the managed list
- * @data: the object to add to the list
+ * @data: the object to remove from the list
  *
  * Remove the list node @item from the managed list @list.
  * Since managed lists are singly-linked, this operation can take O(n) time.
index 61724e9ceb9d323e7cc4edfac7f1fb87c503bc6c..0dc0b4b5d58f8918fd597deb3dc9cb413ed9aed6 100644 (file)
@@ -8,10 +8,10 @@
 #include <mono/metadata/object.h>
 
 typedef struct _MonoMList MonoMList;
-
 MonoMList*  mono_mlist_alloc       (MonoObject *data);
 MonoObject* mono_mlist_get_data    (MonoMList* list);
 void        mono_mlist_set_data    (MonoMList* list, MonoObject *data);
+MonoMList*  mono_mlist_set_next    (MonoMList* list, MonoMList *next);
 int         mono_mlist_length      (MonoMList* list);
 MonoMList*  mono_mlist_next        (MonoMList* list);
 MonoMList*  mono_mlist_last        (MonoMList* list);
index b73ae60fea70822d44e603a8f206ef41f96a3e1a..23b9fdaccd71643ec9a3e522d8e62e9e0cc13a73 100644 (file)
@@ -124,6 +124,8 @@ PERFCTR_COUNTER(THREADPOOL_WORKITEMS, "Work Items Added", "", NumberOfItems64, t
 PERFCTR_COUNTER(THREADPOOL_WORKITEMS_PSEC, "Work Items Added/Sec", "", RateOfCountsPerSecond32, threadpool_workitems)
 PERFCTR_COUNTER(THREADPOOL_IOWORKITEMS, "IO Work Items Added", "", NumberOfItems64, threadpool_ioworkitems)
 PERFCTR_COUNTER(THREADPOOL_IOWORKITEMS_PSEC, "IO Work Items Added/Sec", "", RateOfCountsPerSecond32, threadpool_ioworkitems)
+PERFCTR_COUNTER(THREADPOOL_THREADS, "# of Threads", "", NumberOfItems32, threadpool_threads)
+PERFCTR_COUNTER(THREADPOOL_IOTHREADS, "# of IO Threads", "", NumberOfItems32, threadpool_iothreads)
 
 PERFCTR_CAT(NETWORK, "Network Interface", "", MultiInstance, NetworkInterface, NETWORK_BYTESRECSEC)
 PERFCTR_COUNTER(NETWORK_BYTESRECSEC, "Bytes Received/sec", "", RateOfCountsPerSecond64, unused)
index 48b666df947c598a56bf65728a684c2c9178e57a..6bd5fc032f2ed2c7cf17badc3b0ca967fec0ff9b 100644 (file)
@@ -929,6 +929,12 @@ predef_writable_counter (ImplVtable *vtable, MonoBoolean only_value, MonoCounter
                case COUNTER_THREADPOOL_IOWORKITEMS:
                        sample->rawValue = mono_perfcounters->threadpool_ioworkitems;
                        return TRUE;
+               case COUNTER_THREADPOOL_THREADS:
+                       sample->rawValue = mono_perfcounters->threadpool_threads;
+                       return TRUE;
+               case COUNTER_THREADPOOL_IOTHREADS:
+                       sample->rawValue = mono_perfcounters->threadpool_iothreads;
+                       return TRUE;
                }
                break;
        }
@@ -954,6 +960,8 @@ predef_writable_update (ImplVtable *vtable, MonoBoolean do_incr, gint64 value)
                switch (id) {
                case COUNTER_THREADPOOL_WORKITEMS: ptr64 = (gint64 *) &mono_perfcounters->threadpool_workitems; break;
                case COUNTER_THREADPOOL_IOWORKITEMS: ptr64 = (gint64 *) &mono_perfcounters->threadpool_ioworkitems; break;
+               case COUNTER_THREADPOOL_THREADS: ptr = &mono_perfcounters->threadpool_threads; break;
+               case COUNTER_THREADPOOL_IOTHREADS: ptr = &mono_perfcounters->threadpool_iothreads; break;
                }
                break;
        }
diff --git a/mono/metadata/mono-wsq.c b/mono/metadata/mono-wsq.c
new file mode 100644 (file)
index 0000000..83cc715
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * mono-wsq.c: work-stealing queue
+ *
+ * Authors:
+ *   Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *
+ * Copyright (c) 2010 Novell, Inc (http://www.novell.com)
+ */
+
+#include <string.h>
+#include <mono/metadata/object.h>
+#include <mono/metadata/mono-wsq.h>
+#include <mono/utils/mono-semaphore.h>
+
+#define INITIAL_LENGTH 32
+#define WSQ_DEBUG(...)
+//#define WSQ_DEBUG(...) g_message(__VA_ARGS__)
+
+struct _MonoWSQ {
+       volatile gint head;
+       volatile gint tail;
+       MonoArray *queue;
+       gint32 mask;
+       MonoSemType lock;
+};
+
+static guint32 wsq_tlskey = -1;
+
+void
+mono_wsq_init ()
+{
+       wsq_tlskey = TlsAlloc ();
+}
+
+void
+mono_wsq_cleanup ()
+{
+       if (wsq_tlskey == -1)
+               return;
+       TlsFree (wsq_tlskey);
+       wsq_tlskey = -1;
+}
+
+MonoWSQ *
+mono_wsq_create ()
+{
+       MonoWSQ *wsq;
+       MonoDomain *root;
+
+       wsq = g_new0 (MonoWSQ, 1);
+       wsq->mask = INITIAL_LENGTH - 1;
+       MONO_GC_REGISTER_ROOT (wsq->queue);
+       root = mono_get_root_domain ();
+       wsq->queue = mono_array_new_cached (root, mono_defaults.object_class, INITIAL_LENGTH);
+       MONO_SEM_INIT (&wsq->lock, 1);
+       TlsSetValue (wsq_tlskey, wsq);
+       return wsq;
+}
+
+void
+mono_wsq_destroy (MonoWSQ *wsq)
+{
+       if (wsq == NULL || wsq->queue == NULL)
+               return;
+
+       /* TODO: clean up queue if not empty */
+       MONO_GC_UNREGISTER_ROOT (wsq->queue);
+       MONO_SEM_DESTROY (&wsq->lock);
+       if (wsq_tlskey != -1 && TlsGetValue (wsq_tlskey) == wsq)
+               TlsSetValue (wsq_tlskey, NULL);
+       memset (wsq, 0, sizeof (MonoWSQ));
+       g_free (wsq);
+}
+
+gint
+mono_wsq_count (MonoWSQ *wsq)
+{
+       return ((wsq->tail - wsq->head) & wsq->mask);
+}
+
+gboolean
+mono_wsq_local_push (void *obj)
+{
+       int tail;
+       int head;
+       int count;
+       MonoWSQ *wsq;
+
+       if (obj == NULL)
+               return FALSE;
+
+       wsq = (MonoWSQ *) TlsGetValue (wsq_tlskey);
+       if (wsq == NULL) {
+               WSQ_DEBUG ("local_push: no wsq\n");
+               return FALSE;
+       }
+
+       tail = wsq->tail;
+       if (tail < wsq->head + wsq->mask) {
+               mono_array_setref (wsq->queue, tail & wsq->mask, (MonoObject *) obj);
+               wsq->tail = tail + 1;
+               WSQ_DEBUG ("local_push: OK %p %p\n", wsq, obj);
+               return TRUE;
+       }
+
+       MONO_SEM_WAIT (&wsq->lock);
+       head = wsq->head;
+       count = wsq->tail - wsq->head;
+       if (count >= wsq->mask) {
+               MonoArray *new_array;
+               int length;
+               int i;
+
+               length = mono_array_length (wsq->queue);
+               new_array = mono_array_new_cached (mono_get_root_domain (), mono_defaults.object_class, length * 2);
+               for (i = 0; i < length; i++)
+                       mono_array_setref (new_array, i, mono_array_get (wsq->queue, MonoObject*, (i + head) & wsq->mask));
+
+               memset (mono_array_addr (wsq->queue, MonoObject *, 0), 0, sizeof (MonoObject*) * length);
+               wsq->queue = new_array;
+               wsq->head = 0;
+               wsq->tail = tail = count;
+               wsq->mask = (wsq->mask << 1) | 1;
+       }
+       mono_array_setref (wsq->queue, tail & wsq->mask, obj);
+       wsq->tail = tail + 1;
+       MONO_SEM_POST (&wsq->lock);
+       WSQ_DEBUG ("local_push: LOCK %p  %p\n", wsq, obj);
+       return TRUE;
+}
+
+gboolean
+mono_wsq_local_pop (void **ptr)
+{
+       int tail;
+       gboolean res;
+       MonoWSQ *wsq;
+
+       if (ptr == NULL)
+               return FALSE;
+
+       wsq = (MonoWSQ *) TlsGetValue (wsq_tlskey);
+       if (wsq == NULL) {
+               WSQ_DEBUG ("local_pop: no wsq\n");
+               return FALSE;
+       }
+
+       tail = wsq->tail;
+       if (wsq->head >= tail) {
+               WSQ_DEBUG ("local_pop: empty\n");
+               return FALSE;
+       }
+       tail--;
+       InterlockedExchange (&wsq->tail, tail);
+       if (wsq->head <= tail) {
+               *ptr = mono_array_get (wsq->queue, void *, tail & wsq->mask);
+               mono_array_set (wsq->queue, void *, tail & wsq->mask, NULL);
+               WSQ_DEBUG ("local_pop: GOT ONE %p %p\n", wsq, *ptr);
+               return TRUE;
+       }
+
+       MONO_SEM_WAIT (&wsq->lock);
+       if (wsq->head <= tail) {
+               *ptr = mono_array_get (wsq->queue, void *, tail & wsq->mask);
+               mono_array_set (wsq->queue, void *, tail & wsq->mask, NULL);
+               res = TRUE;
+       } else {
+               wsq->tail = tail + 1;
+               res = FALSE;
+       }
+       MONO_SEM_POST (&wsq->lock);
+       WSQ_DEBUG ("local_pop: LOCK %d %p %p\n", res, wsq, *ptr);
+       return res;
+}
+
+void
+mono_wsq_try_steal (MonoWSQ *wsq, void **ptr, guint32 ms_timeout)
+{
+       if (wsq == NULL || ptr == NULL || *ptr != NULL)
+               return;
+
+       if (TlsGetValue (wsq_tlskey) == wsq)
+               return;
+
+       if (MONO_SEM_TIMEDWAIT (&wsq->lock, ms_timeout)) {
+               int head;
+
+               head = wsq->head;
+               InterlockedExchange (&wsq->head, head + 1);
+               if (head < wsq->tail) {
+                       *ptr = mono_array_get (wsq->queue, void *, head & wsq->mask);
+                       mono_array_set (wsq->queue, void *, head & wsq->mask, NULL);
+                       WSQ_DEBUG ("STEAL %p %p\n", wsq, *ptr);
+               } else {
+                       wsq->head = head;
+               }
+               MONO_SEM_POST (&wsq->lock);
+       }
+}
+
diff --git a/mono/metadata/mono-wsq.h b/mono/metadata/mono-wsq.h
new file mode 100644 (file)
index 0000000..7208dad
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef _MONO_WSQ_H
+#define _MONO_WSQ_H
+
+#include <config.h>
+#include <glib.h>
+#include <mono/metadata/object.h>
+#include <mono/metadata/gc-internal.h>
+#include <mono/io-layer/io-layer.h>
+
+G_BEGIN_DECLS
+
+typedef struct _MonoWSQ MonoWSQ;
+
+void mono_wsq_init (void) MONO_INTERNAL;
+void mono_wsq_cleanup (void) MONO_INTERNAL;
+
+MonoWSQ *mono_wsq_create (void) MONO_INTERNAL;
+void mono_wsq_destroy (MonoWSQ *wsq) MONO_INTERNAL;
+gboolean mono_wsq_local_push (void *obj) MONO_INTERNAL;
+gboolean mono_wsq_local_pop (void **ptr) MONO_INTERNAL;
+void mono_wsq_try_steal (MonoWSQ *wsq, void **ptr, guint32 ms_timeout) MONO_INTERNAL;
+gint mono_wsq_count (MonoWSQ *wsq) MONO_INTERNAL;
+
+G_END_DECLS
+
+#endif
index 90b0a131a1ad716d79ac0dfca6dc58ebd64d58df..9731d8e2d959fee4ba6098028219ffd508afa81c 100644 (file)
@@ -262,5 +262,11 @@ mono_gc_get_write_barrier (void)
        return NULL;
 }
 
+void*
+mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data)
+{
+       return func (data);
+}
+
 #endif
 
index 37be81878e4227ea141a208e9a48782bfba7611e..6fdec1bf10de12029d25c5e3ee967e4e14f1a7a6 100644 (file)
 
 #endif
 
+#ifdef MONO_BIG_ARRAYS
+typedef uint64_t mono_array_size_t;
+typedef int64_t mono_array_lower_bound_t;
+#define MONO_ARRAY_MAX_INDEX G_MAXINT64
+#define MONO_ARRAY_MAX_SIZE  G_MAXUINT64
+#else
+typedef uint32_t mono_array_size_t;
+typedef int32_t mono_array_lower_bound_t;
+#define MONO_ARRAY_MAX_INDEX ((int32_t) 0x7fffffff)
+#define MONO_ARRAY_MAX_SIZE  ((uint32_t) 0xffffffff)
+#endif
+
+typedef struct {
+       mono_array_size_t length;
+       mono_array_lower_bound_t lower_bound;
+} MonoArrayBounds;
+
+struct _MonoArray {
+       MonoObject obj;
+       /* bounds is NULL for szarrays */
+       MonoArrayBounds *bounds;
+       /* total number of elements of the array */
+       mono_array_size_t max_length; 
+       /* we use double to ensure proper alignment on platforms that need it */
+       double vector [MONO_ZERO_LEN_ARRAY];
+};
+
+struct _MonoString {
+       MonoObject object;
+       int32_t length;
+       mono_unichar2 chars [MONO_ZERO_LEN_ARRAY];
+};
+
+#define mono_object_class(obj) (((MonoObject*)(obj))->vtable->klass)
+#define mono_object_domain(obj) (((MonoObject*)(obj))->vtable->domain)
+
+#define mono_string_chars_fast(s) ((mono_unichar2*)(s)->chars)
+#define mono_string_length_fast(s) ((s)->length)
+
+#define mono_array_length_fast(array) ((array)->max_length)
+#define mono_array_addr_with_size_fast(array,size,index) ( ((char*)(array)->vector) + (size) * (index) )
+
 typedef struct {
        MonoObject obj;
        MonoObject *identity;
@@ -229,6 +271,7 @@ typedef struct {
        MonoObject  *async_callback;
        MonoObject  *execution_context;
        MonoObject  *original_context;
+       gint64       add_time;
 } MonoAsyncResult;
 
 typedef struct {
@@ -1351,7 +1394,7 @@ void
 mono_array_full_copy (MonoArray *src, MonoArray *dest) MONO_INTERNAL;
 
 gboolean
-mono_array_calc_byte_len (MonoClass *class, mono_array_size_t len, mono_array_size_t *res) MONO_INTERNAL;
+mono_array_calc_byte_len (MonoClass *class, uintptr_t len, uintptr_t *res) MONO_INTERNAL;
 
 gpointer
 mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *real_proxy) MONO_INTERNAL;
index dfb2a3016631f7a62ba57fc7d8084be3449f3b66..6b4b852da1c0ab43bc637f8318fd1628017f8667 100644 (file)
@@ -1910,11 +1910,29 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
                        if (special_static != SPECIAL_STATIC_NONE) {
                                guint32 size, offset;
                                gint32 align;
+                               gsize default_bitmap [4] = {0};
+                               gsize *bitmap;
+                               int max_set = 0;
+                               MonoClass *fclass;
+                               if (mono_type_is_reference (field->type)) {
+                                       default_bitmap [0] = 1;
+                                       max_set = 1;
+                                       bitmap = default_bitmap;
+                               } else if (mono_type_is_struct (field->type)) {
+                                       fclass = mono_class_from_mono_type (field->type);
+                                       bitmap = compute_class_bitmap (fclass, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, FALSE);
+                               } else {
+                                       default_bitmap [0] = 0;
+                                       max_set = 0;
+                                       bitmap = default_bitmap;
+                               }
                                size = mono_type_size (field->type, &align);
-                               offset = mono_alloc_special_static_data (special_static, size, align);
+                               offset = mono_alloc_special_static_data (special_static, size, align, bitmap, max_set);
                                if (!domain->special_static_fields)
                                        domain->special_static_fields = g_hash_table_new (NULL, NULL);
                                g_hash_table_insert (domain->special_static_fields, field, GUINT_TO_POINTER (offset));
+                               if (bitmap != default_bitmap)
+                                       g_free (bitmap);
                                /* 
                                 * This marks the field as special static to speed up the
                                 * checks in mono_field_static_get/set_value ().
@@ -2080,6 +2098,8 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
        GSList *extra_interfaces = NULL;
        MonoClass *class = remote_class->proxy_class;
        gpointer *interface_offsets;
+       uint8_t *bitmap;
+       int bsize, bcsize;
 
        vt = mono_class_vtable (domain, class);
        g_assert (vt); /*FIXME property handle failure*/
@@ -2167,7 +2187,12 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
        }
 
        pvt->max_interface_id = max_interface_id;
-       pvt->interface_bitmap = mono_domain_alloc0 (domain, sizeof (guint8) * (max_interface_id/8 + 1 ));
+       bsize = sizeof (guint8) * (max_interface_id/8 + 1 );
+#ifdef COMPRESSED_INTERFACE_BITMAP
+       bitmap = g_malloc0 (bsize);
+#else
+       bitmap = mono_domain_alloc0 (domain, bsize);
+#endif
 
        if (! ARCH_USE_IMT) {
                /* initialize interface offsets */
@@ -2179,7 +2204,7 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
        }
        for (i = 0; i < class->interface_offsets_count; ++i) {
                int interface_id = class->interfaces_packed [i]->interface_id;
-               pvt->interface_bitmap [interface_id >> 3] |= (1 << (interface_id & 7));
+               bitmap [interface_id >> 3] |= (1 << (interface_id & 7));
        }
 
        if (extra_interfaces) {
@@ -2196,7 +2221,7 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
                        if (! ARCH_USE_IMT) {
                                interface_offsets [max_interface_id - interf->interface_id] = &pvt->vtable [slot];
                        }
-                       pvt->interface_bitmap [interf->interface_id >> 3] |= (1 << (interf->interface_id & 7));
+                       bitmap [interf->interface_id >> 3] |= (1 << (interf->interface_id & 7));
 
                        iter = NULL;
                        j = 0;
@@ -2218,6 +2243,14 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
                }
        }
 
+#ifdef COMPRESSED_INTERFACE_BITMAP
+       bcsize = mono_compress_bitmap (NULL, bitmap, bsize);
+       pvt->interface_bitmap = mono_domain_alloc0 (domain, bcsize);
+       mono_compress_bitmap (pvt->interface_bitmap, bitmap, bsize);
+       g_free (bitmap);
+#else
+       pvt->interface_bitmap = bitmap;
+#endif
        return pvt;
 }
 
@@ -4298,7 +4331,7 @@ mono_object_clone (MonoObject *obj)
 void
 mono_array_full_copy (MonoArray *src, MonoArray *dest)
 {
-       mono_array_size_t size;
+       uintptr_t size;
        MonoClass *klass = src->obj.vtable->klass;
 
        MONO_ARCH_SAVE_REGS;
@@ -4334,8 +4367,8 @@ MonoArray*
 mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array)
 {
        MonoArray *o;
-       mono_array_size_t size, i;
-       mono_array_size_t *sizes;
+       uintptr_t size, i;
+       uintptr_t *sizes;
        MonoClass *klass = array->obj.vtable->klass;
 
        MONO_ARCH_SAVE_REGS;
@@ -4360,14 +4393,14 @@ mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array)
                return o;
        }
        
-       sizes = alloca (klass->rank * sizeof(mono_array_size_t) * 2);
+       sizes = alloca (klass->rank * sizeof(intptr_t) * 2);
        size = mono_array_element_size (klass);
        for (i = 0; i < klass->rank; ++i) {
                sizes [i] = array->bounds [i].length;
                size *= array->bounds [i].length;
                sizes [i + klass->rank] = array->bounds [i].lower_bound;
        }
-       o = mono_array_new_full (domain, klass, sizes, sizes + klass->rank);
+       o = mono_array_new_full (domain, klass, sizes, (intptr_t*)sizes + klass->rank);
 #ifdef HAVE_SGEN_GC
        if (klass->element_class->valuetype) {
                if (klass->element_class->has_references)
@@ -4416,9 +4449,9 @@ mono_array_clone (MonoArray *array)
 #endif
 
 gboolean
-mono_array_calc_byte_len (MonoClass *class, mono_array_size_t len, mono_array_size_t *res)
+mono_array_calc_byte_len (MonoClass *class, uintptr_t len, uintptr_t *res)
 {
-       mono_array_size_t byte_len;
+       uintptr_t byte_len;
 
        byte_len = mono_array_element_size (class);
        if (CHECK_MUL_OVERFLOW_UN (byte_len, len))
@@ -4444,9 +4477,9 @@ mono_array_calc_byte_len (MonoClass *class, mono_array_size_t len, mono_array_si
  * lower bounds and type.
  */
 MonoArray*
-mono_array_new_full (MonoDomain *domain, MonoClass *array_class, mono_array_size_t *lengths, mono_array_size_t *lower_bounds)
+mono_array_new_full (MonoDomain *domain, MonoClass *array_class, uintptr_t *lengths, intptr_t *lower_bounds)
 {
-       mono_array_size_t byte_len, len, bounds_size;
+       uintptr_t byte_len, len, bounds_size;
        MonoObject *o;
        MonoArray *array;
        MonoArrayBounds *bounds;
@@ -4546,7 +4579,7 @@ mono_array_new_full (MonoDomain *domain, MonoClass *array_class, mono_array_size
  * This routine creates a new szarray with @n elements of type @eclass.
  */
 MonoArray *
-mono_array_new (MonoDomain *domain, MonoClass *eclass, mono_array_size_t n)
+mono_array_new (MonoDomain *domain, MonoClass *eclass, uintptr_t n)
 {
        MonoClass *ac;
 
@@ -4567,11 +4600,11 @@ mono_array_new (MonoDomain *domain, MonoClass *eclass, mono_array_size_t n)
  * can be sure about the domain it operates in.
  */
 MonoArray *
-mono_array_new_specific (MonoVTable *vtable, mono_array_size_t n)
+mono_array_new_specific (MonoVTable *vtable, uintptr_t n)
 {
        MonoObject *o;
        MonoArray *ao;
-       guint32 byte_len;
+       uintptr_t byte_len;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -5243,7 +5276,7 @@ mono_string_to_utf8_checked (MonoString *s, MonoError *error)
  * This is a temporary helper until our string implementation
  * is reworked to always include the null terminating char.
  */
-gunichar2 *
+mono_unichar2*
 mono_string_to_utf16 (MonoString *s)
 {
        char *as;
@@ -6144,7 +6177,6 @@ mono_get_addr_from_ftnptr (gpointer descr)
        return callbacks.get_addr_from_ftnptr (descr);
 }      
 
-#if 0
 /**
  * mono_string_chars:
  * @s: a MonoString
@@ -6152,9 +6184,9 @@ mono_get_addr_from_ftnptr (gpointer descr)
  * Returns a pointer to the UCS16 characters stored in the MonoString
  */
 gunichar2 *
-mono_string_chars(MonoString *s)
+mono_string_chars (MonoString *s)
 {
-       /* This method is here only for documentation extraction, this is a macro */
+       return s->chars;
 }
 
 /**
@@ -6166,7 +6198,33 @@ mono_string_chars(MonoString *s)
 int
 mono_string_length (MonoString *s)
 {
-       /* This method is here only for documentation extraction, this is a macro */
+       return s->length;
+}
+
+/**
+ * mono_array_length:
+ * @array: a MonoArray*
+ *
+ * Returns the total number of elements in the array. This works for
+ * both vectors and multidimensional arrays.
+ */
+uintptr_t
+mono_array_length (MonoArray *array)
+{
+       return array->max_length;
+}
+
+/**
+ * mono_array_addr_with_size:
+ * @array: a MonoArray*
+ * @size: size of the array elements
+ * @idx: index into the array
+ *
+ * Returns the address of the @idx element in the array.
+ */
+char*
+mono_array_addr_with_size (MonoArray *array, int size, uintptr_t idx)
+{
+       return ((char*)(array)->vector) + size * idx;
 }
 
-#endif
index ee21889f3659ed45555b7c2281a428387334b56e..88692693bb0e97109c521e91e69a9599c7d80ea4 100644 (file)
@@ -7,6 +7,8 @@ MONO_BEGIN_DECLS
 
 typedef mono_byte MonoBoolean;
 
+typedef struct _MonoString MonoString;
+typedef struct _MonoArray MonoArray;
 typedef struct _MonoReflectionMethod MonoReflectionMethod;
 typedef struct _MonoReflectionAssembly MonoReflectionAssembly;
 typedef struct _MonoReflectionModule MonoReflectionModule;
@@ -28,46 +30,10 @@ typedef struct {
        MonoThreadsSync *synchronisation;
 } MonoObject;
 
-#ifdef MONO_BIG_ARRAYS
-typedef uint64_t mono_array_size_t;
-typedef int64_t mono_array_lower_bound_t;
-#define MONO_ARRAY_MAX_INDEX G_MAXINT64
-#define MONO_ARRAY_MAX_SIZE  G_MAXUINT64
-#else
-typedef uint32_t mono_array_size_t;
-typedef int32_t mono_array_lower_bound_t;
-#define MONO_ARRAY_MAX_INDEX ((int32_t) 0x7fffffff)
-#define MONO_ARRAY_MAX_SIZE  ((uint32_t) 0xffffffff)
-#endif
-
-typedef struct {
-       mono_array_size_t length;
-       mono_array_lower_bound_t lower_bound;
-} MonoArrayBounds;
-
-typedef struct {
-       MonoObject obj;
-       /* bounds is NULL for szarrays */
-       MonoArrayBounds *bounds;
-       /* total number of elements of the array */
-       mono_array_size_t max_length; 
-       /* we use double to ensure proper alignment on platforms that need it */
-       double vector [MONO_ZERO_LEN_ARRAY];
-} MonoArray;
-
-typedef struct {
-       MonoObject object;
-       int32_t length;
-       mono_unichar2 chars [MONO_ZERO_LEN_ARRAY];
-} MonoString;
-
 typedef MonoObject* (*MonoInvokeFunc)       (MonoMethod *method, void *obj, void **params, MonoObject **exc);
 typedef void*    (*MonoCompileFunc)         (MonoMethod *method);
 typedef void       (*MonoMainThreadFunc)    (void* user_data);
 
-#define mono_object_class(obj) (((MonoObject*)(obj))->vtable->klass)
-#define mono_object_domain(obj) (((MonoObject*)(obj))->vtable->domain)
-
 #define MONO_OBJECT_SETREF(obj,fieldname,value) do {   \
                mono_gc_wbarrier_set_field ((MonoObject*)(obj), &((obj)->fieldname), (MonoObject*)value);       \
                /*(obj)->fieldname = (value);*/ \
@@ -78,9 +44,7 @@ typedef void      (*MonoMainThreadFunc)    (void* user_data);
         mono_gc_wbarrier_generic_store (&((s)->field), (MonoObject*)(value)); \
     } while (0)
 
-#define mono_array_length(array) ((array)->max_length)
 #define mono_array_addr(array,type,index) ((type*)(void*) mono_array_addr_with_size (array, sizeof (type), index))
-#define mono_array_addr_with_size(array,size,index) ( ((char*)(array)->vector) + (size) * (index) )
 #define mono_array_get(array,type,index) ( *(type*)mono_array_addr ((array), type, (index)) ) 
 #define mono_array_set(array,type,index,value) \
        do {    \
@@ -100,8 +64,8 @@ typedef void     (*MonoMainThreadFunc)    (void* user_data);
                mono_gc_wbarrier_arrayref_copy (__p, __s, (count));     \
        } while (0)
 
-#define mono_string_chars(s) ((mono_unichar2*)(s)->chars)
-#define mono_string_length(s) ((s)->length)
+mono_unichar2 *mono_string_chars  (MonoString *s);
+int            mono_string_length (MonoString *s);
 
 MonoObject *
 mono_object_new                    (MonoDomain *domain, MonoClass *klass);
@@ -120,18 +84,24 @@ MonoObject *
 mono_object_new_from_token  (MonoDomain *domain, MonoImage *image, uint32_t token);
 
 MonoArray*
-mono_array_new             (MonoDomain *domain, MonoClass *eclass, mono_array_size_t n);
+mono_array_new             (MonoDomain *domain, MonoClass *eclass, uintptr_t n);
 
 MonoArray*
 mono_array_new_full        (MonoDomain *domain, MonoClass *array_class,
-                            mono_array_size_t *lengths, mono_array_size_t *lower_bounds);
+                            uintptr_t *lengths, intptr_t *lower_bounds);
 
 MonoArray *
-mono_array_new_specific            (MonoVTable *vtable, mono_array_size_t n);
+mono_array_new_specific            (MonoVTable *vtable, uintptr_t n);
 
 MonoArray*
 mono_array_clone           (MonoArray *array);
 
+char*
+mono_array_addr_with_size   (MonoArray *array, int size, uintptr_t idx);
+
+uintptr_t
+mono_array_length           (MonoArray *array);
+
 MonoString*
 mono_string_new_utf16      (MonoDomain *domain, const mono_unichar2 *text, int32_t len);
 
index 330572c6481e0edc7eec9dc340c5ceacafdae6bb..74c238232ccec76b3e80182c78552b15adedb70a 100644 (file)
@@ -13,7 +13,7 @@
 #include <glib.h>
 #include <string.h>
 
-#include <mono/metadata/object.h>
+#include <mono/metadata/object-internals.h>
 #include <mono/metadata/process.h>
 #include <mono/metadata/assembly.h>
 #include <mono/metadata/appdomain.h>
index 31dbd8e55ad8e2089473917a82d60aa9655ff38a..d3e026678cd7b632c24431f17a0c55a7c6d54c3e 100644 (file)
@@ -6119,14 +6119,18 @@ mono_image_set_wrappers_type (MonoReflectionModuleBuilder *moduleb, MonoReflecti
 MonoReflectionAssembly*
 mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly)
 {
-       static MonoClass *System_Reflection_Assembly;
+       static MonoClass *assembly_type;
        MonoReflectionAssembly *res;
        
        CHECK_OBJECT (MonoReflectionAssembly *, assembly, NULL);
-       if (!System_Reflection_Assembly)
-               System_Reflection_Assembly = mono_class_from_name (
-                       mono_defaults.corlib, "System.Reflection", "Assembly");
-       res = (MonoReflectionAssembly *)mono_object_new (domain, System_Reflection_Assembly);
+       if (!assembly_type) {
+               MonoClass *class = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "MonoAssembly");
+               if (class == NULL)
+                       class = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "Assembly");
+               g_assert (class);
+               assembly_type = class;
+       }
+       res = (MonoReflectionAssembly *)mono_object_new (domain, assembly_type);
        res->assembly = assembly;
 
        CACHE_OBJECT (MonoReflectionAssembly *, assembly, res, NULL);
@@ -6847,7 +6851,6 @@ mono_method_body_get_object (MonoDomain *domain, MonoMethod *method)
        static MonoClass *System_Reflection_LocalVariableInfo = NULL;
        static MonoClass *System_Reflection_ExceptionHandlingClause = NULL;
        MonoReflectionMethodBody *ret;
-       MonoMethodNormal *mn;
        MonoMethodHeader *header;
        guint32 method_rva, local_var_sig_token;
     char *ptr;
@@ -6868,7 +6871,6 @@ mono_method_body_get_object (MonoDomain *domain, MonoMethod *method)
            (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
            (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME))
                return NULL;
-       mn = (MonoMethodNormal *)method;
        header = mono_method_get_header (method);
        
        /* Obtain local vars signature token */
@@ -7700,7 +7702,7 @@ mono_reflection_get_token (MonoObject *obj)
                MonoReflectionModule *m = (MonoReflectionModule*)obj;
 
                token = m->token;
-       } else if (strcmp (klass->name, "Assembly") == 0) {
+       } else if (strcmp (klass->name, "Assembly") == 0 || strcmp (klass->name, "MonoAssembly") == 0) {
                token = mono_metadata_make_token (MONO_TABLE_ASSEMBLY, 1);
        } else {
                gchar *msg = g_strdup_printf ("MetadataToken is not supported for type '%s.%s'", klass->name_space, klass->name);
@@ -8684,7 +8686,7 @@ mono_reflection_get_custom_attrs_info (MonoObject *obj)
                MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType *)obj);
                klass = mono_class_from_mono_type (type);
                cinfo = mono_custom_attrs_from_class (klass);
-       } else if (strcmp ("Assembly", klass->name) == 0) {
+       } else if (strcmp ("Assembly", klass->name) == 0 || strcmp ("MonoAssembly", klass->name) == 0) {
                MonoReflectionAssembly *rassembly = (MonoReflectionAssembly*)obj;
                cinfo = mono_custom_attrs_from_assembly (rassembly->assembly);
        } else if (strcmp ("Module", klass->name) == 0) {
@@ -8719,11 +8721,13 @@ mono_reflection_get_custom_attrs_info (MonoObject *obj)
                        g_assert (method);
 
                        cinfo = mono_custom_attrs_from_param (method, param->PositionImpl + 1);
-               } else if (is_sre_method_on_tb_inst (member_class)) {/*XXX This is a workaround for Compiler Context*/
+               } 
+#ifndef DISABLE_REFLECTION_EMIT
+               else if (is_sre_method_on_tb_inst (member_class)) {/*XXX This is a workaround for Compiler Context*/
                        MonoMethod *method = mono_reflection_method_on_tb_inst_get_handle ((MonoReflectionMethodOnTypeBuilderInst*)param->MemberImpl);
                        cinfo = mono_custom_attrs_from_param (method, param->PositionImpl + 1);
                } else if (is_sre_ctor_on_tb_inst (member_class)) { /*XX This is a workaround for Compiler Context*/
-               MonoReflectionCtorOnTypeBuilderInst *c = (MonoReflectionCtorOnTypeBuilderInst*)param->MemberImpl;
+                       MonoReflectionCtorOnTypeBuilderInst *c = (MonoReflectionCtorOnTypeBuilderInst*)param->MemberImpl;
                        MonoMethod *method = NULL;
                        if (is_sre_ctor_builder (mono_object_class (c->cb)))
                                method = ((MonoReflectionCtorBuilder *)c->cb)->mhandle;
@@ -8733,7 +8737,9 @@ mono_reflection_get_custom_attrs_info (MonoObject *obj)
                                g_error ("mono_reflection_get_custom_attrs_info:: can't handle a CTBI with base_method of type %s", mono_type_get_full_name (member_class));
 
                        cinfo = mono_custom_attrs_from_param (method, param->PositionImpl + 1);
-               } else {
+               } 
+#endif
+               else {
                        char *type_name = mono_type_get_full_name (member_class);
                        char *msg = g_strdup_printf ("Custom attributes on a ParamInfo with member %s are not supported", type_name);
                        MonoException *ex = mono_get_exception_not_supported  (msg);
@@ -8852,7 +8858,6 @@ mono_reflection_type_get_underlying_system_type (MonoReflectionType* t)
         return (MonoReflectionType *) mono_runtime_invoke (usertype_method, t, NULL, NULL);
 }
 
-#ifndef DISABLE_REFLECTION_EMIT
 
 static gboolean
 is_corlib_type (MonoClass *class)
@@ -8871,6 +8876,8 @@ is_corlib_type (MonoClass *class)
        return FALSE; \
 } while (0) \
 
+
+#ifndef DISABLE_REFLECTION_EMIT
 static gboolean
 is_sre_array (MonoClass *class)
 {
@@ -8919,42 +8926,6 @@ is_sre_field_builder (MonoClass *class)
        check_corlib_type_cached (class, "System.Reflection.Emit", "FieldBuilder");
 }
 
-static gboolean
-is_sr_mono_method (MonoClass *class)
-{
-       check_corlib_type_cached (class, "System.Reflection", "MonoMethod");
-}
-
-static gboolean
-is_sr_mono_cmethod (MonoClass *class)
-{
-       check_corlib_type_cached (class, "System.Reflection", "MonoCMethod");
-}
-
-static gboolean
-is_sr_mono_generic_method (MonoClass *class)
-{
-       check_corlib_type_cached (class, "System.Reflection", "MonoGenericMethod");
-}
-
-static gboolean
-is_sr_mono_generic_cmethod (MonoClass *class)
-{
-       check_corlib_type_cached (class, "System.Reflection", "MonoGenericCMethod");
-}
-
-static gboolean
-is_sr_mono_field (MonoClass *class)
-{
-       check_corlib_type_cached (class, "System.Reflection", "MonoField");
-}
-
-static gboolean
-is_sr_mono_property (MonoClass *class)
-{
-       check_corlib_type_cached (class, "System.Reflection", "MonoProperty");
-}
-
 static gboolean
 is_sre_method_on_tb_inst (MonoClass *class)
 {
@@ -8967,12 +8938,6 @@ is_sre_ctor_on_tb_inst (MonoClass *class)
        check_corlib_type_cached (class, "System.Reflection.Emit", "ConstructorOnTypeBuilderInst");
 }
 
-gboolean
-mono_class_is_reflection_method_or_constructor (MonoClass *class)
-{
-       return is_sr_mono_method (class) || is_sr_mono_cmethod (class) || is_sr_mono_generic_method (class) || is_sr_mono_generic_cmethod (class);
-}
-
 MonoType*
 mono_reflection_type_get_handle (MonoReflectionType* ref)
 {
@@ -9192,6 +9157,49 @@ is_sre_generic_instance (MonoClass *class)
 
 #endif /* !DISABLE_REFLECTION_EMIT */
 
+
+static gboolean
+is_sr_mono_field (MonoClass *class)
+{
+       check_corlib_type_cached (class, "System.Reflection", "MonoField");
+}
+
+static gboolean
+is_sr_mono_property (MonoClass *class)
+{
+       check_corlib_type_cached (class, "System.Reflection", "MonoProperty");
+}
+
+static gboolean
+is_sr_mono_method (MonoClass *class)
+{
+       check_corlib_type_cached (class, "System.Reflection", "MonoMethod");
+}
+
+static gboolean
+is_sr_mono_cmethod (MonoClass *class)
+{
+       check_corlib_type_cached (class, "System.Reflection", "MonoCMethod");
+}
+
+static gboolean
+is_sr_mono_generic_method (MonoClass *class)
+{
+       check_corlib_type_cached (class, "System.Reflection", "MonoGenericMethod");
+}
+
+static gboolean
+is_sr_mono_generic_cmethod (MonoClass *class)
+{
+       check_corlib_type_cached (class, "System.Reflection", "MonoGenericCMethod");
+}
+
+gboolean
+mono_class_is_reflection_method_or_constructor (MonoClass *class)
+{
+       return is_sr_mono_method (class) || is_sr_mono_cmethod (class) || is_sr_mono_generic_method (class) || is_sr_mono_generic_cmethod (class);
+}
+
 static gboolean
 is_usertype (MonoReflectionType *ref)
 {
@@ -9936,7 +9944,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
 {
        MonoError error;
        MonoMethod *m;
-       MonoMethodNormal *pm;
+       MonoMethodWrapper *wrapperm;
        MonoMarshalSpec **specs;
        MonoReflectionMethodAux *method_aux;
        MonoImage *image;
@@ -9960,12 +9968,10 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
        if ((rmb->attrs & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
                        (rmb->iattrs & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
                m = (MonoMethod *)image_g_new0 (image, MonoMethodPInvoke, 1);
-       else if (rmb->refs)
-               m = (MonoMethod *)image_g_new0 (image, MonoMethodWrapper, 1);
        else
-               m = (MonoMethod *)image_g_new0 (image, MonoMethodNormal, 1);
+               m = (MonoMethod *)image_g_new0 (image, MonoMethodWrapper, 1);
 
-       pm = (MonoMethodNormal*)m;
+       wrapperm = (MonoMethodWrapper*)m;
 
        m->dynamic = dynamic;
        m->slot = -1;
@@ -9975,6 +9981,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
        g_assert (mono_error_ok (&error));
        m->klass = klass;
        m->signature = sig;
+       m->sre_method = TRUE;
        m->skip_visibility = rmb->skip_visibility;
        if (rmb->table_idx)
                m->token = MONO_TOKEN_METHOD_DEF | (*rmb->table_idx);
@@ -10054,7 +10061,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
                                 rmb->ilgen, num_clauses);
                }
 
-               pm->header = header;
+               wrapperm->header = header;
        }
 
        if (rmb->generic_params) {
index 1a0b07a82ec4e41ebd703858f541e294435c970a..fcf93fd19ae1e7132944b42eefab13be5df3e0c4 100644 (file)
@@ -1,3 +1,28 @@
+/*
+ * SGen is licensed under the terms of the MIT X11 license
+ *
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #ifndef __MONO_SGENARCHDEP_H__
 #define __MONO_SGENARCHDEP_H__
 
index 89a1803443f5fa51fab514a9c3c42c87b3002bac..0ce6ac83aa4cc7a5f00752cbc2454af0e0b338b7 100644 (file)
@@ -4,7 +4,7 @@
  * Author:
  *     Paolo Molaro (lupus@ximian.com)
  *
- * Copyright 2005-2009 Novell, Inc (http://www.novell.com)
+ * Copyright 2005-2010 Novell, Inc (http://www.novell.com)
  *
  * Thread start/stop adapted from Boehm's GC:
  * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  *
- * All the rest of the code is LGPL.
+ *
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
  *
  * Important: allocation provides always zeroed memory, having to do
  * a memset after allocation is deadly for performance.
  * 1) 2-word header with no GC pointers in it (first vtable, second to store the
  *    forwarding ptr)
  * 2) gc descriptor is the second word in the vtable (first word in the class)
- * 3) 8 byte alignment is the minimum and enough (not true for special structures, FIXME)
+ * 3) 8 byte alignment is the minimum and enough (not true for special structures (SIMD), FIXME)
  * 4) there is a function to get an object's size and the number of
  *    elements in an array.
  * 5) we know the special way bounds are allocated for complex arrays
+ * 6) we know about proxies and how to treat them when domains are unloaded
  *
  * Always try to keep stack usage to a minimum: no recursive behaviour
  * and no large stack allocs.
@@ -48,7 +71,9 @@
  * When the nursery is full we start a nursery collection: this is performed with a
  * copying GC.
  * When the old generation is full we start a copying GC of the old generation as well:
- * this will be changed to mark/compact in the future.
+ * this will be changed to mark&sweep with copying when fragmentation becomes to severe
+ * in the future.  Maybe we'll even do both during the same collection like IMMIX.
+ *
  * The things that complicate this description are:
  * *) pinned objects: we can't move them so we need to keep track of them
  * *) no precise info of the thread stacks and registers: we need to be able to
 
 /*
  * TODO:
- *) change the jit to emit write barrier calls when needed (we
-  can have specialized write barriers): done with icalls, still need to
-  use some specialized barriers
+
  *) we could have a function pointer in MonoClass to implement
   customized write barriers for value types
- *) the write barrier code could be isolated in a couple of functions: when a
-  thread is stopped if it's inside the barrier it is let go again
-  until we stop outside of them (not really needed, see below GC-safe points)
+
  *) investigate the stuff needed to advance a thread to a GC-safe
-  point (single-stepping, read from unmapped memory etc) and implement it
-  Not needed yet: since we treat the objects reachable from the stack/regs as
-  roots, we store the ptr and exec the write barrier so there is no race.
-  We may need this to solve the issue with setting the length of arrays and strings.
+  point (single-stepping, read from unmapped memory etc) and implement it.
+  This would enable us to inline allocations and write barriers, for example,
+  or at least parts of them, like the write barrier checks.
   We may need this also for handling precise info on stacks, even simple things
   as having uninitialized data on the stack and having to wait for the prolog
   to zero it. Not an issue for the last frame that we scan conservatively.
   We could always not trust the value in the slots anyway.
- *) make the jit info table lock free
+
  *) modify the jit to save info about references in stack locations:
   this can be done just for locals as a start, so that at least
   part of the stack is handled precisely.
- *) Make the debug printf stuff thread and signal safe.
- *) test/fix 64 bit issues
+
  *) test/fix endianess issues
- *) port to non-Linux
- *) add batch moving profile info
+
  *) add more timing info
- *) there is a possible race when an array or string is created: the vtable is set,
-    but the length is set only later so if the GC needs to scan the object in that window,
-    it won't get the correct size for the object. The object can't have references and it will
-    be pinned, but a free memory fragment may be created that overlaps with it.
-    We should change the array max_length field to be at the same offset as the string length:
-    this way we can have a single special alloc function for them that sets the length.
-    Multi-dim arrays have the same issue for rank == 1 for the bounds data.
- *) implement a card table as the write barrier instead of remembered sets?
- *) some sort of blacklist support?
- *) fin_ready_list and critical_fin_list are part of the root set, too
- *) consider lowering the large object min size to 16/32KB or so and benchmark
- *) once mark-compact is implemented we could still keep the
-    copying collector for the old generation and use it if we think
-    it is better (small heaps and no pinning object in the old
-    generation)
-  *) avoid the memory store from copy_object when not needed.
-  *) optimize the write barriers fastpath to happen in managed code
+
+ *) Implement a card table as the write barrier instead of remembered
+    sets?  Card tables are not easy to implement with our current
+    memory layout.  We have several different kinds of major heap
+    objects: Small objects in regular blocks, small objects in pinned
+    chunks and LOS objects.  If we just have a pointer we have no way
+    to tell which kind of object it points into, therefore we cannot
+    know where its card table is.  The least we have to do to make
+    this happen is to get rid of write barriers for indirect stores.
+    (See next item)
+
+ *) Get rid of write barriers for indirect stores.  We can do this by
+    telling the GC to wbarrier-register an object once we do an ldloca
+    or ldelema on it, and to unregister it once it's not used anymore
+    (it can only travel downwards on the stack).  The problem with
+    unregistering is that it needs to happen eventually no matter
+    what, even if exceptions are thrown, the thread aborts, etc.
+    Rodrigo suggested that we could do only the registering part and
+    let the collector find out (pessimistically) when it's safe to
+    unregister, namely when the stack pointer of the thread that
+    registered the object is higher than it was when the registering
+    happened.  This might make for a good first implementation to get
+    some data on performance.
+
+ *) Some sort of blacklist support?  Blacklists is a concept from the
+    Boehm GC: if during a conservative scan we find pointers to an
+    area which we might use as heap, we mark that area as unusable, so
+    pointer retention by random pinning pointers is reduced.
+
+ *) experiment with max small object size (very small right now - 2kb,
+    because it's tied to the max freelist size)
+
+ *) avoid the memory store from copy_object when not needed, i.e. when the object
+    is not copied.
+
   *) add an option to mmap the whole heap in one chunk: it makes for many
      simplifications in the checks (put the nursery at the top and just use a single
      check for inclusion/exclusion): the issue this has is that on 32 bit systems it's
      back to the system (mprotect(PROT_NONE) will still keep the memory allocated if it
      was written to, munmap is needed, but the following mmap may not find the same segment
      free...)
-   *) memzero the fragments after restarting the world and optionally a smaller chunk at a time
-   *) an additional strategy to realloc/expand the nursery when fully pinned is to start
-      allocating objects in the old generation. This means that we can't optimize away write
-      barrier calls in ctors (but that is not valid for other reasons, too).
-   *) add write barriers to the Clone methods
+
+ *) memzero the major fragments after restarting the world and optionally a smaller
+    chunk at a time
+
+ *) investigate having fragment zeroing threads
+
+ *) separate locks for finalization and other minor stuff to reduce
+    lock contention
+
+ *) try a different copying order to improve memory locality
+
+ *) a thread abort after a store but before the write barrier will
+    prevent the write barrier from executing
+
+ *) specialized dynamically generated markers/copiers
+
  */
 #include "config.h"
 #ifdef HAVE_SGEN_GC
 #include <signal.h>
 #include <errno.h>
 #include <assert.h>
+#include <pthread.h>
 #include "metadata/metadata-internals.h"
 #include "metadata/class-internals.h"
 #include "metadata/gc-internal.h"
@@ -620,6 +668,8 @@ static GCMemSection *nursery_section = NULL;
 static mword lowest_heap_address = ~(mword)0;
 static mword highest_heap_address = 0;
 
+static LOCK_DECLARE (interruption_mutex);
+
 typedef struct _FinalizeEntry FinalizeEntry;
 struct _FinalizeEntry {
        FinalizeEntry *next;
@@ -3487,18 +3537,11 @@ major_collection (const char *reason)
        if (xdomain_checks)
                check_for_xdomain_refs ();
 
-       /* 
-        * FIXME: implement Mark/Compact
-        * Until that is done, we can just apply mostly the same alg as for the nursery:
-        * this means we need a big section to potentially copy all the other sections, so
-        * it is not ideal specially with large heaps.
-        */
        if (g_getenv ("MONO_GC_NO_MAJOR")) {
                collect_nursery (0);
                return;
        }
        TV_GETTIME (all_atv);
-       /* FIXME: make sure the nursery next_data ptr is updated */
        nursery_section->next_data = nursery_real_end;
        /* we should also coalesce scanning from sections close to each other
         * and deal with pointers outside of the sections later.
@@ -4124,9 +4167,6 @@ alloc_from_freelist (size_t size)
 }
 
 /* used for the GC-internal data structures */
-/* FIXME: add support for bigger sizes by allocating more than one page
- * in the chunk.
- */
 static void*
 get_internal_mem (size_t size, int type)
 {
@@ -4579,7 +4619,7 @@ mono_gc_alloc_obj (MonoVTable *vtable, size_t size)
 }
 
 void*
-mono_gc_alloc_vector (MonoVTable *vtable, size_t size, mono_array_size_t max_length)
+mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length)
 {
        MonoArray *arr;
 #ifndef DISABLE_CRITICAL_REGION
@@ -4605,7 +4645,7 @@ mono_gc_alloc_vector (MonoVTable *vtable, size_t size, mono_array_size_t max_len
 }
 
 void*
-mono_gc_alloc_array (MonoVTable *vtable, size_t size, mono_array_size_t max_length, mono_array_size_t bounds_size)
+mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uintptr_t bounds_size)
 {
        MonoArray *arr;
        MonoArrayBounds *bounds;
@@ -5649,6 +5689,18 @@ restart_handler (int sig)
        errno = old_errno;
 }
 
+static void
+acquire_gc_locks (void)
+{
+       LOCK_INTERRUPTION;
+}
+
+static void
+release_gc_locks (void)
+{
+       UNLOCK_INTERRUPTION;
+}
+
 static TV_DECLARE (stop_world_time);
 static unsigned long max_pause_usec = 0;
 
@@ -5658,6 +5710,8 @@ stop_world (void)
 {
        int count;
 
+       acquire_gc_locks ();
+
        update_current_thread_stack (&count);
 
        global_stop_count++;
@@ -5693,6 +5747,8 @@ restart_world (void)
                }
        }
 
+       release_gc_locks ();
+
        count = thread_handshake (restart_signal_num);
        TV_GETTIME (end_sw);
        usec = TV_ELAPSED (stop_world_time, end_sw);
@@ -6220,6 +6276,7 @@ gc_register_current_thread (void *addr)
        }
 #elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
                 info->stack_end = (char*)pthread_get_stackaddr_np (pthread_self ());
+                info->stack_start_limit = (char*)info->stack_end - pthread_get_stacksize_np (pthread_self ());
 #else
        {
                /* FIXME: we assume the stack grows down */
@@ -6427,9 +6484,7 @@ alloc_remset (int size, gpointer id) {
  * Note: the write barriers first do the needed GC work and then do the actual store:
  * this way the value is visible to the conservative GC scan after the write barrier
  * itself. If a GC interrupts the barrier in the middle, value will be kept alive by
- * the conservative scan, otherwise by the remembered set scan. FIXME: figure out what
- * happens when we need to record which pointers contain references to the new generation.
- * The write barrier will be executed, but the pointer is still not stored.
+ * the conservative scan, otherwise by the remembered set scan.
  */
 void
 mono_gc_wbarrier_set_field (MonoObject *obj, gpointer field_ptr, MonoObject* value)
@@ -7239,6 +7294,16 @@ mono_gc_free_fixed (void* addr)
        free (addr);
 }
 
+void*
+mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data)
+{
+       void *result;
+       LOCK_INTERRUPTION;
+       result = func (data);
+       UNLOCK_INTERRUPTION;
+       return result;
+}
+
 gboolean
 mono_gc_is_gc_thread (void)
 {
@@ -7746,6 +7811,10 @@ mono_gc_get_write_barrier (void)
        MonoMethodSignature *sig;
 #ifdef MANAGED_WBARRIER
        int label_no_wb_1, label_no_wb_2, label_no_wb_3, label_no_wb_4, label_need_wb, label_slow_path;
+#ifndef ALIGN_NURSERY
+       int label_continue_1, label_continue_2, label_no_wb_5;
+       int dereferenced_var;
+#endif
        int buffer_var, buffer_index_var, dummy_var;
 
 #ifdef HAVE_KW_THREAD
@@ -7797,10 +7866,41 @@ mono_gc_get_write_barrier (void)
                mono_mb_emit_icon (mb, (mword)nursery_start >> DEFAULT_NURSERY_BITS);
                label_no_wb_2 = mono_mb_emit_branch (mb, CEE_BNE_UN);
 #else
-               // FIXME:
-               g_assert_not_reached ();
-#endif
 
+               // if (ptr < (nursery_start)) goto continue;
+               mono_mb_emit_ldarg (mb, 0);
+               mono_mb_emit_ptr (mb, (gpointer) nursery_start);
+               label_continue_1 = mono_mb_emit_branch (mb, CEE_BLT);
+
+               // if (ptr >= nursery_real_end)) goto continue;
+               mono_mb_emit_ldarg (mb, 0);
+               mono_mb_emit_ptr (mb, (gpointer) nursery_real_end);
+               label_continue_2 = mono_mb_emit_branch (mb, CEE_BGE);
+
+               // Otherwise return
+               label_no_wb_1 = mono_mb_emit_branch (mb, CEE_BR);
+
+               // continue:
+               mono_mb_patch_branch (mb, label_continue_1);
+               mono_mb_patch_branch (mb, label_continue_2);
+
+               // Dereference and store in local var
+               dereferenced_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
+               mono_mb_emit_ldarg (mb, 0);
+               mono_mb_emit_byte (mb, CEE_LDIND_I);
+               mono_mb_emit_stloc (mb, dereferenced_var);
+
+               // if (*ptr < nursery_start) return;
+               mono_mb_emit_ldloc (mb, dereferenced_var);
+               mono_mb_emit_ptr (mb, (gpointer) nursery_start);
+               label_no_wb_2 = mono_mb_emit_branch (mb, CEE_BLT);
+
+               // if (*ptr >= nursery_end) return;
+               mono_mb_emit_ldloc (mb, dereferenced_var);
+               mono_mb_emit_ptr (mb, (gpointer) nursery_real_end);
+               label_no_wb_5 = mono_mb_emit_branch (mb, CEE_BGE);
+
+#endif 
                // if (ptr >= stack_end) goto need_wb;
                mono_mb_emit_ldarg (mb, 0);
                EMIT_TLS_ACCESS (mb, stack_end, stack_end_offset);
@@ -7867,6 +7967,9 @@ mono_gc_get_write_barrier (void)
                mono_mb_patch_branch (mb, label_no_wb_2);
                mono_mb_patch_branch (mb, label_no_wb_3);
                mono_mb_patch_branch (mb, label_no_wb_4);
+#ifndef ALIGN_NURSERY
+               mono_mb_patch_branch (mb, label_no_wb_5);
+#endif
                mono_mb_emit_byte (mb, CEE_RET);
 
                // slow path
index 1f8037e3b9612cd3fa54bd3c39c3a78682005412..126bd4a1529cb118cf6551ebcd6a8cecce30957e 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #ifndef __MONO_SGENGC_H__
 #define __MONO_SGENGC_H__
 
@@ -15,6 +38,8 @@
 #define LOCK_INIT(name)
 #define LOCK_GC pthread_mutex_lock (&gc_mutex)
 #define UNLOCK_GC pthread_mutex_unlock (&gc_mutex)
+#define LOCK_INTERRUPTION pthread_mutex_lock (&interruption_mutex)
+#define UNLOCK_INTERRUPTION pthread_mutex_unlock (&interruption_mutex)
 
 /* non-pthread will need to provide their own version of start/stop */
 #define USE_SIGNAL_BASED_START_STOP_WORLD 1
index 5db675164082b1797381fcea503191e407948017..e0a7bbbc2551b2a2b8fac68f90efc81ca6491609 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #define GRAY_QUEUE_SECTION_SIZE        (128 - 3)
 #define GRAY_QUEUE_LENGTH_LIMIT        64
 
index 4f1998513da86288ea78ee386f4c6e61233038e2..7e2d0a4a75f7a96af7c4ed45edf20c887952f9a0 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 enum {
        PIN_TYPE_STACK,
        PIN_TYPE_STATIC_DATA,
index 77a822f49b575f150d697bde28cd1ddacceab995..02eaab0298518dbc3194c5ff4fd3e21694ef3491 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #define PIN_STAGING_AREA_SIZE  1024
 
 static void* pin_staging_area [PIN_STAGING_AREA_SIZE];
index c6966412907f2618d0d97ba365af024dae0897a0..d93a1a8b5580c05cafeed3480642c5c0ca1af028 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 #ifdef BINARY_PROTOCOL
 
 #include "sgen-protocol.h"
index 1574a2f5f90685b3fe00af1958cd30cd081ae40f..867706377a2d214d2b4ddfda547e705d2a51d9e0 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
 enum {
        SGEN_PROTOCOL_COLLECTION,
        SGEN_PROTOCOL_ALLOC,
index 6c4b62ab30cf73c16dcf1c49221bf9c78780b6de..0ceaa727ef28eba20065246d239e69075749f93b 100644 (file)
@@ -1,4 +1,27 @@
 /*
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
  * Scans one object, using the OBJ_XXX macros.  The start of the
  * object must be given in the variable "char* start".  Afterwards,
  * "start" will point to the start of the next object.
index cec33b9dd243c1b7e32401be54dd808145cda77b..bc0b4e95f1084896d262e3b4f0c7964f25a99577 100644 (file)
@@ -141,11 +141,15 @@ static gint32 convert_family(MonoAddressFamily mono_family)
                break;
                
        case AddressFamily_Sna:
+#ifdef AF_SNA
                family=AF_SNA;
+#endif
                break;
                
        case AddressFamily_DecNet:
+#ifdef AF_DECnet
                family=AF_DECnet;
+#endif
                break;
                
        case AddressFamily_AppleTalk:
@@ -192,13 +196,17 @@ static MonoAddressFamily convert_to_mono_family(guint16 af_family)
                break;
 #endif
                
+#ifdef AF_SNA
        case AF_SNA:
                family=AddressFamily_Sna;
                break;
+#endif
                
+#ifdef AF_DECnet
        case AF_DECnet:
                family=AddressFamily_DecNet;
                break;
+#endif
                
        case AF_APPLETALK:
                family=AddressFamily_AppleTalk;
@@ -240,7 +248,9 @@ static gint32 convert_type(MonoSocketType mono_type)
                break;
 
        case SocketType_Rdm:
+#ifdef SOCK_RDM
                type=SOCK_RDM;
+#endif
                break;
 
        case SocketType_Seqpacket:
@@ -1633,7 +1643,7 @@ void ves_icall_System_Net_Sockets_Socket_Select_internal(MonoArray **sockets, gi
        MonoClass *sock_arr_class;
        MonoArray *socks;
        time_t start;
-       mono_array_size_t socks_size;
+       uintptr_t socks_size;
        
        MONO_ARCH_SAVE_REGS;
 
@@ -1712,7 +1722,7 @@ void ves_icall_System_Net_Sockets_Socket_Select_internal(MonoArray **sockets, gi
        }
 
        sock_arr_class= ((MonoObject *)*sockets)->vtable->klass;
-       socks_size = ((mono_array_size_t)ret) + 3; /* space for the NULL delimiters */
+       socks_size = ((uintptr_t)ret) + 3; /* space for the NULL delimiters */
        socks = mono_array_new_full (mono_domain_get (), sock_arr_class, &socks_size, NULL);
 
        mode = idx = 0;
index 639f295032233df96407d2f048a2227186a3e392..1c7d392968d3bc5cf72529b29ff15d4a3a6dd342 100644 (file)
@@ -6,20 +6,19 @@
  *   Gonzalo Paniagua Javier (gonzalo@ximian.com)
  *
  * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
- * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
+ * Copyright 2004-2010 Novell, Inc (http://www.novell.com)
  */
 
 #include <config.h>
 #include <glib.h>
 
 #ifdef MONO_SMALL_CONFIG
-#define THREADS_PER_CPU        2 /* 8 + THREADS_PER_CPU * number of CPUs = max threads */
-#define INITIAL_QUEUE_LENGTH 16
+#define QUEUE_LENGTH 16 /* Must be 2^N */
+#define MAX_POOL_THREADS 128
 #else
-#define THREADS_PER_CPU        10 /* 8 + THREADS_PER_CPU * number of CPUs = max threads */
-#define INITIAL_QUEUE_LENGTH 128
+#define QUEUE_LENGTH 64 /* Must be 2^N */
+#define MAX_POOL_THREADS 1024
 #endif
-#define THREAD_EXIT_TIMEOUT 1000
 
 #include <mono/metadata/domain-internals.h>
 #include <mono/metadata/tabledefs.h>
 #include <mono/metadata/marshal.h>
 #include <mono/metadata/mono-perfcounters.h>
 #include <mono/metadata/socket-io.h>
+#include <mono/metadata/mono-wsq.h>
 #include <mono/io-layer/io-layer.h>
 #include <mono/metadata/gc-internal.h>
 #include <mono/utils/mono-time.h>
 #include <mono/utils/mono-proclib.h>
+#include <mono/utils/mono-semaphore.h>
 #include <errno.h>
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #define THREAD_WANTS_A_BREAK(t) ((t->state & (ThreadState_StopRequested | \
                                                ThreadState_SuspendRequested)) != 0)
 
-#undef EPOLL_DEBUG
-//
+#define SPIN_TRYLOCK(i) (InterlockedCompareExchange (&(i), 1, 0) == 0)
+#define SPIN_LOCK(i) do { \
+                               if (SPIN_TRYLOCK (i)) \
+                                       break; \
+                       } while (1)
+
+#define SPIN_UNLOCK(i) i = 0
+
+#define EPOLL_DEBUG(...)
+#define EPOLL_DEBUG_STMT(...)
+#define TP_DEBUG(...)
+#define TP_DEBUG_STMT(...)
+
+/*
+#define EPOLL_DEBUG(...) g_message(__VA_ARGS__)
+#define EPOLL_DEBUG_STMT(...) do { __VA_ARGS__ } while (0)
+#define TP_DEBUG(...) g_message(__VA_ARGS__)
+#define TP_DEBUG_STMT(...) do { __VA_ARGS__ } while (0)
+*/
+
 /* map of CounterSample.cs */
 struct _MonoCounterSample {
        gint64 rawValue;
@@ -81,8 +100,6 @@ struct _MonoCounterSample {
 /* mono_thread_pool_init called */
 static int tp_inited;
 
-static int pending_io_items;
-
 typedef struct {
        CRITICAL_SECTION io_lock; /* access to sock_to_state */
        int inited;
@@ -108,49 +125,51 @@ typedef struct {
        MonoObject        *state;
        MonoObject        *res;
        MonoArray         *out_args;
-       /* This is a HANDLE, we use guint64 so the managed object layout remains constant */
-       /* THIS FIELD IS NOT USED ANY MORE. Remove it when we feel like breaking corlib compatibility with 2.6 */
-       guint64           wait_event;
 } ASyncCall;
 
 typedef struct {
-       CRITICAL_SECTION lock;
-       MonoArray *array;
-       int first_elem;
-       int next_elem;
+       MonoSemType lock;
+       MonoMList *first; /* GC root */
+       MonoMList *last;
+       MonoMList *unused; /* Up to 20 chunks. GC root */
+       gint head;
+       gint tail;
+       MonoSemType new_job;
+       volatile gint waiting; /* threads waiting for a work item */
 
        /**/
-       GQueue *idle_threads;
-       int idle_started; /* Have we started the idle threads? Interlocked */
+       volatile gint pool_status; /* 0 -> not initialized, 1 -> initialized, 2 -> cleaning up */
        /* min, max, n and busy -> Interlocked */
-       int min_threads;
-       int max_threads;
-       int nthreads;
-       int busy_threads;
+       volatile gint min_threads;
+       volatile gint max_threads;
+       volatile gint nthreads;
+       volatile gint busy_threads;
 
        void (*async_invoke) (gpointer data);
        void *pc_nitems; /* Performance counter for total number of items in added */
-       /* We don't need the rate here since we can compute the different ourselves */
-       /* void *perfc_rate; */
-       MonoCounterSample last_sample;
-
+       void *pc_nthreads; /* Performance counter for total number of active threads */
+       /**/
+       volatile gint destroy_thread;
+       volatile gint ignore_times; /* Used when there's a thread being created or destroyed */
+       volatile gint sp_lock; /* spin lock used to protect ignore_times */
+       volatile gint64 last_check;
+       volatile gint64 time_sum;
+       volatile gint n_sum;
+       gint64 averages [2];
+       /**/
+       //TP_DEBUG_ONLY (gint nodes_created);
+       //TP_DEBUG_ONLY (gint nodes_reused);
+       gboolean is_io;
 } ThreadPool;
 
 static ThreadPool async_tp;
 static ThreadPool async_io_tp;
 
-typedef struct {
-       HANDLE wait_handle;
-       gpointer data;
-       gint timeout;
-       gboolean die;
-} IdleThreadData;
 static void async_invoke_thread (gpointer data);
-static void mono_async_invoke (MonoAsyncResult *ares);
+static MonoObject *mono_async_invoke (ThreadPool *tp, MonoAsyncResult *ares);
 static void threadpool_free_queue (ThreadPool *tp);
 static void threadpool_append_job (ThreadPool *tp, MonoObject *ar);
-static void *threadpool_queue_idle_thread (ThreadPool *tp, IdleThreadData *it);
+static void threadpool_append_jobs (ThreadPool *tp, MonoObject **jobs, gint njobs);
 static void threadpool_init (ThreadPool *tp, int min_threads, int max_threads, void (*async_invoke) (gpointer));
 static void threadpool_start_idle_threads (ThreadPool *tp);
 static void threadpool_kill_idle_threads (ThreadPool *tp);
@@ -159,6 +178,9 @@ static MonoClass *async_call_klass;
 static MonoClass *socket_async_call_klass;
 static MonoClass *process_async_call_klass;
 
+static GPtrArray *wsqs;
+CRITICAL_SECTION wsqs_lock;
+
 /* Hooks */
 static MonoThreadPoolFunc tp_start_func;
 static MonoThreadPoolFunc tp_finish_func;
@@ -207,10 +229,6 @@ socket_io_cleanup (SocketIOData *data)
        data->new_sem = NULL;
        mono_g_hash_table_destroy (data->sock_to_state);
        data->sock_to_state = NULL;
-       EnterCriticalSection (&async_io_tp.lock);
-       threadpool_free_queue (&async_io_tp);
-       threadpool_kill_idle_threads (&async_io_tp);
-       LeaveCriticalSection (&async_io_tp.lock);
        g_free (data->newpfd);
        data->newpfd = NULL;
 #ifdef HAVE_EPOLL
@@ -236,7 +254,7 @@ get_event_from_state (MonoSocketAsyncResult *state)
        case AIO_OP_CONNECT:
                return MONO_POLLOUT;
        default: /* Should never happen */
-               g_print ("get_event_from_state: unknown value in switch!!!\n");
+               g_message ("get_event_from_state: unknown value in switch!!!");
                return 0;
        }
 }
@@ -284,104 +302,34 @@ threadpool_jobs_dec (MonoObject *obj)
        return FALSE;
 }
 
-#ifndef DISABLE_SOCKETS
-static void
-async_invoke_io_thread (gpointer data)
+static MonoObject *
+get_io_event (MonoMList **list, gint event)
 {
-       MonoDomain *domain;
-       MonoInternalThread *thread;
-       IdleThreadData idle_data = {0};
-  
-       idle_data.timeout = INFINITE;
-       idle_data.wait_handle = CreateEvent (NULL, FALSE, FALSE, NULL);
-
-       thread = mono_thread_internal_current ();
-       if (tp_start_func)
-               tp_start_func (tp_hooks_user_data);
-
-       for (;;) {
-               MonoSocketAsyncResult *state;
-               MonoAsyncResult *ar;
-
-               state = (MonoSocketAsyncResult *) data;
-               if (state) {
-                       InterlockedDecrement (&pending_io_items);
-                       ar = state->ares;
-                       switch (state->operation) {
-                       case AIO_OP_RECEIVE:
-                               state->total = ICALL_RECV (state);
-                               break;
-                       case AIO_OP_SEND:
-                               state->total = ICALL_SEND (state);
-                               break;
-                       }
-
-                       /* worker threads invokes methods in different domains,
-                        * so we need to set the right domain here */
-                       domain = ((MonoObject *)ar)->vtable->domain;
-
-                       g_assert (domain);
+       MonoObject *state;
+       MonoMList *current;
+       MonoMList *prev;
 
-                       if (domain->state == MONO_APPDOMAIN_UNLOADED || domain->state == MONO_APPDOMAIN_UNLOADING) {
-                               threadpool_jobs_dec ((MonoObject *)ar);
-                               data = NULL;
-                       } else {
-                               mono_thread_push_appdomain_ref (domain);
-                               if (threadpool_jobs_dec ((MonoObject *)ar)) {
-                                       data = NULL;
-                                       mono_thread_pop_appdomain_ref ();
-                                       continue;
-                               }
-                               if (mono_domain_set (domain, FALSE)) {
-                                       /* ASyncCall *ac; */
-
-                                       if (tp_item_begin_func)
-                                               tp_item_begin_func (tp_item_user_data);
-                                       mono_async_invoke (ar);
-                                       if (tp_item_end_func)
-                                               tp_item_end_func (tp_item_user_data);
-                                       /*
-                                       ac = (ASyncCall *) ar->object_data;
-                                       if (ac->msg->exc != NULL)
-                                               mono_unhandled_exception (ac->msg->exc);
-                                       */
-                                       mono_domain_set (mono_get_root_domain (), TRUE);
-                               }
-                               mono_thread_pop_appdomain_ref ();
-                               InterlockedDecrement (&async_io_tp.busy_threads);
-                               /* If the callee changes the background status, set it back to TRUE */
-                               if (!mono_thread_test_state (thread , ThreadState_Background))
-                                       ves_icall_System_Threading_Thread_SetState (thread, ThreadState_Background);
-                       }
-               }
-
-               data = threadpool_queue_idle_thread (&async_io_tp, &idle_data);
-               while (!idle_data.die && !data) {
-                       guint32 wr;
-                       wr = WaitForSingleObjectEx (idle_data.wait_handle, idle_data.timeout, TRUE);
-                       if (THREAD_WANTS_A_BREAK (thread))
-                               mono_thread_interruption_checkpoint ();
+       current = *list;
+       prev = NULL;
+       state = NULL;
+       while (current) {
+               state = mono_mlist_get_data (current);
+               if (get_event_from_state ((MonoSocketAsyncResult *) state) == event)
+                       break;
                
-                       if (wr != WAIT_TIMEOUT && wr != WAIT_IO_COMPLETION) {
-                               data = idle_data.data;
-                               idle_data.data = NULL;
-                               break; /* We have to exit */
-                       }
-               }
+               prev = current;
+               current = mono_mlist_next (current);
+       }
 
-               if (!data) {
-                       InterlockedDecrement (&async_io_tp.nthreads);
-                       CloseHandle (idle_data.wait_handle);
-                       idle_data.wait_handle = NULL;
-                       if (tp_finish_func)
-                               tp_finish_func (tp_hooks_user_data);
-                       return;
+       if (current) {
+               if (prev) {
+                       mono_mlist_set_next (prev, mono_mlist_next (current));
+               } else {
+                       *list = mono_mlist_next (*list);
                }
-               
-               InterlockedIncrement (&async_io_tp.busy_threads);
        }
 
-       g_assert_not_reached ();
+       return state;
 }
 
 static MonoMList *
@@ -402,10 +350,7 @@ process_io_event (MonoMList *list, int event)
 
        if (list != NULL) {
                oldlist = mono_mlist_remove_item (oldlist, list);
-#ifdef EPOLL_DEBUG
-               g_print ("Dispatching event %d on socket %p\n", event, state->handle);
-#endif
-               InterlockedIncrement (&pending_io_items);
+               EPOLL_DEBUG ("Dispatching event %d on socket %p", event, state->handle);
                threadpool_append_job (&async_io_tp, (MonoObject *) state);
        }
 
@@ -580,6 +525,7 @@ socket_io_poll_main (gpointer p)
 
 #ifdef HAVE_EPOLL
 #define EPOLL_ERRORS (EPOLLERR | EPOLLHUP)
+#define EPOLL_NEVENTS  128
 static void
 socket_io_epoll_main (gpointer p)
 {
@@ -587,13 +533,14 @@ socket_io_epoll_main (gpointer p)
        int epollfd;
        MonoInternalThread *thread;
        struct epoll_event *events, *evt;
-       const int nevents = 512;
        int ready = 0, i;
+       gpointer async_results [EPOLL_NEVENTS * 2]; // * 2 because each loop can add up to 2 results here
+       gint nresults;
 
        data = p;
        epollfd = data->epollfd;
        thread = mono_thread_internal_current ();
-       events = g_new0 (struct epoll_event, nevents);
+       events = g_new0 (struct epoll_event, EPOLL_NEVENTS);
 
        while (1) {
                do {
@@ -601,24 +548,20 @@ socket_io_epoll_main (gpointer p)
                                if (THREAD_WANTS_A_BREAK (thread))
                                        mono_thread_interruption_checkpoint ();
                        }
-#ifdef EPOLL_DEBUG
-                       g_print ("epoll_wait init\n");
-#endif
-                       ready = epoll_wait (epollfd, events, nevents, -1);
-#ifdef EPOLL_DEBUG
-                       {
-                       int err = errno;
-                       g_print ("epoll_wait end with %d ready sockets (%d %s).\n", ready, err, (err) ? g_strerror (err) : "");
-                       errno = err;
-                       }
-#endif
+                       EPOLL_DEBUG ("epoll_wait init");
+                       ready = epoll_wait (epollfd, events, EPOLL_NEVENTS, -1);
+                       EPOLL_DEBUG_STMT(
+                               int err = errno;
+                               EPOLL_DEBUG ("epoll_wait end with %d ready sockets (%d %s).", ready, err, (err) ? g_strerror (err) : "");
+                               errno = err;
+                       );
                } while (ready == -1 && errno == EINTR);
 
                if (ready == -1) {
                        int err = errno;
                        g_free (events);
                        if (err != EBADF)
-                               g_warning ("epoll_wait: %d %s\n", err, g_strerror (err));
+                               g_warning ("epoll_wait: %d %s", err, g_strerror (err));
 
                        close (epollfd);
                        return;
@@ -626,58 +569,59 @@ socket_io_epoll_main (gpointer p)
 
                EnterCriticalSection (&data->io_lock);
                if (data->inited == 0) {
-#ifdef EPOLL_DEBUG
-                       g_print ("data->inited == 0\n");
-#endif
+                       EPOLL_DEBUG ("data->inited == 0");
                        g_free (events);
                        close (epollfd);
                        return; /* cleanup called */
                }
 
+               nresults = 0;
                for (i = 0; i < ready; i++) {
                        int fd;
                        MonoMList *list;
+                       MonoObject *ares;
 
                        evt = &events [i];
                        fd = evt->data.fd;
                        list = mono_g_hash_table_lookup (data->sock_to_state, GINT_TO_POINTER (fd));
-#ifdef EPOLL_DEBUG
-                       g_print ("Event %d on %d list length: %d\n", evt->events, fd, mono_mlist_length (list));
-#endif
+                       EPOLL_DEBUG ("Event %d on %d list length: %d", evt->events, fd, mono_mlist_length (list));
                        if (list != NULL && (evt->events & (EPOLLIN | EPOLL_ERRORS)) != 0) {
-                               list = process_io_event (list, MONO_POLLIN);
+                               ares = get_io_event (&list, MONO_POLLIN);
+                               if (ares != NULL)
+                                       async_results [nresults++] = ares;
                        }
 
                        if (list != NULL && (evt->events & (EPOLLOUT | EPOLL_ERRORS)) != 0) {
-                               list = process_io_event (list, MONO_POLLOUT);
+                               ares = get_io_event (&list, MONO_POLLOUT);
+                               if (ares != NULL)
+                                       async_results [nresults++] = ares;
                        }
 
                        if (list != NULL) {
                                mono_g_hash_table_replace (data->sock_to_state, GINT_TO_POINTER (fd), list);
                                evt->events = get_events_from_list (list);
-#ifdef EPOLL_DEBUG
-                               g_print ("MOD %d to %d\n", fd, evt->events);
-#endif
+                               EPOLL_DEBUG ("MOD %d to %d", fd, evt->events);
                                if (epoll_ctl (epollfd, EPOLL_CTL_MOD, fd, evt)) {
                                        if (epoll_ctl (epollfd, EPOLL_CTL_ADD, fd, evt) == -1) {
-#ifdef EPOLL_DEBUG
-                                               int err = errno;
-                                               g_message ("epoll_ctl(MOD): %d %s fd: %d events: %d", err, g_strerror (err), fd, evt->events);
-                                               errno = err;
-#endif
+                                               EPOLL_DEBUG_STMT (
+                                                       int err = errno;
+                                                       EPOLL_DEBUG ("epoll_ctl(MOD): %d %s fd: %d events: %d", err, g_strerror (err), fd, evt->events);
+                                                       errno = err;
+                                               );
                                        }
                                }
                        } else {
                                mono_g_hash_table_remove (data->sock_to_state, GINT_TO_POINTER (fd));
-#ifdef EPOLL_DEBUG
-                               g_print ("DEL %d\n", fd);
-#endif
+                               EPOLL_DEBUG ("DEL %d", fd);
                                epoll_ctl (epollfd, EPOLL_CTL_DEL, fd, evt);
                        }
                }
                LeaveCriticalSection (&data->io_lock);
+               threadpool_append_jobs (&async_io_tp, (MonoObject **) async_results, nresults);
+               memset (async_results, 0, sizeof (gpointer) * nresults);
        }
 }
+#undef EPOLL_NEVENTS
 #endif
 
 /*
@@ -726,7 +670,7 @@ connect_hack (gpointer x)
        while (connect ((SOCKET) socket_io_data.pipe [1], (SOCKADDR *) addr, sizeof (struct sockaddr_in))) {
                Sleep (500);
                if (++count > 3) {
-                       g_warning ("Error initializing async. sockets %d.\n", WSAGetLastError ());
+                       g_warning ("Error initializing async. sockets %d.", WSAGetLastError ());
                        g_assert (WSAGetLastError ());
                }
        }
@@ -804,7 +748,6 @@ socket_io_init (SocketIOData *data)
        closesocket (srv);
 #endif
        data->sock_to_state = mono_g_hash_table_new_type (g_direct_hash, g_direct_equal, MONO_HASH_VALUE_GC);
-       mono_thread_create_internal (mono_get_root_domain (), threadpool_start_idle_threads, &async_io_tp, TRUE);
 
        if (data->epoll_disabled) {
                data->new_sem = CreateSemaphore (NULL, 1, 1, NULL);
@@ -836,6 +779,7 @@ socket_io_add_poll (MonoSocketAsyncResult *state)
        /* Bug #77637 for the BSD 6 case */
        /* Bug #78888 for the Windows case */
        if (state->operation == AIO_OP_CONNECT && state->blocking == TRUE) {
+               //FIXME: increment number of threads while this one is waiting?
                threadpool_append_job (&async_io_tp, (MonoObject *) state);
                return;
        }
@@ -896,20 +840,18 @@ socket_io_add_epoll (MonoSocketAsyncResult *state)
 
        mono_g_hash_table_replace (data->sock_to_state, state->handle, list);
        event.data.fd = fd;
-#ifdef EPOLL_DEBUG
-       g_print ("%s %d with %d\n", epoll_op == EPOLL_CTL_ADD ? "ADD" : "MOD", fd, event.events);
-#endif
+       EPOLL_DEBUG ("%s %d with %d", epoll_op == EPOLL_CTL_ADD ? "ADD" : "MOD", fd, event.events);
        if (epoll_ctl (data->epollfd, epoll_op, fd, &event) == -1) {
                int err = errno;
                if (epoll_op == EPOLL_CTL_ADD && err == EEXIST) {
                        epoll_op = EPOLL_CTL_MOD;
                        if (epoll_ctl (data->epollfd, epoll_op, fd, &event) == -1) {
-                               g_message ("epoll_ctl(MOD): %d %s\n", err, g_strerror (err));
+                               g_message ("epoll_ctl(MOD): %d %s", err, g_strerror (err));
                        }
                }
        }
-
        LeaveCriticalSection (&data->io_lock);
+
        return TRUE;
 }
 #endif
@@ -928,6 +870,7 @@ socket_io_add (MonoAsyncResult *ares, MonoSocketAsyncResult *state)
        socket_io_add_poll (state);
 }
 
+#ifndef DISABLE_SOCKETS
 static gboolean
 socket_io_filter (MonoObject *target, MonoObject *state)
 {
@@ -973,8 +916,9 @@ socket_io_filter (MonoObject *target, MonoObject *state)
 }
 #endif /* !DISABLE_SOCKETS */
 
-static void
-mono_async_invoke (MonoAsyncResult *ares)
+/* Returns the exception thrown when invoking, if any */
+static MonoObject *
+mono_async_invoke (ThreadPool *tp, MonoAsyncResult *ares)
 {
        ASyncCall *ac = (ASyncCall *)ares->object_data;
        MonoObject *res, *exc = NULL;
@@ -989,30 +933,36 @@ mono_async_invoke (MonoAsyncResult *ares)
                ares->original_context = NULL;
        }
 
-       ac->msg->exc = NULL;
-       res = mono_message_invoke (ares->async_delegate, ac->msg, &exc, &out_args);
-       MONO_OBJECT_SETREF (ac, res, res);
-       MONO_OBJECT_SETREF (ac, msg->exc, exc);
-       MONO_OBJECT_SETREF (ac, out_args, out_args);
-
-       mono_monitor_enter ((MonoObject *) ares);
-       ares->completed = 1;
-       if (ares->handle != NULL)
-               wait_event = mono_wait_handle_get_handle ((MonoWaitHandle *) ares->handle);
-       mono_monitor_exit ((MonoObject *) ares);
-       /* notify listeners */
-       if (wait_event != NULL)
-               SetEvent (wait_event);
-
-       /* call async callback if cb_method != null*/
-       if (ac->cb_method) {
-               MonoObject *exc = NULL;
-               void *pa = &ares;
-               mono_runtime_invoke (ac->cb_method, ac->cb_target, pa, &exc);
-               /* 'exc' will be the previous ac->msg->exc if not NULL and not
-                * catched. If catched, this will be set to NULL and the
-                * exception will not be printed. */
-               MONO_OBJECT_SETREF (ac->msg, exc, exc);
+       if (ac == NULL) {
+               /* Fast path from ThreadPool.*QueueUserWorkItem */
+               void *pa = ares->async_state;
+               mono_runtime_delegate_invoke (ares->async_delegate, &pa, &exc);
+       } else {
+               ac->msg->exc = NULL;
+               res = mono_message_invoke (ares->async_delegate, ac->msg, &exc, &out_args);
+               MONO_OBJECT_SETREF (ac, res, res);
+               MONO_OBJECT_SETREF (ac, msg->exc, exc);
+               MONO_OBJECT_SETREF (ac, out_args, out_args);
+
+               mono_monitor_enter ((MonoObject *) ares);
+               ares->completed = 1;
+               if (ares->handle != NULL)
+                       wait_event = mono_wait_handle_get_handle ((MonoWaitHandle *) ares->handle);
+               mono_monitor_exit ((MonoObject *) ares);
+               /* notify listeners */
+               if (wait_event != NULL)
+                       SetEvent (wait_event);
+
+               /* call async callback if cb_method != null*/
+               if (ac != NULL && ac->cb_method) {
+                       MonoObject *exc = NULL;
+                       void *pa = &ares;
+                       mono_runtime_invoke (ac->cb_method, ac->cb_target, pa, &exc);
+                       /* 'exc' will be the previous ac->msg->exc if not NULL and not
+                        * catched. If catched, this will be set to NULL and the
+                        * exception will not be printed. */
+                       MONO_OBJECT_SETREF (ac->msg, exc, exc);
+               }
        }
 
        /* restore original thread execution context if flow isn't suppressed, i.e. non null */
@@ -1020,23 +970,25 @@ mono_async_invoke (MonoAsyncResult *ares)
                mono_thread_set_execution_context (ares->original_context);
                ares->original_context = NULL;
        }
-
+       return exc;
 }
 
 static void
 threadpool_start_idle_threads (ThreadPool *tp)
 {
-       int needed;
-       int existing;
+       int n;
 
-       needed = (int) InterlockedCompareExchange (&tp->min_threads, 0, -1); 
        do {
-               existing = (int) InterlockedCompareExchange (&tp->nthreads, 0, -1); 
-               if (existing >= needed)
-                       break;
-               InterlockedIncrement (&tp->nthreads);
-               mono_thread_create_internal (mono_get_root_domain (), tp->async_invoke, NULL, TRUE);
-               SleepEx (250, TRUE);
+               while (1) {
+                       n = tp->nthreads;
+                       if (n >= tp->min_threads)
+                               return;
+                       if (InterlockedCompareExchange (&tp->nthreads, n + 1, n) == n)
+                               break;
+               }
+               mono_perfcounter_update_value (tp->pc_nthreads, TRUE, 1);
+               mono_thread_create_internal (mono_get_root_domain (), tp->async_invoke, tp, TRUE);
+               SleepEx (100, TRUE);
        } while (1);
 }
 
@@ -1044,11 +996,11 @@ static void
 threadpool_init (ThreadPool *tp, int min_threads, int max_threads, void (*async_invoke) (gpointer))
 {
        memset (tp, 0, sizeof (ThreadPool));
-       InitializeCriticalSection (&tp->lock);
+       MONO_SEM_INIT (&tp->lock, 1);
        tp->min_threads = min_threads;
        tp->max_threads = max_threads;
        tp->async_invoke = async_invoke;
-       tp->idle_threads = g_queue_new ();
+       MONO_SEM_INIT (&tp->new_job, 0);
 }
 
 static void *
@@ -1073,38 +1025,51 @@ init_perf_counter (const char *category, const char *counter)
 void
 mono_thread_pool_init ()
 {
-       int threads_per_cpu = THREADS_PER_CPU;
-       int cpu_count;
-       int n;
+       gint threads_per_cpu = 1;
+       gint thread_count;
+       gint cpu_count = mono_cpu_count ();
 
        if ((int) InterlockedCompareExchange (&tp_inited, 1, 0) == 1)
                return;
 
+       MONO_GC_REGISTER_ROOT (async_tp.first);
+       MONO_GC_REGISTER_ROOT (async_tp.last);
+       MONO_GC_REGISTER_ROOT (async_tp.unused);
+       MONO_GC_REGISTER_ROOT (async_io_tp.first);
+       MONO_GC_REGISTER_ROOT (async_io_tp.unused);
+       MONO_GC_REGISTER_ROOT (async_io_tp.last);
+
        MONO_GC_REGISTER_ROOT (socket_io_data.sock_to_state);
        InitializeCriticalSection (&socket_io_data.io_lock);
        if (g_getenv ("MONO_THREADS_PER_CPU") != NULL) {
                threads_per_cpu = atoi (g_getenv ("MONO_THREADS_PER_CPU"));
-               if (threads_per_cpu < THREADS_PER_CPU)
-                       threads_per_cpu = THREADS_PER_CPU;
+               if (threads_per_cpu < 1)
+                       threads_per_cpu = 1;
        }
 
-       cpu_count = mono_cpu_count ();
-       n = 8 + 2 * cpu_count; /* 8 is minFreeThreads for ASP.NET */
-       threadpool_init (&async_tp, n, n + threads_per_cpu * cpu_count, async_invoke_thread);
-#ifndef DISABLE_SOCKETS
-       threadpool_init (&async_io_tp, 2 * cpu_count, 8 * cpu_count, async_invoke_io_thread);
-#endif
+       thread_count = MIN (cpu_count * threads_per_cpu, MAX_POOL_THREADS);
+       threadpool_init (&async_tp, thread_count, MAX_POOL_THREADS, async_invoke_thread);
+       threadpool_init (&async_io_tp, cpu_count * 2, cpu_count * 4, async_invoke_thread);
+       async_io_tp.is_io = TRUE;
 
        async_call_klass = mono_class_from_name (mono_defaults.corlib, "System", "MonoAsyncCall");
        g_assert (async_call_klass);
 
+       InitializeCriticalSection (&wsqs_lock);
+       wsqs = g_ptr_array_sized_new (MAX_POOL_THREADS);
+       mono_wsq_init ();
+
        async_tp.pc_nitems = init_perf_counter ("Mono Threadpool", "Work Items Added");
        g_assert (async_tp.pc_nitems);
-       mono_perfcounter_get_sample (async_tp.pc_nitems, FALSE, &async_tp.last_sample);
 
        async_io_tp.pc_nitems = init_perf_counter ("Mono Threadpool", "IO Work Items Added");
        g_assert (async_io_tp.pc_nitems);
-       mono_perfcounter_get_sample (async_io_tp.pc_nitems, FALSE, &async_io_tp.last_sample);
+
+       async_tp.pc_nthreads = init_perf_counter ("Mono Threadpool", "# of Threads");
+       g_assert (async_tp.pc_nthreads);
+
+       async_io_tp.pc_nthreads = init_perf_counter ("Mono Threadpool", "# of IO Threads");
+       g_assert (async_io_tp.pc_nthreads);
 }
 
 MonoAsyncResult *
@@ -1115,7 +1080,7 @@ mono_thread_pool_add (MonoObject *target, MonoMethodMessage *msg, MonoDelegate *
        MonoAsyncResult *ares;
        ASyncCall *ac;
 
-       ac = (ASyncCall*)mono_object_new (mono_domain_get (), async_call_klass);
+       ac = (ASyncCall*)mono_object_new (domain, async_call_klass);
        MONO_OBJECT_SETREF (ac, msg, msg);
        MONO_OBJECT_SETREF (ac, state, state);
 
@@ -1133,9 +1098,6 @@ mono_thread_pool_add (MonoObject *target, MonoMethodMessage *msg, MonoDelegate *
                return ares;
        }
 #endif
-       if (InterlockedCompareExchange (&async_tp.idle_started, 1, 0) == 0)
-               mono_thread_create_internal (mono_get_root_domain (), threadpool_start_idle_threads, &async_tp, TRUE);
-       
        threadpool_append_job (&async_tp, (MonoObject *) ares);
        return ares;
 }
@@ -1153,8 +1115,7 @@ mono_thread_pool_finish (MonoAsyncResult *ares, MonoArray **out_args, MonoObject
        mono_monitor_enter ((MonoObject *) ares);
        
        if (ares->endinvoke_called) {
-               *exc = (MonoObject *)mono_exception_from_name (mono_defaults.corlib, "System", 
-                                             "InvalidOperationException");
+               *exc = (MonoObject *) mono_get_exception_invalid_operation (NULL);
                mono_monitor_exit ((MonoObject *) ares);
                return NULL;
        }
@@ -1186,43 +1147,41 @@ mono_thread_pool_finish (MonoAsyncResult *ares, MonoArray **out_args, MonoObject
 static void
 threadpool_kill_idle_threads (ThreadPool *tp)
 {
-       IdleThreadData *it;
-
-       if (!tp || !tp->idle_threads)
-               return;
+       gint n;
 
-       while ((it = g_queue_pop_head (tp->idle_threads)) != NULL) {
-               it->data = NULL;
-               it->die = TRUE;
-               SetEvent (it->wait_handle);
+       n = (gint) InterlockedCompareExchange (&tp->max_threads, 0, -1);
+       while (n) {
+               n--;
+               MONO_SEM_POST (&tp->new_job);
        }
-       g_queue_free (tp->idle_threads);
-       tp->idle_threads = NULL;
 }
 
 void
 mono_thread_pool_cleanup (void)
 {
-       EnterCriticalSection (&async_tp.lock);
+       if (async_tp.pool_status == 1 && InterlockedCompareExchange (&async_tp.pool_status, 2, 1) == 2)
+               return;
+
+       InterlockedExchange (&async_io_tp.pool_status, 2);
+       MONO_SEM_WAIT (&async_tp.lock);
        threadpool_free_queue (&async_tp);
        threadpool_kill_idle_threads (&async_tp);
-       LeaveCriticalSection (&async_tp.lock);
-       socket_io_cleanup (&socket_io_data); /* Empty when DISABLE_SOCKETS is defined */
-       /* Do we want/need these?
-       DeleteCriticalSection (&async_tp.lock);
-       DeleteCriticalSection (&async_tp.table_lock);
-       DeleteCriticalSection (&socket_io_data.io_lock);
-       */
-}
+       MONO_SEM_POST (&async_tp.lock);
 
-static void
-null_array (MonoArray *a, int first, int last)
-{
-       /* We must null the old array because it might
-          contain cross-appdomain references, which
-          will crash the GC when the domains are
-          unloaded. */
-       memset (mono_array_addr (a, MonoObject*, first), 0, sizeof (MonoObject*) * (last - first));
+       socket_io_cleanup (&socket_io_data); /* Empty when DISABLE_SOCKETS is defined */
+       MONO_SEM_WAIT (&async_io_tp.lock);
+       threadpool_free_queue (&async_io_tp);
+       threadpool_kill_idle_threads (&async_io_tp);
+       MONO_SEM_POST (&async_io_tp.lock);
+       MONO_SEM_DESTROY (&async_io_tp.new_job);
+
+       EnterCriticalSection (&wsqs_lock);
+       mono_wsq_cleanup ();
+       if (wsqs)
+               g_ptr_array_free (wsqs, TRUE);
+       wsqs = NULL;
+       LeaveCriticalSection (&wsqs_lock);
+       MONO_SEM_DESTROY (&async_tp.new_job);
 }
 
 /* Caller must enter &tp->lock */
@@ -1230,208 +1189,186 @@ static MonoObject*
 dequeue_job_nolock (ThreadPool *tp)
 {
        MonoObject *ar;
-       int count;
+       MonoArray *array;
+       MonoMList *list;
 
-       if (!tp->array || tp->first_elem == tp->next_elem)
-               return NULL;
-       ar = mono_array_get (tp->array, MonoObject*, tp->first_elem);
-       mono_array_set (tp->array, MonoObject*, tp->first_elem, NULL);
-       tp->first_elem++;
-       count = tp->next_elem - tp->first_elem;
-       /* reduce the size of the array if it's mostly empty */
-       if (mono_array_length (tp->array) > INITIAL_QUEUE_LENGTH && count < (mono_array_length (tp->array) / 3)) {
-               MonoArray *newa = mono_array_new_cached (mono_get_root_domain (), mono_defaults.object_class, mono_array_length (tp->array) / 2);
-               mono_array_memcpy_refs (newa, 0, tp->array, tp->first_elem, count);
-               null_array (tp->array, tp->first_elem, tp->next_elem);
-               tp->array = newa;
-               tp->first_elem = 0;
-               tp->next_elem = count;
-       }
+       list = tp->first;
+       do {
+               if (mono_runtime_is_shutting_down ())
+                       return NULL;
+               if (!list || tp->head == tp->tail)
+                       return NULL;
+
+               array = (MonoArray *) mono_mlist_get_data (list);
+               ar = mono_array_get (array, MonoObject *, tp->head % QUEUE_LENGTH);
+               mono_array_set (array, MonoObject *, tp->head % QUEUE_LENGTH, NULL);
+               tp->head++;
+               if ((tp->head % QUEUE_LENGTH) == 0) {
+                       list = tp->first;
+                       tp->first = mono_mlist_next (list);
+                       if (tp->first == NULL)
+                               tp->last = NULL;
+                       if (mono_mlist_length (tp->unused) < 20) {
+                               /* reuse this chunk */
+                               tp->unused = mono_mlist_set_next (list, tp->unused);
+                       }
+                       tp->head -= QUEUE_LENGTH;
+                       tp->tail -= QUEUE_LENGTH;
+               }
+               list = tp->first;
+       } while (ar == NULL);
        return ar;
 }
 
 /* Call after entering &tp->lock */
-static int
-signal_idle_threads (ThreadPool *tp)
+static gboolean
+threadpool_start_thread (ThreadPool *tp)
 {
-       IdleThreadData *it;
-       int result = 0;
-       int njobs;
-
-       njobs = tp->next_elem - tp->first_elem;
-       while (njobs > 0 && (it = g_queue_pop_head (tp->idle_threads)) != NULL) {
-               it->data = dequeue_job_nolock (tp);
-               if (it->data == NULL)
-                       break; /* Should never happen */
-               result++;
-               njobs--;
-               it->timeout = INFINITE;
-               SetEvent (it->wait_handle);
+       gint n;
+
+       while ((n = tp->nthreads) < tp->max_threads) {
+               if (InterlockedCompareExchange (&tp->nthreads, n + 1, n) == n) {
+                       mono_perfcounter_update_value (tp->pc_nthreads, TRUE, 1);
+                       mono_thread_create_internal (mono_get_root_domain (), tp->async_invoke, tp, TRUE);
+                       return TRUE;
+               }
        }
-       return njobs;
+
+       return FALSE;
 }
 
-/* Call after entering &tp->lock */
-static gboolean
-threadpool_start_thread (ThreadPool *tp, gpointer arg)
+static void
+pulse_on_new_job (ThreadPool *tp)
 {
-       gint max;
-       gint n;
+       if (tp->waiting)
+               MONO_SEM_POST (&tp->new_job);
+}
 
-       max = (gint) InterlockedCompareExchange (&tp->max_threads, 0, -1);
-       n = (gint) InterlockedCompareExchange (&tp->nthreads, 0, -1);
-       if (max <= n)
-               return FALSE;
-       InterlockedIncrement (&tp->nthreads);
-       mono_thread_create_internal (mono_get_root_domain (), tp->async_invoke, arg, TRUE);
-       return TRUE;
+void
+icall_append_job (MonoObject *ar)
+{
+       threadpool_append_job (&async_tp, ar);
 }
 
-/*
-static const char *
-get_queue_name (ThreadPool *tp)
+static void
+threadpool_append_job (ThreadPool *tp, MonoObject *ar)
 {
-       if (tp == &async_tp)
-               return "TP";
-       if (tp == &async_io_tp)
-               return "IO";
-       return "(Unknown)";
+       threadpool_append_jobs (tp, &ar, 1);
 }
-*/
 
-static gpointer
-threadpool_queue_idle_thread (ThreadPool *tp, IdleThreadData *it)
+static MonoMList *
+create_or_reuse_list (ThreadPool *tp)
 {
-       /*
-       MonoCounterSample sample;
-       float rate;
-       */
-       gpointer result = NULL;
-       CRITICAL_SECTION *cs = &tp->lock;
-
-       EnterCriticalSection (cs);
-       if (tp->idle_threads == NULL) {
-               it->die = TRUE;
-               LeaveCriticalSection (cs);
-               return NULL; /* We are shutting down */
-       }
-       /*
-       if (mono_100ns_ticks () - tp->last_sample.timeStamp > 10000 * 1000) {
-               float elapsed_ticks;
-               mono_perfcounter_get_sample (tp->pc_nitems, FALSE, &sample);
-
-               elapsed_ticks = (float) (sample.timeStamp - tp->last_sample.timeStamp);
-               rate = ((float) (sample.rawValue - tp->last_sample.rawValue)) / elapsed_ticks * 10000000;
-               printf ("Queue: %s NThreads: %d Rate: %.2f Total items: %lld Time(ms): %.2f\n", get_queue_name (tp),
-                                               InterlockedCompareExchange (&tp->nthreads, 0, -1), rate,
-                                               sample.rawValue - tp->last_sample.rawValue, elapsed_ticks / 10000);
-               memcpy (&tp->last_sample, &sample, sizeof (sample));
-       }
-       */
+       MonoMList *list;
+       MonoArray *array;
 
-       it->data = result = dequeue_job_nolock (tp);
-       if (result != NULL) {
-               signal_idle_threads (tp);
+       list = NULL;
+       if (tp->unused) {
+               list = tp->unused;
+               tp->unused = mono_mlist_next (list);
+               mono_mlist_set_next (list, NULL);
+               //TP_DEBUG (tp->nodes_reused++);
        } else {
-               int min, n;
-               min = (gint) InterlockedCompareExchange (&tp->min_threads, 0, -1);
-               n = (gint) InterlockedCompareExchange (&tp->nthreads, 0, -1);
-               if (n <= min) {
-                       g_queue_push_tail (tp->idle_threads, it);
-               } else {
-                       /* TODO: figure out when threads should be told to die */
-                       /* it->die = TRUE; */
-                       g_queue_push_tail (tp->idle_threads, it);
-               }
+               array = mono_array_new_cached (mono_get_root_domain (), mono_defaults.object_class, QUEUE_LENGTH);
+               list = mono_mlist_alloc ((MonoObject *) array);
+               //TP_DEBUG (tp->nodes_created++);
        }
-       LeaveCriticalSection (cs);
-       return result;
+       return list;
 }
 
 static void
-threadpool_append_job (ThreadPool *tp, MonoObject *ar)
+threadpool_append_jobs (ThreadPool *tp, MonoObject **jobs, gint njobs)
 {
-       CRITICAL_SECTION *cs;
-
-       cs = &tp->lock;
-       threadpool_jobs_inc (ar); 
-       EnterCriticalSection (cs);
-       if (tp->idle_threads == NULL) { 
-               LeaveCriticalSection (cs);
-               return; /* We are shutting down */
-       }
-       if (ar->vtable->domain->state == MONO_APPDOMAIN_UNLOADING ||
-                       ar->vtable->domain->state == MONO_APPDOMAIN_UNLOADED) {
-               LeaveCriticalSection (cs);
+       MonoArray *array;
+       MonoMList *list;
+       MonoObject *ar;
+       gint i;
+       gboolean lock_taken = FALSE; /* We won't take the lock when the local queue is used */
+
+       if (mono_runtime_is_shutting_down ())
                return;
-       }
 
-       mono_perfcounter_update_value (tp->pc_nitems, TRUE, 1);
-       if (tp->array && (tp->next_elem < mono_array_length (tp->array))) {
-               mono_array_setref (tp->array, tp->next_elem, ar);
-               tp->next_elem++;
-               if (signal_idle_threads (tp) > 0 && threadpool_start_thread (tp, ar)) {
-                       tp->next_elem--;
-                       mono_array_setref (tp->array, tp->next_elem, NULL);
+       if (tp->pool_status == 0 && InterlockedCompareExchange (&tp->pool_status, 1, 0) == 0)
+               mono_thread_create_internal (mono_get_root_domain (), threadpool_start_idle_threads, tp, TRUE);
+
+       for (i = 0; i < njobs; i++) {
+               ar = jobs [i];
+               if (ar == NULL)
+                       continue; /* Might happen when cleaning domain jobs */
+               if (!tp->is_io) {
+                       MonoAsyncResult *o = (MonoAsyncResult *) ar;
+                       o->add_time = mono_100ns_ticks ();
                }
-               LeaveCriticalSection (cs);
-               return;
-       }
+               threadpool_jobs_inc (ar); 
+               mono_perfcounter_update_value (tp->pc_nitems, TRUE, 1);
+               if (!tp->is_io && mono_wsq_local_push (ar))
+                       continue;
 
-       if (!tp->array) {
-               MONO_GC_REGISTER_ROOT (tp->array);
-               tp->array = mono_array_new_cached (mono_get_root_domain (), mono_defaults.object_class, INITIAL_QUEUE_LENGTH);
-       } else {
-               int count = tp->next_elem - tp->first_elem;
-               /* slide the array or create a larger one if it's full */
-               if (tp->first_elem) {
-                       mono_array_memcpy_refs (tp->array, 0, tp->array, tp->first_elem, count);
-                       null_array (tp->array, count, tp->next_elem);
-               } else {
-                       MonoArray *newa = mono_array_new_cached (mono_get_root_domain (), mono_defaults.object_class, mono_array_length (tp->array) * 2);
-                       mono_array_memcpy_refs (newa, 0, tp->array, tp->first_elem, count);
-                       null_array (tp->array, count, tp->next_elem);
-                       tp->array = newa;
+               if (!lock_taken) {
+                       MONO_SEM_WAIT (&tp->lock);
+                       lock_taken = TRUE;
                }
-               tp->first_elem = 0;
-               tp->next_elem = count;
-       }
-       mono_array_setref (tp->array, tp->next_elem, ar);
-       tp->next_elem++;
-       if (signal_idle_threads (tp) > 0 && threadpool_start_thread (tp, ar)) {
-               tp->next_elem--;
-               mono_array_setref (tp->array, tp->next_elem, NULL);
+               if ((tp->tail % QUEUE_LENGTH) == 0) {
+                       list = create_or_reuse_list (tp);
+                       if (tp->last != NULL)
+                               mono_mlist_set_next (tp->last, list);
+                       tp->last = list;
+                       if (tp->first == NULL)
+                               tp->first = tp->last;
+               }
+
+               array = (MonoArray *) mono_mlist_get_data (tp->last);
+               mono_array_setref (array, tp->tail % QUEUE_LENGTH, ar);
+               tp->tail++;
        }
-       LeaveCriticalSection (cs);
+       if (lock_taken)
+               MONO_SEM_POST (&tp->lock);
+       for (i = 0; i < MIN(njobs, tp->max_threads); i++)
+               pulse_on_new_job (tp);
 }
 
-
 static void
 threadpool_clear_queue (ThreadPool *tp, MonoDomain *domain)
 {
-       int i, count = 0;
-       EnterCriticalSection (&tp->lock);
-       /*remove*/
-       for (i = tp->first_elem; i < tp->next_elem; ++i) {
-               MonoObject *obj = mono_array_get (tp->array, MonoObject*, i);
-               if (obj->vtable->domain == domain) {
-                       mono_array_set (tp->array, MonoObject*, i, NULL);
-                       InterlockedDecrement (&domain->threadpool_jobs);
-                       ++count;
+       MonoMList *current;
+       MonoArray *array;
+       MonoObject *obj;
+       int domain_count;
+       int i;
+
+       domain_count = 0;
+       MONO_SEM_WAIT (&tp->lock);
+       current = tp->first;
+       while (current) {
+               array = (MonoArray *) mono_mlist_get_data (current);
+               for (i = 0; i < QUEUE_LENGTH; i++) {
+                       obj = mono_array_get (array, MonoObject*, i);
+                       if (obj != NULL && obj->vtable->domain == domain) {
+                               domain_count++;
+                               mono_array_setref (array, i, NULL);
+                       }
                }
+               current = mono_mlist_next (current);
        }
-       /*compact*/
-       if (count) {
-               int idx = 0;
-               for (i = tp->first_elem; i < tp->next_elem; ++i) {
-                       MonoObject *obj = mono_array_get (tp->array, MonoObject*, i);
-                       if (obj)
-                               mono_array_set (tp->array, MonoObject*, idx++, obj);
-               }
-               tp->first_elem = 0;
-               tp->next_elem = count;
+
+       if (!domain_count) {
+               MONO_SEM_POST (&tp->lock);
+               return;
+       }
+
+       current = tp->first;
+       tp->first = NULL;
+       tp->last = NULL;
+       tp->head = 0;
+       tp->tail = 0;
+       MONO_SEM_POST (&tp->lock);
+       /* Re-add everything but the nullified elements */
+       while (current) {
+               array = (MonoArray *) mono_mlist_get_data (current);
+               threadpool_append_jobs (tp, mono_array_addr (array, MonoObject *, 0), QUEUE_LENGTH);
+               memset (mono_array_addr (array, MonoObject *, 0), 0, sizeof (MonoObject *) * QUEUE_LENGTH);
+               current = mono_mlist_next (current);
        }
-       LeaveCriticalSection (&tp->lock);
 }
 
 /*
@@ -1483,16 +1420,196 @@ mono_thread_pool_remove_domain_jobs (MonoDomain *domain, int timeout)
 static void
 threadpool_free_queue (ThreadPool *tp)
 {
-       if (tp->array)
-               null_array (tp->array, tp->first_elem, tp->next_elem);
-       tp->array = NULL;
-       tp->first_elem = tp->next_elem = 0;
+       tp->head = tp->tail = 0;
+       tp->first = NULL;
+       tp->unused = NULL;
 }
 
 gboolean
 mono_thread_pool_is_queue_array (MonoArray *o)
 {
-       return o == async_tp.array || o == async_io_tp.array;
+       gpointer obj = o;
+
+       // FIXME: need some fix in sgen code.
+       // There are roots at: async*tp.unused (MonoMList) and wsqs [n]->queue (MonoArray)
+       return obj == async_tp.first || obj == async_io_tp.first;
+}
+
+static void
+add_wsq (MonoWSQ *wsq)
+{
+       int i;
+
+       if (wsq == NULL)
+               return;
+
+       EnterCriticalSection (&wsqs_lock);
+       if (wsqs == NULL) {
+               LeaveCriticalSection (&wsqs_lock);
+               return;
+       }
+       for (i = 0; i < wsqs->len; i++) {
+               if (g_ptr_array_index (wsqs, i) == NULL) {
+                       wsqs->pdata [i] = wsq;
+                       LeaveCriticalSection (&wsqs_lock);
+                       return;
+               }
+       }
+       g_ptr_array_add (wsqs, wsq);
+       LeaveCriticalSection (&wsqs_lock);
+}
+
+static void
+remove_wsq (MonoWSQ *wsq)
+{
+       int i;
+
+       if (wsq == NULL)
+               return;
+
+       EnterCriticalSection (&wsqs_lock);
+       if (wsqs == NULL) {
+               LeaveCriticalSection (&wsqs_lock);
+               return;
+       }
+       for (i = 0; i < wsqs->len; i++) {
+               if (g_ptr_array_index (wsqs, i) == wsq) {
+                       wsqs->pdata [i] = NULL;
+                       LeaveCriticalSection (&wsqs_lock);
+                       return;
+               }
+       }
+       /* Should not happen */
+       LeaveCriticalSection (&wsqs_lock);
+}
+
+static void
+try_steal (gpointer *data, gboolean retry)
+{
+       int i;
+       int ms;
+
+       if (wsqs == NULL || data == NULL || *data != NULL)
+               return;
+
+       ms = 0;
+       do {
+               if (mono_runtime_is_shutting_down ())
+                       return;
+               for (i = 0; i < wsqs->len; i++) {
+                       if (mono_runtime_is_shutting_down ()) {
+                               return;
+                       }
+                       mono_wsq_try_steal (wsqs->pdata [i], data, ms);
+                       if (*data != NULL) {
+                               return;
+                       }
+               }
+               ms += 10;
+       } while (retry && ms < 11);
+}
+
+static gboolean
+dequeue_or_steal (ThreadPool *tp, gpointer *data)
+{
+       if (mono_runtime_is_shutting_down ())
+               return FALSE;
+       TP_DEBUG ("Dequeue");
+       MONO_SEM_WAIT (&tp->lock);
+       *data = dequeue_job_nolock (tp);
+       MONO_SEM_POST (&tp->lock);
+       if (!tp->is_io && !*data)
+               try_steal (data, FALSE);
+       return (*data != NULL);
+}
+
+static void
+process_idle_times (ThreadPool *tp, gint64 t)
+{
+       gint64 ticks;
+       gint64 avg;
+       gboolean compute_avg;
+       gint new_threads;
+       gint64 per1;
+
+       if (tp->ignore_times)
+               return;
+
+       compute_avg = FALSE;
+       ticks = mono_100ns_ticks ();
+       t = ticks - t;
+       SPIN_LOCK (tp->sp_lock);
+       if (tp->ignore_times) {
+               SPIN_UNLOCK (tp->sp_lock);
+               return;
+       }
+       tp->time_sum += t;
+       tp->n_sum++;
+       if (tp->last_check == 0)
+               tp->last_check = ticks;
+       else if ((ticks - tp->last_check) > 5000000) {
+               tp->ignore_times = 1;
+               compute_avg = TRUE;
+       }
+       SPIN_UNLOCK (tp->sp_lock);
+
+       if (!compute_avg)
+               return;
+
+       //printf ("Items: %d Time elapsed: %.3fs\n", tp->n_sum, (ticks - tp->last_check) / 10000.0);
+       new_threads = 0;
+       avg = tp->time_sum / tp->n_sum;
+       if (tp->averages [1] == 0) {
+               tp->averages [1] = avg;
+       } else {
+               per1 = ((100 * (ABS (avg - tp->averages [1]))) / tp->averages [1]);
+               if (per1 > 5) {
+                       if (avg > tp->averages [1]) {
+                               if (tp->averages [1] < tp->averages [0]) {
+                                       new_threads = -1;
+                               } else {
+                                       new_threads = 1;
+                               }
+                       } else if (avg < tp->averages [1] && tp->averages [1] < tp->averages [0]) {
+                               new_threads = 1;
+                       }
+               } else {
+                       int min, n;
+                       min = tp->min_threads;
+                       n = tp->nthreads;
+                       if ((n - min) < min && tp->busy_threads == n)
+                               new_threads = 1;
+               }
+               /*
+               if (new_threads != 0) {
+                       printf ("n: %d per1: %lld avg=%lld avg1=%lld avg0=%lld\n", new_threads, per1, avg, tp->averages [1], tp->averages [0]);
+               }
+               */
+       }
+
+       tp->time_sum = 0;
+       tp->n_sum = 0;
+       tp->last_check = mono_100ns_ticks ();
+
+       tp->averages [0] = tp->averages [1];
+       tp->averages [1] = avg;
+       tp->ignore_times = 0;
+
+       if (tp->waiting == 0 && new_threads == 1) {
+               threadpool_start_thread (tp);
+       } else if (new_threads == -1) {
+               if (InterlockedCompareExchange (&tp->destroy_thread, 1, 0) == 0)
+                       pulse_on_new_job (tp);
+       }
+}
+
+static gboolean
+should_i_die (ThreadPool *tp)
+{
+       gboolean result = FALSE;
+       if (tp->destroy_thread == 1 && InterlockedCompareExchange (&tp->destroy_thread, 0, 1) == 1)
+               result = (tp->nthreads > tp->min_threads);
+       return result;
 }
 
 static void
@@ -1500,26 +1617,50 @@ async_invoke_thread (gpointer data)
 {
        MonoDomain *domain;
        MonoInternalThread *thread;
-       IdleThreadData idle_data = {0};
+       MonoWSQ *wsq;
+       ThreadPool *tp;
+       gboolean must_die;
   
-       idle_data.timeout = INFINITE;
-       idle_data.wait_handle = CreateEvent (NULL, FALSE, FALSE, NULL);
+       tp = data;
+       wsq = NULL;
+       if (!tp->is_io) {
+               wsq = mono_wsq_create ();
+               add_wsq (wsq);
+       }
+
        thread = mono_thread_internal_current ();
        if (tp_start_func)
                tp_start_func (tp_hooks_user_data);
+       data = NULL;
        for (;;) {
                MonoAsyncResult *ar;
+               gboolean is_io_task;
 
+               is_io_task = FALSE;
                ar = (MonoAsyncResult *) data;
                if (ar) {
+#ifndef DISABLE_SOCKETS
+                       is_io_task = (strcmp (((MonoObject *) data)->vtable->klass->name, "AsyncResult"));
+                       if (is_io_task) {
+                               MonoSocketAsyncResult *state = (MonoSocketAsyncResult *) data;
+                               ar = state->ares;
+                               switch (state->operation) {
+                               case AIO_OP_RECEIVE:
+                                       state->total = ICALL_RECV (state);
+                                       break;
+                               case AIO_OP_SEND:
+                                       state->total = ICALL_SEND (state);
+                                       break;
+                               }
+                       }
+#endif
+
                        /* worker threads invokes methods in different domains,
                         * so we need to set the right domain here */
                        domain = ((MonoObject *)ar)->vtable->domain;
-
                        g_assert (domain);
 
-                       if (domain->state == MONO_APPDOMAIN_UNLOADED || domain->state == MONO_APPDOMAIN_UNLOADING) {
+                       if (mono_runtime_is_shutting_down ()) {
                                threadpool_jobs_dec ((MonoObject *)ar);
                                data = NULL;
                        } else {
@@ -1535,7 +1676,11 @@ async_invoke_thread (gpointer data)
 
                                        if (tp_item_begin_func)
                                                tp_item_begin_func (tp_item_user_data);
-                                       mono_async_invoke (ar);
+
+                                       if (!is_io_task)
+                                               process_idle_times (tp, ar->add_time);
+                                       /*FIXME: Do something with the exception returned? */
+                                       mono_async_invoke (tp, ar);
                                        if (tp_item_end_func)
                                                tp_item_end_func (tp_item_user_data);
                                        /*
@@ -1546,36 +1691,63 @@ async_invoke_thread (gpointer data)
                                        mono_domain_set (mono_get_root_domain (), TRUE);
                                }
                                mono_thread_pop_appdomain_ref ();
-                               InterlockedDecrement (&async_tp.busy_threads);
+                               InterlockedDecrement (&tp->busy_threads);
                                /* If the callee changes the background status, set it back to TRUE */
                                if (!mono_thread_test_state (thread , ThreadState_Background))
                                        ves_icall_System_Threading_Thread_SetState (thread, ThreadState_Background);
                        }
                }
-               data = threadpool_queue_idle_thread (&async_tp, &idle_data);
-               while (!idle_data.die && !data) {
-                       guint32 wr;
-                       wr = WaitForSingleObjectEx (idle_data.wait_handle, idle_data.timeout, TRUE);
-                       if (THREAD_WANTS_A_BREAK (thread))
-                               mono_thread_interruption_checkpoint ();
-               
-                       if (wr != WAIT_TIMEOUT && wr != WAIT_IO_COMPLETION) {
-                               data = idle_data.data;
-                               break; /* We have to exit */
+
+               data = NULL;
+               must_die = should_i_die (tp);
+               TP_DEBUG ("Trying to get a job");
+               if (!must_die && (tp->is_io || !mono_wsq_local_pop (&data)))
+                       dequeue_or_steal (tp, &data);
+               TP_DEBUG ("Done trying to get a job %p", data);
+
+               while (!must_die && !data) {
+                       gboolean res;
+
+                       TP_DEBUG ("Waiting");
+                       InterlockedIncrement (&tp->waiting);
+                       while ((res = MONO_SEM_WAIT (&tp->new_job)) && errno == EINTR) {
+                               if (mono_runtime_is_shutting_down ())
+                                       break;
+                               if (THREAD_WANTS_A_BREAK (thread))
+                                       mono_thread_interruption_checkpoint ();
                        }
+                       TP_DEBUG ("Done waiting");
+                       InterlockedDecrement (&tp->waiting);
+                       //FIXME: res == 0 on windows when interrupted!
+                       if (mono_runtime_is_shutting_down ())
+                               break;
+                       must_die = should_i_die (tp);
+                       dequeue_or_steal (tp, &data);
                }
-               idle_data.data = NULL;
 
                if (!data) {
-                       InterlockedDecrement (&async_tp.nthreads);
-                       CloseHandle (idle_data.wait_handle);
-                       idle_data.wait_handle = NULL;
-                       if (tp_finish_func)
-                               tp_finish_func (tp_hooks_user_data);
-                       return;
+                       gint nt;
+                       gboolean down;
+                       while (1) {
+                               nt = tp->nthreads;
+                               down = mono_runtime_is_shutting_down ();
+                               if (!down && nt <= tp->min_threads)
+                                       break;
+                               if (down || InterlockedCompareExchange (&tp->nthreads, nt - 1, nt) == nt) {
+                                       mono_perfcounter_update_value (tp->pc_nthreads, TRUE, -1);
+                                       TP_DEBUG ("DIE");
+                                       if (!tp->is_io) {
+                                               remove_wsq (wsq);
+                                               mono_wsq_destroy (wsq);
+                                       }
+                                       if (tp_finish_func)
+                                               tp_finish_func (tp_hooks_user_data);
+                                       return;
+                               }
+                       }
                }
                
-               InterlockedIncrement (&async_tp.busy_threads);
+               InterlockedIncrement (&tp->busy_threads);
        }
 
        g_assert_not_reached ();
@@ -1584,21 +1756,13 @@ async_invoke_thread (gpointer data)
 void
 ves_icall_System_Threading_ThreadPool_GetAvailableThreads (gint *workerThreads, gint *completionPortThreads)
 {
-       gint busy, busy_io;
-
-       MONO_ARCH_SAVE_REGS;
-
-       busy = (gint) InterlockedCompareExchange (&async_tp.busy_threads, 0, -1);
-       busy_io = (gint) InterlockedCompareExchange (&async_io_tp.busy_threads, 0, -1);
-       *workerThreads = async_tp.max_threads - busy;
-       *completionPortThreads = async_io_tp.max_threads - busy_io;
+       *workerThreads = 1024;//async_tp.max_threads - (gint) InterlockedCompareExchange (&async_tp.busy_threads, 0, -1);
+       *completionPortThreads = async_io_tp.max_threads - (gint) InterlockedCompareExchange (&async_io_tp.busy_threads, 0, -1);
 }
 
 void
 ves_icall_System_Threading_ThreadPool_GetMaxThreads (gint *workerThreads, gint *completionPortThreads)
 {
-       MONO_ARCH_SAVE_REGS;
-
        *workerThreads = (gint) InterlockedCompareExchange (&async_tp.max_threads, 0, -1);
        *completionPortThreads = (gint) InterlockedCompareExchange (&async_io_tp.max_threads, 0, -1);
 }
@@ -1606,30 +1770,15 @@ ves_icall_System_Threading_ThreadPool_GetMaxThreads (gint *workerThreads, gint *
 void
 ves_icall_System_Threading_ThreadPool_GetMinThreads (gint *workerThreads, gint *completionPortThreads)
 {
-       gint workers, workers_io;
-
-       MONO_ARCH_SAVE_REGS;
-
-       workers = (gint) InterlockedCompareExchange (&async_tp.min_threads, 0, -1);
-       workers_io = (gint) InterlockedCompareExchange (&async_io_tp.min_threads, 0, -1);
-
-       *workerThreads = workers;
-       *completionPortThreads = workers_io;
-}
-
-static void
-start_idle_threads (void)
-{
-       threadpool_start_idle_threads (&async_tp);
+       *workerThreads = (gint) InterlockedCompareExchange (&async_tp.min_threads, 0, -1);
+       *completionPortThreads = (gint) InterlockedCompareExchange (&async_io_tp.min_threads, 0, -1);
 }
 
 MonoBoolean
 ves_icall_System_Threading_ThreadPool_SetMinThreads (gint workerThreads, gint completionPortThreads)
 {
-       int max_threads;
-       int max_io_threads;
-
-       MONO_ARCH_SAVE_REGS;
+       gint max_threads;
+       gint max_io_threads;
 
        max_threads = InterlockedCompareExchange (&async_tp.max_threads, -1, -1);
        if (workerThreads <= 0 || workerThreads > max_threads)
@@ -1641,18 +1790,17 @@ ves_icall_System_Threading_ThreadPool_SetMinThreads (gint workerThreads, gint co
 
        InterlockedExchange (&async_tp.min_threads, workerThreads);
        InterlockedExchange (&async_io_tp.min_threads, completionPortThreads);
-       mono_thread_create_internal (mono_get_root_domain (), start_idle_threads, NULL, TRUE);
+       //FIXME: check the number of threads before starting this one
+       mono_thread_create_internal (mono_get_root_domain (), threadpool_start_idle_threads, &async_tp, TRUE);
        return TRUE;
 }
 
 MonoBoolean
 ves_icall_System_Threading_ThreadPool_SetMaxThreads (gint workerThreads, gint completionPortThreads)
 {
-       int min_threads;
-       int min_io_threads;
-       int cpu_count;
-
-       MONO_ARCH_SAVE_REGS;
+       gint min_threads;
+       gint min_io_threads;
+       gint cpu_count;
 
        cpu_count = mono_cpu_count ();
        min_threads = InterlockedCompareExchange (&async_tp.min_threads, -1, -1);
@@ -1704,4 +1852,3 @@ mono_install_threadpool_item_hooks (MonoThreadPoolItemFunc begin_func, MonoThrea
        tp_item_user_data = user_data;
 }
 
-
index edf35561ced26176a2a9ba65ac1938b7a20632a7..003ba6a124f5ea35b5809483a501394d971b4040 100644 (file)
@@ -7,6 +7,7 @@
 /* No managed code here */
 void mono_thread_pool_init (void) MONO_INTERNAL;
 
+void icall_append_job (MonoObject *ar) MONO_INTERNAL;
 MonoAsyncResult *
 mono_thread_pool_add     (MonoObject *target, MonoMethodMessage *msg, 
                          MonoDelegate *async_callback, MonoObject *state) MONO_INTERNAL;
index c00ac865c1cba72c8af50be97c78a23178319dc5..c1a625e394e1b4b250cf1ad27b7210169a809a2d 100644 (file)
@@ -223,4 +223,9 @@ void mono_thread_interruption_checkpoint (void) MONO_INTERNAL;
 void mono_thread_force_interruption_checkpoint (void) MONO_INTERNAL;
 gint32* mono_thread_interruption_request_flag (void) MONO_INTERNAL;
 
+uint32_t mono_alloc_special_static_data (uint32_t static_type, uint32_t size, uint32_t align, uintptr_t *bitmap, int max_set) MONO_INTERNAL;
+void*    mono_get_special_static_data   (uint32_t offset) MONO_INTERNAL;
+
+MonoException* mono_thread_resume_interruption (void) MONO_INTERNAL;
+
 #endif /* _MONO_METADATA_THREADS_TYPES_H_ */
index 94e92076f3f371605feb14334a6d261fc33610e2..59e029eac500453d989227c33d44d9683eeaf7cf 100644 (file)
@@ -165,6 +165,7 @@ static guint32 default_stacksize = 0;
 #define default_stacksize_for_thread(thread) ((thread)->stack_size? (thread)->stack_size: default_stacksize)
 
 static void thread_adjust_static_data (MonoInternalThread *thread);
+static void mono_free_static_data (gpointer* static_data, gboolean threadlocal);
 static void mono_init_static_data_info (StaticDataInfo *static_data);
 static guint32 mono_alloc_static_data_slot (StaticDataInfo *static_data, guint32 size, guint32 align);
 static gboolean mono_thread_resume (MonoInternalThread* thread);
@@ -561,7 +562,7 @@ static void thread_cleanup (MonoInternalThread *thread)
 
        thread->cached_culture_info = NULL;
 
-       mono_gc_free_fixed (thread->static_data);
+       mono_free_static_data (thread->static_data, TRUE);
        thread->static_data = NULL;
 
        /*
@@ -2321,28 +2322,26 @@ void
 ves_icall_System_Threading_Thread_ResetAbort (void)
 {
        MonoInternalThread *thread = mono_thread_internal_current ();
+       gboolean was_aborting;
 
        ensure_synch_cs_set (thread);
        
        EnterCriticalSection (thread->synch_cs);
-
+       was_aborting = thread->state & ThreadState_AbortRequested;
        thread->state &= ~ThreadState_AbortRequested;
-       
-       if (!thread->abort_exc) {
+       LeaveCriticalSection (thread->synch_cs);
+
+       if (!was_aborting) {
                const char *msg = "Unable to reset abort because no abort was requested";
-               LeaveCriticalSection (thread->synch_cs);
                mono_raise_exception (mono_get_exception_thread_state (msg));
-       } else {
-               thread->abort_exc = NULL;
-               if (thread->abort_state_handle) {
-                       mono_gchandle_free (thread->abort_state_handle);
-                       /* This is actually not necessary - the handle
-                          only counts if the exception is set */
-                       thread->abort_state_handle = 0;
-               }
        }
-       
-       LeaveCriticalSection (thread->synch_cs);
+       thread->abort_exc = NULL;
+       if (thread->abort_state_handle) {
+               mono_gchandle_free (thread->abort_state_handle);
+               /* This is actually not necessary - the handle
+                  only counts if the exception is set */
+               thread->abort_state_handle = 0;
+       }
 }
 
 void
@@ -3465,20 +3464,55 @@ static const int static_data_size [NUM_STATIC_DATA_IDX] = {
 };
 #endif
 
+static uintptr_t* static_reference_bitmaps [NUM_STATIC_DATA_IDX];
+
+#ifdef HAVE_SGEN_GC
+static void
+mark_tls_slots (void *addr, MonoGCCopyFunc mark_func)
+{
+       int i;
+       gpointer *static_data = addr;
+       for (i = 0; i < NUM_STATIC_DATA_IDX; ++i) {
+               int j, numwords;
+               void **ptr;
+               if (!static_data [i])
+                       continue;
+               numwords = 1 + static_data_size [i] / sizeof (gpointer) / (sizeof(uintptr_t) * 8);
+               ptr = static_data [i];
+               for (j = 0; j < numwords; ++j, ptr += sizeof (uintptr_t) * 8) {
+                       uintptr_t bmap = static_reference_bitmaps [i][j];
+                       void ** p = ptr;
+                       while (bmap) {
+                               if ((bmap & 1) && *p) {
+                                       *p = mark_func (*p);
+                               }
+                               p++;
+                               bmap >>= 1;
+                       }
+               }
+       }
+}
+#endif
+
 /*
  *  mono_alloc_static_data
  *
  *   Allocate memory blocks for storing threads or context static data
  */
 static void 
-mono_alloc_static_data (gpointer **static_data_ptr, guint32 offset)
+mono_alloc_static_data (gpointer **static_data_ptr, guint32 offset, gboolean threadlocal)
 {
        guint idx = (offset >> 24) - 1;
        int i;
 
        gpointer* static_data = *static_data_ptr;
        if (!static_data) {
-               static_data = mono_gc_alloc_fixed (static_data_size [0], NULL);
+               static void* tls_desc = NULL;
+#ifdef HAVE_SGEN_GC
+               if (!tls_desc)
+                       tls_desc = mono_gc_make_root_descr_user (mark_tls_slots);
+#endif
+               static_data = mono_gc_alloc_fixed (static_data_size [0], threadlocal?tls_desc:NULL);
                *static_data_ptr = static_data;
                static_data [0] = static_data;
        }
@@ -3486,10 +3520,33 @@ mono_alloc_static_data (gpointer **static_data_ptr, guint32 offset)
        for (i = 1; i <= idx; ++i) {
                if (static_data [i])
                        continue;
+#ifdef HAVE_SGEN_GC
+               static_data [i] = threadlocal?g_malloc0 (static_data_size [i]):mono_gc_alloc_fixed (static_data_size [i], NULL);
+#else
                static_data [i] = mono_gc_alloc_fixed (static_data_size [i], NULL);
+#endif
        }
 }
 
+static void 
+mono_free_static_data (gpointer* static_data, gboolean threadlocal)
+{
+       int i;
+       for (i = 1; i < NUM_STATIC_DATA_IDX; ++i) {
+               if (!static_data [i])
+                       continue;
+#ifdef HAVE_SGEN_GC
+               if (threadlocal)
+                       g_free (static_data [i]);
+               else
+                       mono_gc_free_fixed (static_data [i]);
+#else
+               mono_gc_free_fixed (static_data [i]);
+#endif
+       }
+       mono_gc_free_fixed (static_data);
+}
+
 /*
  *  mono_init_static_data_info
  *
@@ -3546,7 +3603,7 @@ thread_adjust_static_data (MonoInternalThread *thread)
        if (thread_static_info.offset || thread_static_info.idx > 0) {
                /* get the current allocated size */
                offset = thread_static_info.offset | ((thread_static_info.idx + 1) << 24);
-               mono_alloc_static_data (&(thread->static_data), offset);
+               mono_alloc_static_data (&(thread->static_data), offset, TRUE);
        }
        mono_threads_unlock ();
 }
@@ -3557,7 +3614,7 @@ alloc_thread_static_data_helper (gpointer key, gpointer value, gpointer user)
        MonoInternalThread *thread = value;
        guint32 offset = GPOINTER_TO_UINT (user);
 
-       mono_alloc_static_data (&(thread->static_data), offset);
+       mono_alloc_static_data (&(thread->static_data), offset, TRUE);
 }
 
 static MonoThreadDomainTls*
@@ -3578,6 +3635,39 @@ search_tls_slot_in_freelist (StaticDataInfo *static_data, guint32 size, guint32
        return NULL;
 }
 
+static void
+update_tls_reference_bitmap (guint32 offset, uintptr_t *bitmap, int max_set)
+{
+       int i;
+       int idx = (offset >> 24) - 1;
+       uintptr_t *rb;
+       if (!static_reference_bitmaps [idx])
+               static_reference_bitmaps [idx] = g_new0 (uintptr_t, 1 + static_data_size [idx] / sizeof(gpointer) / (sizeof(uintptr_t) * 8));
+       rb = static_reference_bitmaps [idx];
+       offset &= 0xffffff;
+       offset /= sizeof (gpointer);
+       /* offset is now the bitmap offset */
+       for (i = 0; i < max_set; ++i) {
+               if (bitmap [i / sizeof (uintptr_t)] & (1 << (i & (sizeof (uintptr_t) * 8 -1))))
+                       rb [(offset + i) / (sizeof (uintptr_t) * 8)] |= (1 << ((offset + i) & (sizeof (uintptr_t) * 8 -1)));
+       }
+}
+
+static void
+clear_reference_bitmap (guint32 offset, guint32 size)
+{
+       int idx = (offset >> 24) - 1;
+       uintptr_t *rb;
+       rb = static_reference_bitmaps [idx];
+       offset &= 0xffffff;
+       offset /= sizeof (gpointer);
+       size /= sizeof (gpointer);
+       size += offset;
+       /* offset is now the bitmap offset */
+       for (; offset < size; ++offset)
+               rb [offset / (sizeof (uintptr_t) * 8)] &= ~(1 << (offset & (sizeof (uintptr_t) * 8 -1)));
+}
+
 /*
  * The offset for a special static variable is composed of three parts:
  * a bit that indicates the type of static data (0:thread, 1:context),
@@ -3587,11 +3677,10 @@ search_tls_slot_in_freelist (StaticDataInfo *static_data, guint32 size, guint32
  */
 
 guint32
-mono_alloc_special_static_data (guint32 static_type, guint32 size, guint32 align)
+mono_alloc_special_static_data (guint32 static_type, guint32 size, guint32 align, uintptr_t *bitmap, int max_set)
 {
        guint32 offset;
-       if (static_type == SPECIAL_STATIC_THREAD)
-       {
+       if (static_type == SPECIAL_STATIC_THREAD) {
                MonoThreadDomainTls *item;
                mono_threads_lock ();
                item = search_tls_slot_in_freelist (&thread_static_info, size, align);
@@ -3602,13 +3691,12 @@ mono_alloc_special_static_data (guint32 static_type, guint32 size, guint32 align
                } else {
                        offset = mono_alloc_static_data_slot (&thread_static_info, size, align);
                }
+               update_tls_reference_bitmap (offset, bitmap, max_set);
                /* This can be called during startup */
                if (threads != NULL)
                        mono_g_hash_table_foreach (threads, alloc_thread_static_data_helper, GUINT_TO_POINTER (offset));
                mono_threads_unlock ();
-       }
-       else
-       {
+       } else {
                g_assert (static_type == SPECIAL_STATIC_CONTEXT);
                mono_contexts_lock ();
                offset = mono_alloc_static_data_slot (&context_static_info, size, align);
@@ -3638,7 +3726,7 @@ mono_get_special_static_data (guint32 offset)
                MonoAppContext *context = mono_context_get ();
                if (!context->static_data || !context->static_data [idx]) {
                        mono_contexts_lock ();
-                       mono_alloc_static_data (&(context->static_data), offset);
+                       mono_alloc_static_data (&(context->static_data), offset, FALSE);
                        mono_contexts_unlock ();
                }
                return ((char*) context->static_data [idx]) + (offset & 0xffffff);      
@@ -3679,6 +3767,7 @@ do_free_special (gpointer key, gpointer value, gpointer data)
                MonoThreadDomainTls *item = g_new0 (MonoThreadDomainTls, 1);
                data.offset = offset & 0x7fffffff;
                data.size = size;
+               clear_reference_bitmap (data.offset, data.size);
                if (threads != NULL)
                        mono_g_hash_table_foreach (threads, free_thread_static_data_helper, &data);
                item->offset = offset;
@@ -3913,6 +4002,37 @@ mono_thread_request_interruption (gboolean running_managed)
        }
 }
 
+/*This function should be called by a thread after it has exited all of
+ * its handle blocks at interruption time.*/
+MonoException*
+mono_thread_resume_interruption (void)
+{
+       MonoInternalThread *thread = mono_thread_internal_current ();
+       gboolean still_aborting;
+
+       /* The thread may already be stopping */
+       if (thread == NULL)
+               return NULL;
+
+       ensure_synch_cs_set (thread);
+       EnterCriticalSection (thread->synch_cs);
+       still_aborting = (thread->state & ThreadState_AbortRequested) != 0;
+       LeaveCriticalSection (thread->synch_cs);
+
+       /*This can happen if the protected block called Thread::ResetAbort*/
+       if (!still_aborting)
+               return FALSE;
+
+       if (InterlockedCompareExchange (&thread->interruption_requested, 1, 0) == 1)
+               return NULL;
+       InterlockedIncrement (&thread_interruption_requested);
+
+#ifndef HOST_WIN32
+       wapi_self_interrupt ();
+#endif
+       return mono_thread_execute_interruption (thread);
+}
+
 gboolean mono_thread_interruption_requested ()
 {
        if (thread_interruption_requested) {
index 41e97cef4dbe3cd0ebc7e8f7e613bdff93dd15fd..cd084ae50ce8e517ab39b61f586e3fc2d356c507 100644 (file)
@@ -46,8 +46,6 @@ void     mono_thread_set_manage_callback (MonoThread *thread, MonoThreadManageCa
 
 extern void mono_threads_set_default_stacksize (uint32_t stacksize);
 extern uint32_t mono_threads_get_default_stacksize (void);
-uint32_t  mono_alloc_special_static_data (uint32_t static_type, uint32_t size, uint32_t align);
-void* mono_get_special_static_data   (uint32_t offset);
 
 void mono_threads_request_thread_dump (void);
 
index 92c6c632f37d3dad201cbc851374248e6ccf6c51..979dc1771053f69fe04d4312318741402a585536 100644 (file)
@@ -3407,7 +3407,7 @@ do_invoke_method (VerifyContext *ctx, int method_token, gboolean virtual)
                copy.stype &= ~POINTER_MASK;
 
                if (virt_check_this && !stack_slot_is_this_pointer (value) && !(method->klass->valuetype || stack_slot_is_boxed_value (value)))
-                       CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Cannot call a non-final virtual method from an objet diferent thant the this pointer at 0x%04x", ctx->ip_offset));
+                       CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Cannot use the call opcode with a non-final virtual method on an object diferent thant the this pointer at 0x%04x", ctx->ip_offset));
 
                if (constrained && virtual) {
                        if (!stack_slot_is_managed_pointer (value))
index 35afd94cbbbf80b6769c3efa23b92d0785c94bff..19f7ff6f7990997711b638b1c9da4eaf9718a5e5 100755 (executable)
@@ -1,3 +1,270 @@
+2010-03-26  Andreas Faerber  <andreas.faerber@web.de>
+
+       * Makefile.am (version.h): Check for pure .git directory only,
+       fixes SVN revision when using git without git-svn.
+
+       Contributed under MIT/X11 license.
+
+2010-03-26  Zoltan Varga  <vargaz@gmail.com>
+
+       * aot-runtime.c: Apply some openbsd changes from openbsd ports.
+
+2010-03-24 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * basic-simd.cs: Test for vector x scalar binary operators.
+
+2010-03-24 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * simd-intrincs.c (simd_intrinsic_emit_binary): Support binary
+       intrinsics with expanded scalar arguments.
+
+2010-03-24 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * mini-exceptions.c (get_exception_catch_class): Non catch clauses
+       don't have an exception class, so don't decode it. This would crash
+       with filter clauses.
+
+2010-03-24  U-anarquia\miguel  <miguel@anarquia>
+
+       Make sure that trunk builds with DISABLE_JIT, an update to the
+       PlayStation 3 port.
+       
+       * mini.c (mini_get_shared_method): this code seems to be necessary
+       regardless of whether DISABLE_JIT has been defined.
+
+       (mono_jit_compile_method_inner): it seems that this method is
+       required even in full AOT mode, so ifdef out only the pieces that
+       try to genrate code (the body of code that applies patches to the
+       code).  
+
+       (mini_method_compile): do not compile when using DISABLE_JIT.
+
+       * mini-ppc.c (mono_arch_get_allocatable_int_vars)
+       (mono_arch_output_basic_block, mono-arch_emit_exceptions): Do not
+       compile when DISABLE_JIT is set.
+
+2010-03-24  Mark Probst  <mark.probst@gmail.com>
+
+       * mini.c (mono_create_tls_get): Only create a TLS operation if the
+       arch really supports it.
+
+2010-03-24  Mark Probst  <mark.probst@gmail.com>
+
+       * mini-x86.c, mini-x86.h, mini.c: CEE_MONO_TLS support for Darwin/x86.
+
+2010-03-23  Neale Ferguson <neale@sinenomine.net>
+
+       * exceptions-s390x.c: Add support for
+       mono_arch_get_throw_corlib_exception and fix throw by name.
+
+       * mini-s390x.c: Add IMT support; Fix stack parameter passing
+       logic (especially for varargs); Correct localloc sizing; Add
+       mono_arch_get_this_arg_from_call and
+       mono_arch_get_this_arg_from_call.
+
+       * mini-s390x.h: Add support for facility list extraction;
+       Correct/update MONO_ARCH_xxx settings.
+
+       * mini-s390.c: Minor corrections to instruction output for
+       varargs. No IMT implementation - I think it's time to deprecate
+       s390 and just leave s390x.
+
+       * tramp-s390x.c: Correct creation of trampoline instruction
+
+
+       * cpu-s390x.md: Update some instruction lengths
+
+2010-03-23  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini-generic-sharing.c (fill_in_rgctx_template_slot): Remove an assert which
+       can be hit with partial sharing.
+
+       * mini-generic-sharing.c (get_shared_class): Handle partially shared methods
+       in non-shared classes correctly.
+       (generic_inst_is_sharable): Allow all primitive types in partial sharing.
+       Turn on partial sharing.
+
+2010-03-23  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini-amd64.h: Put back MONO_ARCH_NOMAP32BIT for OpenBSD which was removed
+       by mistake.
+
+2010-03-23  Zoltan Varga  <vargaz@gmail.com>
+
+       * method-to-ir.c (mono_method_to_ir): Handle the failure of
+       mono_method_signature ().
+
+       * mini-trampolines.c (mono_delegate_trampoline): Ditto.
+
+       * mini.c (mini_method_compile): Get the signature of cfg->method early with
+       error checking, so later calls do not need error checking.
+
+2010-03-22  Zoltan Varga  <vargaz@gmail.com>
+
+       * exceptions-amd64.c: Add support for OpenBSD which has no UCONTEXT_GREGS.
+
+       * mini-amd64.h: Enable MONO_ARCH_USE_SIGACTION on OpenBSD as well.
+
+2010-03-22 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * mini-exceptions.c (mono_handle_exception_internal): Don't
+       check try_end for archs different than s390. 
+
+       * mini.c (create_jit_info): Don't crash if the finallt block is the
+       last one.
+
+2010-03-22 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * driver.c (mono_main): Don't free global codeman under linux since
+       glic now peeks at code on stack for more archs than just amd64.
+
+Mon Mar 22 18:09:09 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * mini.c, method-to-ir.c: changes to support compressed interface
+       bitmaps.
+
+2010-03-22  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini-x86.h: Applied patch from Robert Nagy (Robert@openbsd.org).
+       Use sigaction on OpenBSD too.
+
+2010-03-22  Zoltan Varga  <vargaz@gmail.com>
+
+       * debugger-agent.c (event_req_matches_assembly): Handle request modifiers too.
+
+2010-03-21  Andreas Faerber  <andreas.faerber@web.de>
+
+       * debugger-agent.c: #include sys/select.h for fd_set.
+
+       Code is contributed under MIT/X11 license.
+
+2010-03-21  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini.c (SIG_HANDLER_SIGNATURE): Fix the build on platforms without sigaction
+       (openbsd+amd64 ?).
+
+2010-03-21  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini-ppc.c (mono_arch_emit_exceptions): Avoid an assert in ppc_patch () for
+       some large methods with lots of exception handlers. Fixes #440924.
+
+Sat Mar 20 11:56:24 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * method-to-ir.c: remove code duplication for interface checks.
+
+2010-03-19  Zoltan Varga  <vargaz@gmail.com>
+
+       * debugger-agent.c (clear_event_requests_for_assembly): New helper function.
+       (assembly_unload): Clear all event requests referencing the to-be unloaded
+       assembly.
+
+
+Fri Mar 19 16:45:20 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * mini.h, mini-exceptions.c: restore the state of the stack
+       guard page permissions.
+
+2010-03-19  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini-trampolines.c (common_call_trampoline): Remove the condition guarding the
+       call site patching code, it doesn't appear to be needed.
+
+2010-03-19  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini-generic-sharing.c: Add infrastructure for partial sharing, ie.
+       sharing generic methods whose type arguments are a mix of reference and
+       non-reference types. Not yet turned on.
+
+       * mini.c (mini_get_shared_method): New helper function to return
+       the method which will be compiled/registered in the JIT tables when doing
+       generic sharing.
+       (mono_domain_lookup_shared_generic): Moved to mini.c from mini-generic-sharing.c,
+       use mini_get_shared_method ().
+
+       * mini.c (mini_method_compile): Register the same method which is compiled when
+       doing generic sharing.
+
+       * mini.c aot-compiler.c aot-runtime.c: Add support for partial sharing.
+
+       * generics.cs: Add partial sharing tests.
+
+2010-03-17 Jerry Maine  <crashfourit@gmail.com>
+
+       * mini.h : Changed the SIMD_VERSION* enum values to match those in Mono.Simd.AccelMode.
+                  Add an enum value that or's all possable values together. Add an enum value
+                  that marks the end of the used bit indexes.
+
+       * mini-amd64.c : Make changes to match the changes in mini.h 
+
+       * mini-x86.c : Make changes to match the changes in mini.h
+
+       * simd-intrinsics.c : Reorder the SimdIntrinsc struct to add more bits to
+                  simd_version to support more simd versions. Changed the name of
+                  simd_version to simd_version_flags to make it more intuitive that
+                  it now contains bit flags. Reordered the *_intrinsics arrays to
+                  match the changes above. Changed emit_intrinsics() to use the new
+                  setup mentioned above.
+
+       Code is contributed under MIT/X11 license.
+
+2010-03-17 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * mini-*.c (mono_arch_output_basic_block): Record try block holes on all
+       remaining archs. Alpha and hppa maintainers, please stand up.
+
+2010-03-17  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini-ppc.c (mono_arch_build_imt_thunk): Always save and restore r11 since it
+       is needed even when fail_tramp!=NULL.
+
+2010-03-17  Zoltan Varga  <vargaz@gmail.com>
+
+       * debugger-agent.c (insert_breakpoint): Write a log message.
+
+2010-03-16 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * iltests.il.in: Add a few tests for LEAVE going over multiple
+       finally clauses.
+
+2010-03-16 Rodrigo Kumpera  <rkumpera@novell.com>
+
+        * mini-x86.c (mono_arch_output_basic_block): Record try block holes.
+
+2010-03-16 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * mini.h (MonoBasicBlock): Add native_length field.
+       * mini.h (MonoCompile): Add try_block_holes field.
+       * mini.h (MonoInst): Add exception_clause pointer to
+       the data union.
+
+       * mini.c (mono_codegen): Calculate MonoBasicBlock::native_length.
+       * mini.c (mono_cfg_add_try_hole): New function to register possible
+       holes in try blocks.
+       * mini.c (create_jit_info): Fill in the holes information.
+
+       * mini-exceptions.c: Verify for holes when checking if an IP is covered
+       by a try block.
+
+       * method-to-ir.c: Add the EH clause to the CALL_HANDLE instruction.
+
+Tue Mar 16 13:16:16 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * jit-icalls.c: adjusted for the array API changes.
+
+2010-03-16  Zoltan Varga  <vargaz@gmail.com>
+
+       * iltests.il.in: Disable the fconv_to_i test on sparc too.
+
+2010-03-16  Zoltan Varga  <vargaz@gmail.com>
+
+       * debugger-agent.c: Simplify the way breakpoints are processed by removing
+       the 'pending' flag. This fixes support for appdomains too.
+
+
+Mon Mar 15 18:25:49 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * mini-amd64.c, mini-ia64.c: remove direct access to method->header.
+
 2010-03-12  Zoltan Varga  <vargaz@gmail.com>
 
        * simd-intrinsics.c (simd_intrinsic_emit_getter): Don't emit shuffle opcodes
index 4fe7052d646598acd68ea5513fc55231baf1da1e..093077b1f5674079af14af1524c2836876d763e0 100644 (file)
@@ -586,7 +586,7 @@ EXTRA_DIST = $(common_BURGSRC) TestDriver.cs ldscript ldscript.mono \
        $(posix_sources)
 
 version.h: Makefile
-       if test -d $(top_srcdir)/.git/svn; then svn_info="git log --no-color --first-parent -n1 --grep=git-svn-id: --pretty=format:%b | sed -n -e 's,git-svn-id: \(.*\)@\(.*\) .*,URL: \1 Revision: \2,p'"; fi; \
+       if test -d $(top_srcdir)/.git; then svn_info="git log --no-color --first-parent -n1 --grep=git-svn-id: --pretty=format:%b | sed -n -e 's,git-svn-id: \(.*\)@\(.*\) .*,URL: \1 Revision: \2,p'"; fi; \
        if test -d $(srcdir)/.svn; then svn_info='svn info'; fi; \
        if test -n "$$svn_info"; then \
                (cd $(top_srcdir); \
index a9b498587db92adc85b5a21c8f405ece09ceecf0..0afd5ba593f32b784d7f93d424757d18e01bd034 100644 (file)
@@ -2360,7 +2360,7 @@ add_generic_class (MonoAotCompile *acfg, MonoClass *klass)
 
        iter = NULL;
        while ((method = mono_class_get_methods (klass, &iter))) {
-               if (mono_method_is_generic_sharable_impl (method, FALSE))
+               if (mono_method_is_generic_sharable_impl_full (method, FALSE, FALSE))
                        /* Already added */
                        continue;
 
@@ -2481,18 +2481,98 @@ add_generic_instances (MonoAotCompile *acfg)
                token = MONO_TOKEN_METHOD_SPEC | (i + 1);
                method = mono_get_method (acfg->image, token, NULL);
 
-               context = mono_method_get_context (method);
-               if (context && ((context->class_inst && context->class_inst->is_open) ||
-                                               (context->method_inst && context->method_inst->is_open)))
+               if (method->klass->image != acfg->image)
                        continue;
 
-               if (method->klass->image != acfg->image)
+               context = mono_method_get_context (method);
+
+               if (context && ((context->class_inst && context->class_inst->is_open)))
                        continue;
 
-               if (mono_method_is_generic_sharable_impl (method, FALSE))
-                       /* Already added */
+               /*
+                * For open methods, create an instantiation which can be passed to the JIT.
+                * FIXME: Handle class_inst as well.
+                */
+               if (context && context->method_inst && context->method_inst->is_open) {
+                       MonoGenericContext shared_context;
+                       MonoGenericInst *inst;
+                       MonoType **type_argv;
+                       int i;
+                       MonoMethod *declaring_method;
+                       gboolean supported = TRUE;
+
+                       /* Check that the context doesn't contain open constructed types */
+                       if (context->class_inst) {
+                               inst = context->class_inst;
+                               for (i = 0; i < inst->type_argc; ++i) {
+                                       if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
+                                               continue;
+                                       if (mono_class_is_open_constructed_type (inst->type_argv [i]))
+                                               supported = FALSE;
+                               }
+                       }
+                       if (context->method_inst) {
+                               inst = context->method_inst;
+                               for (i = 0; i < inst->type_argc; ++i) {
+                                       if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
+                                               continue;
+                                       if (mono_class_is_open_constructed_type (inst->type_argv [i]))
+                                               supported = FALSE;
+                               }
+                       }
+
+                       if (!supported)
+                               continue;
+
+                       memset (&shared_context, 0, sizeof (MonoGenericContext));
+
+                       inst = context->class_inst;
+                       if (inst) {
+                               type_argv = g_new0 (MonoType*, inst->type_argc);
+                               for (i = 0; i < inst->type_argc; ++i) {
+                                       if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
+                                               type_argv [i] = &mono_defaults.object_class->byval_arg;
+                                       else
+                                               type_argv [i] = inst->type_argv [i];
+                               }
+                               
+                               shared_context.class_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv);
+                               g_free (type_argv);
+                       }
+
+                       inst = context->method_inst;
+                       if (inst) {
+                               type_argv = g_new0 (MonoType*, inst->type_argc);
+                               for (i = 0; i < inst->type_argc; ++i) {
+                                       if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
+                                               type_argv [i] = &mono_defaults.object_class->byval_arg;
+                                       else
+                                               type_argv [i] = inst->type_argv [i];
+                               }
+
+                               shared_context.method_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv);
+                               g_free (type_argv);
+                       }
+
+                       if (method->is_generic || method->klass->generic_container)
+                               declaring_method = method;
+                       else
+                               declaring_method = mono_method_get_declaring_generic_method (method);
+
+                       method = mono_class_inflate_generic_method (declaring_method, &shared_context);
+               }
+
+               /* 
+                * If the method is fully sharable, it was already added in place of its
+                * generic definition.
+                */
+               if (mono_method_is_generic_sharable_impl_full (method, FALSE, FALSE))
                        continue;
 
+               /*
+                * FIXME: Partially shared methods are not shared here, so we end up with
+                * many identical methods.
+                */
                add_extra_method (acfg, method);
        }
 
@@ -4821,6 +4901,8 @@ emit_extra_methods (MonoAotCompile *acfg)
 
                nmethods ++;
 
+               method = cfg->method_to_register;
+
                name = NULL;
                if (method->wrapper_type) {
                        /* 
index 31900e6b9b4125eebdd9c8fa3fba73649ce1004a..327ec8c3c8f700278c4cfd41c942f2c341303be5 100644 (file)
@@ -953,7 +953,7 @@ find_symbol (MonoDl *module, gpointer *globals, const char *name, gpointer *valu
 #define SHT_ARM_EXIDX 0x70000001
 #endif
 
-#ifdef HAVE_DL_ITERATE_PHDR
+#if defined(HAVE_DL_ITERATE_PHDR) && defined(PT_GNU_EH_FRAME)
 static int
 dl_callback (struct dl_phdr_info *info, size_t size, void *data)
 {
@@ -1208,7 +1208,7 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
 
        assembly->image->aot_module = amodule;
  
-#ifdef HAVE_DL_ITERATE_PHDR
+#if defined(HAVE_DL_ITERATE_PHDR) && defined(PT_GNU_EH_FRAME)
        /* Lookup the address of the .eh_frame_hdr () section if available */
        dl_iterate_phdr (dl_callback, amodule);
 #endif 
@@ -2948,7 +2948,11 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
        g_assert (klass->inited);
 
        /* Find method index */
-       if (method->is_inflated && mono_method_is_generic_sharable_impl (method, FALSE)) {
+       if (method->is_inflated && mono_method_is_generic_sharable_impl_full (method, FALSE, FALSE)) {
+               /* 
+                * For generic methods, we store the fully shared instance in place of the
+                * original method.
+                */
                method = mono_method_get_declaring_generic_method (method);
                method_index = mono_metadata_token_index (method->token) - 1;
        } else if (method->is_inflated || !method->token) {
@@ -3012,6 +3016,11 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
                                return code;
                }
 
+               if (method_index == 0xffffff && method->is_inflated && mono_method_is_generic_sharable_impl_full (method, FALSE, TRUE)) {
+                       /* Partial sharing */
+                       method_index = find_extra_method (mini_get_shared_method (method), &amodule);
+               }
+
                if (method_index == 0xffffff) {
                        if (mono_aot_only && mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT)) {
                                char *full_name;
index f03c47ef4507f16b128c03d8f64bce4a2b8a8129..9784983e184f245f97c1b7d63edc0ca6b9ba4fcc 100644 (file)
@@ -3122,6 +3122,20 @@ public class SimdTests {
                return 0;
        }
 
+
+       public static int test_0_scala_vector4f_mul () {
+               Vector4f a = new Vector4f (1, 2, 3, 4);
+               Vector4f b = 2 * a;
+               Vector4f c = a * 3;
+
+               if (b.X != 2f || b.Y != 4f || b.Z != 6f || b.W != 8f )
+                       return 1;
+               if (c.X != 3f || c.Y != 6f || c.Z != 9f || c.W != 12f )
+                       return 1;
+
+               return 0;
+       }
+
        public static int Main (String[] args) {
                return TestDriver.RunTests (typeof (SimdTests), args);
        }
index 8f8a5078da00a13cb07c5415b7d0b27cf25f6500..d0de41a208cc0a2293c32b9a2e7af256411dafb3 100644 (file)
@@ -92,7 +92,7 @@ cond_exc_no: len:8
 cond_exc_ov: len:8
 div_imm: dest:i src1:i src2:i len:24
 div_un_imm: dest:i src1:i src2:i len:24
-endfinally: len:28
+endfinally: len:8
 fcall: dest:g len:26 clob:c
 fcall_membase: dest:g src1:b len:14 clob:c
 fcall_reg: dest:g src1:i len:10 clob:c
@@ -262,7 +262,7 @@ int_shr_un: dest:i src1:i src2:i clob:s len:12
 int_shr_un_imm: dest:i src1:i len:10
 int_subcc: dest:i src1:i src2:i len:12
 int_sub: dest:i src1:i src2:i len:12
-int_sub_imm: dest:i src1:i len:18
+int_sub_imm: dest:i src1:i len:20
 int_xor: dest:i src1:i src2:i len:12
 int_xor_imm: dest:i src1:i len:24
 int_conv_to_r4: dest:f src1:i len:16
index 1ca3f469918abe0aaac12317cf989a361c0ccb6a..58e426a969ba649a86b866f5651c0539aa387be2 100644 (file)
@@ -14,6 +14,9 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
@@ -597,6 +600,8 @@ static void stop_single_stepping (void);
 
 static void suspend_current (void);
 
+static void clear_event_requests_for_assembly (MonoAssembly *assembly);
+
 /* Submodule init/cleanup */
 static void breakpoints_init (void);
 static void breakpoints_cleanup (void);
@@ -2413,7 +2418,7 @@ process_frame (StackFrameInfo *info, MonoContext *ctx, gpointer user_data)
                info->il_offset = mono_debug_il_offset_from_address (method, info->domain, info->native_offset);
        }
 
-       DEBUG (1, fprintf (stderr, "\tFrame: %s %d %d %d\n", mono_method_full_name (method, TRUE), info->native_offset, info->il_offset, info->managed));
+       DEBUG (1, fprintf (log_file, "\tFrame: %s %d %d %d\n", mono_method_full_name (method, TRUE), info->native_offset, info->il_offset, info->managed));
 
        if (!info->managed && method->wrapper_type != MONO_WRAPPER_DYNAMIC_METHOD) {
                /*
@@ -2911,6 +2916,8 @@ static void
 assembly_unload (MonoProfiler *prof, MonoAssembly *assembly)
 {
        process_profiler_event (EVENT_KIND_ASSEMBLY_UNLOAD, assembly);
+
+       clear_event_requests_for_assembly (assembly);
 }
 
 static void
@@ -3018,7 +3025,6 @@ jit_end (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo, int result)
 typedef struct {
        long il_offset, native_offset;
        guint8 *ip;
-       gboolean pending, entry;
        MonoJitInfo *ji;
 } BreakpointInstance;
 
@@ -3034,7 +3040,6 @@ typedef struct {
         */
        MonoMethod *method;
        long il_offset;
-       gboolean pending, entry;
        EventRequest *req;
        /* 
         * A list of BreakpointInstance structures describing where the breakpoint
@@ -3118,6 +3123,8 @@ insert_breakpoint (MonoSeqPointInfo *seq_points, MonoJitInfo *ji, MonoBreakpoint
                NOT_IMPLEMENTED;
 #endif
        }
+
+       DEBUG(1, fprintf (log_file, "[dbg] Inserted breakpoint at %s:0x%x.\n", mono_method_full_name (ji->method, TRUE), (int)il_offset));      
 }
 
 static void
@@ -3143,6 +3150,12 @@ remove_breakpoint (BreakpointInstance *inst)
 #endif
 }      
 
+static inline gboolean
+bp_matches_method (MonoBreakpoint *bp, MonoMethod *method)
+{
+       return (!bp->method || method == bp->method || (method->is_inflated && ((MonoMethodInflated*)method)->declaring == bp->method));
+}
+
 /*
  * add_pending_breakpoints:
  *
@@ -3151,7 +3164,7 @@ remove_breakpoint (BreakpointInstance *inst)
 static void
 add_pending_breakpoints (MonoMethod *method, MonoJitInfo *ji)
 {
-       int i;
+       int i, j;
        MonoSeqPointInfo *seq_points;
        MonoDomain *domain;
 
@@ -3164,8 +3177,19 @@ add_pending_breakpoints (MonoMethod *method, MonoJitInfo *ji)
 
        for (i = 0; i < breakpoints->len; ++i) {
                MonoBreakpoint *bp = g_ptr_array_index (breakpoints, i);
+               gboolean found = FALSE;
+
+               if (!bp_matches_method (bp, method))
+                       continue;
 
-               if (bp->pending && (bp->method == method || !bp->method || (method->is_inflated && ((MonoMethodInflated*)method)->declaring == bp->method))) {
+               for (j = 0; j < bp->children->len; ++j) {
+                       BreakpointInstance *inst = g_ptr_array_index (bp->children, j);
+
+                       if (inst->ji == ji)
+                               found = TRUE;
+               }
+
+               if (!found) {
                        mono_domain_lock (domain);
                        seq_points = g_hash_table_lookup (domain_jit_info (domain)->seq_points, ji->method);
                        mono_domain_unlock (domain);
@@ -3208,15 +3232,8 @@ set_bp_in_method_cb (gpointer key, gpointer value, gpointer user_data)
        MonoBreakpoint *bp = user_data;
        MonoDomain *domain = mono_domain_get ();
 
-       if (bp->method) {
-               if (method->is_inflated && ((MonoMethodInflated*)method)->declaring == bp->method) {
-                       /* Generic instance */
-                       set_bp_in_method (domain, method, seq_points, bp);
-               }
-       } else {
-               /* Method entry/exit */
+       if (bp_matches_method (bp, method))
                set_bp_in_method (domain, method, seq_points, bp);
-       }
 }
 
 /*
@@ -3230,13 +3247,11 @@ set_bp_in_method_cb (gpointer key, gpointer value, gpointer user_data)
 static MonoBreakpoint*
 set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req)
 {
-       MonoSeqPointInfo *seq_points;
        MonoDomain *domain;
        MonoBreakpoint *bp;
 
        // FIXME: 
        // - suspend/resume the vm to prevent code patching problems
-       // - appdomains
        // - multiple breakpoints on the same location
        // - dynamic methods
        // - races
@@ -3251,22 +3266,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req)
 
        domain = mono_domain_get ();
        mono_domain_lock (domain);
-       if (method) {
-               seq_points = g_hash_table_lookup (domain_jit_info (domain)->seq_points, method);
-               if (seq_points) {
-                       set_bp_in_method (domain, method, seq_points, bp);
-               } else {
-                       if (method->is_generic)
-                               /* There might be already JITted instances */
-                               g_hash_table_foreach (domain_jit_info (domain)->seq_points, set_bp_in_method_cb, bp);
-
-                       /* Not yet JITted */
-                       bp->pending = TRUE;
-               }
-       } else {
-               g_hash_table_foreach (domain_jit_info (domain)->seq_points, set_bp_in_method_cb, bp);
-               bp->pending = TRUE;
-       }
+       g_hash_table_foreach (domain_jit_info (domain)->seq_points, set_bp_in_method_cb, bp);
        mono_domain_unlock (domain);
 
        mono_loader_lock ();
@@ -3298,6 +3298,12 @@ clear_breakpoint (MonoBreakpoint *bp)
        g_free (bp);
 }
 
+static gboolean
+breakpoint_matches_assembly (MonoBreakpoint *bp, MonoAssembly *assembly)
+{
+       return bp->method && bp->method->klass->image->assembly == assembly;
+}
+
 static void
 process_breakpoint_inner (DebuggerTlsData *tls, MonoContext *ctx)
 {
@@ -4401,6 +4407,58 @@ clear_event_request (int req_id, int etype)
        mono_loader_unlock ();
 }
 
+static gboolean
+event_req_matches_assembly (EventRequest *req, MonoAssembly *assembly)
+{
+       if (req->event_kind == EVENT_KIND_BREAKPOINT)
+               return breakpoint_matches_assembly (req->info, assembly);
+       else {
+               int i, j;
+
+               for (i = 0; i < req->nmodifiers; ++i) {
+                       Modifier *m = &req->modifiers [i];
+
+                       if (m->kind == MOD_KIND_EXCEPTION_ONLY && m->data.exc_class && m->data.exc_class->image->assembly == assembly)
+                               return TRUE;
+                       if (m->kind == MOD_KIND_ASSEMBLY_ONLY && m->data.assemblies) {
+                               for (j = 0; m->data.assemblies [j]; ++j)
+                                       if (m->data.assemblies [j] == assembly)
+                                               return TRUE;
+                       }
+               }
+       }
+
+       return FALSE;
+}
+
+/*
+ * clear_event_requests_for_assembly:
+ *
+ *   Clear all events requests which reference ASSEMBLY.
+ */
+static void
+clear_event_requests_for_assembly (MonoAssembly *assembly)
+{
+       int i;
+       gboolean found;
+
+       mono_loader_lock ();
+       found = TRUE;
+       while (found) {
+               found = FALSE;
+               for (i = 0; i < event_requests->len; ++i) {
+                       EventRequest *req = g_ptr_array_index (event_requests, i);
+
+                       if (event_req_matches_assembly (req, assembly)) {
+                               clear_event_request (req->id, req->event_kind);
+                               found = TRUE;
+                               break;
+                       }
+               }
+       }
+       mono_loader_unlock ();
+}
+
 static void
 add_thread (gpointer key, gpointer value, gpointer user_data)
 {
index 3607a96baa9e1af401ca4e8c3188221b0f109c56..b5581274a4cee1fa7696c5cbbdf572b6daae5c38 100644 (file)
@@ -1770,6 +1770,7 @@ mono_main (int argc, char* argv[])
         * shut down), it will crash:
         * http://mail-archives.apache.org/mod_mbox/harmony-dev/200801.mbox/%3C200801130327.41572.gshimansky@apache.org%3E
         * Testcase: tests/main-exit-background-change.exe.
+        * Testcase: test/main-returns-background-abort-resetabort.exe.
         * To make this race less frequent, we avoid freeing the global code manager.
         * Since mono_main () is hopefully only used by the runtime executable, this 
         * will only cause a shutdown leak. This workaround also has the advantage
@@ -1777,8 +1778,11 @@ mono_main (int argc, char* argv[])
         * FIXME: Fix this properly by waiting for threads to really exit using 
         * pthread_join (). This cannot be done currently as the io-layer calls
         * pthread_detach ().
+        *
+        * This used to be an amd64 only crash, but it looks like now most glibc targets do unwinding
+        * that requires reading the target code.
         */
-#ifdef __x86_64__
+#ifdef __linux__
                mono_dont_free_global_codeman = TRUE;
 #endif
 
index fede465efb2c046cb00cd790f70f469c02e09e8e..7ab4d62976dfa514b8a3756e945be6b1127a62c1 100644 (file)
@@ -698,7 +698,7 @@ mono_arch_handle_exception (void *sigctx, gpointer obj, gboolean test_only)
        return TRUE;
 }
 
-#ifdef MONO_ARCH_USE_SIGACTION
+#if defined(MONO_ARCH_USE_SIGACTION) && defined(UCONTEXT_GREGS)
 static inline guint64*
 gregs_from_ucontext (ucontext_t *ctx)
 {
@@ -708,7 +708,7 @@ gregs_from_ucontext (ucontext_t *ctx)
 void
 mono_arch_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
 {
-#ifdef MONO_ARCH_USE_SIGACTION
+#if defined(MONO_ARCH_USE_SIGACTION) && defined(UCONTEXT_GREGS)
        ucontext_t *ctx = (ucontext_t*)sigctx;
 
     guint64 *gregs = gregs_from_ucontext (ctx);
@@ -726,6 +726,22 @@ mono_arch_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
        mctx->r13 = gregs [REG_R13];
        mctx->r14 = gregs [REG_R14];
        mctx->r15 = gregs [REG_R15];
+#elif defined(MONO_ARCH_USE_SIGACTION)
+       ucontext_t *ctx = (ucontext_t*)sigctx;
+
+       mctx->rax = UCONTEXT_REG_RAX (ctx);
+       mctx->rbx = UCONTEXT_REG_RBX (ctx);
+       mctx->rcx = UCONTEXT_REG_RCX (ctx);
+       mctx->rdx = UCONTEXT_REG_RDX (ctx);
+       mctx->rbp = UCONTEXT_REG_RBP (ctx);
+       mctx->rsp = UCONTEXT_REG_RSP (ctx);
+       mctx->rsi = UCONTEXT_REG_RSI (ctx);
+       mctx->rdi = UCONTEXT_REG_RDI (ctx);
+       mctx->rip = UCONTEXT_REG_RIP (ctx);
+       mctx->r12 = UCONTEXT_REG_R12 (ctx);
+       mctx->r13 = UCONTEXT_REG_R13 (ctx);
+       mctx->r14 = UCONTEXT_REG_R14 (ctx);
+       mctx->r15 = UCONTEXT_REG_R15 (ctx);
 #else
        MonoContext *ctx = (MonoContext *)sigctx;
 
@@ -748,7 +764,7 @@ mono_arch_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
 void
 mono_arch_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
 {
-#ifdef MONO_ARCH_USE_SIGACTION
+#if defined(MONO_ARCH_USE_SIGACTION) && defined(UCONTEXT_GREGS)
        ucontext_t *ctx = (ucontext_t*)sigctx;
 
     guint64 *gregs = gregs_from_ucontext (ctx);
@@ -766,6 +782,22 @@ mono_arch_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
        gregs [REG_R13] = mctx->r13;
        gregs [REG_R14] = mctx->r14;
        gregs [REG_R15] = mctx->r15;
+#elif defined(MONO_ARCH_USE_SIGACTION)
+       ucontext_t *ctx = (ucontext_t*)sigctx;
+
+       UCONTEXT_REG_RAX (ctx) = mctx->rax;
+       UCONTEXT_REG_RBX (ctx) = mctx->rbx;
+       UCONTEXT_REG_RCX (ctx) = mctx->rcx;
+       UCONTEXT_REG_RDX (ctx) = mctx->rdx;
+       UCONTEXT_REG_RBP (ctx) = mctx->rbp;
+       UCONTEXT_REG_RSP (ctx) = mctx->rsp;
+       UCONTEXT_REG_RSI (ctx) = mctx->rsi;
+       UCONTEXT_REG_RDI (ctx) = mctx->rdi;
+       UCONTEXT_REG_RIP (ctx) = mctx->rip;
+       UCONTEXT_REG_R12 (ctx) = mctx->r12;
+       UCONTEXT_REG_R13 (ctx) = mctx->r13;
+       UCONTEXT_REG_R14 (ctx) = mctx->r14;
+       UCONTEXT_REG_R15 (ctx) = mctx->r15;
 #else
        MonoContext *ctx = (MonoContext *)sigctx;
 
@@ -788,14 +820,16 @@ mono_arch_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
 gpointer
 mono_arch_ip_from_context (void *sigctx)
 {
-       
-#ifdef MONO_ARCH_USE_SIGACTION
-
+#if defined(MONO_ARCH_USE_SIGACTION) && defined(UCONTEXT_GREGS)
        ucontext_t *ctx = (ucontext_t*)sigctx;
 
     guint64 *gregs = gregs_from_ucontext (ctx);
 
        return (gpointer)gregs [REG_RIP];
+#elif defined(MONO_ARCH_USE_SIGACTION)
+       ucontext_t *ctx = (ucontext_t*)sigctx;
+
+       return (gpointer)UCONTEXT_REG_RIP (ctx);
 #else
        MonoContext *ctx = sigctx;
        return (gpointer)ctx->rip;
@@ -852,7 +886,7 @@ altstack_handle_and_restore (void *sigctx, gpointer obj, gboolean stack_ovf)
 void
 mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, gboolean stack_ovf)
 {
-#ifdef MONO_ARCH_USE_SIGACTION
+#if defined(MONO_ARCH_USE_SIGACTION) && defined(UCONTEXT_GREGS)
        MonoException *exc = NULL;
        ucontext_t *ctx = (ucontext_t*)sigctx;
        guint64 *gregs = gregs_from_ucontext (ctx);
index 91d7859f5795e203ccc0e5177091213d8f0437a9..abb48d2a0516ca70fe6382fcc59a9614d7ba8bdc 100644 (file)
@@ -27,7 +27,7 @@
 
 #define S390_THROWSTACK_ACCPRM         S390_MINIMAL_STACK_SIZE
 #define S390_THROWSTACK_FPCPRM         (S390_THROWSTACK_ACCPRM+sizeof(gpointer))
-#define S390_THROWSTACK_RETHROW                (S390_THROWSTACK_FPCPRM+sizeof(gint32))
+#define S390_THROWSTACK_RETHROW                (S390_THROWSTACK_FPCPRM+sizeof(gulong))
 #define S390_THROWSTACK_INTREGS                (S390_THROWSTACK_RETHROW+sizeof(gboolean))
 #define S390_THROWSTACK_FLTREGS                (S390_THROWSTACK_INTREGS+(16*sizeof(gulong)))
 #define S390_THROWSTACK_ACCREGS                (S390_THROWSTACK_FLTREGS+(16*sizeof(gdouble)))
@@ -74,6 +74,12 @@ gboolean mono_arch_handle_exception (void     *ctx,
 /*                 G l o b a l   V a r i a b l e s                  */
 /*------------------------------------------------------------------*/
 
+typedef enum {
+       by_none,
+       by_name,
+       by_token
+} throwType;
+
 /*====================== End of Global Variables ===================*/
 
 /*------------------------------------------------------------------*/
@@ -128,21 +134,21 @@ mono_arch_get_call_filter (void)
        /*------------------------------------------------------*/
        /* save general registers on stack                      */
        /*------------------------------------------------------*/
-       s390_stmg (code, s390_r0, s390_r13, STK_BASE, S390_CALLFILTER_INTREGS);
+       s390_stmg (code, s390_r0, STK_BASE, STK_BASE, S390_CALLFILTER_INTREGS);
 
        /*------------------------------------------------------*/
        /* save floating point registers on stack               */
        /*------------------------------------------------------*/
-//     pos = S390_CALLFILTER_FLTREGS;
-//     for (i = 0; i < 16; ++i) {
-//             s390_std (code, i, 0, STK_BASE, pos);
-//             pos += sizeof (gdouble);
-//     }
+       pos = S390_CALLFILTER_FLTREGS;
+       for (i = 0; i < 16; ++i) {
+               s390_std (code, i, 0, STK_BASE, pos);
+               pos += sizeof (gdouble);
+       }
 
        /*------------------------------------------------------*/
        /* save access registers on stack                       */
        /*------------------------------------------------------*/
-//     s390_stam (code, s390_a0, s390_a15, STK_BASE, S390_CALLFILTER_ACCREGS);
+       s390_stam (code, s390_a0, s390_a15, STK_BASE, S390_CALLFILTER_ACCREGS);
 
        /*------------------------------------------------------*/
        /* Get A(Context)                                       */
@@ -171,7 +177,7 @@ mono_arch_get_call_filter (void)
        }
        
        /*------------------------------------------------------*/
-       /* Point at the copied stack frame and call the filter  */
+       /* Go call filter                                       */
        /*------------------------------------------------------*/
        s390_lgr  (code, s390_r1, s390_r0);
        s390_basr (code, s390_r14, s390_r1);
@@ -185,14 +191,14 @@ mono_arch_get_call_filter (void)
        /* Restore all the regs from the stack                  */
        /*------------------------------------------------------*/
        s390_lmg  (code, s390_r0, s390_r13, STK_BASE, S390_CALLFILTER_INTREGS);
-//     pos = S390_CALLFILTER_FLTREGS;
-//     for (i = 0; i < 16; ++i) {
-//             s390_ld (code, i, 0, STK_BASE, pos);
-//             pos += sizeof (gdouble);
-//     }
+       pos = S390_CALLFILTER_FLTREGS;
+       for (i = 0; i < 16; ++i) {
+               s390_ld (code, i, 0, STK_BASE, pos);
+               pos += sizeof (gdouble);
+       }
 
        s390_lgr  (code, s390_r2, s390_r14);
-//     s390_lam  (code, s390_a0, s390_a15, STK_BASE, S390_CALLFILTER_ACCREGS);
+       s390_lam  (code, s390_a0, s390_a15, STK_BASE, S390_CALLFILTER_ACCREGS);
        s390_aghi (code, s390_r15, alloc_size);
        s390_lmg  (code, s390_r6, s390_r14, STK_BASE, S390_REG_SAVE_OFFSET);
        s390_br   (code, s390_r14);
@@ -218,13 +224,17 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
 {
        MonoContext ctx;
        int iReg;
+       static void (*restore_context) (MonoContext *);
+
+       if (!restore_context)
+               restore_context = mono_arch_get_restore_context();
        
        memset(&ctx, 0, sizeof(ctx));
 
        getcontext(&ctx);
 
        /* adjust eip so that it point into the call instruction */
-       ip -= 6;
+       ip -= 2;
 
        for (iReg = 0; iReg < 16; iReg++) {
                ctx.uc_mcontext.gregs[iReg]         = int_regs[iReg];
@@ -243,7 +253,7 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
                        mono_ex->stack_trace = NULL;
        }
        mono_arch_handle_exception (&ctx, exc, FALSE);
-       setcontext(&ctx);
+       restore_context(&ctx);
 
        g_assert_not_reached ();
 }
@@ -264,7 +274,7 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
 
 static gpointer 
 get_throw_exception_generic (guint8 *start, int size, 
-                            int by_name, gboolean rethrow)
+                            throwType type, gboolean rethrow)
 {
        guint8 *code;
        int alloc_size, pos, i;
@@ -276,17 +286,33 @@ get_throw_exception_generic (guint8 *start, int size,
        s390_lgr  (code, s390_r14, STK_BASE);
        s390_aghi (code, STK_BASE, -alloc_size);
        s390_stg  (code, s390_r14, 0, STK_BASE, 0);
-       if (by_name) {
+       switch (type) {
+       case by_name : 
                s390_lgr  (code, s390_r4, s390_r2);
+               s390_lg   (code, s390_r3, 0, s390_r2, G_STRUCT_OFFSET(MonoException, object));
                s390_basr (code, s390_r13, 0);
-               s390_j    (code, 14);
+               s390_j    (code, 10);
                s390_llong(code, mono_defaults.corlib);
-               s390_llong(code, "System");
                s390_llong(code, mono_exception_from_name);
+               s390_lg   (code, s390_r3, 0, s390_r3, G_STRUCT_OFFSET(MonoVTable, klass));
+               s390_lg   (code, s390_r2, 0, s390_r13, 4);
+               s390_lg   (code, s390_r1, 0, s390_r13, 12);
+               s390_lg   (code, s390_r4, 0, s390_r3, G_STRUCT_OFFSET(MonoClass, name));
+               s390_lg   (code, s390_r3, 0, s390_r3, G_STRUCT_OFFSET(MonoClass, name_space));
+               s390_basr (code, s390_r14, s390_r1);
+               break;
+       case by_token : 
+               s390_lgr  (code, s390_r3, s390_r2);
+               s390_basr (code, s390_r13, 0);
+               s390_j    (code, 10);
+               s390_llong(code, mono_defaults.exception_class->image);
+               s390_llong(code, mono_exception_from_token);
                s390_lg   (code, s390_r2, 0, s390_r13, 4);
-               s390_lg   (code, s390_r3, 0, s390_r13, 12);
-               s390_lg   (code, s390_r1, 0, s390_r13, 20);
+               s390_lg   (code, s390_r1, 0, s390_r13, 12);
                s390_basr (code, s390_r14, s390_r1);
+               break;
+       case by_none :
+               break;
        }
        /*------------------------------------------------------*/
        /* save the general registers on the stack              */
@@ -314,10 +340,11 @@ get_throw_exception_generic (guint8 *start, int size,
        s390_stam (code, s390_r0, s390_r15, STK_BASE, S390_THROWSTACK_ACCREGS);
 
        /*------------------------------------------------------*/
-       /* call throw_exception (exc, ip, sp, gr, fr, ar)       */
-       /* exc is already in place in r2                        */
+       /* call throw_exception (tkn, ip, sp, gr, fr, ar, re)   */
+       /* - r2 already contains *exc                           */
        /*------------------------------------------------------*/
        s390_lgr  (code, s390_r4, s390_r1);        /* caller sp */
+
        /*------------------------------------------------------*/
        /* pointer to the saved int regs                        */
        /*------------------------------------------------------*/
@@ -325,7 +352,7 @@ get_throw_exception_generic (guint8 *start, int size,
        s390_la   (code, s390_r6, 0, STK_BASE, S390_THROWSTACK_FLTREGS);
        s390_la   (code, s390_r7, 0, STK_BASE, S390_THROWSTACK_ACCREGS);
        s390_stg  (code, s390_r7, 0, STK_BASE, S390_THROWSTACK_ACCPRM);
-       s390_stfpc(code, STK_BASE, S390_THROWSTACK_FPCPRM);
+       s390_stfpc(code, STK_BASE, S390_THROWSTACK_FPCPRM+4);
        s390_lghi (code, s390_r7, rethrow);
        s390_stg  (code, s390_r7, 0, STK_BASE, S390_THROWSTACK_RETHROW);
        s390_basr (code, s390_r13, 0);
@@ -361,7 +388,7 @@ mono_arch_get_throw_exception (void)
        if (inited)
                return start;
        start = mono_global_codeman_reserve (SZ_THROW);
-       get_throw_exception_generic (start, SZ_THROW, FALSE, FALSE);
+       get_throw_exception_generic (start, SZ_THROW, by_none, FALSE);
        inited = 1;
        return start;
 }
@@ -395,6 +422,33 @@ mono_arch_get_rethrow_exception (void)
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - arch_get_corlib_exception                         */
+/*                                                                  */
+/* Function    - Return a function pointer which can be used to    */
+/*                raise corlib exceptions. The return function has  */
+/*                the following signature:                          */
+/*                void (*func) (guint32 token, guint32 offset)     */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
+gpointer 
+mono_arch_get_throw_corlib_exception(void)
+{
+       static guint8 *start;
+       static int inited = 0;
+
+       if (inited)
+               return start;
+       start = mono_global_codeman_reserve (SZ_THROW);
+       get_throw_exception_generic (start, SZ_THROW, by_token, FALSE);
+       inited = 1;
+       return start;
+}      
+
+/*========================= End of Function ========================*/
+
 /*------------------------------------------------------------------*/
 /*                                                                  */
 /* Name                - arch_get_throw_exception_by_name                  */
@@ -415,7 +469,7 @@ mono_arch_get_throw_exception_by_name (void)
        if (inited)
                return start;
        start = mono_global_codeman_reserve (SZ_THROW);
-       get_throw_exception_generic (start, SZ_THROW, TRUE, FALSE);
+       get_throw_exception_generic (start, SZ_THROW, by_name, FALSE);
        inited = 1;
        return start;
 }      
index d1901330dda11b3c64d4bae67e5f574a9b175316..a75e3ad59a8f5c5a21a2c5a0b29374f3787d9914 100644 (file)
@@ -563,10 +563,54 @@ class Tests {
                return 0;
        }
 
+       public static int test_0_partial_sharing () {
+               if (PartialShared1 (new List<string> (), 1) != typeof (string))
+                       return 1;
+               if (PartialShared1 (new List<Tests> (), 1) != typeof (Tests))
+                       return 2;
+               if (PartialShared2 (new List<string> (), 1) != typeof (int))
+                       return 3;
+               if (PartialShared2 (new List<Tests> (), 1) != typeof (int))
+                       return 4;
+               return 0;
+       }
+
+       public static int test_6_partial_sharing_linq () {
+               var messages = new List<Message> ();
+
+               messages.Add (new Message () { MessageID = 5 });
+               messages.Add (new Message () { MessageID = 6 });
+
+               return messages.Max(i => i.MessageID);
+       }
+
+       public static int test_0_partial_shared_method_in_nonshared_class () {
+               var c = new Class1<double> ();
+               return (c.Foo<string> (5).GetType () == typeof (Class1<string>)) ? 0 : 1;
+       }
+
+       class Message {
+               public int MessageID {
+                       get; set;
+               }
+       }
+
+       public static Type PartialShared1<T, K> (List<T> list, K k) {
+               return typeof (T);
+       }
+
+       public static Type PartialShared2<T, K> (List<T> list, K k) {
+               return typeof (K);
+       }
+
     public class Class1<T> {
                public virtual void Do (Class2<T> t) {
                        t.Foo ();
                }
+
+               public virtual object Foo<U> (T t) {
+                       return new Class1<U> ();
+               }
        }
 
        public interface IFace1<T> {
index 1363799ad4b4bb53e3b190963a950cd321d29cd9..3b56c0658b3932fef198b71219a4826837fc6dc5 100644 (file)
@@ -957,7 +957,7 @@ COND:   ldloc.0
                ret
        }
 
-#if !defined(__ppc__) && !defined(__powerpc__) && !defined(__arm__)
+#if !defined(__ppc__) && !defined(__powerpc__) && !defined(__arm__) && !defined(__sparc__)
        // PPC handles overflow by clipping, but this test assumes
        // no overflow handling.  According to ECMA the result of
        // float->int conversion is undefined if overflow occurs, so
@@ -2448,4 +2448,72 @@ OK_2:
         IL_004b:  ret
     }
 
+       .method public static int32 test_2_leave_multiple_blocks_from_end ()
+       {
+               .locals init (int32 V_0)
+
+               .try {
+                       .try {
+                               nop
+                               nop
+                               leave END
+                       } finally {
+                               ldloc.0
+                               ldc.i4.1
+                               add
+                               stloc.0
+                               endfinally
+                       }
+                       nop
+                       leave END
+               } finally {
+                       ldloc.0
+                       ldc.i4.1
+                       add
+                       stloc.0
+                       endfinally
+               }
+END:
+               ldloc.0
+               ret
+       }
+
+       .method public static int32 test_3_leave_multiple_blocks_from_hole ()
+       {
+               .locals init (int32 V_0)
+
+               .try {
+                       .try {
+                               ldloc.0
+                               brtrue REST
+                               leave BEFORE_END
+REST:
+                               nop
+                               nop
+                               leave END
+                       } finally {
+                               ldloc.0
+                               ldc.i4.1
+                               add
+                               stloc.0
+                               endfinally
+                       }
+                       nop
+                       leave END
+               } finally {
+                       ldloc.0
+                       ldc.i4.1
+                       add
+                       stloc.0
+                       endfinally
+               }
+BEFORE_END:
+               ldloc.0
+               ldc.i4.1
+               add
+               stloc.0
+END:
+               ldloc.0
+               ret
+       }
 }
index 54c8010d0b675620efb42691a783d813ff9c78a7..fd1de882efff4dae1fadada00b49555dc741d9f9 100644 (file)
@@ -637,8 +637,8 @@ mono_array_new_va (MonoMethod *cm, ...)
 {
        MonoDomain *domain = mono_domain_get ();
        va_list ap;
-       guint32 *lengths;
-       guint32 *lower_bounds;
+       uintptr_t *lengths;
+       intptr_t *lower_bounds;
        int pcount;
        int rank;
        int i, d;
@@ -650,22 +650,22 @@ mono_array_new_va (MonoMethod *cm, ...)
 
        va_start (ap, cm);
        
-       lengths = alloca (sizeof (guint32) * pcount);
+       lengths = alloca (sizeof (uintptr_t) * pcount);
        for (i = 0; i < pcount; ++i)
                lengths [i] = d = va_arg(ap, int);
 
        if (rank == pcount) {
                /* Only lengths provided. */
                if (cm->klass->byval_arg.type == MONO_TYPE_ARRAY) {
-                       lower_bounds = alloca (sizeof (guint32) * rank);
-                       memset (lower_bounds, 0, sizeof (guint32) * rank);
+                       lower_bounds = alloca (sizeof (intptr_t) * rank);
+                       memset (lower_bounds, 0, sizeof (intptr_t) * rank);
                } else {
                        lower_bounds = NULL;
                }
        } else {
                g_assert (pcount == (rank * 2));
                /* lower bounds are first. */
-               lower_bounds = lengths;
+               lower_bounds = (intptr_t*)lengths;
                lengths += rank;
        }
        va_end(ap);
@@ -678,8 +678,8 @@ MonoArray *
 mono_array_new_1 (MonoMethod *cm, guint32 length)
 {
        MonoDomain *domain = mono_domain_get ();
-       guint32 lengths [1];
-       guint32 *lower_bounds;
+       uintptr_t lengths [1];
+       intptr_t *lower_bounds;
        int pcount;
        int rank;
 
@@ -693,8 +693,8 @@ mono_array_new_1 (MonoMethod *cm, guint32 length)
        g_assert (rank == pcount);
 
        if (cm->klass->byval_arg.type == MONO_TYPE_ARRAY) {
-               lower_bounds = alloca (sizeof (guint32) * rank);
-               memset (lower_bounds, 0, sizeof (guint32) * rank);
+               lower_bounds = alloca (sizeof (intptr_t) * rank);
+               memset (lower_bounds, 0, sizeof (intptr_t) * rank);
        } else {
                lower_bounds = NULL;
        }
@@ -706,8 +706,8 @@ MonoArray *
 mono_array_new_2 (MonoMethod *cm, guint32 length1, guint32 length2)
 {
        MonoDomain *domain = mono_domain_get ();
-       guint32 lengths [2];
-       guint32 *lower_bounds;
+       uintptr_t lengths [2];
+       intptr_t *lower_bounds;
        int pcount;
        int rank;
 
@@ -722,8 +722,8 @@ mono_array_new_2 (MonoMethod *cm, guint32 length1, guint32 length2)
        g_assert (rank == pcount);
 
        if (cm->klass->byval_arg.type == MONO_TYPE_ARRAY) {
-               lower_bounds = alloca (sizeof (guint32) * rank);
-               memset (lower_bounds, 0, sizeof (guint32) * rank);
+               lower_bounds = alloca (sizeof (intptr_t) * rank);
+               memset (lower_bounds, 0, sizeof (intptr_t) * rank);
        } else {
                lower_bounds = NULL;
        }
@@ -735,8 +735,8 @@ MonoArray *
 mono_array_new_3 (MonoMethod *cm, guint32 length1, guint32 length2, guint32 length3)
 {
        MonoDomain *domain = mono_domain_get ();
-       guint32 lengths [3];
-       guint32 *lower_bounds;
+       uintptr_t lengths [3];
+       intptr_t *lower_bounds;
        int pcount;
        int rank;
 
@@ -752,8 +752,8 @@ mono_array_new_3 (MonoMethod *cm, guint32 length1, guint32 length2, guint32 leng
        g_assert (rank == pcount);
 
        if (cm->klass->byval_arg.type == MONO_TYPE_ARRAY) {
-               lower_bounds = alloca (sizeof (guint32) * rank);
-               memset (lower_bounds, 0, sizeof (guint32) * rank);
+               lower_bounds = alloca (sizeof (intptr_t) * rank);
+               memset (lower_bounds, 0, sizeof (intptr_t) * rank);
        } else {
                lower_bounds = NULL;
        }
index 9ee967d577aaa031f5f09dc9061b75af18d0d509..87e259d63fc861391516ae38453a44fa365fed3d 100644 (file)
@@ -495,7 +495,6 @@ mono_find_final_block (MonoCompile *cfg, unsigned char *ip, unsigned char *targe
 {
        MonoMethodHeader *header = cfg->header;
        MonoExceptionClause *clause;
-       MonoBasicBlock *handler;
        int i;
        GList *res = NULL;
 
@@ -503,11 +502,8 @@ mono_find_final_block (MonoCompile *cfg, unsigned char *ip, unsigned char *targe
                clause = &header->clauses [i];
                if (MONO_OFFSET_IN_CLAUSE (clause, (ip - header->code)) && 
                    (!MONO_OFFSET_IN_CLAUSE (clause, (target - header->code)))) {
-                       if (clause->flags == type) {
-                               handler = cfg->cil_offset_to_bb [clause->handler_offset];
-                               g_assert (handler);
-                               res = g_list_append (res, handler);
-                       }
+                       if (clause->flags == type)
+                               res = g_list_append (res, clause);
                }
        }
        return res;
@@ -1374,17 +1370,26 @@ mini_emit_load_intf_reg_vtable (MonoCompile *cfg, int intf_reg, int vtable_reg,
        }
 }
 
-/* 
- * Emit code which loads into "intf_bit_reg" a nonzero value if the MonoClass
- * stored in "klass_reg" implements the interface "klass".
- */
 static void
-mini_emit_load_intf_bit_reg_class (MonoCompile *cfg, int intf_bit_reg, int klass_reg, MonoClass *klass)
+mini_emit_interface_bitmap_check (MonoCompile *cfg, int intf_bit_reg, int base_reg, int offset, MonoClass *klass)
 {
        int ibitmap_reg = alloc_preg (cfg);
+#ifdef COMPRESSED_INTERFACE_BITMAP
+       MonoInst *args [2];
+       MonoInst *res, *ins;
+       NEW_LOAD_MEMBASE (cfg, ins, OP_LOAD_MEMBASE, ibitmap_reg, base_reg, offset);
+       MONO_ADD_INS (cfg->cbb, ins);
+       args [0] = ins;
+       if (cfg->compile_aot)
+               EMIT_NEW_AOTCONST (cfg, args [1], MONO_PATCH_INFO_IID, klass);
+       else
+               EMIT_NEW_ICONST (cfg, args [1], klass->interface_id);
+       res = mono_emit_jit_icall (cfg, mono_class_interface_match, args);
+       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, intf_bit_reg, res->dreg);
+#else
        int ibitmap_byte_reg = alloc_preg (cfg);
 
-       MONO_EMIT_NEW_LOAD_MEMBASE (cfg, ibitmap_reg, klass_reg, G_STRUCT_OFFSET (MonoClass, interface_bitmap));
+       MONO_EMIT_NEW_LOAD_MEMBASE (cfg, ibitmap_reg, base_reg, offset);
 
        if (cfg->compile_aot) {
                int iid_reg = alloc_preg (cfg);
@@ -1405,6 +1410,17 @@ mini_emit_load_intf_bit_reg_class (MonoCompile *cfg, int intf_bit_reg, int klass
                MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI1_MEMBASE, ibitmap_byte_reg, ibitmap_reg, klass->interface_id >> 3);
                MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, intf_bit_reg, ibitmap_byte_reg, 1 << (klass->interface_id & 7));
        }
+#endif
+}
+
+/* 
+ * Emit code which loads into "intf_bit_reg" a nonzero value if the MonoClass
+ * stored in "klass_reg" implements the interface "klass".
+ */
+static void
+mini_emit_load_intf_bit_reg_class (MonoCompile *cfg, int intf_bit_reg, int klass_reg, MonoClass *klass)
+{
+       mini_emit_interface_bitmap_check (cfg, intf_bit_reg, klass_reg, G_STRUCT_OFFSET (MonoClass, interface_bitmap), klass);
 }
 
 /* 
@@ -1414,30 +1430,7 @@ mini_emit_load_intf_bit_reg_class (MonoCompile *cfg, int intf_bit_reg, int klass
 static void
 mini_emit_load_intf_bit_reg_vtable (MonoCompile *cfg, int intf_bit_reg, int vtable_reg, MonoClass *klass)
 {
-       int ibitmap_reg = alloc_preg (cfg);
-       int ibitmap_byte_reg = alloc_preg (cfg);
-       MONO_EMIT_NEW_LOAD_MEMBASE (cfg, ibitmap_reg, vtable_reg, G_STRUCT_OFFSET (MonoVTable, interface_bitmap));
-
-       if (cfg->compile_aot) {
-               int iid_reg = alloc_preg (cfg);
-               int shifted_iid_reg = alloc_preg (cfg);
-               int ibitmap_byte_address_reg = alloc_preg (cfg);
-               int masked_iid_reg = alloc_preg (cfg);
-               int iid_one_bit_reg = alloc_preg (cfg);
-               int iid_bit_reg = alloc_preg (cfg);
-               MONO_EMIT_NEW_AOTCONST (cfg, iid_reg, klass, MONO_PATCH_INFO_IID);
-               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, shifted_iid_reg, iid_reg, 3);
-               MONO_EMIT_NEW_BIALU (cfg, OP_PADD, ibitmap_byte_address_reg, ibitmap_reg, shifted_iid_reg);
-               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADU1_MEMBASE, ibitmap_byte_reg, ibitmap_byte_address_reg, 0);
-               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, masked_iid_reg, iid_reg, 7);
-               MONO_EMIT_NEW_ICONST (cfg, iid_one_bit_reg, 1);
-               MONO_EMIT_NEW_BIALU (cfg, OP_ISHL, iid_bit_reg, iid_one_bit_reg, masked_iid_reg);
-               MONO_EMIT_NEW_BIALU (cfg, OP_IAND, intf_bit_reg, ibitmap_byte_reg, iid_bit_reg);
-       } else {
-               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI1_MEMBASE, ibitmap_byte_reg, ibitmap_reg, klass->interface_id >> 3);
-               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_IAND_IMM, intf_bit_reg, ibitmap_byte_reg, 1 << (klass->interface_id & 7));
-       }
+       mini_emit_interface_bitmap_check (cfg, intf_bit_reg, vtable_reg, G_STRUCT_OFFSET (MonoVTable, interface_bitmap), klass);
 }
 
 /* 
@@ -6088,7 +6081,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        array_rank = cmethod->klass->rank;
                                        fsig = mono_method_signature (cmethod);
                                } else {
-                                       if (mono_method_signature (cmethod)->pinvoke) {
+                                       fsig = mono_method_signature (cmethod);
+
+                                       if (!fsig)
+                                               goto load_error;
+
+                                       if (fsig->pinvoke) {
                                                MonoMethod *wrapper = mono_marshal_get_native_wrapper (cmethod,
                                                        check_for_pending_exc, FALSE);
                                                fsig = mono_method_signature (wrapper);
@@ -8930,11 +8928,16 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                        if ((handlers = mono_find_final_block (cfg, ip, target, MONO_EXCEPTION_CLAUSE_FINALLY))) {
                                GList *tmp;
+                               MonoExceptionClause *clause;
+
                                for (tmp = handlers; tmp; tmp = tmp->next) {
-                                       tblock = tmp->data;
+                                       clause = tmp->data;
+                                       tblock = cfg->cil_offset_to_bb [clause->handler_offset];
+                                       g_assert (tblock);
                                        link_bblock (cfg, bblock, tblock);
                                        MONO_INST_NEW (cfg, ins, OP_CALL_HANDLER);
                                        ins->inst_target_bb = tblock;
+                                       ins->inst_eh_block = clause;
                                        MONO_ADD_INS (bblock, ins);
                                        bblock->has_call_handler = 1;
                                        if (COMPILE_LLVM (cfg)) {
index 61fdb31e7819e06c732210e03df591871152ee62..ebe8b3c23fff6ac14255ca45a6236e6cba50b1f4 100644 (file)
@@ -985,17 +985,17 @@ mono_arch_cpu_enumerate_simd_versions (void)
 
        if (cpuid (1, &eax, &ebx, &ecx, &edx)) {
                if (edx & (1 << 25))
-                       sse_opts |= 1 << SIMD_VERSION_SSE1;
+                       sse_opts |= SIMD_VERSION_SSE1;
                if (edx & (1 << 26))
-                       sse_opts |= 1 << SIMD_VERSION_SSE2;
+                       sse_opts |= SIMD_VERSION_SSE2;
                if (ecx & (1 << 0))
-                       sse_opts |= 1 << SIMD_VERSION_SSE3;
+                       sse_opts |= SIMD_VERSION_SSE3;
                if (ecx & (1 << 9))
-                       sse_opts |= 1 << SIMD_VERSION_SSSE3;
+                       sse_opts |= SIMD_VERSION_SSSE3;
                if (ecx & (1 << 19))
-                       sse_opts |= 1 << SIMD_VERSION_SSE41;
+                       sse_opts |= SIMD_VERSION_SSE41;
                if (ecx & (1 << 20))
-                       sse_opts |= 1 << SIMD_VERSION_SSE42;
+                       sse_opts |= SIMD_VERSION_SSE42;
        }
 
        /* Yes, all this needs to be done to check for sse4a.
@@ -1006,7 +1006,7 @@ mono_arch_cpu_enumerate_simd_versions (void)
                if ((((unsigned int) eax) >= 0x80000001) && (ebx == 0x68747541) && (ecx == 0x444D4163) && (edx == 0x69746E65)) {
                        cpuid (0x80000001, &eax, &ebx, &ecx, &edx);
                        if (ecx & (1 << 6))
-                               sse_opts |= 1 << SIMD_VERSION_SSE4a;
+                               sse_opts |= SIMD_VERSION_SSE4a;
                }
        }
 
@@ -1771,6 +1771,7 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig)
        ArgInfo *ainfo;
        int j;
        LLVMCallInfo *linfo;
+       MonoType *t;
 
        n = sig->param_count + sig->hasthis;
 
@@ -1804,6 +1805,11 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig)
        for (i = 0; i < n; ++i) {
                ainfo = cinfo->args + i;
 
+               if (i >= sig->hasthis)
+                       t = sig->params [i - sig->hasthis];
+               else
+                       t = &mono_defaults.int_class->byval_arg;
+
                linfo->args [i].storage = LLVMArgNone;
 
                switch (ainfo->storage) {
@@ -1815,16 +1821,15 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig)
                        linfo->args [i].storage = LLVMArgInFPReg;
                        break;
                case ArgOnStack:
-                       if ((i >= sig->hasthis) && (MONO_TYPE_ISSTRUCT(sig->params [i - sig->hasthis]))) {
+                       if (MONO_TYPE_ISSTRUCT (t)) {
                                linfo->args [i].storage = LLVMArgVtypeByVal;
                        } else {
                                linfo->args [i].storage = LLVMArgInIReg;
-                               if (!sig->params [i - sig->hasthis]->byref) {
-                                       if (sig->params [i - sig->hasthis]->type == MONO_TYPE_R4) {
+                               if (!t->byref) {
+                                       if (t->type == MONO_TYPE_R4)
                                                linfo->args [i].storage = LLVMArgInFPReg;
-                                       } else if (sig->params [i - sig->hasthis]->type == MONO_TYPE_R8) {
+                                       else if (t->type == MONO_TYPE_R8)
                                                linfo->args [i].storage = LLVMArgInFPReg;
-                                       }
                                }
                        }
                        break;
@@ -4320,6 +4325,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 8);
                        mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_target_bb);
                        amd64_call_imm (code, 0);
+                       mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                        /* Restore stack alignment */
                        amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, 8);
                        break;
@@ -5679,7 +5685,7 @@ mono_arch_emit_prolog (MonoCompile *cfg)
        gboolean args_clobbered = FALSE;
        gboolean trace = FALSE;
 
-       cfg->code_size =  MAX (((MonoMethodNormal *)method)->header->code_size * 4, 10240);
+       cfg->code_size =  MAX (cfg->header->code_size * 4, 10240);
 
        code = cfg->native_code = g_malloc (cfg->code_size);
 
index 982a98fbc725d821539cb47af7ddaeeb89593e85..f16b5231c5d8e3892fe616ee7a899377967b00f8 100644 (file)
@@ -256,10 +256,6 @@ typedef struct {
 
 #endif
 
-#ifdef __OpenBSD__
-#undef MONO_ARCH_USE_SIGACTION
-#endif
-
 #endif /* HOST_WIN32 */
 
 #if defined (__NetBSD__)
@@ -284,7 +280,11 @@ typedef struct {
 
 #define MONO_ARCH_NOMAP32BIT
 
-#elif defined (__FreeBSD__) || defined (__OpenBSD__)
+#elif defined (__OpenBSD__)
+
+#define MONO_ARCH_NOMAP32BIT
+
+#elif defined (__FreeBSD__)
 
 #define REG_RAX 7
 #define REG_RCX 4
index d6d11211af2e7cb0680d7897387777f2e0b3eaf3..0a72637f062ad53b5efd0e90572c5925241fab7c 100644 (file)
@@ -3817,6 +3817,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                case OP_CALL_HANDLER: 
                        mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_target_bb);
                        ARM_BL (code, 0);
+                       mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                        break;
                case OP_LABEL:
                        ins->inst_c0 = code - cfg->native_code;
index fa2ab771e2b9b61712391b06a9c3faef1879e10f..3ff5faa1306b27d1abeb8d2e5a0743697f7046ec 100644 (file)
@@ -197,6 +197,34 @@ mono_get_throw_corlib_exception (void)
        return throw_corlib_exception_func;
 }
 
+static gboolean
+is_address_protected (MonoJitInfo *ji, MonoJitExceptionInfo *ei, gpointer ip)
+{
+       MonoTryBlockHoleTableJitInfo *table;
+       int i;
+       guint32 offset;
+       guint16 clause;
+
+       /*FIXME check if under s390 it should be ei->try_start >= ip*/
+       if (ei->try_start > ip || ip >= ei->try_end)
+               return FALSE;
+
+       if (!ji->has_try_block_holes)
+               return TRUE;
+
+       table = mono_jit_info_get_try_block_hole_table_info (ji);
+       offset = (guint32)((char*)ip - (char*)ji->code_start);
+       clause = (guint16)(ei - ji->clauses);
+       g_assert (clause < ji->num_clauses);
+
+       for (i = 0; i < table->num_holes; ++i) {
+               MonoTryBlockHoleJitInfo *hole = &table->holes [i];
+               if (hole->clause == clause && hole->offset <= offset && hole->offset + hole->length > offset)
+                       return FALSE;
+       }
+       return TRUE;
+}
+
 #ifdef MONO_ARCH_HAVE_FIND_JIT_INFO_EXT
 
 /*
@@ -454,7 +482,7 @@ get_generic_context_from_stack_frame (MonoJitInfo *ji, gpointer generic_info)
                class = generic_info;
        }
 
-       g_assert (!ji->method->klass->generic_container);
+       //g_assert (!ji->method->klass->generic_container);
        if (ji->method->klass->generic_class)
                method_container_class = ji->method->klass->generic_class->container_class;
        else
@@ -1045,7 +1073,8 @@ get_exception_catch_class (MonoJitExceptionInfo *ei, MonoJitInfo *ji, MonoContex
        MonoType *inflated_type;
        MonoGenericContext context;
 
-       if (!catch_class)
+       /*MonoJitExceptionInfo::data is an union used by filter and finally clauses too.*/
+       if (!catch_class || ei->flags != MONO_EXCEPTION_CLAUSE_NONE)
                return NULL;
 
        if (!ji->has_generic_jit_info || !mono_jit_info_get_generic_jit_info (ji)->has_this)
@@ -1300,11 +1329,10 @@ mono_handle_exception_internal (MonoContext *ctx, gpointer obj, gpointer origina
                                         * a call which causes an exception. Testcase: tests/exception8.cs.
                                         * FIXME: Clean this up.
                                         */
-                                       if (ei->try_start < MONO_CONTEXT_GET_IP (ctx) && 
+                                       if (ei->try_start < MONO_CONTEXT_GET_IP (ctx) && MONO_CONTEXT_GET_IP (ctx) <= ei->try_end) {
 #else
-                                       if (ei->try_start <= MONO_CONTEXT_GET_IP (ctx) && 
+                                       if (is_address_protected (ji, ei, MONO_CONTEXT_GET_IP (ctx))) {
 #endif
-                                           MONO_CONTEXT_GET_IP (ctx) <= ei->try_end) { 
                                                /* catch block */
                                                MonoClass *catch_class = get_exception_catch_class (ei, ji, ctx);
 
@@ -1367,8 +1395,7 @@ mono_handle_exception_internal (MonoContext *ctx, gpointer obj, gpointer origina
 
                                                        return 0;
                                                }
-                                               if (!test_only && ei->try_start <= MONO_CONTEXT_GET_IP (ctx) && 
-                                                   MONO_CONTEXT_GET_IP (ctx) < ei->try_end &&
+                                               if (!test_only && is_address_protected (ji, ei, MONO_CONTEXT_GET_IP (ctx)) &&
                                                    (ei->flags == MONO_EXCEPTION_CLAUSE_FAULT)) {
                                                        if (mono_trace_is_enabled () && mono_trace_eval (ji->method))
                                                                g_print ("EXCEPTION: fault clause %d of %s\n", i, mono_method_full_name (ji->method, TRUE));
@@ -1376,8 +1403,7 @@ mono_handle_exception_internal (MonoContext *ctx, gpointer obj, gpointer origina
                                                        mono_debugger_call_exception_handler (ei->handler_start, MONO_CONTEXT_GET_SP (ctx), obj);
                                                        call_filter (ctx, ei->handler_start);
                                                }
-                                               if (!test_only && ei->try_start <= MONO_CONTEXT_GET_IP (ctx) && 
-                                                   MONO_CONTEXT_GET_IP (ctx) < ei->try_end &&
+                                               if (!test_only && is_address_protected (ji, ei, MONO_CONTEXT_GET_IP (ctx)) &&
                                                    (ei->flags == MONO_EXCEPTION_CLAUSE_FINALLY)) {
                                                        if (mono_trace_is_enabled () && mono_trace_eval (ji->method))
                                                                g_print ("EXCEPTION: finally clause %d of %s\n", i, mono_method_full_name (ji->method, TRUE));
@@ -1537,8 +1563,7 @@ mono_debugger_run_finally (MonoContext *start_ctx)
        for (i = 0; i < ji->num_clauses; i++) {
                MonoJitExceptionInfo *ei = &ji->clauses [i];
 
-               if ((ei->try_start <= MONO_CONTEXT_GET_IP (&ctx)) && 
-                   (MONO_CONTEXT_GET_IP (&ctx) < ei->try_end) &&
+               if (is_address_protected (ji, ei, MONO_CONTEXT_GET_IP (&ctx)) &&
                    (ei->flags & MONO_EXCEPTION_CLAUSE_FINALLY)) {
                        call_filter (&ctx, ei->handler_start);
                }
@@ -1593,6 +1618,7 @@ mono_setup_altstack (MonoJitTlsData *tls)
                /* mprotect can fail for the main thread stack */
                gpointer gaddr = mono_valloc (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON|MONO_MMAP_FIXED);
                g_assert (gaddr == tls->stack_ovf_guard_base);
+               tls->stack_ovf_valloced = TRUE;
        }
 
        /*
@@ -1629,6 +1655,10 @@ mono_free_altstack (MonoJitTlsData *tls)
 
        if (tls->signal_stack)
                mono_vfree (tls->signal_stack, MONO_ARCH_SIGNAL_STACK_SIZE);
+       if (tls->stack_ovf_valloced)
+               mono_vfree (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size);
+       else
+               mono_mprotect (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_READ|MONO_MMAP_WRITE);
 }
 
 #else /* !MONO_ARCH_SIGSEGV_ON_ALTSTACK */
index 758cf85bf78174bccc1333cfbbb6cda9a1bbb364..e1868e4df2a20c621aaab50e18abd1a89ac7b66b 100644 (file)
@@ -14,6 +14,9 @@
 
 #include "mini.h"
 
+#define ALLOW_PARTIAL_SHARING TRUE
+//#define ALLOW_PARTIAL_SHARING FALSE
+
 static void
 mono_class_unregister_image_generic_subclasses (MonoImage *image, gpointer user_data);
 
@@ -582,7 +585,122 @@ free_inflated_info (int info_type, gpointer info)
 }
 
 static MonoRuntimeGenericContextOtherInfoTemplate
-class_get_rgctx_template_oti (MonoClass *class, int type_argc, guint32 slot, gboolean temporary, gboolean *do_free);
+class_get_rgctx_template_oti (MonoClass *class, int type_argc, guint32 slot, gboolean temporary, gboolean shared, gboolean *do_free);
+static MonoClass*
+class_uninstantiated (MonoClass *class)
+{
+       if (class->generic_class)
+               return class->generic_class->container_class;
+       return class;
+}
+
+static gboolean
+generic_inst_is_sharable (MonoGenericInst *inst, gboolean allow_type_vars,
+                                                 gboolean allow_partial)
+{
+       gboolean has_refs;
+       int i;
+
+       has_refs = FALSE;
+       for (i = 0; i < inst->type_argc; ++i) {
+               MonoType *type = inst->type_argv [i];
+
+               if (MONO_TYPE_IS_REFERENCE (type) || (allow_type_vars && (type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR)))
+                       has_refs = TRUE;
+       }
+       for (i = 0; i < inst->type_argc; ++i) {
+               MonoType *type = inst->type_argv [i];
+
+               if (MONO_TYPE_IS_REFERENCE (type) || (allow_type_vars && (type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR)))
+                       continue;
+               /*
+                * Allow non ref arguments, if there is at least one ref argument
+                * (partial sharing).
+                * FIXME: Allow more types
+                */
+               if (allow_partial && !type->byref && (((type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8)) || (type->type == MONO_TYPE_I) || (type->type == MONO_TYPE_U)))
+                       continue;
+
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+/*
+ * mono_is_partially_sharable_inst:
+ *
+ *   Return TRUE if INST has ref and non-ref type arguments.
+ */
+gboolean
+mono_is_partially_sharable_inst (MonoGenericInst *inst)
+{
+       int i;
+       gboolean has_refs = FALSE, has_non_refs = FALSE;
+
+       for (i = 0; i < inst->type_argc; ++i) {
+               if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
+                       has_refs = TRUE;
+               else
+                       has_non_refs = TRUE;
+       }
+
+       return has_refs && has_non_refs;
+}
+
+/*
+ * get_shared_class:
+ *
+ *   Return the class used to store information when using generic sharing.
+ * For fully shared classes, it is the generic definition, for partially shared
+ * classes, it is an instance with all ref type arguments replaced by the type parameters
+ * of its generic definition.
+ */
+static MonoClass*
+get_shared_class (MonoClass *class)
+{
+       /*
+        * FIXME: This conflicts with normal instances. Also, some code in this file
+        * like class_get_rgctx_template_oti treats these as normal generic instances
+        * instead of generic classes.
+        */
+       //g_assert_not_reached ();
+
+       if (class->is_inflated) {
+               MonoGenericContext *context = &class->generic_class->context;
+               MonoGenericContext *container_context;
+               MonoGenericContext shared_context;
+               MonoGenericInst *inst;
+               MonoType **type_argv;
+               int i;
+
+               inst = context->class_inst;
+               if (mono_is_partially_sharable_inst (inst)) {
+                       container_context = &class->generic_class->container_class->generic_container->context;
+                       type_argv = g_new0 (MonoType*, inst->type_argc);
+                       for (i = 0; i < inst->type_argc; ++i) {
+                               if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
+                                       type_argv [i] = container_context->class_inst->type_argv [i];
+                               else
+                                       type_argv [i] = inst->type_argv [i];
+                       }
+
+                       memset (&shared_context, 0, sizeof (MonoGenericContext));
+                       shared_context.class_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv);
+                       g_free (type_argv);
+
+                       return mono_class_inflate_generic_class (class->generic_class->container_class, &shared_context);
+               } else if (!generic_inst_is_sharable (inst, TRUE, FALSE)) {
+                       /* Happens for partially shared methods of nono-sharable generic class */
+                       return class;
+               }
+       }
+
+       return class_uninstantiated (class);
+}
 
 /*
  * mono_class_get_runtime_generic_context_template:
@@ -597,8 +715,6 @@ mono_class_get_runtime_generic_context_template (MonoClass *class)
        MonoRuntimeGenericContextTemplate *parent_template, *template;
        guint32 i;
 
-       g_assert (!class->generic_class);
-
        mono_loader_lock ();
        template = class_lookup_rgctx_template (class);
        mono_loader_unlock ();
@@ -606,6 +722,8 @@ mono_class_get_runtime_generic_context_template (MonoClass *class)
        if (template)
                return template;
 
+       //g_assert (get_shared_class (class) == class);
+
        template = alloc_template (class);
 
        mono_loader_lock ();
@@ -627,7 +745,7 @@ mono_class_get_runtime_generic_context_template (MonoClass *class)
                                for (i = 0; i < num_entries; ++i) {
                                        MonoRuntimeGenericContextOtherInfoTemplate oti;
 
-                                       oti = class_get_rgctx_template_oti (class->parent, type_argc, i, FALSE, NULL);
+                                       oti = class_get_rgctx_template_oti (class->parent, type_argc, i, FALSE, FALSE, NULL);
                                        if (oti.data && oti.data != MONO_RGCTX_SLOT_USED_MARKER) {
                                                rgctx_template_set_other_slot (class->image, template, type_argc, i,
                                                        oti.data, oti.info_type);
@@ -679,16 +797,16 @@ mono_class_get_runtime_generic_context_template (MonoClass *class)
  * LOCKING: loader lock
  */
 static MonoRuntimeGenericContextOtherInfoTemplate
-class_get_rgctx_template_oti (MonoClass *class, int type_argc, guint32 slot, gboolean temporary, gboolean *do_free)
+class_get_rgctx_template_oti (MonoClass *class, int type_argc, guint32 slot, gboolean temporary, gboolean shared, gboolean *do_free)
 {
        g_assert ((temporary && do_free) || (!temporary && !do_free));
 
-       if (class->generic_class) {
+       if (class->generic_class && !shared) {
                MonoRuntimeGenericContextOtherInfoTemplate oti;
                gboolean tmp_do_free;
 
                oti = class_get_rgctx_template_oti (class->generic_class->container_class,
-                       type_argc, slot, TRUE, &tmp_do_free);
+                                                                                       type_argc, slot, TRUE, FALSE, &tmp_do_free);
                if (oti.data) {
                        gpointer info = oti.data;
                        oti.data = inflate_other_info (&oti, &class->generic_class->context, class, temporary);
@@ -714,14 +832,6 @@ class_get_rgctx_template_oti (MonoClass *class, int type_argc, guint32 slot, gbo
        }
 }
 
-static MonoClass*
-class_uninstantiated (MonoClass *class)
-{
-       if (class->generic_class)
-               return class->generic_class->container_class;
-       return class;
-}
-
 static gpointer
 class_type_info (MonoDomain *domain, MonoClass *class, int info_type)
 {
@@ -840,8 +950,6 @@ fill_in_rgctx_template_slot (MonoClass *class, int type_argc, int index, gpointe
        MonoRuntimeGenericContextTemplate *template = mono_class_get_runtime_generic_context_template (class);
        MonoClass *subclass;
 
-       g_assert (!class->generic_class);
-
        rgctx_template_set_other_slot (class->image, template, type_argc, index, data, info_type);
 
        /* Recurse for all subclasses */
@@ -854,10 +962,9 @@ fill_in_rgctx_template_slot (MonoClass *class, int type_argc, int index, gpointe
                MonoRuntimeGenericContextOtherInfoTemplate subclass_oti;
                MonoRuntimeGenericContextTemplate *subclass_template = class_lookup_rgctx_template (subclass);
 
-               g_assert (!subclass->generic_class);
                g_assert (subclass_template);
 
-               subclass_oti = class_get_rgctx_template_oti (subclass->parent, type_argc, index, FALSE, NULL);
+               subclass_oti = class_get_rgctx_template_oti (subclass->parent, type_argc, index, FALSE, FALSE, NULL);
                g_assert (subclass_oti.data);
 
                fill_in_rgctx_template_slot (subclass, type_argc, index, subclass_oti.data, info_type);
@@ -950,9 +1057,6 @@ lookup_or_register_other_info (MonoClass *class, int type_argc, gpointer data, i
        MonoRuntimeGenericContextOtherInfoTemplate *oti_list, *oti;
        int i;
 
-       g_assert (!class->generic_class);
-       g_assert (class->generic_container || type_argc);
-
        mono_loader_lock ();
 
        oti_list = get_other_info_templates (rgctx_template, type_argc);
@@ -1134,8 +1238,8 @@ fill_runtime_generic_context (MonoVTable *class_vtable, MonoRuntimeGenericContex
 
        mono_domain_unlock (domain);
 
-       oti = class_get_rgctx_template_oti (class_uninstantiated (class),
-                       method_inst ? method_inst->type_argc : 0, slot, TRUE, &do_free);
+       oti = class_get_rgctx_template_oti (get_shared_class (class),
+                                                                               method_inst ? method_inst->type_argc : 0, slot, TRUE, TRUE, &do_free);
        /* This might take the loader lock */
        info = instantiate_other_info (domain, &oti, &context, class);
 
@@ -1289,49 +1393,36 @@ mono_method_lookup_rgctx (MonoVTable *class_vtable, MonoGenericInst *method_inst
        return mrgctx;
 }
 
-static gboolean
-generic_inst_is_sharable (MonoGenericInst *inst, gboolean allow_type_vars)
-{
-       int i;
-
-       for (i = 0; i < inst->type_argc; ++i) {
-               MonoType *type = inst->type_argv [i];
-               int type_type;
-
-               if (MONO_TYPE_IS_REFERENCE (type))
-                       continue;
-
-               type_type = mono_type_get_type (type);
-               if (allow_type_vars && (type_type == MONO_TYPE_VAR || type_type == MONO_TYPE_MVAR))
-                       continue;
-
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
 /*
- * mono_generic_context_is_sharable:
+ * mono_generic_context_is_sharable_full:
  * @context: a generic context
  *
  * Returns whether the generic context is sharable.  A generic context
- * is sharable iff all of its type arguments are reference type.
+ * is sharable iff all of its type arguments are reference type, or some of them have a
+ * reference type, and ALLOW_PARTIAL is TRUE.
  */
 gboolean
-mono_generic_context_is_sharable (MonoGenericContext *context, gboolean allow_type_vars)
+mono_generic_context_is_sharable_full (MonoGenericContext *context,
+                                                                          gboolean allow_type_vars,
+                                                                          gboolean allow_partial)
 {
        g_assert (context->class_inst || context->method_inst);
 
-       if (context->class_inst && !generic_inst_is_sharable (context->class_inst, allow_type_vars))
+       if (context->class_inst && !generic_inst_is_sharable (context->class_inst, allow_type_vars, allow_partial))
                return FALSE;
 
-       if (context->method_inst && !generic_inst_is_sharable (context->method_inst, allow_type_vars))
+       if (context->method_inst && !generic_inst_is_sharable (context->method_inst, allow_type_vars, allow_partial))
                return FALSE;
 
        return TRUE;
 }
 
+gboolean
+mono_generic_context_is_sharable (MonoGenericContext *context, gboolean allow_type_vars)
+{
+       return mono_generic_context_is_sharable_full (context, allow_type_vars, ALLOW_PARTIAL_SHARING);
+}
+
 /*
  * mono_method_is_generic_impl:
  * @method: a method
@@ -1375,16 +1466,18 @@ has_constraints (MonoGenericContainer *container)
 }
 
 /*
- * mono_method_is_generic_sharable_impl:
+ * mono_method_is_generic_sharable_impl_full:
  * @method: a method
  * @allow_type_vars: whether to regard type variables as reference types
+ * @alloc_partial: whether to allow partial sharing
  *
  * Returns TRUE iff the method is inflated or part of an inflated
  * class, its context is sharable and it has no constraints on its
  * type parameters.  Otherwise returns FALSE.
  */
 gboolean
-mono_method_is_generic_sharable_impl (MonoMethod *method, gboolean allow_type_vars)
+mono_method_is_generic_sharable_impl_full (MonoMethod *method, gboolean allow_type_vars,
+                                                                                  gboolean allow_partial)
 {
        if (!mono_method_is_generic_impl (method))
                return FALSE;
@@ -1393,7 +1486,7 @@ mono_method_is_generic_sharable_impl (MonoMethod *method, gboolean allow_type_va
                MonoMethodInflated *inflated = (MonoMethodInflated*)method;
                MonoGenericContext *context = &inflated->context;
 
-               if (!mono_generic_context_is_sharable (context, allow_type_vars))
+               if (!mono_generic_context_is_sharable_full (context, allow_type_vars, allow_partial))
                        return FALSE;
 
                g_assert (inflated->declaring);
@@ -1405,7 +1498,7 @@ mono_method_is_generic_sharable_impl (MonoMethod *method, gboolean allow_type_va
        }
 
        if (method->klass->generic_class) {
-               if (!mono_generic_context_is_sharable (&method->klass->generic_class->context, allow_type_vars))
+               if (!mono_generic_context_is_sharable_full (&method->klass->generic_class->context, allow_type_vars, allow_partial))
                        return FALSE;
 
                g_assert (method->klass->generic_class->container_class &&
@@ -1421,6 +1514,12 @@ mono_method_is_generic_sharable_impl (MonoMethod *method, gboolean allow_type_va
        return TRUE;
 }
 
+gboolean
+mono_method_is_generic_sharable_impl (MonoMethod *method, gboolean allow_type_vars)
+{
+       return mono_method_is_generic_sharable_impl_full (method, allow_type_vars, ALLOW_PARTIAL_SHARING);
+}
+
 gboolean
 mono_method_needs_static_rgctx_invoke (MonoMethod *method, gboolean allow_type_vars)
 {
@@ -1486,46 +1585,6 @@ mono_method_construct_object_context (MonoMethod *method)
        return object_context;
 }
 
-/*
- * mono_domain_lookup_shared_generic:
- * @domain: a domain
- * @open_method: an open generic method
- *
- * Looks up the jit info for method via the domain's jit code hash.
- */
-MonoJitInfo*
-mono_domain_lookup_shared_generic (MonoDomain *domain, MonoMethod *open_method)
-{
-       static gboolean inited = FALSE;
-       static int lookups = 0;
-       static int failed_lookups = 0;
-
-       MonoGenericContext object_context;
-       MonoMethod *object_method;
-       MonoJitInfo *ji;
-
-       object_context = mono_method_construct_object_context (open_method);
-       object_method = mono_class_inflate_generic_method (open_method, &object_context);
-
-       mono_domain_jit_code_hash_lock (domain);
-       ji = mono_internal_hash_table_lookup (&domain->jit_code_hash, object_method);
-       if (ji && !ji->has_generic_jit_info)
-               ji = NULL;
-       mono_domain_jit_code_hash_unlock (domain);
-
-       if (!inited) {
-               mono_counters_register ("Shared generic lookups", MONO_COUNTER_INT|MONO_COUNTER_GENERICS, &lookups);
-               mono_counters_register ("Failed shared generic lookups", MONO_COUNTER_INT|MONO_COUNTER_GENERICS, &failed_lookups);
-               inited = TRUE;
-       }
-
-       ++lookups;
-       if (!ji)
-               ++failed_lookups;
-
-       return ji;
-}
-
 static gboolean gshared_supported;
 
 void
index 5d5cc6e900728e1c9e3429cc5be9193b2e310cdc..6a504588ceaa746eac3893f270649ba55714c15f 100644 (file)
@@ -3007,6 +3007,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        ia64_movl (code, GP_SCRATCH_REG2, 0);
                        ia64_mov_to_br (code, IA64_B6, GP_SCRATCH_REG2);
                        ia64_br_cond_reg (code, IA64_B6);
+                       // FIXME:
+                       //mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                        ia64_codegen_set_one_ins_per_bundle (code, FALSE);
                        break;
                case OP_START_HANDLER: {
@@ -3809,7 +3811,7 @@ mono_arch_emit_prolog (MonoCompile *cfg)
 
        cinfo = get_call_info (cfg, cfg->mempool, sig, FALSE);
 
-       cfg->code_size =  MAX (((MonoMethodNormal *)method)->header->code_size * 4, 512);
+       cfg->code_size =  MAX (cfg->header->code_size * 4, 512);
 
        if (mono_jit_trace_calls != NULL && mono_trace_eval (method))
                cfg->code_size += 1024;
index 8d6f8f1509d372dec71e2f71f4ce74b3a02b66c0..de827e33b96e4cf1990eee0ac3df1461e9c3e9cb 100644 (file)
@@ -3813,6 +3813,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        mips_addiu (code, mips_t9, mips_t9, 0);
                        mips_jalr (code, mips_t9, mips_ra);
                        mips_nop (code);
+                       /*FIXME should it be before the NOP or not? Does MIPS has a delay slot like sparc?*/
+                       mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                        break;
                case OP_LABEL:
                        ins->inst_c0 = code - cfg->native_code;
index 4223529a783629d60de84b102dd2bfb0260915a5..6c962bab95f38d31e8e65deb1a67816919d2108a 100755 (executable)
@@ -752,6 +752,7 @@ is_regsize_var (MonoType *t) {
        return FALSE;
 }
 
+#ifndef DISABLE_JIT
 GList *
 mono_arch_get_allocatable_int_vars (MonoCompile *cfg)
 {
@@ -779,6 +780,7 @@ mono_arch_get_allocatable_int_vars (MonoCompile *cfg)
 
        return vars;
 }
+#endif /* ifndef DISABLE_JIT */
 
 GList *
 mono_arch_get_global_int_regs (MonoCompile *cfg)
@@ -3238,6 +3240,7 @@ emit_unreserve_param_area (MonoCompile *cfg, guint8 *code)
 
 #define MASK_SHIFT_IMM(i)      ((i) & MONO_PPC_32_64_CASE (0x1f, 0x3f))
 
+#ifndef DISABLE_JIT
 void
 mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 {
@@ -4148,6 +4151,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                case OP_CALL_HANDLER: 
                        mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_target_bb);
                        ppc_bl (code, 0);
+                       mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                        break;
                case OP_LABEL:
                        ins->inst_c0 = code - cfg->native_code;
@@ -4653,6 +4657,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 
        cfg->code_len = code - cfg->native_code;
 }
+#endif /* !DISABLE_JIT */
 
 void
 mono_arch_register_lowlevel_calls (void)
@@ -4678,6 +4683,7 @@ mono_arch_register_lowlevel_calls (void)
        } while (0)
 #endif
 
+#ifndef DISABLE_JIT
 void
 mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors)
 {
@@ -5413,6 +5419,7 @@ mono_arch_emit_epilog (MonoCompile *cfg)
        g_assert (cfg->code_len < cfg->code_size);
 
 }
+#endif /* ifndef DISABLE_JIT */
 
 /* remove once throw_exception_by_name is eliminated */
 static int
@@ -5436,6 +5443,7 @@ exception_id_by_name (const char *name)
        return 0;
 }
 
+#ifndef DISABLE_JIT
 void
 mono_arch_emit_exceptions (MonoCompile *cfg)
 {
@@ -5523,7 +5531,7 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
 
                        unsigned char *ip = patch_info->ip.i + cfg->native_code;
                        i = exception_id_by_name (patch_info->data.target);
-                       if (exc_throw_pos [i]) {
+                       if (exc_throw_pos [i] && !(ip > exc_throw_pos [i] && ip - exc_throw_pos [i] > 50000)) {
                                ppc_patch (ip, exc_throw_pos [i]);
                                patch_info->type = MONO_PATCH_INFO_NONE;
                                break;
@@ -5561,6 +5569,7 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
 
        g_assert (cfg->code_len <= cfg->code_size);
 }
+#endif
 
 #if DEAD_CODE
 static int
@@ -5782,26 +5791,26 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
                }
                size += item->chunk_size;
        }
+       /* the initial load of the vtable address */
+       size += PPC_LOAD_SEQUENCE_LENGTH + LOADSTORE_SIZE;
        if (fail_tramp) {
                code = mono_method_alloc_generic_virtual_thunk (domain, size);
        } else {
-               /* the initial load of the vtable address */
-               size += PPC_LOAD_SEQUENCE_LENGTH + LOADSTORE_SIZE;
                code = mono_domain_code_reserve (domain, size);
        }
        start = code;
-       if (!fail_tramp) {
-               /*
-                * We need to save and restore r11 because it might be
-                * used by the caller as the vtable register, so
-                * clobbering it will trip up the magic trampoline.
-                *
-                * FIXME: Get rid of this by making sure that r11 is
-                * not used as the vtable register in interface calls.
-                */
-               ppc_stptr (code, ppc_r11, PPC_RET_ADDR_OFFSET, ppc_sp);
-               ppc_load (code, ppc_r11, (gsize)(& (vtable->vtable [0])));
-       }
+
+       /*
+        * We need to save and restore r11 because it might be
+        * used by the caller as the vtable register, so
+        * clobbering it will trip up the magic trampoline.
+        *
+        * FIXME: Get rid of this by making sure that r11 is
+        * not used as the vtable register in interface calls.
+        */
+       ppc_stptr (code, ppc_r11, PPC_RET_ADDR_OFFSET, ppc_sp);
+       ppc_load (code, ppc_r11, (gsize)(& (vtable->vtable [0])));
+
        for (i = 0; i < count; ++i) {
                MonoIMTCheckItem *item = imt_entries [i];
                item->code_target = code;
index a35c4f527b131fe3935b996fabda0d9161c7b594..3168f5183a607f4dcc089b9b5e8194c1d98bbdd4 100644 (file)
@@ -107,21 +107,18 @@ if (ins->inst_target_bb->native_offset) {                                         \
                 MonoInst *inst;                                                \
                int tmpr = 0;                                                   \
                int sReg, dReg;                                                 \
-               MONO_INST_NEW (cfg, inst, OP_NOP);                                                              \
+               MONO_INST_NEW (cfg, inst, OP_NOP);                              \
                if (size > 256) {                                               \
-                       tmpr = mono_alloc_preg (cfg); \
-                       MONO_EMIT_NEW_ICONST(cfg,tmpr,size);                    \
                        inst->dreg        = dest;                               \
                        inst->inst_offset = offset;                             \
                        inst->sreg1       = src;                                \
                        inst->inst_imm    = imm;                                \
-                       inst->sreg2       = tmpr;                               \
                } else {                                                        \
                        if (s390_is_uimm12(offset)) {                           \
                                inst->dreg        = dest;                       \
                                inst->inst_offset = offset;                     \
                        } else {                                                \
-                               dReg = mono_alloc_preg (cfg); \
+                               dReg = mono_alloc_preg (cfg);                   \
                                MONO_EMIT_NEW_BIALU_IMM(cfg, OP_ADD_IMM,        \
                                        dReg, dest, offset);                    \
                                inst->dreg        = dReg;                       \
@@ -131,16 +128,16 @@ if (ins->inst_target_bb->native_offset) {                                         \
                                inst->sreg1       = src;                        \
                                inst->inst_imm    = imm;                        \
                        } else {                                                \
-                               sReg = mono_alloc_preg (cfg); \
+                               sReg = mono_alloc_preg (cfg);                   \
                                MONO_EMIT_NEW_BIALU_IMM(cfg, OP_ADD_IMM,        \
                                        sReg, src, imm);                        \
                                inst->sreg1       = sReg;                       \
                                inst->inst_imm    = 0;                          \
                        }                                                       \
                }                                                               \
-                inst->opcode     = OP_S390_MOVE;                               \
-               inst->backend.size        = size;                                       \
-        MONO_ADD_INS (cfg->cbb, inst); \
+                inst->opcode           = OP_S390_MOVE;                         \
+               inst->backend.size      = size;                                 \
+        MONO_ADD_INS (cfg->cbb, inst);                                                 \
        } while (0)
 
 #define MONO_OUTPUT_VTR(cfg, size, dr, sr, so) do {                            \
@@ -3778,6 +3775,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        mono_add_patch_info (cfg, code-cfg->native_code, 
                                             MONO_PATCH_INFO_BB, ins->inst_target_bb);
                        s390_brasl (code, s390_r14, 0);
+                       mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                }
                        break;
                case OP_LABEL: {
@@ -4193,34 +4191,39 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                                        s390_mvc  (code, ins->backend.size, ins->dreg, 
                                                   ins->inst_offset, ins->sreg1, ins->inst_imm);
                                } else {
-                                       s390_lr   (code, s390_r0, ins->dreg);
+                                       s390_lr  (code, s390_r0, ins->dreg);
                                        if (s390_is_imm16 (ins->inst_offset)) {
                                                s390_ahi  (code, s390_r0, ins->inst_offset);
                                        } else {
                                                s390_basr (code, s390_r13, 0);
-                                               s390_j    (code, 4);
-                                               s390_word (code, ins->inst_offset);
+                                               s390_j    (code, 6);
+                                               s390_long (code, ins->inst_offset);
                                                s390_a    (code, s390_r0, 0, s390_r13, 4);
                                        }
-                                       s390_lr   (code, s390_r14, s390_r12);
-                                       s390_lr   (code, s390_r12, ins->sreg1);
+                                       s390_lr  (code, s390_r12, ins->sreg1);
                                        if (s390_is_imm16 (ins->inst_imm)) {
                                                s390_ahi  (code, s390_r12, ins->inst_imm);
                                        } else {
                                                s390_basr (code, s390_r13, 0);
-                                               s390_j    (code, 4);
-                                               s390_word (code, ins->inst_imm);
+                                               s390_j    (code, 6);
+                                               s390_long (code, ins->inst_imm);
                                                s390_a    (code, s390_r12, 0, s390_r13, 4);
                                        }
-                                       s390_lr   (code, s390_r1, ins->sreg1);
+                                       if (s390_is_imm16 (ins->backend.size)) {
+                                               s390x_lhi (code, s390_r1, ins->backend.size);
+                                       } else {
+                                               s390_basr (code, s390_r13, 0);
+                                               s390_j    (code, 6);
+                                               s390_long (code, ins->backend.size);
+                                               s390_l    (code, s390_r1, 0, s390_r13, 4);
+                                       }
+                                       s390_lr   (code, s390_r1, ins->backend.size);
                                        s390_lr   (code, s390_r13, s390_r1);
                                        s390_mvcle(code, s390_r0, s390_r12, 0, 0);
                                        s390_jo   (code, -2);
-                                       s390_lr   (code, s390_r12, s390_r14);
                                }
                        }
                }
-                       break;
                case OP_ATOMIC_ADD_I4: {
                        s390_lr  (code, s390_r1, ins->sreg2);
                        s390_l   (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
index bfdfdefdc388994430ae58bdf5d917d31605f31a..b3526a659fb8cb8d9da84fd08064b209e3d15cf4 100644 (file)
 /*                 D e f i n e s                                    */
 /*------------------------------------------------------------------*/
 
-#define EMIT_COND_BRANCH(ins,cond)                                                     \
-{                                                                                      \
+#define MAX_ARCH_DELEGATE_PARAMS 7
+
+#define EMIT_COND_BRANCH(ins,cond)                                             \
+{                                                                              \
 if (ins->inst_true_bb->native_offset) {                                        \
        int displace;                                                           \
        displace = ((cfg->native_code +                                         \
@@ -36,8 +38,8 @@ if (ins->inst_true_bb->native_offset) {                                       \
 }                                                                              \
 }
 
-#define EMIT_UNCOND_BRANCH(ins)                                                        \
-{                                                                                      \
+#define EMIT_UNCOND_BRANCH(ins)                                                \
+{                                                                              \
 if (ins->inst_target_bb->native_offset) {                                      \
        int displace;                                                           \
        displace = ((cfg->native_code +                                         \
@@ -126,23 +128,19 @@ if (ins->inst_target_bb->native_offset) {                                         \
 
 #define MONO_EMIT_NEW_MOVE(cfg,dest,offset,src,imm,size) do {                  \
                 MonoInst *inst;                                                \
-               int tmpr = 0;                                                   \
                int sReg, dReg;                                                 \
-               MONO_INST_NEW (cfg, inst, OP_NOP);                                                              \
+               MONO_INST_NEW (cfg, inst, OP_NOP);                              \
                if (size > 256) {                                               \
-                       tmpr = mono_alloc_preg (cfg); \
-                       MONO_EMIT_NEW_ICONST(cfg,tmpr,size);                    \
                        inst->dreg        = dest;                               \
                        inst->inst_offset = offset;                             \
                        inst->sreg1       = src;                                \
                        inst->inst_imm    = imm;                                \
-                       inst->sreg2       = tmpr;                               \
                } else {                                                        \
                        if (s390_is_uimm12(offset)) {                           \
                                inst->dreg        = dest;                       \
                                inst->inst_offset = offset;                     \
                        } else {                                                \
-                               dReg = mono_alloc_preg (cfg); \
+                               dReg = mono_alloc_preg (cfg);                   \
                                MONO_EMIT_NEW_BIALU_IMM(cfg, OP_ADD_IMM,        \
                                        dReg, dest, offset);                    \
                                inst->dreg        = dReg;                       \
@@ -152,16 +150,16 @@ if (ins->inst_target_bb->native_offset) {                                         \
                                inst->sreg1       = src;                        \
                                inst->inst_imm    = imm;                        \
                        } else {                                                \
-                               sReg = mono_alloc_preg (cfg); \
+                               sReg = mono_alloc_preg (cfg);                   \
                                MONO_EMIT_NEW_BIALU_IMM(cfg, OP_ADD_IMM,        \
                                        sReg, src, imm);                        \
                                inst->sreg1       = sReg;                       \
                                inst->inst_imm    = 0;                          \
                        }                                                       \
                }                                                               \
-                inst->opcode     = OP_S390_MOVE;                               \
-               inst->backend.size        = size;                                       \
-        MONO_ADD_INS (cfg->cbb, inst); \
+                inst->opcode           = OP_S390_MOVE;                         \
+               inst->backend.size      = size;                                 \
+        MONO_ADD_INS (cfg->cbb, inst);                                         \
        } while (0)
 
 #define MONO_OUTPUT_VTR(cfg, size, dr, sr, so) do {                            \
@@ -187,7 +185,7 @@ if (ins->inst_target_bb->native_offset) {                                   \
                                reg, sr, so);                                   \
                break;                                                          \
        }                                                                       \
-       mono_call_inst_add_outarg_reg(cfg, call, reg, dr, FALSE);       \
+       mono_call_inst_add_outarg_reg(cfg, call, reg, dr, FALSE);               \
 } while (0)
 
 #define MONO_OUTPUT_VTS(cfg, size, dr, dx, sr, so) do {                                \
@@ -207,14 +205,14 @@ if (ins->inst_target_bb->native_offset) {                                         \
                                dr, dx, tmpr);                                  \
                break;                                                          \
                case 2:                                                         \
-                       tmpr = mono_alloc_preg (cfg); \
+                       tmpr = mono_alloc_preg (cfg);                           \
                        MONO_EMIT_NEW_LOAD_MEMBASE_OP(cfg, OP_LOADU2_MEMBASE,   \
                                tmpr, sr, so);                                  \
                        MONO_EMIT_NEW_STORE_MEMBASE(cfg, OP_STORE_MEMBASE_REG,  \
                                dr, dx, tmpr);                                  \
                break;                                                          \
                case 4:                                                         \
-                       tmpr = mono_alloc_preg (cfg);   \
+                       tmpr = mono_alloc_preg (cfg);                           \
                        MONO_EMIT_NEW_LOAD_MEMBASE_OP(cfg, OP_LOADI4_MEMBASE,   \
                                tmpr, sr, so);                                  \
                        MONO_EMIT_NEW_STORE_MEMBASE(cfg, OP_STORE_MEMBASE_REG,  \
@@ -235,6 +233,16 @@ if (ins->inst_target_bb->native_offset) {                                  \
 
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 
+/*
+ * imt thunking size values
+ */
+#define CMP_SIZE       24
+#define LOADCON_SIZE   20
+#define LOAD_SIZE      6
+#define BR_SIZE                2
+#define JUMP_SIZE      6
+#define ENABLE_WRONG_METHOD_CHECK 0
+
 /*========================= End of Defines =========================*/
 
 /*------------------------------------------------------------------*/
@@ -370,6 +378,8 @@ pthread_key_t lmf_addr_key;
 
 gboolean lmf_addr_key_inited = FALSE; 
 
+facilityList_t facs;
+
 #if 0
 
 extern __thread MonoDomain *tls_appdomain;
@@ -1136,23 +1146,51 @@ mono_arch_cpu_init (void)
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_init.                                   */
+/*                                                                  */
+/* Function    - Initialize architecture specific code.            */
+/*                                                                 */
+/*------------------------------------------------------------------*/
 
-/*
- * Initialize architecture specific code.
- */
 void
 mono_arch_init (void)
 {
+#if 0
+       /*
+        * When we do an architectural level set at z9 or better 
+        * we can use the STFLE instruction to show us
+        * what hardware facilities are available
+        */
+       int lFacility = sizeof(facs) % 8;
+
+       memset((char *) &facs, 0, sizeof(facs));
+
+       __asm__ ("      lgfr    0,%1\n"
+                "      stfle   %0\n"
+                : "=m" (facs) : "r" (lFacility) : "0", "cc");
+#endif
+
 }
 
-/*
- * Cleanup architecture specific code.
- */
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_cleanup.                                */
+/*                                                                  */
+/* Function    - Cleanup architecture specific code    .           */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
 void
 mono_arch_cleanup (void)
 {
 }
 
+/*========================= End of Function ========================*/
+
 /*------------------------------------------------------------------*/
 /*                                                                  */
 /* Name                - mono_arch_cpu_optimizazions                       */
@@ -1309,7 +1347,8 @@ mono_arch_flush_icache (guint8 *code, gint size)
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
-static void inline
+// static void inline
+static void 
 add_general (guint *gr, size_data *sz, ArgInfo *ainfo)
 {
        if (*gr > S390_LAST_ARG_REG) {
@@ -1398,7 +1437,7 @@ add_float (guint *fr,  size_data *sz, ArgInfo *ainfo)
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - get_call_info                                   */
+/* Name                - get_call_info                                     */
 /*                                                                  */
 /* Function    - Determine the amount of space required for code   */
 /*               and stack. In addition determine starting points  */
@@ -1522,6 +1561,13 @@ enum_retvalue:
                nParm++;
        }
 
+       if ((sig->call_convention == MONO_CALL_VARARG) && (sig->param_count == 0)) {
+               gr = S390_LAST_ARG_REG + 1;
+
+               /* Emit the signature cookie just before the implicit arguments */
+               add_general (&gr, sz, &cinfo->sigCookie);
+       }
+
        /*----------------------------------------------------------*/
        /* We determine the size of the parameter code and stack    */
        /* requirements by checking the types and sizes of the      */
@@ -1702,6 +1748,8 @@ enum_retvalue:
        /* Handle the case where there are no implicit arguments    */
        /*----------------------------------------------------------*/
        if ((sig->call_convention == MONO_CALL_VARARG) &&
+           (nParm > 0) &&
+           (!sig->pinvoke) &&
            (sig->param_count == sig->sentinelpos)) {
                gr = S390_LAST_ARG_REG + 1;
                add_general (&gr, sz, &cinfo->sigCookie);
@@ -1804,7 +1852,11 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        /* to point at the local variables.                             */
        /* add parameter area size for called functions                 */
        /*--------------------------------------------------------------*/
-       offset          = (cfg->param_area + S390_MINIMAL_STACK_SIZE);
+       if (cfg->param_area == 0)
+               offset = S390_MINIMAL_STACK_SIZE;
+       else
+               offset = cfg->param_area;
+
        cfg->sig_cookie = 0;
 
        if (cinfo->struct_ret) {
@@ -1935,9 +1987,9 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                        continue;
 
                /*--------------------------------------------------*/
-               /* inst->backend.is_pinvoke indicates native sized value types, */
-               /* this is used by the pinvoke wrappers when they   */
-               /* call functions returning structure               */
+               /* inst->backend.is_pinvoke indicates native sized  */
+               /* value typs this is used by the pinvoke wrappers  */
+               /* when they call functions returning structure     */
                /*--------------------------------------------------*/
                if (inst->backend.is_pinvoke && MONO_TYPE_ISSTRUCT (inst->inst_vtype))
                        size = mono_class_native_size (mono_class_from_mono_type(inst->inst_vtype), 
@@ -1971,13 +2023,25 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        /*------------------------------------------------------*/
        cfg->stack_offset = S390_ALIGN(offset, S390_STACK_ALIGNMENT);
 
+       /*------------------------------------------------------*/
+       /* Fix offsets for args whose value is in parent frame  */
+       /*------------------------------------------------------*/
+       for (iParm = sArg; iParm < eArg; ++iParm) {
+               inst = cfg->args [iParm];
+
+               if (inst->opcode == OP_S390_STKARG) {
+                       inst->opcode = OP_REGOFFSET;
+                       inst->inst_offset += cfg->stack_offset;
+               }
+       }
 }
 
 /*========================= End of Function ========================*/
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_create_vars                                 */
+/* Name                - mono_arch_create_vars                             */
+/*                                                                  */
 /*------------------------------------------------------------------*/
 
 void
@@ -2001,6 +2065,12 @@ mono_arch_create_vars (MonoCompile *cfg)
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - add_outarg_reg2.                                  */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
 static void
 add_outarg_reg2 (MonoCompile *cfg, MonoCallInst *call, ArgStorage storage, int reg, MonoInst *tree)
 {
@@ -2033,6 +2103,14 @@ add_outarg_reg2 (MonoCompile *cfg, MonoCallInst *call, ArgStorage storage, int r
        }
 }
 
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - emit_sig_cookie.                                  */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
 static void
 emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo)
 {
@@ -2061,12 +2139,14 @@ emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo)
        MONO_ADD_INS (cfg->cbb, sig_arg);
 
        MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, STK_BASE, 
-                                                                cinfo->sigCookie.offset, sig_arg->dreg);
+                                    cinfo->sigCookie.offset, sig_arg->dreg);
 }
 
+/*========================= End of Function ========================*/
+
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_emit_call                                   */
+/* Name                - mono_arch_emit_call                               */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
@@ -2079,7 +2159,9 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
        int i, n, lParamArea;
        CallInfo *cinfo;
        ArgInfo *ainfo = NULL;
-       int stackSize;
+       int stackSize;    
+       MonoMethodHeader *header;
+       int frmReg;
 
        sig = call->signature;
        n = sig->param_count + sig->hasthis;
@@ -2087,7 +2169,8 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
        
        cinfo = get_call_info (cfg, cfg->mempool, sig, sig->pinvoke);
 
-       stackSize         = cinfo->sz.stack_size + cinfo->sz.local_size + cinfo->sz.parm_size + cinfo->sz.offset;
+       stackSize         = cinfo->sz.stack_size + cinfo->sz.local_size + 
+                           cinfo->sz.parm_size + cinfo->sz.offset;
        call->stack_usage = MAX(stackSize, call->stack_usage);
        lParamArea        = MAX((call->stack_usage-S390_MINIMAL_STACK_SIZE-cinfo->sz.parm_size), 0);
        cfg->param_area   = MAX(((signed) cfg->param_area), lParamArea);
@@ -2101,6 +2184,12 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, cinfo->ret.reg, FALSE);
        }
 
+       header = mono_method_get_header (cfg->method);
+       if ((cfg->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
+               frmReg = s390_r11;
+       else
+               frmReg = STK_BASE;
+
        for (i = 0; i < n; ++i) {
                MonoType *t;
 
@@ -2114,6 +2203,7 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                in = call->args [i];
 
                if ((sig->call_convention == MONO_CALL_VARARG) &&
+                   (!sig->pinvoke) &&
                    (i == sig->sentinelpos)) {
                        emit_sig_cookie (cfg, call, cinfo);
                }
@@ -2178,33 +2268,34 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                                 */
                                int treg = mono_alloc_preg (cfg);
                                MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ADD_IMM, treg, 
-                                                                                STK_BASE, ainfo->offparm);
+                                                        frmReg, ainfo->offparm);
                                mono_call_inst_add_outarg_reg (cfg, call, treg, ainfo->reg, FALSE);
                        } else if (ainfo->regtype == RegTypeStructByAddrOnStack) {
                                /* The address of the valuetype is passed on the stack */
                                int treg = mono_alloc_preg (cfg);
                                MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ADD_IMM, treg, 
-                                                                                STK_BASE, ainfo->offparm);
+                                                        frmReg, ainfo->offparm);
                                MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG,
-                                                                                        ainfo->reg, ainfo->offset, treg);
+                                                            ainfo->reg, ainfo->offset, treg);
                        }
                        break;
                }
                case RegTypeBase:
                        if (!t->byref && t->type == MONO_TYPE_R4) {
                                MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER4_MEMBASE_REG, 
-                                                                                        STK_BASE, ainfo->offset + 4,
-                                                                                        in->dreg);
+                                                            STK_BASE, ainfo->offset + 4,
+                                                            in->dreg);
                        } else if (!t->byref && (t->type == MONO_TYPE_R8)) {
                                MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER8_MEMBASE_REG, 
-                                                                                        STK_BASE, ainfo->offset,
-                                                                                        in->dreg);
+                                                            STK_BASE, ainfo->offset,
+                                                            in->dreg);
                        } else {
                                MONO_INST_NEW (cfg, ins, OP_STORE_MEMBASE_REG);
                                ins->inst_destbasereg = STK_BASE;
                                ins->inst_offset = ainfo->offset;
                                ins->sreg1 = in->dreg;
 
+#if 0
                                /* This is needed by MonoTypedRef->value to point to the correct data */
                                if ((sig->call_convention == MONO_CALL_VARARG) &&
                                        (i >= sig->sentinelpos)) {
@@ -2222,6 +2313,7 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                                                break;
                                        }
                                }
+#endif
 
                                MONO_ADD_INS (cfg->cbb, ins);
                        }
@@ -2236,6 +2328,7 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
         * Handle the case where there are no implicit arguments 
         */
        if ((sig->call_convention == MONO_CALL_VARARG) &&
+           (!sig->pinvoke) &&
            (i == sig->sentinelpos)) {
                emit_sig_cookie (cfg, call, cinfo);
        }
@@ -2245,7 +2338,7 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_emit_outarg_vt                              */
+/* Name                - mono_arch_emit_outarg_vt                          */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
@@ -2284,14 +2377,25 @@ mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src)
 
                mono_call_inst_add_outarg_reg (cfg, call, dreg, ainfo->reg, TRUE);
        } else {
-               MONO_EMIT_NEW_MOVE (cfg, STK_BASE, ainfo->offparm,
+               MonoMethodHeader *header;
+               int srcReg;
+
+               header = mono_method_get_header (cfg->method);
+               if ((cfg->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
+                       srcReg = s390_r11;
+               else
+                       srcReg = STK_BASE;
+
+               MONO_EMIT_NEW_MOVE (cfg, srcReg, ainfo->offparm,
                                                         src->dreg, 0, size);
        }
 }
 
+/*========================= End of Function ========================*/
+
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_emit_setret                                 */
+/* Name                - mono_arch_emit_setret                             */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
@@ -2521,14 +2625,25 @@ handle_enum:
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_peephole_pass_1                         */
+/*                                                                  */
+/* Function    - Form a peephole pass at the code looking for      */
+/*               simple optimizations.                             */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
 void
 mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
 }
 
+/*========================= End of Function ========================*/
+
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_peephole_pass                                     */
+/* Name                - mono_arch_peephole_pass_2                         */
 /*                                                                  */
 /* Function    - Form a peephole pass at the code looking for      */
 /*               simple optimizations.                             */
@@ -2547,6 +2662,12 @@ mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_lowering_pass.                          */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
 void
 mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
 {
@@ -3885,8 +4006,15 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;
                case OP_LOCALLOC: {
-                       int alloca_skip = S390_MINIMAL_STACK_SIZE + cfg->param_area;
-                       int area_offset = S390_ALIGN(alloca_skip, S390_STACK_ALIGNMENT);
+                       int alloca_skip;
+                       int area_offset;
+
+                       if (cfg->param_area == 0)
+                               alloca_skip = S390_MINIMAL_STACK_SIZE;
+                       else
+                               alloca_skip = cfg->param_area;
+
+                       area_offset = S390_ALIGN(alloca_skip, S390_STACK_ALIGNMENT);
                        s390_lgr  (code, s390_r1, ins->sreg1);
                        if (ins->flags & MONO_INST_INIT)
                                s390_lgr  (code, s390_r0, ins->sreg1);
@@ -3984,6 +4112,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        mono_add_patch_info (cfg, code-cfg->native_code, 
                                             MONO_PATCH_INFO_BB, ins->inst_target_bb);
                        s390_brasl (code, s390_r14, 0);
+                       mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                }
                        break;
                case OP_LABEL: {
@@ -4396,24 +4525,35 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                                                   ins->inst_offset, ins->sreg1, ins->inst_imm);
                                } else {
                                        s390_lgr  (code, s390_r0, ins->dreg);
-                                       if (s390_is_imm16 (ins->inst_offset)) {
-                                               s390_aghi (code, s390_r0, ins->inst_offset);
-                                       } else {
-                                               s390_basr (code, s390_r13, 0);
-                                               s390_j    (code, 6);
-                                               s390_llong(code, ins->inst_offset);
-                                               s390_a    (code, s390_r0, 0, s390_r13, 4);
+                                       if (ins->inst_offset > 0) {
+                                               if (s390_is_imm16 (ins->inst_offset)) {
+                                                       s390_aghi (code, s390_r0, ins->inst_offset);
+                                               } else {
+                                                       s390_basr (code, s390_r13, 0);
+                                                       s390_j    (code, 6);
+                                                       s390_llong(code, ins->inst_offset);
+                                                       s390_ag   (code, s390_r0, 0, s390_r13, 4);
+                                               }
                                        }
                                        s390_lgr  (code, s390_r12, ins->sreg1);
-                                       if (s390_is_imm16 (ins->inst_imm)) {
-                                               s390_aghi (code, s390_r12, ins->inst_imm);
+                                       if (ins->inst_imm > 0) {
+                                               if (s390_is_imm16 (ins->inst_imm)) {
+                                                       s390_aghi (code, s390_r12, ins->inst_imm);
+                                               } else {
+                                                       s390_basr (code, s390_r13, 0);
+                                                       s390_j    (code, 6);
+                                                       s390_llong(code, ins->inst_imm);
+                                                       s390_ag   (code, s390_r12, 0, s390_r13, 4);
+                                               }
+                                       }
+                                       if (s390_is_imm16 (ins->backend.size)) {
+                                               s390_lghi (code, s390_r1, ins->backend.size);
                                        } else {
                                                s390_basr (code, s390_r13, 0);
                                                s390_j    (code, 6);
-                                               s390_llong(code, ins->inst_imm);
-                                               s390_ag   (code, s390_r12, 0, s390_r13, 4);
+                                               s390_llong(code, ins->backend.size);
+                                               s390_lg   (code, s390_r1, 0, s390_r13, 4);
                                        }
-                                       s390_lgr  (code, s390_r1, ins->sreg1);
                                        s390_lgr  (code, s390_r13, s390_r1);
                                        s390_mvcle(code, s390_r0, s390_r12, 0, 0);
                                        s390_jo   (code, -2);
@@ -4903,13 +5043,13 @@ mono_arch_emit_prolog (MonoCompile *cfg)
                /*---------------------------------------------------------------*/
                /* On return from this call r2 have the address of the &lmf      */
                /*---------------------------------------------------------------*/
-               s390_basr(code, s390_r10, 0);
+               s390_basr(code, s390_r14, 0);
                s390_j   (code, 6);
                mono_add_patch_info (cfg, code - cfg->native_code, 
                                     MONO_PATCH_INFO_INTERNAL_METHOD, 
                                     (gpointer)"mono_get_lmf_addr");
                s390_llong(code, 0);
-               s390_lg   (code, s390_r1, 0, s390_r10, 4);
+               s390_lg   (code, s390_r1, 0, s390_r14, 4);
                s390_basr (code, s390_r14, s390_r1);
 
                /*---------------------------------------------------------------*/     
@@ -5114,7 +5254,8 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
                                /*---------------------------------------------*/
                                s390_basr (code, s390_r13, 0);
                                s390_j    (code, 6);
-                               s390_llong(code, patch_info->data.target);
+//                             s390_llong(code, patch_info->data.target);
+                               s390_llong(code, exc_class->type_token);
                                /*---------------------------------------------*/
                                /* Load return address & parameter register    */
                                /*---------------------------------------------*/
@@ -5127,7 +5268,7 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
                                s390_basr (code, s390_r13, 0);
                                s390_j    (code, 6);
                                patch_info->type      = MONO_PATCH_INFO_INTERNAL_METHOD;
-                               patch_info->data.name = "mono_arch_throw_exception_by_name";
+                               patch_info->data.name = "mono_arch_throw_corlib_exception";
                                patch_info->ip.i      = code - cfg->native_code;
                                s390_llong(code, 0);
                                s390_lg   (code, s390_r1, 0, s390_r13, 4);
@@ -5468,3 +5609,366 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
 }
 
 /*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_get_this_arg_from_call.                 */
+/*                                                                  */
+/* Function    -                                                   */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
+gpointer
+mono_arch_get_this_arg_from_call (MonoGenericSharingContext *gsctx, MonoMethodSignature *sig, mgreg_t *regs, guint8 *code)
+{
+       MonoLMF *lmf = (MonoLMF *) ((gchar *) regs - sizeof(MonoLMF));
+
+       /* FIXME: handle returning a struct */
+       if (MONO_TYPE_ISSTRUCT (sig->ret))
+               return (gpointer) lmf->gregs [s390_r3];
+       return (gpointer) lmf->gregs [s390_r2];
+}
+
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - get_delegate_invoke_impl.                         */
+/*                                                                  */
+/* Function    -                                                   */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
+static gpointer
+get_delegate_invoke_impl (gboolean has_target, guint32 param_count, guint32 *code_len, gboolean aot)
+{
+       guint8 *code, *start;
+
+       if (has_target) {
+               int size = 32;
+
+               start = code = mono_global_codeman_reserve (size);
+
+               /* Replace the this argument with the target */
+               s390_lg   (code, s390_r1, 0, s390_r2, G_STRUCT_OFFSET(MonoDelegate, method_ptr));
+               s390_lg   (code, s390_r2, 0, s390_r2, G_STRUCT_OFFSET(MonoDelegate, target));
+               s390_br   (code, s390_r1);
+               g_assert ((code - start) <= size);
+
+               mono_arch_flush_icache (start, size);
+       } else {
+               int size, i;
+
+               size = 32 + param_count * 8;
+               start = code = mono_global_codeman_reserve (size);
+
+               s390_lg   (code, s390_r1, 0, s390_r2, G_STRUCT_OFFSET(MonoDelegate, method_ptr));
+               /* slide down the arguments */
+               for (i = 0; i < param_count; ++i) {
+                       s390_lgr (code, (s390_r2 + i), (s390_r2 + i + 1));
+               }
+               s390_br   (code, s390_r1);
+
+               g_assert ((code - start) <= size);
+
+               mono_arch_flush_icache (start, size);
+       }
+
+       if (code_len)
+               *code_len = code - start;
+
+       return start;
+}
+
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_get_delegate_invoke_impls.              */
+/*                                                                  */
+/* Function    -                                                   */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
+GSList*
+mono_arch_get_delegate_invoke_impls (void)
+{
+       GSList *res = NULL;
+       guint8 *code;
+       guint32 code_len;
+       int i;
+
+       code = get_delegate_invoke_impl (TRUE, 0, &code_len, TRUE);
+       res = g_slist_prepend (res, mono_aot_tramp_info_create (g_strdup ("delegate_invoke_impl_has_target"), code, code_len));
+
+       for (i = 0; i < MAX_ARCH_DELEGATE_PARAMS; ++i) {
+               code = get_delegate_invoke_impl (FALSE, i, &code_len, TRUE);
+               res = g_slist_prepend (res, mono_aot_tramp_info_create (g_strdup_printf ("delegate_invoke_impl_target_%d", i), code, code_len));
+       }
+
+       return res;
+}
+
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_get_delegate_invoke_impl.               */
+/*                                                                  */
+/* Function    -                                                   */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
+gpointer
+mono_arch_get_delegate_invoke_impl (MonoMethodSignature *sig, gboolean has_target)
+{
+       guint8 *code, *start;
+
+       /* FIXME: Support more cases */
+       if (MONO_TYPE_ISSTRUCT (sig->ret))
+               return NULL;
+
+       if (has_target) {
+               static guint8* cached = NULL;
+
+               if (cached)
+                       return cached;
+
+               if (mono_aot_only)
+                       start = mono_aot_get_named_code ("delegate_invoke_impl_has_target");
+               else
+                       start = get_delegate_invoke_impl (TRUE, 0, NULL, FALSE);
+
+               mono_memory_barrier ();
+
+               cached = start;
+       } else {
+               static guint8* cache [MAX_ARCH_DELEGATE_PARAMS + 1] = {NULL};
+               int i;
+
+               if (sig->param_count > MAX_ARCH_DELEGATE_PARAMS)
+                       return NULL;
+               for (i = 0; i < sig->param_count; ++i)
+                       if (!mono_is_regsize_var (sig->params [i]))
+                               return NULL;
+
+
+               code = cache [sig->param_count];
+               if (code)
+                       return code;
+
+               if (mono_aot_only) {
+                       char *name = g_strdup_printf ("delegate_invoke_impl_target_%d", sig->param_count);
+                       start = mono_aot_get_named_code (name);
+                       g_free (name);
+               } else {
+                       start = get_delegate_invoke_impl (FALSE, sig->param_count, NULL, FALSE);
+               }
+
+               mono_memory_barrier ();
+
+               cache [sig->param_count] = start;
+       }
+       return start;
+}
+
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_build_imt_thunk.                        */
+/*                                                                  */
+/* Function    -                                                   */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
+gpointer
+mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, 
+                          MonoIMTCheckItem **imt_entries, int count,
+                          gpointer fail_tramp)
+{
+       int i;
+       int size = 0;
+       guchar *code, *start;
+
+       for (i = 0; i < count; ++i) {
+               MonoIMTCheckItem *item = imt_entries [i];
+               if (item->is_equals) {
+                       if (item->check_target_idx) {
+                               if (!item->compare_done)
+                                       item->chunk_size += CMP_SIZE + JUMP_SIZE;
+                               if (item->has_target_code)
+                                       item->chunk_size += BR_SIZE + JUMP_SIZE + LOADCON_SIZE;
+                               else
+                                       item->chunk_size += BR_SIZE + JUMP_SIZE + LOADCON_SIZE + 
+                                                           LOAD_SIZE;
+                       } else {
+                               if (fail_tramp) {
+                                       item->chunk_size += CMP_SIZE + 2 * BR_SIZE + JUMP_SIZE + 
+                                                           2 * LOADCON_SIZE;
+                                       if (!item->has_target_code)
+                                               item->chunk_size += LOAD_SIZE;
+                               } else {
+                                       item->chunk_size += LOADCON_SIZE + LOAD_SIZE + BR_SIZE;
+#if ENABLE_WRONG_METHOD_CHECK
+                                       item->chunk_size += CMP_SIZE + JUMP_SIZE;
+#endif
+                               }
+                       }
+               } else {
+                       item->chunk_size += CMP_SIZE + JUMP_SIZE;
+                       imt_entries [item->check_target_idx]->compare_done = TRUE;
+               }
+               size += item->chunk_size;
+       }
+
+       if (fail_tramp)
+               code = mono_method_alloc_generic_virtual_thunk (domain, size);
+       else
+               code = mono_domain_code_reserve (domain, size);
+
+       start = code;
+
+       for (i = 0; i < count; ++i) {
+               MonoIMTCheckItem *item = imt_entries [i];
+               item->code_target = (guint8 *) code;
+               if (item->is_equals) {
+                       if (item->check_target_idx) {
+                               if (!item->compare_done) {
+                                       s390_basr (code, s390_r13, s390_r0);
+                                       s390_j    (code, 6);
+                                       s390_llong(code, item->key);
+                                       s390_lg   (code, s390_r0, 0, s390_r13, 4);
+                                       s390_cgr  (code, s390_r0, MONO_ARCH_IMT_REG);
+                               }
+                               item->jmp_code = (guint8*) code;
+                               s390_jcl (code, S390_CC_NE, 0);
+                               
+                               s390_basr (code, s390_r13, s390_r0);
+                               s390_j    (code, 6);
+                               if (item->has_target_code)  {
+                                       s390_llong(code, item->value.target_code);
+                                       s390_lg   (code, s390_r1, 0, s390_r13, 4);
+                               } else {        
+                                       s390_llong(code, (&(vtable->vtable [item->value.vtable_slot])));
+                                       s390_lg   (code, s390_r1, 0, s390_r13, 4);
+                                       s390_lg   (code, s390_r1, 0, s390_r1, 0);
+                               }
+                               s390_br   (code, s390_r1);
+                       } else {
+                               if (fail_tramp) {
+                                       gint64  target;
+
+                                       s390_basr (code, s390_r13, s390_r0);
+                                       s390_j    (code, 6);
+                                       s390_llong(code, item->key);
+                                       s390_lg   (code, s390_r0, 0, s390_r13, 4);
+                                       s390_cgr  (code, s390_r0, MONO_ARCH_IMT_REG);
+                                       item->jmp_code = (guint8*) code;
+                                       s390_jcl  (code, S390_CC_NE, 0);
+                                       s390_basr (code, s390_r13, s390_r0);
+                                       s390_j    (code, 6);
+                                       if (item->has_target_code) {
+                                               s390_llong(code, item->value.target_code);
+                                               s390_lg   (code, s390_r1, 0, s390_r13, 4);
+                                       } else {
+                                               g_assert (vtable);
+                                               s390_llong(code, (&(vtable->vtable [item->value.vtable_slot])));
+                                               s390_lg   (code, s390_r1, 0, s390_r13, 4);
+                                               s390_lg   (code, s390_r1, 0, s390_r1, 0);
+                                       }
+                                       s390_br   (code, s390_r1);
+                                       target = S390_RELATIVE(item->jmp_code, code);
+                                       s390_patch_rel(item->jmp_code+2, target);
+                                       s390_basr (code, s390_r13, s390_r0);
+                                       s390_j    (code, 6);
+                                       s390_llong(code, fail_tramp);
+                                       s390_lg   (code, s390_r1, 0, s390_r13, 4);
+                                       s390_br   (code, s390_r1);
+                                       item->jmp_code = NULL;
+                               } else {
+                               /* enable the commented code to assert on wrong method */
+#if ENABLE_WRONG_METHOD_CHECK
+                                       g_assert_not_reached ();
+#endif
+                                       s390_basr (code, s390_r13, s390_r0);
+                                       s390_j    (code, 6);
+                                       s390_llong(code, (&(vtable->vtable [item->value.vtable_slot])));
+                                       s390_lg   (code, s390_r1, 0, s390_r13, 4);
+                                       s390_lg   (code, s390_r1, 0, s390_r1, 0);
+                                       s390_br   (code, s390_r1);
+#if ENABLE_WRONG_METHOD_CHECK
+                                       g_assert_not_reached ();
+#endif
+                               }
+                       }
+               } else {
+                       s390_basr (code, s390_r13, s390_r0);
+                       s390_j    (code, 6);
+                       s390_llong(code, item->key);
+                       s390_lg   (code, s390_r0, 0, s390_r13, 4);
+                       s390_cgr  (code, MONO_ARCH_IMT_REG, s390_r0);
+                       item->jmp_code = (guint8 *) code;
+                       s390_jcl  (code, S390_CC_GE, 0);
+               }
+       }
+       /* patch the branches to get to the target items */
+       for (i = 0; i < count; ++i) {
+               MonoIMTCheckItem *item = imt_entries [i];
+               if (item->jmp_code) {
+                       if (item->check_target_idx) {
+                               gint64 offset;
+                               offset = S390_RELATIVE(imt_entries [item->check_target_idx]->code_target,
+                                                      item->jmp_code);
+                               s390_patch_rel ((guchar *) item->jmp_code + 2, (guint64) offset);
+                       }
+               }
+       }
+
+       mono_arch_flush_icache ((guint8*)start, (code - start));
+
+       if (!fail_tramp)
+               mono_stats.imt_thunks_size += (code - start);
+
+       g_assert (code - start <= size);
+
+       return (start);
+}
+
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_find_imt_method.                        */
+/*                                                                  */
+/* Function    - Get the method address from MONO_ARCH_IMT_REG     */
+/*               found in the save area.                           */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
+MonoMethod*
+mono_arch_find_imt_method (mgreg_t *regs, guint8 *code)
+{
+       MonoLMF *lmf = (MonoLMF *) ((gchar *) regs - sizeof(MonoLMF));
+
+       return ((MonoMethod *) lmf->gregs [MONO_ARCH_IMT_REG]);
+}
+
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_find_this_argument.                     */
+/*                                                                  */
+/* Function    -                                                   */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
+MonoObject *
+mono_arch_find_this_argument (mgreg_t *regs, MonoMethod *method, 
+                             MonoGenericSharingContext *gsctx)
+{
+        return mono_arch_get_this_arg_from_call (gsctx, mono_method_signature (method), regs, NULL);
+}  
+
+/*========================= End of Function ========================*/
index 62545a57e87c29fd89ae5f9e83c1b1d6371c6d29..f15de7cfef7cb3964f47d5d77892f3851d39b116 100644 (file)
@@ -63,17 +63,60 @@ typedef struct
        void *return_address;
 } MonoS390StackFrame;
 
+typedef struct
+{
+       char    n3:1;           // N3 instructions present
+       char    zArch:1;        // z/Architecture mode installed
+       char    zAct:1;         // z/Architecture mode active
+       char    date:1;         // DATE enhancement facility
+       char    idte1:1;        // IDTE present (PST)
+       char    idte2:1;        // IDTE present (REG)
+       char    asnlx:1;        // ASN and LX reuse facility
+       char    stfle:1;        // STFLE installed
+       char    zDATe:1;        // Enhanced DAT in z mode
+       char    srstat:1;       // Sense running status facility
+       char    cSSKE:1;        // Conditional SSKE facility
+       char    topo:1;         // COnfiguration topology facility
+       char    xTrans2:1;      // Extended translation facility 2
+       char    msgSec:1;       // Message security facility
+       char    longDsp:1;      // Long displacement facility
+       char    hiPerfLD:1;     // High performance long displacement facility
+       char    hfpMAS:1;       // HFP multiply-and-add/subtrace facility
+       char    xImm:1;         // Extended immediate facility
+       char    xTrans3:1;      // Extended translation facility 3
+       char    hfpUnX:1;       // HFP unnormalized extension facility
+       char    etf2:1;         // ETF2-enhancement facility
+       char    stckf:1;        // Store-clock-fast facility
+       char    parse:1;        // Parsing enhancement facility
+       char    mvcos:1;        // MVCOS facility
+       char    todSteer:1;     // TOD-clock steering facility
+       char    etf3:1;         // ETF3-enhancement facility
+       char    xCPUtm:1;       // Extract CPU time facility
+       char    csst:1;         // Compare-swap-and-store facility
+       char    csst2:1;        // Compare-swap-and-store facility 2
+       char    giX:1;          // General instructions extension facility
+       char    exX:1;          // Execute extensions facility
+       char    ibm:1;          // IBM internal use
+       char    fps:1;          // Floating point support enhancement
+       char    dfp:1;          // Decimal floating point facility
+       char    hiDFP:1;        // High Performance DFP facility
+       char    pfpo:1;         // PFPO instruction facility
+} __attribute__((aligned(8))) facilityList_t;
+       
 // #define MONO_ARCH_SIGSEGV_ON_ALTSTACK               1
-#define MONO_ARCH_EMULATE_LCONV_TO_R8_UN       1
-#define MONO_ARCH_NO_EMULATE_LONG_MUL_OPTS     1
-#define MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS    1
-#define MONO_ARCH_HAVE_IS_INT_OVERFLOW         1
-#define MONO_ARCH_NEED_DIV_CHECK               1
-#define MONO_ARCH_HAVE_ATOMIC_ADD 1
-#define MONO_ARCH_HAVE_ATOMIC_EXCHANGE 1
-#define MONO_ARCH_SIGNAL_STACK_SIZE            256*1024
-#define MONO_ARCH_HAVE_DECOMPOSE_OPTS 1
-// #define MONO_ARCH_HAVE_THROW_CORLIB_EXCEPTION       1
+#define MONO_ARCH_EMULATE_LCONV_TO_R8_UN               1
+#define MONO_ARCH_NO_EMULATE_LONG_MUL_OPTS             1
+#define MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS            1
+#define MONO_ARCH_HAVE_IS_INT_OVERFLOW                 1
+#define MONO_ARCH_NEED_DIV_CHECK                       1
+#define MONO_ARCH_HAVE_ATOMIC_ADD                      1
+#define MONO_ARCH_HAVE_ATOMIC_EXCHANGE                         1
+#define MONO_ARCH_SIGNAL_STACK_SIZE                    256*1024
+#define MONO_ARCH_HAVE_DECOMPOSE_OPTS                  1
+#define MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE      1
+#define MONO_ARCH_HAVE_THROW_CORLIB_EXCEPTION          1
+#define MONO_ARCH_HAVE_IMT                             1
+#define MONO_ARCH_IMT_REG                              s390_r9
 #define MONO_ARCH_HAVE_THROW_EXCEPTION_BY_NAME 1
 
 #define MONO_ARCH_USE_SIGACTION        1
index 985ce563c6dc39405e32099a1e72d053b25ef39d..eb94c7c862b2c0a1480b51266c098b00f931e09f 100644 (file)
@@ -3214,6 +3214,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        /* This is a jump inside the method, so call_simple works even on V9 */
                        sparc_call_simple (code, 0);
                        sparc_nop (code);
+                       mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                        break;
                case OP_LABEL:
                        ins->inst_c0 = (guint8*)code - cfg->native_code;
index 9eef82842b836c6f5af1fdcda2011c0429c1c148..fb7f6380dadfb17758bda3e17776347c6a300901 100644 (file)
@@ -7,6 +7,7 @@
 #include <mono/metadata/marshal.h>
 #include <mono/metadata/tabledefs.h>
 #include <mono/utils/mono-counters.h>
+#include <mono/utils/mono-error-internals.h>
 
 #include "mini.h"
 #include "debug-mini.h"
@@ -560,8 +561,7 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp
 
                if (plt_entry) {
                        mono_arch_patch_plt_entry (plt_entry, NULL, regs, addr);
-               } else if (!generic_shared || (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
-                       mono_domain_lookup_shared_generic (mono_domain_get (), declaring)) {
+               } else {
                        if (generic_shared) {
                                if (m->wrapper_type != MONO_WRAPPER_NONE)
                                        m = mono_marshal_method_from_wrapper (m);
@@ -569,9 +569,7 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp
                        }
 
                        /* Patch calling code */
-                       if (plt_entry) {
-
-                       } else {
+                       {
                                MonoJitInfo *target_ji = 
                                        mono_jit_info_table_find (mono_domain_get (), mono_get_addr_from_ftnptr (compiled_method));
 
@@ -882,6 +880,8 @@ mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, gui
        MonoMethod *invoke = tramp_data [0];
        guint8 *impl_this = tramp_data [1];
        guint8 *impl_nothis = tramp_data [2];
+       MonoError err;
+       MonoMethodSignature *sig;
 
        trampoline_calls ++;
 
@@ -910,14 +910,29 @@ mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, gui
 #endif
                                method = mono_marshal_get_remoting_invoke (method);
                }
-               else if (mono_method_signature (method)->hasthis && method->klass->valuetype)
-                       method = mono_marshal_get_unbox_wrapper (method);
+               else {
+                       mono_error_init (&err);
+                       sig = mono_method_signature_checked (method, &err);
+                       if (!sig)
+                               mono_error_raise_exception (&err);
+                               
+                       if (sig->hasthis && method->klass->valuetype)
+                               method = mono_marshal_get_unbox_wrapper (method);
+               }
        } else {
                ji = mono_jit_info_table_find (domain, mono_get_addr_from_ftnptr (delegate->method_ptr));
                if (ji)
                        method = ji->method;
        }
-       callvirt = !delegate->target && method && mono_method_signature (method)->hasthis;
+
+       if (method) {
+               mono_error_init (&err);
+               sig = mono_method_signature_checked (method, &err);
+               if (!sig)
+                       mono_error_raise_exception (&err);
+
+               callvirt = !delegate->target && sig->hasthis;
+       }
 
        if (method && method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
                method = mono_marshal_get_synchronized_wrapper (method);
index 31e84791f5305a9bd9e865729f127e9f4ed9c5d8..e818084c2afae6fcf99627e73d5cfe66d8056e5e 100644 (file)
@@ -733,17 +733,17 @@ mono_arch_cpu_enumerate_simd_versions (void)
 
        if (cpuid (1, &eax, &ebx, &ecx, &edx)) {
                if (edx & (1 << 25))
-                       sse_opts |= 1 << SIMD_VERSION_SSE1;
+                       sse_opts |= SIMD_VERSION_SSE1;
                if (edx & (1 << 26))
-                       sse_opts |= 1 << SIMD_VERSION_SSE2;
+                       sse_opts |= SIMD_VERSION_SSE2;
                if (ecx & (1 << 0))
-                       sse_opts |= 1 << SIMD_VERSION_SSE3;
+                       sse_opts |= SIMD_VERSION_SSE3;
                if (ecx & (1 << 9))
-                       sse_opts |= 1 << SIMD_VERSION_SSSE3;
+                       sse_opts |= SIMD_VERSION_SSSE3;
                if (ecx & (1 << 19))
-                       sse_opts |= 1 << SIMD_VERSION_SSE41;
+                       sse_opts |= SIMD_VERSION_SSE41;
                if (ecx & (1 << 20))
-                       sse_opts |= 1 << SIMD_VERSION_SSE42;
+                       sse_opts |= SIMD_VERSION_SSE42;
        }
 
        /* Yes, all this needs to be done to check for sse4a.
@@ -754,7 +754,7 @@ mono_arch_cpu_enumerate_simd_versions (void)
                if ((((unsigned int) eax) >= 0x80000001) && (ebx == 0x68747541) && (ecx == 0x444D4163) && (edx == 0x69746E65)) {
                        cpuid (0x80000001, &eax, &ebx, &ecx, &edx);
                        if (ecx & (1 << 6))
-                               sse_opts |= 1 << SIMD_VERSION_SSE4a;
+                               sse_opts |= SIMD_VERSION_SSE4a;
                }
        }
 
@@ -1163,6 +1163,7 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig)
        CallInfo *cinfo;
        ArgInfo *ainfo;
        LLVMCallInfo *linfo;
+       MonoType *t;
 
        n = sig->param_count + sig->hasthis;
 
@@ -1206,6 +1207,11 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig)
        for (i = 0; i < n; ++i) {
                ainfo = cinfo->args + i;
 
+               if (i >= sig->hasthis)
+                       t = sig->params [i - sig->hasthis];
+               else
+                       t = &mono_defaults.int_class->byval_arg;
+
                linfo->args [i].storage = LLVMArgNone;
 
                switch (ainfo->storage) {
@@ -1217,16 +1223,15 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig)
                        linfo->args [i].storage = LLVMArgInFPReg;
                        break;
                case ArgOnStack:
-                       if ((i >= sig->hasthis) && (MONO_TYPE_ISSTRUCT(sig->params [i - sig->hasthis]))) {
+                       if (MONO_TYPE_ISSTRUCT (t)) {
                                linfo->args [i].storage = LLVMArgVtypeByVal;
                        } else {
                                linfo->args [i].storage = LLVMArgInIReg;
-                               if (!sig->params [i - sig->hasthis]->byref) {
-                                       if (sig->params [i - sig->hasthis]->type == MONO_TYPE_R4) {
+                               if (t->byref) {
+                                       if (t->type == MONO_TYPE_R4)
                                                linfo->args [i].storage = LLVMArgInFPReg;
-                                       } else if (sig->params [i - sig->hasthis]->type == MONO_TYPE_R8) {
+                                       else if (t->type == MONO_TYPE_R8)
                                                linfo->args [i].storage = LLVMArgInFPReg;
-                                       }
                                }
                        }
                        break;
@@ -2029,6 +2034,23 @@ emit_move_return_value (MonoCompile *cfg, MonoInst *ins, guint8 *code)
        return code;
 }
 
+gboolean
+mono_x86_have_tls_get (void)
+{
+#ifdef __APPLE__
+       guint32 *ins = (guint32*)pthread_getspecific;
+       /*
+        * We're looking for these two instructions:
+        *
+        * mov    0x4(%esp),%eax
+        * mov    %gs:0x48(,%eax,4),%eax
+        */
+       return ins [0] == 0x0424448b && ins [1] == 0x85048b65 && ins [2] == 0x00000048;
+#else
+       return TRUE;
+#endif
+}
+
 /*
  * mono_x86_emit_tls_get:
  * @code: buffer to store code to
@@ -2044,7 +2066,10 @@ emit_move_return_value (MonoCompile *cfg, MonoInst *ins, guint8 *code)
 guint8*
 mono_x86_emit_tls_get (guint8* code, int dreg, int tls_offset)
 {
-#ifdef TARGET_WIN32
+#if defined(__APPLE__)
+       x86_prefix (code, X86_GS_PREFIX);
+       x86_mov_reg_mem (code, dreg, 0x48 + tls_offset * 4, 4);
+#elif defined(TARGET_WIN32)
        /* 
         * See the Under the Hood article in the May 1996 issue of Microsoft Systems 
         * Journal and/or a disassembly of the TlsGet () function.
@@ -2981,6 +3006,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        x86_alu_reg_imm (code, X86_SUB, X86_ESP, MONO_ARCH_FRAME_ALIGNMENT - 4);
                        mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_target_bb);
                        x86_call_imm (code, 0);
+                       mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                        x86_alu_reg_imm (code, X86_ADD, X86_ESP, MONO_ARCH_FRAME_ALIGNMENT - 4);
                        break;
                case OP_START_HANDLER: {
index bfd8d282a7fc786c3d9d8c00ebe22f5ce5961195..bc7e0dff1a753582babbdd9866ffed3b3accb87e 100644 (file)
@@ -44,7 +44,8 @@ LONG CALLBACK seh_handler(EXCEPTION_POINTERS* ep);
 
 #endif /* HOST_WIN32 */
 
-#if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__)
+#if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
+       defined(__FreeBSD__) || defined(__OpenBSD__)
 #define MONO_ARCH_USE_SIGACTION
 #endif
 
@@ -242,7 +243,7 @@ typedef struct {
 #define MONO_ARCH_HAVE_ATOMIC_EXCHANGE 1
 #define MONO_ARCH_HAVE_ATOMIC_CAS 1
 #define MONO_ARCH_HAVE_IMT 1
-#define MONO_ARCH_HAVE_TLS_GET 1
+#define MONO_ARCH_HAVE_TLS_GET (mono_x86_have_tls_get ())
 #define MONO_ARCH_IMT_REG X86_EDX
 #define MONO_ARCH_VTABLE_REG X86_EDX
 #define MONO_ARCH_RGCTX_REG X86_EDX
@@ -304,5 +305,8 @@ mono_x86_emit_tls_get (guint8* code, int dreg, int tls_offset) MONO_INTERNAL;
 guint32
 mono_x86_get_this_arg_offset (MonoGenericSharingContext *gsctx, MonoMethodSignature *sig) MONO_INTERNAL;
 
+gboolean
+mono_x86_have_tls_get (void) MONO_INTERNAL;
+
 #endif /* __MONO_MINI_X86_H__ */  
 
index 797fe2417142a0a861f314276da8286e124a9d5d..d741005704766fc766a6fe4b2222a747100028e1 100644 (file)
@@ -169,6 +169,12 @@ mono_running_on_valgrind (void)
                return FALSE;
 }
 
+typedef struct {
+       MonoExceptionClause *clause;
+       MonoBasicBlock *basic_block;
+       int start_offset;
+} TryBlockHole;
+
 typedef struct {
        void *ip;
        MonoMethod *method;
@@ -2461,18 +2467,19 @@ static MonoInst*
 mono_create_tls_get (MonoCompile *cfg, int offset)
 {
 #ifdef MONO_ARCH_HAVE_TLS_GET
-       MonoInst* ins;
-       
-       if (offset == -1)
-               return NULL;
-       
-       MONO_INST_NEW (cfg, ins, OP_TLS_GET);
-       ins->dreg = mono_alloc_preg (cfg);
-       ins->inst_offset = offset;
-       return ins;
-#else
-       return NULL;
+       if (MONO_ARCH_HAVE_TLS_GET) {
+               MonoInst* ins;
+
+               if (offset == -1)
+                       return NULL;
+
+               MONO_INST_NEW (cfg, ins, OP_TLS_GET);
+               ins->dreg = mono_alloc_preg (cfg);
+               ins->inst_offset = offset;
+               return ins;
+       }
 #endif
+       return NULL;
 }
 
 MonoInst*
@@ -3244,6 +3251,7 @@ mono_codegen (MonoCompile *cfg)
                bb->native_offset = cfg->code_len;
                //if ((bb == cfg->bb_entry) || !(bb->region == -1 && !bb->dfn))
                        mono_arch_output_basic_block (cfg, bb);
+               bb->native_length = cfg->code_len - bb->native_offset;
 
                if (bb == cfg->bb_exit) {
                        cfg->epilog_begin = cfg->code_len;
@@ -3363,10 +3371,12 @@ compute_reachable (MonoBasicBlock *bb)
 static MonoJitInfo*
 create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
 {
+       GSList *tmp;
        MonoMethodHeader *header;
        MonoJitInfo *jinfo;
        int num_clauses;
        int generic_info_size;
+       int holes_size = 0, num_holes = 0;
 
        g_assert (method_to_compile == cfg->method);
        header = cfg->header;
@@ -3376,6 +3386,24 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
        else
                generic_info_size = 0;
 
+       if (cfg->try_block_holes) {
+               for (tmp = cfg->try_block_holes; tmp; tmp = tmp->next) {
+                       TryBlockHole *hole = tmp->data;
+                       MonoExceptionClause *ec = hole->clause;
+                       int hole_end = hole->basic_block->native_offset + hole->basic_block->native_length;
+                       MonoBasicBlock *clause_last_bb = cfg->cil_offset_to_bb [ec->try_offset + ec->try_len];
+                       g_assert (clause_last_bb);
+
+                       /* Holes at the end of a try region can be represented by simply reducing the size of the block itself.*/
+                       if (clause_last_bb->native_offset != hole_end)
+                               ++num_holes;
+               }
+               if (num_holes)
+                       holes_size = sizeof (MonoTryBlockHoleTableJitInfo) + num_holes * sizeof (MonoTryBlockHoleJitInfo);
+               if (G_UNLIKELY (cfg->verbose_level >= 4))
+                       printf ("Number of try block holes %d\n", num_holes);
+       }
+
        if (COMPILE_LLVM (cfg))
                num_clauses = cfg->llvm_ex_info_len;
        else
@@ -3383,11 +3411,11 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
 
        if (cfg->method->dynamic) {
                jinfo = g_malloc0 (MONO_SIZEOF_JIT_INFO + (num_clauses * sizeof (MonoJitExceptionInfo)) +
-                               generic_info_size);
+                               generic_info_size + holes_size);
        } else {
                jinfo = mono_domain_alloc0 (cfg->domain, MONO_SIZEOF_JIT_INFO +
                                (num_clauses * sizeof (MonoJitExceptionInfo)) +
-                               generic_info_size);
+                               generic_info_size + holes_size);
        }
 
        jinfo->method = cfg->method_to_register;
@@ -3446,6 +3474,62 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
                }
        }
 
+       if (num_holes) {
+               MonoTryBlockHoleTableJitInfo *table;
+               int i;
+
+               jinfo->has_try_block_holes = 1;
+               table = mono_jit_info_get_try_block_hole_table_info (jinfo);
+               table->num_holes = (guint16)num_holes;
+               i = 0;
+               for (tmp = cfg->try_block_holes; tmp; tmp = tmp->next) {
+                       MonoTryBlockHoleJitInfo *hole;
+                       TryBlockHole *hole_data = tmp->data;
+                       MonoExceptionClause *ec = hole_data->clause;
+                       int hole_end = hole_data->basic_block->native_offset + hole_data->basic_block->native_length;
+                       MonoBasicBlock *clause_last_bb = cfg->cil_offset_to_bb [ec->try_offset + ec->try_len];
+                       g_assert (clause_last_bb);
+
+                       /* Holes at the end of a try region can be represented by simply reducing the size of the block itself.*/
+                       if (clause_last_bb->native_offset == hole_end)
+                               continue;
+
+                       hole = &table->holes [i++];
+                       hole->clause = hole_data->clause - &header->clauses [0];
+                       hole->offset = (guint32)hole_data->start_offset;
+                       hole->length = (guint16)(hole_data->basic_block->native_length - hole_data->start_offset);
+               }
+               g_assert (i == num_holes);
+       }
+
+       if (G_UNLIKELY (header->num_clauses && cfg->verbose_level >= 4)) {
+               GSList *tmp;
+               int i;
+               printf ("\nException Handling Data\n");
+               for (i = 0; i < header->num_clauses; i++) {
+                       MonoExceptionClause *ec = &header->clauses [i];
+                       int try_start = cfg->cil_offset_to_bb [ec->try_offset]->native_offset;
+                       int try_end  = cfg->cil_offset_to_bb [ec->try_offset + ec->try_len]->native_offset;
+                       int handler_start = cfg->cil_offset_to_bb [ec->handler_offset]->native_offset;
+                       int handler_end;
+                       if (ec->handler_offset + ec->handler_len < header->code_size)
+                               handler_end =  cfg->cil_offset_to_bb [ec->handler_offset + ec->handler_len]->native_offset;
+                       else
+                               handler_end = cfg->epilog_begin;
+
+                       printf ("EH clause %d flags %x try IL %x-%x NATIVE %x-%x handler IL %x-%x NATIVE %x-%x\n",
+                               i, ec->flags,
+                               ec->try_offset, ec->try_offset + ec->try_len, try_start, try_end,
+                               ec->handler_offset, ec->handler_offset + ec->handler_len, handler_start, handler_end);
+               }
+               for (tmp = cfg->try_block_holes; tmp; tmp = tmp->next) {
+                       TryBlockHole *hole = tmp->data;
+                       int block = hole->clause - &header->clauses [0];
+                       printf ("try block hole at eh clause %d range %x-%x\n",
+                               block, hole->start_offset, hole->basic_block->native_offset + hole->basic_block->native_length);
+               }
+       }
+
        if (COMPILE_LLVM (cfg)) {
                if (num_clauses)
                        memcpy (&jinfo->clauses [0], &cfg->llvm_ex_info [0], num_clauses * sizeof (MonoJitExceptionInfo));
@@ -3482,7 +3566,26 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
                        tblock = cfg->cil_offset_to_bb [ec->handler_offset];
                        g_assert (tblock);
                        ei->handler_start = cfg->native_code + tblock->native_offset;
+
+                       for (tmp = cfg->try_block_holes; tmp; tmp = tmp->next) {
+                               TryBlockHole *hole = tmp->data;
+                               gpointer hole_end = cfg->native_code + (hole->basic_block->native_offset + hole->basic_block->native_length);
+                               if (hole->clause == ec && hole_end == ei->try_end) {
+                                       if (G_UNLIKELY (cfg->verbose_level >= 4))
+                                               printf ("\tShortening try block %d from %p to %p\n", i, ei->try_end, cfg->native_code + hole->start_offset);
+                                       ei->try_end = cfg->native_code + hole->start_offset;
+                                       break;
+                               }
+                       }
+               }
+
+               if (G_UNLIKELY (cfg->verbose_level >= 4)) {
+                       for (i = 0; i < jinfo->num_clauses; i++) {
+                               MonoJitExceptionInfo *ei = &jinfo->clauses [i];
+                               printf ("JitInfo EH clause %d flags %x try %p-%p handler %p\n", i, ei->flags, ei->try_start, ei->try_end, ei->handler_start);
+                       }
                }
+
        }
 
        /* 
@@ -3504,7 +3607,80 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
 
        return jinfo;
 }
+#endif
 
+/*
+ * mini_get_shared_method:
+ *
+ *   Return the method which is actually compiled/registered when doing generic sharing.
+ */
+MonoMethod*
+mini_get_shared_method (MonoMethod *method)
+{
+       MonoGenericContext shared_context;
+       MonoMethod *declaring_method, *res;
+       int i;
+       gboolean partial = FALSE;
+
+       if (method->is_generic || method->klass->generic_container)
+               declaring_method = method;
+       else
+               declaring_method = mono_method_get_declaring_generic_method (method);
+
+       if (declaring_method->is_generic)
+               shared_context = mono_method_get_generic_container (declaring_method)->context;
+       else
+               shared_context = declaring_method->klass->generic_container->context;
+
+       /* Handle partial sharing */
+       if (method != declaring_method && method->is_inflated && !mono_method_is_generic_sharable_impl_full (method, FALSE, FALSE)) {
+               MonoGenericContext *context = mono_method_get_context (method);
+               MonoGenericInst *inst;
+               MonoType **type_argv;
+
+               /* 
+                * Create the shared context by replacing the ref type arguments with
+                * type parameters, and keeping the rest.
+                */
+               partial = TRUE;
+               inst = context->class_inst;
+               if (inst) {
+                       type_argv = g_new0 (MonoType*, inst->type_argc);
+                       for (i = 0; i < inst->type_argc; ++i) {
+                               if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
+                                       type_argv [i] = shared_context.class_inst->type_argv [i];
+                               else
+                                       type_argv [i] = inst->type_argv [i];
+                       }
+
+                       shared_context.class_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv);
+                       g_free (type_argv);
+               }
+
+               inst = context->method_inst;
+               if (inst) {
+                       type_argv = g_new0 (MonoType*, inst->type_argc);
+                       for (i = 0; i < inst->type_argc; ++i) {
+                               if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
+                                       type_argv [i] = shared_context.method_inst->type_argv [i];
+                               else
+                                       type_argv [i] = inst->type_argv [i];
+                       }
+
+                       shared_context.method_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv);
+                       g_free (type_argv);
+               }
+       }
+
+    res = mono_class_inflate_generic_method (declaring_method, &shared_context);
+       if (!partial) {
+               /* The result should be an inflated method whose parent is not inflated */
+               g_assert (!res->klass->is_inflated);
+       }
+       return res;
+}
+
+#ifndef DISABLE_JIT
 /*
  * mini_method_compile:
  * @method: the method to compile
@@ -3521,6 +3697,8 @@ MonoCompile*
 mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gboolean run_cctors, gboolean compile_aot, int parts)
 {
        MonoMethodHeader *header;
+       MonoMethodSignature *sig;
+       MonoError err;
        guint8 *ip;
        MonoCompile *cfg;
        int dfn, i, code_size_ratio;
@@ -3535,9 +3713,13 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
                MONO_PROBE_METHOD_COMPILE_BEGIN (method);
  
        if (compile_aot)
-               /* We are passed the original generic method definition */
+               /* 
+                * We might get passed the original generic method definition or
+                * instances with type parameters.
+                * FIXME: Remove the method->klass->generic_class limitation.
+                */
                try_generic_shared = mono_class_generic_sharing_enabled (method->klass) &&
-                       (opts & MONO_OPT_GSHARED) && (method->is_generic || method->klass->generic_container);
+                       (opts & MONO_OPT_GSHARED) && ((method->is_generic || method->klass->generic_container) || (!method->klass->generic_class && mono_method_is_generic_sharable_impl (method, TRUE)));
        else
                try_generic_shared = mono_class_generic_sharing_enabled (method->klass) &&
                        (opts & MONO_OPT_GSHARED) && mono_method_is_generic_sharable_impl (method, FALSE);
@@ -3557,25 +3739,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
 
  restart_compile:
        if (try_generic_shared) {
-               MonoMethod *declaring_method;
-               MonoGenericContext *shared_context;
-
-               if (compile_aot) {
-                       declaring_method = method;
-               } else {
-                       declaring_method = mono_method_get_declaring_generic_method (method);
-                       if (method->klass->generic_class)
-                               g_assert (method->klass->generic_class->container_class == declaring_method->klass);
-                       else
-                               g_assert (method->klass == declaring_method->klass);
-               }
-
-               if (declaring_method->is_generic)
-                       shared_context = &(mono_method_get_generic_container (declaring_method)->context);
-               else
-                       shared_context = &declaring_method->klass->generic_container->context;
-
-               method_to_compile = mono_class_inflate_generic_method (declaring_method, shared_context);
+               method_to_compile = mini_get_shared_method (method);
                g_assert (method_to_compile);
        } else {
                method_to_compile = method;
@@ -3609,9 +3773,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
        }
 
        if (cfg->generic_sharing_context) {
-               MonoGenericContext object_context = mono_method_construct_object_context (method_to_compile);
-
-               method_to_register = mono_class_inflate_generic_method (method_to_compile, &object_context);
+               method_to_register = method_to_compile;
        } else {
                g_assert (method == method_to_compile);
                method_to_register = method;
@@ -3637,6 +3799,17 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
                }
        }
 
+       mono_error_init (&err);
+       sig = mono_method_signature_checked (cfg->method, &err);        
+       if (!sig) {
+               cfg->exception_type = MONO_EXCEPTION_TYPE_LOAD;
+               cfg->exception_message = g_strdup (mono_error_get_message (&err));
+               mono_error_cleanup (&err);
+               if (MONO_PROBE_METHOD_COMPILE_END_ENABLED ())
+                       MONO_PROBE_METHOD_COMPILE_END (method, FALSE);
+               return cfg;
+       }
+
        header = cfg->header;
        if (!header) {
                MonoLoaderError *error;
@@ -3745,7 +3918,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
        if (getenv ("MONO_VERBOSE_METHOD")) {
                char *name = getenv ("MONO_VERBOSE_METHOD");
 
-               if (strchr (name, '.') || strchr (name, ':')) {
+               if ((strchr (name, '.') > name) || strchr (name, ':')) {
                        MonoMethodDesc *desc;
                        
                        desc = mono_method_desc_new (name, TRUE);
@@ -3767,7 +3940,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
                if (COMPILE_LLVM (cfg))
                        g_print ("converting llvm method %s\n", mono_method_full_name (method, TRUE));
                else if (cfg->generic_sharing_context)
-                       g_print ("converting shared method %s\n", mono_method_full_name (method, TRUE));
+                       g_print ("converting shared method %s\n", mono_method_full_name (method_to_compile, TRUE));
                else
                        g_print ("converting method %s\n", mono_method_full_name (method, TRUE));
        }
@@ -4328,17 +4501,29 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
 
 #endif /* DISABLE_JIT */
 
-static MonoJitInfo*
-lookup_generic_method (MonoDomain *domain, MonoMethod *method)
+MonoJitInfo*
+mono_domain_lookup_shared_generic (MonoDomain *domain, MonoMethod *method)
 {
-       MonoMethod *open_method;
+       static gboolean inited = FALSE;
+       static int lookups = 0;
+       static int failed_lookups = 0;
+       MonoJitInfo *ji;
 
-       if (!mono_method_is_generic_sharable_impl (method, FALSE))
-               return NULL;
+       ji = mono_internal_hash_table_lookup (&domain->jit_code_hash, mini_get_shared_method (method));
+       if (ji && !ji->has_generic_jit_info)
+               ji = NULL;
+
+       if (!inited) {
+               mono_counters_register ("Shared generic lookups", MONO_COUNTER_INT|MONO_COUNTER_GENERICS, &lookups);
+               mono_counters_register ("Failed shared generic lookups", MONO_COUNTER_INT|MONO_COUNTER_GENERICS, &failed_lookups);
+               inited = TRUE;
+       }
 
-       open_method = mono_method_get_declaring_generic_method (method);
+       ++lookups;
+       if (!ji)
+               ++failed_lookups;
 
-       return mono_domain_lookup_shared_generic (domain, open_method);
+       return ji;
 }
 
 /*
@@ -4352,7 +4537,9 @@ lookup_method_inner (MonoDomain *domain, MonoMethod *method)
        if (ji)
                return ji;
 
-       return lookup_generic_method (domain, method);
+       if (!mono_method_is_generic_sharable_impl (method, FALSE))
+               return NULL;
+       return mono_domain_lookup_shared_generic (domain, method);
 }
 
 static MonoJitInfo*
@@ -4612,6 +4799,7 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
 
        mono_destroy_compile (cfg);
 
+#ifndef DISABLE_JIT
        if (domain_jit_info (target_domain)->jump_target_hash) {
                MonoJumpInfo patch_info;
                GSList *list, *tmp;
@@ -4629,6 +4817,7 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
        }
 
        mono_emit_jit_map (jinfo);
+#endif
        mono_domain_unlock (target_domain);
        mono_loader_unlock ();
 
@@ -5093,18 +5282,19 @@ SIG_HANDLER_SIGNATURE (mono_sigill_signal_handler)
        mono_arch_handle_exception (ctx, exc, FALSE);
 }
 
+#if defined(MONO_ARCH_USE_SIGACTION) || defined(HOST_WIN32)
+#define HAVE_SIG_INFO
+#endif
+
 void
 SIG_HANDLER_SIGNATURE (mono_sigsegv_signal_handler)
 {
-#ifndef MONO_ARCH_SIGSEGV_ON_ALTSTACK
-       MonoException *exc = NULL;
-#endif
        MonoJitInfo *ji;
        MonoJitTlsData *jit_tls = TlsGetValue (mono_jit_tls_id);
 
        GET_CONTEXT;
 
-#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
+#if defined(MONO_ARCH_SOFT_DEBUG_SUPPORTED) && defined(HAVE_SIG_INFO)
        if (mono_arch_is_single_step_event (info, ctx)) {
                mono_debugger_agent_single_step_event (ctx);
                return;
@@ -5114,7 +5304,7 @@ SIG_HANDLER_SIGNATURE (mono_sigsegv_signal_handler)
        }
 #endif
 
-#ifndef HOST_WIN32
+#if !defined(HOST_WIN32) && defined(HAVE_SIG_INFO)
        if (mono_aot_is_pagefault (info->si_addr)) {
                mono_aot_handle_pagefault (info->si_addr);
                return;
@@ -5164,7 +5354,7 @@ SIG_HANDLER_SIGNATURE (mono_sigsegv_signal_handler)
                mono_handle_native_sigsegv (SIGSEGV, ctx);
        }
                        
-       mono_arch_handle_exception (ctx, exc, FALSE);
+       mono_arch_handle_exception (ctx, NULL, FALSE);
 #endif
 }
 
@@ -5429,7 +5619,7 @@ mini_init (const char *filename, const char *runtime_version)
 #endif
 
 #ifdef MONO_ARCH_HAVE_TLS_GET
-       mono_runtime_set_has_tls_get (TRUE);
+       mono_runtime_set_has_tls_get (MONO_ARCH_HAVE_TLS_GET);
 #else
        mono_runtime_set_has_tls_get (FALSE);
 #endif
@@ -5739,6 +5929,10 @@ mini_init (const char *filename, const char *runtime_version)
        register_icall (mono_isfinite, "mono_isfinite", "uint32 double", FALSE);
 #endif
 
+#ifdef COMPRESSED_INTERFACE_BITMAP
+       register_icall (mono_class_interface_match, "mono_class_interface_match", "uint32 ptr int32", TRUE);
+#endif
+
 #if SIZEOF_REGISTER == 4
        mono_register_opcode_emulation (OP_FCONV_TO_U, "__emul_fconv_to_u", "uint32 double", mono_fconv_u4, TRUE);
 #endif
@@ -6054,4 +6248,15 @@ mono_arch_instrument_epilog (MonoCompile *cfg, void *func, void *p, gboolean ena
        return mono_arch_instrument_epilog_full (cfg, func, p, enable_arguments, FALSE);
 }
 
+void
+mono_cfg_add_try_hole (MonoCompile *cfg, MonoExceptionClause *clause, guint8 *start, MonoBasicBlock *bb)
+{
+       TryBlockHole *hole = mono_mempool_alloc (cfg->mempool, sizeof (TryBlockHole));
+       hole->clause = clause;
+       hole->start_offset = start - cfg->native_code;
+       hole->basic_block = bb;
+
+       cfg->try_block_holes = g_slist_append_mempool (cfg->mempool, cfg->try_block_holes, hole);
+}
+
 #endif
index 6fc3632a8335d61329e1ca3fe88ce231ae4bdce2..a97bfdfd3bd0c4bcc66e66f86fff18400c1700fe 100644 (file)
@@ -465,8 +465,9 @@ struct MonoBasicBlock {
        /* Length of the CIL block */
        gint32 cil_length;
 
-       /* The address of the generated code, used for fixups */
+       /* The offset of the generated code, used for fixups */
        int native_offset;
+       int native_length;
        int max_offset;
        int max_length;
 
@@ -609,6 +610,7 @@ struct MonoInst {
                        MonoClass *klass;
                        int *phi_args;
                        MonoCallInst *call_inst;
+                       MonoExceptionClause *exception_clause;
                } op [2];
                gint64 i8const;
                double r8const;
@@ -730,6 +732,7 @@ enum {
 #define inst_call   data.op[1].call_inst
 
 #define inst_phi_args   data.op[1].phi_args
+#define inst_eh_block   data.op[1].exception_clause
 
 /* instruction description for use in regalloc/scheduling */
 enum {
@@ -809,6 +812,7 @@ typedef struct {
        guint32          signal_stack_size;
        gpointer         stack_ovf_guard_base;
        guint32          stack_ovf_guard_size;
+       guint            stack_ovf_valloced : 1;
        void            (*abort_func) (MonoObject *object);
        /* Used to implement --debug=casts */
        MonoClass       *class_cast_from, *class_cast_to;
@@ -1141,6 +1145,8 @@ typedef struct {
 
        MonoJitExceptionInfo *llvm_ex_info;
        guint32 llvm_ex_info_len;
+
+       GSList *try_block_holes;
 } MonoCompile;
 
 typedef enum {
@@ -1947,11 +1953,21 @@ mono_class_check_context_used (MonoClass *class) MONO_INTERNAL;
 gboolean
 mono_generic_context_is_sharable (MonoGenericContext *context, gboolean allow_type_vars) MONO_INTERNAL;
 
+gboolean
+mono_generic_context_is_sharable_full (MonoGenericContext *context, gboolean allow_type_vars, gboolean allow_partial) MONO_INTERNAL;
+
 gboolean
 mono_method_is_generic_impl (MonoMethod *method) MONO_INTERNAL;
+
 gboolean
 mono_method_is_generic_sharable_impl (MonoMethod *method, gboolean allow_type_vars) MONO_INTERNAL;
 
+gboolean
+mono_method_is_generic_sharable_impl_full (MonoMethod *method, gboolean allow_type_vars, gboolean allow_partial) MONO_INTERNAL;
+
+gboolean
+mono_is_partially_sharable_inst (MonoGenericInst *inst) MONO_INTERNAL;
+
 MonoGenericSharingContext* mono_get_generic_context_from_code (guint8 *code) MONO_INTERNAL;
 
 MonoGenericContext* mini_method_get_context (MonoMethod *method) MONO_INTERNAL;
@@ -1971,12 +1987,16 @@ MonoGenericContext* mini_class_get_context (MonoClass *class) MONO_INTERNAL;
 
 MonoType* mini_get_basic_type_from_generic (MonoGenericSharingContext *gsctx, MonoType *type) MONO_INTERNAL;
 MonoType* mini_type_get_underlying_type (MonoGenericSharingContext *gsctx, MonoType *type) MONO_INTERNAL;
+MonoMethod* mini_get_shared_method (MonoMethod *method) MONO_INTERNAL;
+MonoMethod* mini_get_shared_method_to_register (MonoMethod *method) MONO_INTERNAL;
 
 int mini_type_stack_size (MonoGenericSharingContext *gsctx, MonoType *t, int *align) MONO_INTERNAL;
 int mini_type_stack_size_full (MonoGenericSharingContext *gsctx, MonoType *t, guint32 *align, gboolean pinvoke) MONO_INTERNAL;
 void type_to_eval_stack_type (MonoCompile *cfg, MonoType *type, MonoInst *inst) MONO_INTERNAL;
 guint mono_type_to_regmove (MonoCompile *cfg, MonoType *type) MONO_INTERNAL;
 
+void mono_cfg_add_try_hole (MonoCompile *cfg, MonoExceptionClause *clause, guint8 *start, MonoBasicBlock *bb) MONO_INTERNAL;
+
 /* wapihandles.c */
 int mini_wapi_hps (int argc, char **argv) MONO_INTERNAL;
 
@@ -1988,18 +2008,28 @@ int mini_wapi_seminfo (int argc, char **argv) MONO_INTERNAL;
 
 /*
 This enum MUST be kept in sync with its managed mirror Mono.Simd.AccelMode.
-The AccelMode values are masks while the ones here are the bit indexes.
  */
 enum {
-       SIMD_VERSION_SSE1       = 0,
-       SIMD_VERSION_SSE2       = 1,
-       SIMD_VERSION_SSE3       = 2,
-       SIMD_VERSION_SSSE3      = 3,
-       SIMD_VERSION_SSE41      = 4,
-       SIMD_VERSION_SSE42      = 5,
-       SIMD_VERSION_SSE4a      = 6,
+       SIMD_VERSION_SSE1       = 1 << 0,
+       SIMD_VERSION_SSE2       = 1 << 1,
+       SIMD_VERSION_SSE3       = 1 << 2,
+       SIMD_VERSION_SSSE3      = 1 << 3,
+       SIMD_VERSION_SSE41      = 1 << 4,
+       SIMD_VERSION_SSE42      = 1 << 5,
+       SIMD_VERSION_SSE4a      = 1 << 6,
+       SIMD_VERSION_ALL        = SIMD_VERSION_SSE1 | SIMD_VERSION_SSE2 |
+                         SIMD_VERSION_SSE3 | SIMD_VERSION_SSSE3 |
+                         SIMD_VERSION_SSE41 | SIMD_VERSION_SSE42 |
+                         SIMD_VERSION_SSE4a,
+
+       /* this value marks the end of the bit indexes used in 
+        * this emum.
+        */
+       SIMD_VERSION_INDEX_END = 6 
 };
 
+#define MASK(x) (1 << x)
+
 enum {
        SIMD_COMP_EQ,
        SIMD_COMP_LT,
index 15abb5e9951de52932e7749007a8fd878a58c29c..aaf6a1935df772c8d327bbe61f6b49cd49f27d1b 100644 (file)
@@ -121,392 +121,392 @@ enum {
 typedef struct {
        guint16 name;
        guint16 opcode;
+       guint8 simd_version_flags;
        guint8 simd_emit_mode : 4;
-       guint8 simd_version : 4;
-       guint8 flags;
+       guint8 flags : 4;
 } SimdIntrinsc;
 
 static const SimdIntrinsc vector4f_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_R4, SIMD_EMIT_CTOR },
-       { SN_AddSub, OP_ADDSUBPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE3 },
-       { SN_AndNot, OP_ANDNPS, SIMD_EMIT_BINARY },
-       { SN_CompareEqual, OP_COMPPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_EQ },
-       { SN_CompareLessEqual, OP_COMPPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_LE },
-       { SN_CompareLessThan, OP_COMPPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_LT },
-       { SN_CompareNotEqual, OP_COMPPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_NEQ },
-       { SN_CompareNotLessEqual, OP_COMPPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_NLE },
-       { SN_CompareNotLessThan, OP_COMPPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_NLT },
-       { SN_CompareOrdered, OP_COMPPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_ORD },
-       { SN_CompareUnordered, OP_COMPPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_UNORD },
-       { SN_DuplicateHigh, OP_DUPPS_HIGH, SIMD_EMIT_UNARY, SIMD_VERSION_SSE3 },
-       { SN_DuplicateLow, OP_DUPPS_LOW, SIMD_EMIT_UNARY, SIMD_VERSION_SSE3 },
-       { SN_HorizontalAdd, OP_HADDPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE3 },
-       { SN_HorizontalSub, OP_HSUBPS, SIMD_EMIT_BINARY, SIMD_VERSION_SSE3 },   
-       { SN_InterleaveHigh, OP_UNPACK_HIGHPS, SIMD_EMIT_BINARY },
-       { SN_InterleaveLow, OP_UNPACK_LOWPS, SIMD_EMIT_BINARY },
-       { SN_InvSqrt, OP_RSQRTPS, SIMD_EMIT_UNARY },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_Max, OP_MAXPS, SIMD_EMIT_BINARY },
-       { SN_Min, OP_MINPS, SIMD_EMIT_BINARY },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_Reciprocal, OP_RCPPS, SIMD_EMIT_UNARY },
-       { SN_Shuffle, OP_PSHUFLED, SIMD_EMIT_SHUFFLE },
-       { SN_Sqrt, OP_SQRTPS, SIMD_EMIT_UNARY },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_StoreNonTemporal, OP_STOREX_NTA_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_get_W, 3, SIMD_EMIT_GETTER },
-       { SN_get_X, 0, SIMD_EMIT_GETTER },
-       { SN_get_Y, 1, SIMD_EMIT_GETTER },
-       { SN_get_Z, 2, SIMD_EMIT_GETTER },
-       { SN_op_Addition, OP_ADDPS, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_ANDPS, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_ORPS, SIMD_EMIT_BINARY },
-       { SN_op_Division, OP_DIVPS, SIMD_EMIT_BINARY },
-       { SN_op_Equality, OP_COMPPS, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_EQ },
-       { SN_op_ExclusiveOr, OP_XORPS, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST }, 
-       { SN_op_Inequality, OP_COMPPS, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_NEQ },
-       { SN_op_Multiply, OP_MULPS, SIMD_EMIT_BINARY },
-       { SN_op_Subtraction, OP_SUBPS, SIMD_EMIT_BINARY },
-       { SN_set_W, 3, SIMD_EMIT_SETTER },
-       { SN_set_X, 0, SIMD_EMIT_SETTER },
-       { SN_set_Y, 1, SIMD_EMIT_SETTER },
-       { SN_set_Z, 2, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_R4, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_AddSub, OP_ADDSUBPS, SIMD_VERSION_SSE3, SIMD_EMIT_BINARY},
+       { SN_AndNot, OP_ANDNPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY},
+       { SN_CompareEqual, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_EQ },
+       { SN_CompareLessEqual, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_LE },
+       { SN_CompareLessThan, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_LT },
+       { SN_CompareNotEqual, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_NEQ },
+       { SN_CompareNotLessEqual, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_NLE },
+       { SN_CompareNotLessThan, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_NLT },
+       { SN_CompareOrdered, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_ORD },
+       { SN_CompareUnordered, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_UNORD },
+       { SN_DuplicateHigh, OP_DUPPS_HIGH, SIMD_VERSION_SSE3, SIMD_EMIT_UNARY },
+       { SN_DuplicateLow, OP_DUPPS_LOW, SIMD_VERSION_SSE3, SIMD_EMIT_UNARY },
+       { SN_HorizontalAdd, OP_HADDPS, SIMD_VERSION_SSE3, SIMD_EMIT_BINARY },
+       { SN_HorizontalSub, OP_HSUBPS, SIMD_VERSION_SSE3, SIMD_EMIT_BINARY },   
+       { SN_InterleaveHigh, OP_UNPACK_HIGHPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_InterleaveLow, OP_UNPACK_LOWPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_InvSqrt, OP_RSQRTPS, SIMD_VERSION_SSE1, SIMD_EMIT_UNARY },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_Max, OP_MAXPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_Min, OP_MINPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_Reciprocal, OP_RCPPS, SIMD_VERSION_SSE1, SIMD_EMIT_UNARY },
+       { SN_Shuffle, OP_PSHUFLED, SIMD_VERSION_SSE1, SIMD_EMIT_SHUFFLE },
+       { SN_Sqrt, OP_SQRTPS, SIMD_VERSION_SSE1, SIMD_EMIT_UNARY },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_StoreNonTemporal, OP_STOREX_NTA_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_get_W, 3, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_Z, 2, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_op_Addition, OP_ADDPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_ANDPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_ORPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Division, OP_DIVPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Equality, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_EQ },
+       { SN_op_ExclusiveOr, OP_XORPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST }, 
+       { SN_op_Inequality, OP_COMPPS, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_NEQ },
+       { SN_op_Multiply, OP_MULPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Subtraction, OP_SUBPS, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_W, 3, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_Z, 2, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER }
 };
 
 static const SimdIntrinsc vector2d_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_R8, SIMD_EMIT_CTOR },
-       { SN_AddSub, OP_ADDSUBPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE3 },
-       { SN_AndNot, OP_ANDNPD, SIMD_EMIT_BINARY },
-       { SN_CompareEqual, OP_COMPPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_EQ },
-       { SN_CompareLessEqual, OP_COMPPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_LE },
-       { SN_CompareLessThan, OP_COMPPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_LT },
-       { SN_CompareNotEqual, OP_COMPPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_NEQ },
-       { SN_CompareNotLessEqual, OP_COMPPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_NLE },
-       { SN_CompareNotLessThan, OP_COMPPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_NLT },
-       { SN_CompareOrdered, OP_COMPPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_ORD },
-       { SN_CompareUnordered, OP_COMPPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1, SIMD_COMP_UNORD },
-       { SN_Duplicate, OP_DUPPD, SIMD_EMIT_UNARY, SIMD_VERSION_SSE3 },
-       { SN_HorizontalAdd, OP_HADDPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE3 },
-       { SN_HorizontalSub, OP_HSUBPD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE3 },   
-       { SN_InterleaveHigh, OP_UNPACK_HIGHPD, SIMD_EMIT_BINARY },
-       { SN_InterleaveLow, OP_UNPACK_LOWPD, SIMD_EMIT_BINARY },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_Max, OP_MAXPD, SIMD_EMIT_BINARY },
-       { SN_Min, OP_MINPD, SIMD_EMIT_BINARY },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_Sqrt, OP_SQRTPD, SIMD_EMIT_UNARY },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_get_X, 0, SIMD_EMIT_GETTER_QWORD },
-       { SN_get_Y, 1, SIMD_EMIT_GETTER_QWORD },
-       { SN_op_Addition, OP_ADDPD, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_ANDPD, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_ORPD, SIMD_EMIT_BINARY },
-       { SN_op_Division, OP_DIVPD, SIMD_EMIT_BINARY },
-       { SN_op_ExclusiveOr, OP_XORPD, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST }, 
-       { SN_op_Multiply, OP_MULPD, SIMD_EMIT_BINARY },
-       { SN_op_Subtraction, OP_SUBPD, SIMD_EMIT_BINARY },
-       { SN_set_X, 0, SIMD_EMIT_SETTER },
-       { SN_set_Y, 1, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_R8, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_AddSub, OP_ADDSUBPD, SIMD_VERSION_SSE3, SIMD_EMIT_BINARY,},
+       { SN_AndNot, OP_ANDNPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_CompareEqual, OP_COMPPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_EQ },
+       { SN_CompareLessEqual, OP_COMPPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_LE },
+       { SN_CompareLessThan, OP_COMPPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_LT },
+       { SN_CompareNotEqual, OP_COMPPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_NEQ },
+       { SN_CompareNotLessEqual, OP_COMPPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_NLE },
+       { SN_CompareNotLessThan, OP_COMPPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_NLT },
+       { SN_CompareOrdered, OP_COMPPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_ORD },
+       { SN_CompareUnordered, OP_COMPPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_COMP_UNORD },
+       { SN_Duplicate, OP_DUPPD, SIMD_VERSION_SSE3, SIMD_EMIT_UNARY },
+       { SN_HorizontalAdd, OP_HADDPD, SIMD_VERSION_SSE3, SIMD_EMIT_BINARY },
+       { SN_HorizontalSub, OP_HSUBPD, SIMD_VERSION_SSE3, SIMD_EMIT_BINARY },   
+       { SN_InterleaveHigh, OP_UNPACK_HIGHPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_InterleaveLow, OP_UNPACK_LOWPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_Max, OP_MAXPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_Min, OP_MINPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_Sqrt, OP_SQRTPD, SIMD_VERSION_SSE1, SIMD_EMIT_UNARY },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_get_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER_QWORD },
+       { SN_get_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER_QWORD },
+       { SN_op_Addition, OP_ADDPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_ANDPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_ORPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Division, OP_DIVPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_ExclusiveOr, OP_XORPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST }, 
+       { SN_op_Multiply, OP_MULPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Subtraction, OP_SUBPD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
 };
 
 static const SimdIntrinsc vector2ul_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_I8, SIMD_EMIT_CTOR },
-       { SN_CompareEqual, OP_PCMPEQQ, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_UnpackHigh, OP_UNPACK_HIGHQ, SIMD_EMIT_BINARY },
-       { SN_UnpackLow, OP_UNPACK_LOWQ, SIMD_EMIT_BINARY },
-       { SN_get_X, 0, SIMD_EMIT_GETTER_QWORD },
-       { SN_get_Y, 1, SIMD_EMIT_GETTER_QWORD },
-       { SN_op_Addition, OP_PADDQ, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_PAND, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_POR, SIMD_EMIT_BINARY },
-       { SN_op_ExclusiveOr, OP_PXOR, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST },
-       { SN_op_LeftShift, OP_PSHLQ, SIMD_EMIT_SHIFT },
-       { SN_op_Multiply, OP_PMULQ, SIMD_EMIT_BINARY },
-       { SN_op_RightShift, OP_PSHRQ, SIMD_EMIT_SHIFT },
-       { SN_op_Subtraction, OP_PSUBQ, SIMD_EMIT_BINARY },
-       { SN_set_X, 0, SIMD_EMIT_SETTER },
-       { SN_set_Y, 1, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_I8, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_CompareEqual, OP_PCMPEQQ, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_UnpackHigh, OP_UNPACK_HIGHQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackLow, OP_UNPACK_LOWQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_get_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER_QWORD },
+       { SN_get_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER_QWORD },
+       { SN_op_Addition, OP_PADDQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_PAND, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_POR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_ExclusiveOr, OP_PXOR, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1 },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST },
+       { SN_op_LeftShift, OP_PSHLQ, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Multiply, OP_PMULQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_RightShift, OP_PSHRQ, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Subtraction, OP_PSUBQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
 };
 
 static const SimdIntrinsc vector2l_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_I8, SIMD_EMIT_CTOR },
-       { SN_CompareEqual, OP_PCMPEQQ, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_CompareGreaterThan, OP_PCMPGTQ, SIMD_EMIT_BINARY, SIMD_VERSION_SSE42 },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_LogicalRightShift, OP_PSHRQ, SIMD_EMIT_SHIFT },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_UnpackHigh, OP_UNPACK_HIGHQ, SIMD_EMIT_BINARY },
-       { SN_UnpackLow, OP_UNPACK_LOWQ, SIMD_EMIT_BINARY },
-       { SN_get_X, 0, SIMD_EMIT_GETTER_QWORD },
-       { SN_get_Y, 1, SIMD_EMIT_GETTER_QWORD },
-       { SN_op_Addition, OP_PADDQ, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_PAND, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_POR, SIMD_EMIT_BINARY },
-       { SN_op_ExclusiveOr, OP_PXOR, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST },
-       { SN_op_LeftShift, OP_PSHLQ, SIMD_EMIT_SHIFT },
-       { SN_op_Multiply, OP_PMULQ, SIMD_EMIT_BINARY },
-       { SN_op_Subtraction, OP_PSUBQ, SIMD_EMIT_BINARY },
-       { SN_set_X, 0, SIMD_EMIT_SETTER },
-       { SN_set_Y, 1, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_I8, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_CompareEqual, OP_PCMPEQQ, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_CompareGreaterThan, OP_PCMPGTQ, SIMD_VERSION_SSE42, SIMD_EMIT_BINARY },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_LogicalRightShift, OP_PSHRQ, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_UnpackHigh, OP_UNPACK_HIGHQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackLow, OP_UNPACK_LOWQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_get_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER_QWORD },
+       { SN_get_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER_QWORD },
+       { SN_op_Addition, OP_PADDQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_PAND, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_POR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_ExclusiveOr, OP_PXOR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST },
+       { SN_op_LeftShift, OP_PSHLQ, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Multiply, OP_PMULQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Subtraction, OP_PSUBQ, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
 };
 
 static const SimdIntrinsc vector4ui_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_I4, SIMD_EMIT_CTOR },
-       { SN_ArithmeticRightShift, OP_PSARD, SIMD_EMIT_SHIFT },
-       { SN_CompareEqual, OP_PCMPEQD, SIMD_EMIT_BINARY },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_Max, OP_PMAXD_UN, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_Min, OP_PMIND_UN, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_Shuffle, OP_PSHUFLED, SIMD_EMIT_SHUFFLE },
-       { SN_SignedPackWithSignedSaturation, OP_PACKD, SIMD_EMIT_BINARY },
-       { SN_SignedPackWithUnsignedSaturation, OP_PACKD_UN, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_UnpackHigh, OP_UNPACK_HIGHD, SIMD_EMIT_BINARY },
-       { SN_UnpackLow, OP_UNPACK_LOWD, SIMD_EMIT_BINARY },
-       { SN_get_W, 3, SIMD_EMIT_GETTER },
-       { SN_get_X, 0, SIMD_EMIT_GETTER },
-       { SN_get_Y, 1, SIMD_EMIT_GETTER },
-       { SN_get_Z, 2, SIMD_EMIT_GETTER },
-       { SN_op_Addition, OP_PADDD, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_PAND, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_POR, SIMD_EMIT_BINARY },
-       { SN_op_Equality, OP_PCMPEQD, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_EQ },
-       { SN_op_ExclusiveOr, OP_PXOR, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST },
-       { SN_op_Inequality, OP_PCMPEQD, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_NEQ },
-       { SN_op_LeftShift, OP_PSHLD, SIMD_EMIT_SHIFT },
-       { SN_op_Multiply, OP_PMULD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_op_RightShift, OP_PSHRD, SIMD_EMIT_SHIFT },
-       { SN_op_Subtraction, OP_PSUBD, SIMD_EMIT_BINARY },
-       { SN_set_W, 3, SIMD_EMIT_SETTER },
-       { SN_set_X, 0, SIMD_EMIT_SETTER },
-       { SN_set_Y, 1, SIMD_EMIT_SETTER },
-       { SN_set_Z, 2, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_I4, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_ArithmeticRightShift, OP_PSARD, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_CompareEqual, OP_PCMPEQD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_Max, OP_PMAXD_UN, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_Min, OP_PMIND_UN, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_Shuffle, OP_PSHUFLED, SIMD_VERSION_SSE1, SIMD_EMIT_SHUFFLE },
+       { SN_SignedPackWithSignedSaturation, OP_PACKD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_SignedPackWithUnsignedSaturation, OP_PACKD_UN, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_UnpackHigh, OP_UNPACK_HIGHD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackLow, OP_UNPACK_LOWD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_get_W, 3, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_Z, 2, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_op_Addition, OP_PADDD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_PAND, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_POR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Equality, OP_PCMPEQD, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_EQ },
+       { SN_op_ExclusiveOr, OP_PXOR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST },
+       { SN_op_Inequality, OP_PCMPEQD, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_NEQ },
+       { SN_op_LeftShift, OP_PSHLD, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Multiply, OP_PMULD, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_op_RightShift, OP_PSHRD, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Subtraction, OP_PSUBD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_W, 3, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_Z, 2, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
 };
 
 static const SimdIntrinsc vector4i_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_I4, SIMD_EMIT_CTOR },
-       { SN_CompareEqual, OP_PCMPEQD, SIMD_EMIT_BINARY },
-       { SN_CompareGreaterThan, OP_PCMPGTD, SIMD_EMIT_BINARY },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_LogicalRightShift, OP_PSHRD, SIMD_EMIT_SHIFT },
-       { SN_Max, OP_PMAXD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_Min, OP_PMIND, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_PackWithSignedSaturation, OP_PACKD, SIMD_EMIT_BINARY },
-       { SN_PackWithUnsignedSaturation, OP_PACKD_UN, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_Shuffle, OP_PSHUFLED, SIMD_EMIT_SHUFFLE },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_UnpackHigh, OP_UNPACK_HIGHD, SIMD_EMIT_BINARY },
-       { SN_UnpackLow, OP_UNPACK_LOWD, SIMD_EMIT_BINARY },
-       { SN_get_W, 3, SIMD_EMIT_GETTER },
-       { SN_get_X, 0, SIMD_EMIT_GETTER },
-       { SN_get_Y, 1, SIMD_EMIT_GETTER },
-       { SN_get_Z, 2, SIMD_EMIT_GETTER },
-       { SN_op_Addition, OP_PADDD, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_PAND, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_POR, SIMD_EMIT_BINARY },
-       { SN_op_Equality, OP_PCMPEQD, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_EQ },
-       { SN_op_ExclusiveOr, OP_PXOR, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST },
-       { SN_op_Inequality, OP_PCMPEQD, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_NEQ },
-       { SN_op_LeftShift, OP_PSHLD, SIMD_EMIT_SHIFT },
-       { SN_op_Multiply, OP_PMULD, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_op_RightShift, OP_PSARD, SIMD_EMIT_SHIFT },
-       { SN_op_Subtraction, OP_PSUBD, SIMD_EMIT_BINARY },
-       { SN_set_W, 3, SIMD_EMIT_SETTER },
-       { SN_set_X, 0, SIMD_EMIT_SETTER },
-       { SN_set_Y, 1, SIMD_EMIT_SETTER },
-       { SN_set_Z, 2, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_I4, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_CompareEqual, OP_PCMPEQD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_CompareGreaterThan, OP_PCMPGTD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_LogicalRightShift, OP_PSHRD, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_Max, OP_PMAXD, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_Min, OP_PMIND, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_PackWithSignedSaturation, OP_PACKD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_PackWithUnsignedSaturation, OP_PACKD_UN, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_Shuffle, OP_PSHUFLED, SIMD_VERSION_SSE1, SIMD_EMIT_SHUFFLE },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_UnpackHigh, OP_UNPACK_HIGHD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackLow, OP_UNPACK_LOWD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_get_W, 3, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_Z, 2, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_op_Addition, OP_PADDD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_PAND, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_POR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Equality, OP_PCMPEQD, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_EQ },
+       { SN_op_ExclusiveOr, OP_PXOR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST },
+       { SN_op_Inequality, OP_PCMPEQD, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_NEQ },
+       { SN_op_LeftShift, OP_PSHLD, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Multiply, OP_PMULD, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_op_RightShift, OP_PSARD, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Subtraction, OP_PSUBD, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_W, 3, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_X, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_Y, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_Z, 2, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
 };
 
 static const SimdIntrinsc vector8us_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_I2, SIMD_EMIT_CTOR },
-       { SN_AddWithSaturation, OP_PADDW_SAT_UN, SIMD_EMIT_BINARY },
-       { SN_ArithmeticRightShift, OP_PSARW, SIMD_EMIT_SHIFT },
-       { SN_Average, OP_PAVGW_UN, SIMD_EMIT_BINARY },
-       { SN_CompareEqual, OP_PCMPEQW, SIMD_EMIT_BINARY },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_Max, OP_PMAXW_UN, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_Min, OP_PMINW_UN, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_MultiplyStoreHigh, OP_PMULW_HIGH_UN, SIMD_EMIT_BINARY },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_ShuffleHigh, OP_PSHUFLEW_HIGH, SIMD_EMIT_SHUFFLE },
-       { SN_ShuffleLow, OP_PSHUFLEW_LOW, SIMD_EMIT_SHUFFLE },
-       { SN_SignedPackWithSignedSaturation, OP_PACKW, SIMD_EMIT_BINARY },
-       { SN_SignedPackWithUnsignedSaturation, OP_PACKW_UN, SIMD_EMIT_BINARY },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_SubtractWithSaturation, OP_PSUBW_SAT_UN, SIMD_EMIT_BINARY },
-       { SN_UnpackHigh, OP_UNPACK_HIGHW, SIMD_EMIT_BINARY },
-       { SN_UnpackLow, OP_UNPACK_LOWW, SIMD_EMIT_BINARY },
-       { SN_get_V0, 0, SIMD_EMIT_GETTER },
-       { SN_get_V1, 1, SIMD_EMIT_GETTER },
-       { SN_get_V2, 2, SIMD_EMIT_GETTER },
-       { SN_get_V3, 3, SIMD_EMIT_GETTER },
-       { SN_get_V4, 4, SIMD_EMIT_GETTER },
-       { SN_get_V5, 5, SIMD_EMIT_GETTER },
-       { SN_get_V6, 6, SIMD_EMIT_GETTER },
-       { SN_get_V7, 7, SIMD_EMIT_GETTER },
-       { SN_op_Addition, OP_PADDW, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_PAND, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_POR, SIMD_EMIT_BINARY },
-       { SN_op_Equality, OP_PCMPEQW, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_EQ },
-       { SN_op_ExclusiveOr, OP_PXOR, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST },
-       { SN_op_Inequality, OP_PCMPEQW, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_NEQ },
-       { SN_op_LeftShift, OP_PSHLW, SIMD_EMIT_SHIFT },
-       { SN_op_Multiply, OP_PMULW, SIMD_EMIT_BINARY },
-       { SN_op_RightShift, OP_PSHRW, SIMD_EMIT_SHIFT },
-       { SN_op_Subtraction, OP_PSUBW, SIMD_EMIT_BINARY },
-       { SN_set_V0, 0, SIMD_EMIT_SETTER },
-       { SN_set_V1, 1, SIMD_EMIT_SETTER },
-       { SN_set_V2, 2, SIMD_EMIT_SETTER },
-       { SN_set_V3, 3, SIMD_EMIT_SETTER },
-       { SN_set_V4, 4, SIMD_EMIT_SETTER },
-       { SN_set_V5, 5, SIMD_EMIT_SETTER },
-       { SN_set_V6, 6, SIMD_EMIT_SETTER },
-       { SN_set_V7, 7, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_I2, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_AddWithSaturation, OP_PADDW_SAT_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_ArithmeticRightShift, OP_PSARW, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_Average, OP_PAVGW_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_CompareEqual, OP_PCMPEQW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY, SIMD_VERSION_SSE1 },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_Max, OP_PMAXW_UN, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_Min, OP_PMINW_UN, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_MultiplyStoreHigh, OP_PMULW_HIGH_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_ShuffleHigh, OP_PSHUFLEW_HIGH, SIMD_VERSION_SSE1, SIMD_EMIT_SHUFFLE },
+       { SN_ShuffleLow, OP_PSHUFLEW_LOW, SIMD_VERSION_SSE1, SIMD_EMIT_SHUFFLE },
+       { SN_SignedPackWithSignedSaturation, OP_PACKW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_SignedPackWithUnsignedSaturation, OP_PACKW_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_SubtractWithSaturation, OP_PSUBW_SAT_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackHigh, OP_UNPACK_HIGHW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackLow, OP_UNPACK_LOWW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_get_V0, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V1, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V2, 2, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V3, 3, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V4, 4, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V5, 5, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V6, 6, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V7, 7, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_op_Addition, OP_PADDW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_PAND, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_POR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Equality, OP_PCMPEQW, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_EQ },
+       { SN_op_ExclusiveOr, OP_PXOR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST },
+       { SN_op_Inequality, OP_PCMPEQW, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_NEQ },
+       { SN_op_LeftShift, OP_PSHLW, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Multiply, OP_PMULW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_RightShift, OP_PSHRW, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Subtraction, OP_PSUBW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_V0, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V1, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V2, 2, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V3, 3, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V4, 4, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V5, 5, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V6, 6, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V7, 7, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
 };
 
 static const SimdIntrinsc vector8s_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_I2, SIMD_EMIT_CTOR },
-       { SN_AddWithSaturation, OP_PADDW_SAT, SIMD_EMIT_BINARY },
-       { SN_CompareEqual, OP_PCMPEQW, SIMD_EMIT_BINARY },
-       { SN_CompareGreaterThan, OP_PCMPGTW, SIMD_EMIT_BINARY },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_LogicalRightShift, OP_PSHRW, SIMD_EMIT_SHIFT },
-       { SN_Max, OP_PMAXW, SIMD_EMIT_BINARY },
-       { SN_Min, OP_PMINW, SIMD_EMIT_BINARY },
-       { SN_MultiplyStoreHigh, OP_PMULW_HIGH, SIMD_EMIT_BINARY },
-       { SN_PackWithSignedSaturation, OP_PACKW, SIMD_EMIT_BINARY },
-       { SN_PackWithUnsignedSaturation, OP_PACKW_UN, SIMD_EMIT_BINARY },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_ShuffleHigh, OP_PSHUFLEW_HIGH, SIMD_EMIT_SHUFFLE },
-       { SN_ShuffleLow, OP_PSHUFLEW_LOW, SIMD_EMIT_SHUFFLE },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_SubtractWithSaturation, OP_PSUBW_SAT_UN, SIMD_EMIT_BINARY },
-       { SN_UnpackHigh, OP_UNPACK_HIGHW, SIMD_EMIT_BINARY },
-       { SN_UnpackLow, OP_UNPACK_LOWW, SIMD_EMIT_BINARY },
-       { SN_get_V0, 0, SIMD_EMIT_GETTER },
-       { SN_get_V1, 1, SIMD_EMIT_GETTER },
-       { SN_get_V2, 2, SIMD_EMIT_GETTER },
-       { SN_get_V3, 3, SIMD_EMIT_GETTER },
-       { SN_get_V4, 4, SIMD_EMIT_GETTER },
-       { SN_get_V5, 5, SIMD_EMIT_GETTER },
-       { SN_get_V6, 6, SIMD_EMIT_GETTER },
-       { SN_get_V7, 7, SIMD_EMIT_GETTER },
-       { SN_op_Addition, OP_PADDW, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_PAND, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_POR, SIMD_EMIT_BINARY },
-       { SN_op_Equality, OP_PCMPEQW, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_EQ },
-       { SN_op_ExclusiveOr, OP_PXOR, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST },
-       { SN_op_Inequality, OP_PCMPEQW, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_NEQ },
-       { SN_op_LeftShift, OP_PSHLW, SIMD_EMIT_SHIFT },
-       { SN_op_Multiply, OP_PMULW, SIMD_EMIT_BINARY },
-       { SN_op_RightShift, OP_PSARW, SIMD_EMIT_SHIFT },
-       { SN_op_Subtraction, OP_PSUBW, SIMD_EMIT_BINARY },
-       { SN_set_V0, 0, SIMD_EMIT_SETTER },
-       { SN_set_V1, 1, SIMD_EMIT_SETTER },
-       { SN_set_V2, 2, SIMD_EMIT_SETTER },
-       { SN_set_V3, 3, SIMD_EMIT_SETTER },
-       { SN_set_V4, 4, SIMD_EMIT_SETTER },
-       { SN_set_V5, 5, SIMD_EMIT_SETTER },
-       { SN_set_V6, 6, SIMD_EMIT_SETTER },
-       { SN_set_V7, 7, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_I2, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_AddWithSaturation, OP_PADDW_SAT, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_CompareEqual, OP_PCMPEQW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_CompareGreaterThan, OP_PCMPGTW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_LogicalRightShift, OP_PSHRW, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_Max, OP_PMAXW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_Min, OP_PMINW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_MultiplyStoreHigh, OP_PMULW_HIGH, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_PackWithSignedSaturation, OP_PACKW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_PackWithUnsignedSaturation, OP_PACKW_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_ShuffleHigh, OP_PSHUFLEW_HIGH, SIMD_VERSION_SSE1, SIMD_EMIT_SHUFFLE },
+       { SN_ShuffleLow, OP_PSHUFLEW_LOW, SIMD_VERSION_SSE1, SIMD_EMIT_SHUFFLE },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_SubtractWithSaturation, OP_PSUBW_SAT_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackHigh, OP_UNPACK_HIGHW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackLow, OP_UNPACK_LOWW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_get_V0, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V1, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V2, 2, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V3, 3, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V4, 4, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V5, 5, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V6, 6, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V7, 7, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_op_Addition, OP_PADDW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_PAND, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_POR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Equality, OP_PCMPEQW, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_EQ },
+       { SN_op_ExclusiveOr, OP_PXOR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST },
+       { SN_op_Inequality, OP_PCMPEQW, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_NEQ },
+       { SN_op_LeftShift, OP_PSHLW, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Multiply, OP_PMULW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_RightShift, OP_PSARW, SIMD_VERSION_SSE1, SIMD_EMIT_SHIFT },
+       { SN_op_Subtraction, OP_PSUBW, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_V0, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V1, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V2, 2, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V3, 3, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V4, 4, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V5, 5, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V6, 6, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V7, 7, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
 };
 
 static const SimdIntrinsc vector16b_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_I1, SIMD_EMIT_CTOR },
-       { SN_AddWithSaturation, OP_PADDB_SAT_UN, SIMD_EMIT_BINARY },
-       { SN_Average, OP_PAVGB_UN, SIMD_EMIT_BINARY },
-       { SN_CompareEqual, OP_PCMPEQB, SIMD_EMIT_BINARY },
-       { SN_ExtractByteMask, 0, SIMD_EMIT_EXTRACT_MASK },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_Max, OP_PMAXB_UN, SIMD_EMIT_BINARY },
-       { SN_Min, OP_PMINB_UN, SIMD_EMIT_BINARY },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_SubtractWithSaturation, OP_PSUBB_SAT_UN, SIMD_EMIT_BINARY },
-       { SN_SumOfAbsoluteDifferences, OP_PSUM_ABS_DIFF, SIMD_EMIT_BINARY },
-       { SN_UnpackHigh, OP_UNPACK_HIGHB, SIMD_EMIT_BINARY },
-       { SN_UnpackLow, OP_UNPACK_LOWB, SIMD_EMIT_BINARY },
-       { SN_get_V0, 0, SIMD_EMIT_GETTER },
-       { SN_get_V1, 1, SIMD_EMIT_GETTER },
-       { SN_get_V10, 10, SIMD_EMIT_GETTER },
-       { SN_get_V11, 11, SIMD_EMIT_GETTER },
-       { SN_get_V12, 12, SIMD_EMIT_GETTER },
-       { SN_get_V13, 13, SIMD_EMIT_GETTER },
-       { SN_get_V14, 14, SIMD_EMIT_GETTER },
-       { SN_get_V15, 15, SIMD_EMIT_GETTER },
-       { SN_get_V2, 2, SIMD_EMIT_GETTER },
-       { SN_get_V3, 3, SIMD_EMIT_GETTER },
-       { SN_get_V4, 4, SIMD_EMIT_GETTER },
-       { SN_get_V5, 5, SIMD_EMIT_GETTER },
-       { SN_get_V6, 6, SIMD_EMIT_GETTER },
-       { SN_get_V7, 7, SIMD_EMIT_GETTER },
-       { SN_get_V8, 8, SIMD_EMIT_GETTER },
-       { SN_get_V9, 9, SIMD_EMIT_GETTER },
-       { SN_op_Addition, OP_PADDB, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_PAND, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_POR, SIMD_EMIT_BINARY },
-       { SN_op_Equality, OP_PCMPEQB, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_EQ },
-       { SN_op_ExclusiveOr, OP_PXOR, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST },
-       { SN_op_Inequality, OP_PCMPEQB, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_NEQ },
-       { SN_op_Subtraction, OP_PSUBB, SIMD_EMIT_BINARY },
-       { SN_set_V0, 0, SIMD_EMIT_SETTER },
-       { SN_set_V1, 1, SIMD_EMIT_SETTER },
-       { SN_set_V10, 10, SIMD_EMIT_SETTER },
-       { SN_set_V11, 11, SIMD_EMIT_SETTER },
-       { SN_set_V12, 12, SIMD_EMIT_SETTER },
-       { SN_set_V13, 13, SIMD_EMIT_SETTER },
-       { SN_set_V14, 14, SIMD_EMIT_SETTER },
-       { SN_set_V15, 15, SIMD_EMIT_SETTER },
-       { SN_set_V2, 2, SIMD_EMIT_SETTER },
-       { SN_set_V3, 3, SIMD_EMIT_SETTER },
-       { SN_set_V4, 4, SIMD_EMIT_SETTER },
-       { SN_set_V5, 5, SIMD_EMIT_SETTER },
-       { SN_set_V6, 6, SIMD_EMIT_SETTER },
-       { SN_set_V7, 7, SIMD_EMIT_SETTER },
-       { SN_set_V8, 8, SIMD_EMIT_SETTER },
-       { SN_set_V9, 9, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_I1, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_AddWithSaturation, OP_PADDB_SAT_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_Average, OP_PAVGB_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_CompareEqual, OP_PCMPEQB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_ExtractByteMask, 0, SIMD_VERSION_SSE1, SIMD_EMIT_EXTRACT_MASK },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_Max, OP_PMAXB_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_Min, OP_PMINB_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_SubtractWithSaturation, OP_PSUBB_SAT_UN, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_SumOfAbsoluteDifferences, OP_PSUM_ABS_DIFF, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackHigh, OP_UNPACK_HIGHB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackLow, OP_UNPACK_LOWB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_get_V0, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V1, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V10, 10, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V11, 11, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V12, 12, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V13, 13, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V14, 14, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V15, 15, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V2, 2, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V3, 3, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V4, 4, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V5, 5, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V6, 6, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V7, 7, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V8, 8, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V9, 9, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_op_Addition, OP_PADDB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_PAND, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_POR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Equality, OP_PCMPEQB, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_EQ },
+       { SN_op_ExclusiveOr, OP_PXOR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST },
+       { SN_op_Inequality, OP_PCMPEQB, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_NEQ },
+       { SN_op_Subtraction, OP_PSUBB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_V0, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V1, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V10, 10, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V11, 11, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V12, 12, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V13, 13, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V14, 14, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V15, 15, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V2, 2, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V3, 3, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V4, 4, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V5, 5, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V6, 6, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V7, 7, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V8, 8, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V9, 9, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
 };
 
 /*
@@ -514,62 +514,62 @@ Missing:
 setters
  */
 static const SimdIntrinsc vector16sb_intrinsics[] = {
-       { SN_ctor, OP_EXPAND_I1, SIMD_EMIT_CTOR },
-       { SN_AddWithSaturation, OP_PADDB_SAT, SIMD_EMIT_BINARY },
-       { SN_CompareEqual, OP_PCMPEQB, SIMD_EMIT_BINARY },
-       { SN_CompareGreaterThan, OP_PCMPGTB, SIMD_EMIT_BINARY },
-       { SN_ExtractByteMask, 0, SIMD_EMIT_EXTRACT_MASK },
-       { SN_LoadAligned, 0, SIMD_EMIT_LOAD_ALIGNED },
-       { SN_Max, OP_PMAXB, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_Min, OP_PMINB, SIMD_EMIT_BINARY, SIMD_VERSION_SSE41 },
-       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_0 },
-       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_1 },
-       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_2 },
-       { SN_PrefetchNonTemporal, 0, SIMD_EMIT_PREFETCH, SIMD_VERSION_SSE1, SIMD_PREFETCH_MODE_NTA },
-       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_EMIT_STORE },
-       { SN_SubtractWithSaturation, OP_PSUBB_SAT, SIMD_EMIT_BINARY },
-       { SN_UnpackHigh, OP_UNPACK_HIGHB, SIMD_EMIT_BINARY },
-       { SN_UnpackLow, OP_UNPACK_LOWB, SIMD_EMIT_BINARY },
-       { SN_get_V0, 0, SIMD_EMIT_GETTER },
-       { SN_get_V1, 1, SIMD_EMIT_GETTER },
-       { SN_get_V10, 10, SIMD_EMIT_GETTER },
-       { SN_get_V11, 11, SIMD_EMIT_GETTER },
-       { SN_get_V12, 12, SIMD_EMIT_GETTER },
-       { SN_get_V13, 13, SIMD_EMIT_GETTER },
-       { SN_get_V14, 14, SIMD_EMIT_GETTER },
-       { SN_get_V15, 15, SIMD_EMIT_GETTER },
-       { SN_get_V2, 2, SIMD_EMIT_GETTER },
-       { SN_get_V3, 3, SIMD_EMIT_GETTER },
-       { SN_get_V4, 4, SIMD_EMIT_GETTER },
-       { SN_get_V5, 5, SIMD_EMIT_GETTER },
-       { SN_get_V6, 6, SIMD_EMIT_GETTER },
-       { SN_get_V7, 7, SIMD_EMIT_GETTER },
-       { SN_get_V8, 8, SIMD_EMIT_GETTER },
-       { SN_get_V9, 9, SIMD_EMIT_GETTER },
-       { SN_op_Addition, OP_PADDB, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseAnd, OP_PAND, SIMD_EMIT_BINARY },
-       { SN_op_BitwiseOr, OP_POR, SIMD_EMIT_BINARY },
-       { SN_op_Equality, OP_PCMPEQB, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_EQ },
-       { SN_op_ExclusiveOr, OP_PXOR, SIMD_EMIT_BINARY },
-       { SN_op_Explicit, 0, SIMD_EMIT_CAST },
-       { SN_op_Inequality, OP_PCMPEQB, SIMD_EMIT_EQUALITY, SIMD_VERSION_SSE1, SIMD_COMP_NEQ },
-       { SN_op_Subtraction, OP_PSUBB, SIMD_EMIT_BINARY },
-       { SN_set_V0, 0, SIMD_EMIT_SETTER },
-       { SN_set_V1, 1, SIMD_EMIT_SETTER },
-       { SN_set_V10, 10, SIMD_EMIT_SETTER },
-       { SN_set_V11, 11, SIMD_EMIT_SETTER },
-       { SN_set_V12, 12, SIMD_EMIT_SETTER },
-       { SN_set_V13, 13, SIMD_EMIT_SETTER },
-       { SN_set_V14, 14, SIMD_EMIT_SETTER },
-       { SN_set_V15, 15, SIMD_EMIT_SETTER },
-       { SN_set_V2, 2, SIMD_EMIT_SETTER },
-       { SN_set_V3, 3, SIMD_EMIT_SETTER },
-       { SN_set_V4, 4, SIMD_EMIT_SETTER },
-       { SN_set_V5, 5, SIMD_EMIT_SETTER },
-       { SN_set_V6, 6, SIMD_EMIT_SETTER },
-       { SN_set_V7, 7, SIMD_EMIT_SETTER },
-       { SN_set_V8, 8, SIMD_EMIT_SETTER },
-       { SN_set_V9, 9, SIMD_EMIT_SETTER },
+       { SN_ctor, OP_EXPAND_I1, SIMD_VERSION_SSE1, SIMD_EMIT_CTOR },
+       { SN_AddWithSaturation, OP_PADDB_SAT, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_CompareEqual, OP_PCMPEQB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_CompareGreaterThan, OP_PCMPGTB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_ExtractByteMask, 0, SIMD_VERSION_SSE1, SIMD_EMIT_EXTRACT_MASK },
+       { SN_LoadAligned, 0, SIMD_VERSION_SSE1, SIMD_EMIT_LOAD_ALIGNED },
+       { SN_Max, OP_PMAXB, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_Min, OP_PMINB, SIMD_VERSION_SSE41, SIMD_EMIT_BINARY },
+       { SN_PrefetchTemporalAllCacheLevels, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_0 },
+       { SN_PrefetchTemporal1stLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_1 },
+       { SN_PrefetchTemporal2ndLevelCache, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_2 },
+       { SN_PrefetchNonTemporal, 0, SIMD_VERSION_SSE1, SIMD_EMIT_PREFETCH, SIMD_PREFETCH_MODE_NTA },
+       { SN_StoreAligned, OP_STOREX_ALIGNED_MEMBASE_REG, SIMD_VERSION_SSE1, SIMD_EMIT_STORE },
+       { SN_SubtractWithSaturation, OP_PSUBB_SAT, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackHigh, OP_UNPACK_HIGHB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_UnpackLow, OP_UNPACK_LOWB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_get_V0, 0, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V1, 1, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V10, 10, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V11, 11, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V12, 12, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V13, 13, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V14, 14, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V15, 15, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V2, 2, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V3, 3, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V4, 4, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V5, 5, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V6, 6, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V7, 7, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V8, 8, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_get_V9, 9, SIMD_VERSION_SSE1, SIMD_EMIT_GETTER },
+       { SN_op_Addition, OP_PADDB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseAnd, OP_PAND, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_BitwiseOr, OP_POR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Equality, OP_PCMPEQB, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_EQ },
+       { SN_op_ExclusiveOr, OP_PXOR, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_op_Explicit, 0, SIMD_VERSION_SSE1, SIMD_EMIT_CAST },
+       { SN_op_Inequality, OP_PCMPEQB, SIMD_VERSION_SSE1, SIMD_EMIT_EQUALITY, SIMD_COMP_NEQ },
+       { SN_op_Subtraction, OP_PSUBB, SIMD_VERSION_SSE1, SIMD_EMIT_BINARY },
+       { SN_set_V0, 0, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V1, 1, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V10, 10, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V11, 11, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V12, 12, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V13, 13, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V14, 14, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V15, 15, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V2, 2, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V3, 3, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V4, 4, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V5, 5, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V6, 6, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V7, 7, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V8, 8, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
+       { SN_set_V9, 9, SIMD_VERSION_SSE1, SIMD_EMIT_SETTER },
 };
 
 static guint32 simd_supported_versions;
@@ -866,22 +866,74 @@ get_simd_ctor_spill_area (MonoCompile *cfg, MonoClass *avector_klass)
        return cfg->simd_ctor_var;
 }
 
+static int
+mono_type_to_expand_op (MonoType *type)
+{
+       switch (type->type) {
+       case MONO_TYPE_I1:
+       case MONO_TYPE_U1:
+               return OP_EXPAND_I1;
+       case MONO_TYPE_I2:
+       case MONO_TYPE_U2:
+               return OP_EXPAND_I2;
+       case MONO_TYPE_I4:
+       case MONO_TYPE_U4:
+               return OP_EXPAND_I4;
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8:
+               return OP_EXPAND_I8;
+       case MONO_TYPE_R4:
+               return OP_EXPAND_R4;
+       case MONO_TYPE_R8:
+               return OP_EXPAND_R8;
+       }
+       g_assert_not_reached ();
+}
+
+static int
+get_simd_vreg_or_expanded_scalar (MonoCompile *cfg, MonoMethod *cmethod, MonoInst *src, int position)
+{
+       MonoInst *ins;
+       MonoMethodSignature *sig = mono_method_signature (cmethod);
+       int expand_op;
+
+       g_assert (sig->param_count == 2);
+       g_assert (position == 0 || position == 1);
+
+       if (mono_class_from_mono_type (sig->params [position])->simd_type)
+               return get_simd_vreg (cfg, cmethod, src);
+
+       expand_op = mono_type_to_expand_op (sig->params [position]);
+       MONO_INST_NEW (cfg, ins, expand_op);
+       ins->klass = cmethod->klass;
+       ins->sreg1 = src->dreg;
+       ins->type = STACK_VTYPE;
+       ins->dreg = alloc_ireg (cfg);
+       MONO_ADD_INS (cfg->cbb, ins);
+
+       if (expand_op == OP_EXPAND_R4)
+               ins->backend.spill_var = get_int_to_float_spill_area (cfg);
+       else if (expand_op == OP_EXPAND_R8)
+               ins->backend.spill_var = get_double_spill_area (cfg);
+
+       return ins->dreg;
+}
+
 static MonoInst*
 simd_intrinsic_emit_binary (const SimdIntrinsc *intrinsic, MonoCompile *cfg, MonoMethod *cmethod, MonoInst **args)
 {
        MonoInst* ins;
        int left_vreg, right_vreg;
 
-       left_vreg = get_simd_vreg (cfg, cmethod, args [0]);
-       right_vreg = get_simd_vreg (cfg, cmethod, args [1]);
-       
+       left_vreg = get_simd_vreg_or_expanded_scalar (cfg, cmethod, args [0], 0);
+       right_vreg = get_simd_vreg_or_expanded_scalar (cfg, cmethod, args [1], 1);
+
 
        MONO_INST_NEW (cfg, ins, intrinsic->opcode);
        ins->klass = cmethod->klass;
        ins->sreg1 = left_vreg;
        ins->sreg2 = right_vreg;
        ins->type = STACK_VTYPE;
-       ins->klass = cmethod->klass;
        ins->dreg = alloc_ireg (cfg);
        ins->inst_c0 = intrinsic->flags;
        MONO_ADD_INS (cfg->cbb, ins);
@@ -1384,9 +1436,16 @@ emit_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
                        mono_print_ins (args [i]);
                }
        }
-       if (result->simd_version && !((1 << result->simd_version) & simd_supported_versions)) {
-               if (IS_DEBUG_ON (cfg))
-                       printf ("function %s::%s/%d requires unsuported SIMD instruction set %s \n", cmethod->klass->name, cmethod->name, fsig->param_count, simd_version_name (result->simd_version));
+       if (result->simd_version_flags && !(result->simd_version_flags & simd_supported_versions)) {
+               if (IS_DEBUG_ON (cfg)) {
+                       int x;
+                       printf ("function %s::%s/%d requires one of unsuported SIMD instruction set(s): ", cmethod->klass->name, cmethod->name, fsig->param_count);
+                       for (x = 1; x <= SIMD_VERSION_INDEX_END; x++)
+                               if (result->simd_version_flags & (1 << x))
+                                       printf ("%s ", simd_version_name (1 << x));
+
+                       printf ("\n");
+               }
                return NULL;
        }
 
index 0398aa6191e3c6c36600222c8075d912b92e4bfb..b635e7ce6b706970b1cf440d82c73976771d8813 100644 (file)
@@ -74,7 +74,7 @@
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_get_unbox_trampoline                        */
+/* Name                - mono_arch_get_unbox_trampoline                    */
 /*                                                                  */
 /* Function    - Return a pointer to a trampoline which does the   */
 /*               unboxing before calling the method.               */
@@ -119,9 +119,9 @@ mono_arch_get_unbox_trampoline (MonoGenericSharingContext *gsctx, MonoMethod *me
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_patch_callsite                              */
+/* Name                - mono_arch_patch_callsite                          */
 /*                                                                  */
-/* Function    - Patch a non-virtual callsite so it calls @addr.       */
+/* Function    - Patch a non-virtual callsite so it calls @addr.   */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
@@ -157,6 +157,14 @@ mono_arch_patch_callsite (guint8 *method_start, guint8 *orig_code, guint8 *addr)
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_patch_plt_entry.                        */
+/*                                                                  */
+/* Function    - Patch a PLT entry - unused as yet.                */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
 void
 mono_arch_patch_plt_entry (guint8 *code, gpointer *got, mgreg_t *regs, guint8 *addr)
 {
@@ -167,9 +175,9 @@ mono_arch_patch_plt_entry (guint8 *code, gpointer *got, mgreg_t *regs, guint8 *a
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_nullify_class_init_trampoline               */
+/* Name                - mono_arch_nullify_class_init_trampoline           */
 /*                                                                  */
-/* Function    - Nullify a call which calls a class init trampoline    */
+/* Function    - Nullify a call which calls a class init trampoline*/
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
@@ -185,6 +193,14 @@ mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_nullify_plt_entry                       */
+/*                                                                  */
+/* Function    - Nullify a PLT entry call.                         */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
 void
 mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 {
@@ -195,9 +211,9 @@ mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_get_vcall_slot                              */
+/* Name                - mono_arch_get_vcall_slot                          */
 /*                                                                  */
-/* Function    - This method is called by the arch independent         */
+/* Function    - This method is called by the arch independent     */
 /*            trampoline code to determine the vtable slot used by  */
 /*            the call which invoked the trampoline.                */
 /*                                                                  */
@@ -215,9 +231,13 @@ mono_arch_get_vcall_slot (guint8 *code, mgreg_t *regs, int *displacement)
        guchar* base;
        unsigned short opcode;
        char *sp;
+       MonoLMF *lmf = (MonoLMF *) ((gchar *) regs - sizeof(MonoLMF));
 
        // We are passed sp instead of the register array
-       sp = (char*)regs;
+#if 0
+       sp = (char *) regs;
+#endif
+       sp = (char *) lmf->gregs[s390_r15];
 
        *displacement = 0;
 
@@ -227,7 +247,7 @@ mono_arch_get_vcall_slot (guint8 *code, mgreg_t *regs, int *displacement)
                return NULL;
 
        /*-----------------------------------*/
-       /* This is a bras r14,Rz instruction */
+       /* This is a basr r14,Rz instruction */
        /* If it's preceded by a LG Rx,d(Ry) */
        /* If Rz == 1 then this is virtual   */
        /* call.                             */
@@ -238,8 +258,7 @@ mono_arch_get_vcall_slot (guint8 *code, mgreg_t *regs, int *displacement)
        /* If call is preceded by LGR then   */
        /* there's nothing to patch          */
        /*-----------------------------------*/
-       if ((code[0] == 0xb9) &&
-               (code[1] == 0x04))
+       if ((code[0] == 0xb9) && (code[1] == 0x04))
                return NULL;
 
        /*-----------------------------------*/
@@ -257,10 +276,15 @@ mono_arch_get_vcall_slot (guint8 *code, mgreg_t *regs, int *displacement)
        /* hh  = high 8 bits of displacement */
        /*-----------------------------------*/
        reg      = code[0] >> 4;
-       *displacement = (code[2] << 12) +
-               ((code[0] & 0x0f) << 8) +
-               code[1];
+       *displacement = (code[2] << 12) |
+                       ((code[0] & 0x0f) << 8) |
+                       code[1];
 
+       if (code[2] & 0x80)
+               *displacement |= 0xfff00000;
+
+       base = ((guchar *) lmf->gregs[reg]);
+#if 0
        if (reg > 5)
                base = *((guchar **) (sp + S390_REG_SAVE_OFFSET +
                                                          sizeof(long)*(reg-6)));
@@ -268,6 +292,7 @@ mono_arch_get_vcall_slot (guint8 *code, mgreg_t *regs, int *displacement)
                base = *((guchar **) ((sp - CREATE_STACK_SIZE) +
                                                          CREATE_GR_OFFSET +
                                                          sizeof(long)*(reg-2)));
+#endif
        if (lkReg != 1)
                /* Non virtual call */
                return NULL;
@@ -279,7 +304,7 @@ mono_arch_get_vcall_slot (guint8 *code, mgreg_t *regs, int *displacement)
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_create_trampoline_code                            */
+/* Name                - mono_arch_create_trampoline_code                  */
 /*                                                                  */
 /* Function    - Create the designated type of trampoline according*/
 /*                to the 'tramp_type' parameter.                    */
@@ -303,7 +328,7 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
          stack size big enough to save our registers.
          -----------------------------------------------------------*/
                
-       s390_stmg (buf, s390_r6, s390_r14, STK_BASE, S390_REG_SAVE_OFFSET);
+       s390_stmg (buf, s390_r6, s390_r15, STK_BASE, S390_REG_SAVE_OFFSET);
        s390_lgr  (buf, s390_r11, s390_r15);
        s390_aghi (buf, STK_BASE, -CREATE_STACK_SIZE);
        s390_stg  (buf, s390_r11, 0, STK_BASE, 0);
@@ -388,12 +413,14 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
        /*---------------------------------------------------------------*/     
        /* Save general and floating point registers                     */     
        /*---------------------------------------------------------------*/     
-       s390_stmg  (buf, s390_r2, s390_r12, s390_r13,
-                           G_STRUCT_OFFSET(MonoLMF, gregs[2]));                
-       for (i = 0; i < 16; i++) {
-               s390_std  (buf, i, 0, s390_r13,
-                                  G_STRUCT_OFFSET(MonoLMF, fregs[i]));
-       }                                               
+       s390_mvc   (buf, 4*sizeof(gulong), s390_r13, G_STRUCT_OFFSET(MonoLMF, gregs[2]), 
+                   STK_BASE, CREATE_GR_OFFSET);
+       s390_mvc   (buf, 10*sizeof(gulong), s390_r13, G_STRUCT_OFFSET(MonoLMF, gregs[6]), 
+                   s390_r11, S390_REG_SAVE_OFFSET);
+
+       /* Simply copy fpregs already saved above                        */
+       s390_mvc   (buf, 16*sizeof(double), s390_r13, G_STRUCT_OFFSET(MonoLMF, fregs[0]),
+                   STK_BASE, CREATE_FP_OFFSET);
 
        /*---------------------------------------------------------------*/
        /* STEP 2: call the C trampoline function                        */
@@ -402,8 +429,7 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
        /* Set arguments */
 
        /* Arg 1: mgreg_t *regs. We pass sp instead */
-       s390_lgr  (buf, s390_r2, STK_BASE);
-       s390_ahi  (buf, s390_r2, CREATE_STACK_SIZE);
+       s390_la  (buf, s390_r2, 0, STK_BASE, CREATE_STACK_SIZE);
                
        /* Arg 2: code (next address to the instruction that called us) */
        if (tramp_type == MONO_TRAMPOLINE_JUMP) {
@@ -474,9 +500,9 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_create_specific_trampoline                  */
+/* Name                - mono_arch_create_specific_trampoline              */
 /*                                                                  */
-/* Function    - Creates the given kind of specific trampoline         */
+/* Function    - Creates the given kind of specific trampoline     */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
@@ -516,10 +542,20 @@ mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_ty
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_create_rgctx_lazy_fetch_trampoline      */
+/*                                                                  */
+/* Function    -                                                   */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
 gpointer
 mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 encoded_offset)
 {
        /* FIXME: implement! */
        g_assert_not_reached ();
        return NULL;
-}
+}      
+
+/*========================= End of Function ========================*/
index bb39f27ad80caf1f1f992905cf86fd644cfa992d..2a4e1588da56c6046289121cffb6187bf254ffea 100644 (file)
@@ -1,4 +1,9 @@
 
+Tue Mar 16 11:20:14 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * mono-profiler-iomap.c: fix some API usage and add a warning
+       about this code.
+
 Wed Mar 3 19:17:14 CET 2010 Paolo Molaro <lupus@ximian.com>
 
        * mono-profiler-iomap.c: use the normal allocation callback.
index 1b69c6a3e85728a0a4ec4ac92c4dfaedbbe105e3..d3f3f8e2970a8985fd4bccdc79303f2611cabeb2 100644 (file)
@@ -5,6 +5,9 @@
  *   Marek Habersack <mhabersack@novell.com>
  *
  * Copyright (c) 2009 Novell, Inc (http://novell.com)
+ *
+ * Note: this profiler is completely unsafe wrt handling managed objects,
+ * don't use and don't copy code from here.
  */
 #include "config.h"
 
@@ -225,7 +228,7 @@ static gboolean saved_strings_find_func (gpointer key, gpointer value, gpointer
        gchar *utf_str;
        guint32 hash;
 
-       if (!info || !saved || saved->string->length != info->len)
+       if (!info || !saved || mono_string_length (saved->string) != info->len)
                return FALSE;
 
        utf_str = mono_string_to_utf8 (saved->string);
@@ -475,7 +478,7 @@ static void mono_portability_remember_alloc (MonoProfiler *prof, MonoObject *obj
 {
        if (klass != string_class)
                return;
-       mono_portability_remember_string (prof, mono_object_domain (obj), (MonoString*)obj);
+       mono_portability_remember_string (prof, mono_object_get_domain (obj), (MonoString*)obj);
 }
 
 static void mono_portability_iomap_event (MonoProfiler *prof, const char *report, const char *pathname, const char *new_pathname)
index bca5d5809347f5564854cc649bb6b85a39dafecc..d891ad3243c7321eee866472109f1fc2af9a3305 100644 (file)
@@ -1,6 +1,8 @@
 /Makefile.in
 /Makefile
 /*.stdout
+/*.stderr
+/*.aotlog
 /.deps
 /.libs
 /libtest.la
index d425c055833a4dd2f13d7cc4bacf32b2e8fe5d51..fd5b09ecd2ce6c51ddb67a6ad90d2d5050d3fbd5 100644 (file)
@@ -1,3 +1,17 @@
+2010-03-23  Zoltan Varga  <vargaz@gmail.com>
+
+       * Makefile.am (BASE_TEST_CS_SRC): Remove make-imt-test.cs, it is not a test.
+
+       * test-runner.cs: Add an option to run the tests with different optimization
+       sets.
+
+       * Makefile.am: Make it possible to run the normal+gshared tests using the managed
+       test runner by passing the M=1 option to make.
+
+2010-03-18  Zoltan Varga  <vargaz@gmail.com>
+
+       * Makefile.am (runtest): Save the output of the aot compiler into a file.
+
 2010-03-05  Robert Jordan  <robertj@gmx.net>
 
        * remoting4.cs: Add test for bug #504886.
index ad9d74609d8a23e32f6f8d8ce5202ce03eb6c060..a00d850480e6b665407c30949ae75cac852313fb 100644 (file)
@@ -20,17 +20,17 @@ JITTEST_PROG_RUN = MONO_SHARED_DIR=$(mono_build_root)/runtime MONO_CFG_DIR=$(mon
 RUNTIME_ARGS=--config tests-config --optimize=all --debug
 
 with_mono_path = MONO_PATH=$(mcs_topdir)/class/lib/net_2_0
-with_mono_path21 = MONO_PATH=$(mcs_topdir)/class/lib/net_2_1_raw
+with_mono_path_moonlight = MONO_PATH=$(mcs_topdir)/class/lib/moonlight_raw
 
 RUNTIME = $(with_mono_path) $(top_builddir)/runtime/mono-wrapper
-RUNTIME21 = $(with_mono_path21) $(top_builddir)/runtime/mono-wrapper
+RUNTIME_MOONLIGHT = $(with_mono_path_moonlight) $(top_builddir)/runtime/mono-wrapper
 
 MKBUNDLE = \
        PKG_CONFIG_PATH=$(top_builddir):$(PKG_CONFIG_PATH) \
        $(RUNTIME) $(mcs_topdir)/class/lib/net_2_0/mkbundle.exe
 
 MCS = $(RUNTIME) $(mcs_topdir)/class/lib/net_2_0/gmcs.exe -unsafe -nowarn:0162 -nowarn:0168 -nowarn:0219 -debug
-SMCS = $(RUNTIME21) --runtime=moonlight --security=temporary-smcs-hack $(mcs_topdir)/class/lib/net_2_1_raw/smcs.exe -unsafe -nowarn:0162 -nowarn:0168 -nowarn:0219
+SMCS = $(RUNTIME_MOONLIGHT) --runtime=moonlight --security=temporary-smcs-hack $(mcs_topdir)/class/lib/moonlight_raw/smcs.exe -unsafe -nowarn:0162 -nowarn:0168 -nowarn:0219
 ILASM = $(RUNTIME) $(mcs_topdir)/class/lib/net_2_0/ilasm.exe
 
 BENCHSRC=fib.cs random.cs nested-loops.cs ackermann.cs tight-loop.cs sieve.cs
@@ -250,7 +250,6 @@ BASE_TEST_CS_SRC=           \
        exists.cs               \
        handleref.cs    \
        transparentproxy.cs \
-       make-imt-test.cs \
        dbnull-missing.cs       \
        test-type-ctor.cs       \
        soft-float-tests.cs     \
@@ -585,7 +584,7 @@ runtest: $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQS
        failed_tests="";\
        for i in $(TESTSI_CS) $(TESTBS) $(TESTSI_IL); do        \
                rm -f $${i}.so; \
-               if [ x$(AOT) = x1 ]; then if echo $(AOT_DISABLED_TESTS) | grep -v -q $${i}; then $(with_mono_path) $(JITTEST_PROG_RUN) --aot --debug $${i} > /dev/null || exit 1; fi; fi; \
+               if [ x$(AOT) = x1 ]; then if echo $(AOT_DISABLED_TESTS) | grep -v -q $${i}; then $(with_mono_path) $(JITTEST_PROG_RUN) --aot --debug $${i} > $${i}.aotlog 2>&1 || exit 1; fi; fi; \
                if $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS); \
                then \
                        passed=`expr $${passed} + 1`; \
@@ -603,7 +602,7 @@ runtest-managed: test-runner.exe $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la
        @$(RUNTIME) ./test-runner.exe -j a --disabled '$(DISABLED_TESTS)' $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
 
 testjit:
-       @$(MAKE) runtest
+       @if test x$(M) != x; then $(MAKE) runtest-managed; else $(MAKE) runtest; fi
 
 testaot:
        @$(MAKE) AOT=1 runtest
@@ -758,7 +757,7 @@ coreclr-security.exe : coreclr-security.cs
 
 test-coreclr-security : coreclr-security.exe
        @echo "Testing coreclr-security.exe..."
-       @$(RUNTIME21) --security=core-clr-test coreclr-security.exe
+       @$(RUNTIME_MOONLIGHT) --security=core-clr-test coreclr-security.exe
 endif
 
 EXTRA_DIST += generic-unboxing.2.il
@@ -788,7 +787,8 @@ gshared: test-generic-sharing
 gshared-aot:
        @$(MAKE) AOT=1 gshared
 
-test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe     \
+GSHARED_TESTS = \
+               generics-sharing.2.exe shared-generic-methods.2.exe     \
                shared-generic-synchronized.2.exe generic-initobj.2.exe         \
                generics-sharing-other-exc.2.exe generic-box.2.exe              \
                generic-unbox.2.exe generic-delegate.2.exe generic-sizeof.2.exe \
@@ -813,6 +813,8 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe  \
                bug-472600.2.exe bug-473482.2.exe bug-473999.2.exe              \
                bug-479763.2.exe generic-xdomain.2.exe                          \
                generic-type-load-exception.2.exe
+
+test-generic-sharing-normal: $(GSHARED_TESTS)
        @for fn in $+ ; do      \
                echo "Testing $$fn ...";        \
                MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared                $$fn > $$fn.stdout || exit 1;     \
@@ -822,6 +824,12 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe \
                if [ x$(AOT) = x1 ]; then MONO_GENERIC_SHARING=all $(with_mono_path) $(JITTEST_PROG_RUN) --aot --debug $$fn > /dev/null || exit 1; MONO_GENERIC_SHARING=all $(RUNTIME) $$fn > $$fn.stdout || exit 1; fi; \
        done
 
+test-generic-sharing-managed: test-runner.exe $(GSHARED_TESTS)
+       @$(RUNTIME) ./test-runner.exe -j a --opt-sets "gshared gshared,shared gshared,-inline gshared,-inline,shared" $(GSHARED_TESTS)
+
+test-generic-sharing:
+       @if test x$(M) != x; then $(MAKE) test-generic-sharing-managed; else $(MAKE) test-generic-sharing-normal; fi
+
 EXTRA_DIST += async-exceptions.cs
 async-exceptions.exe : async-exceptions.cs
        $(MCS) -out:async-exceptions.exe $(srcdir)/async-exceptions.cs
@@ -871,4 +879,4 @@ endif
 libtest_la_SOURCES = libtest.c
 libtest_la_LIBADD = $(glib_libs)
 
-CLEANFILES = $(TESTSI_CS) $(TESTSI_IL) $(STRESS_TESTS) *.dll *.stdout *.exe stest.dat
+CLEANFILES = $(TESTSI_CS) $(TESTSI_IL) $(STRESS_TESTS) *.dll *.stdout *.aotlog *.exe stest.dat
index fdca71a76552d55239181dfa53cfca076b3fd2a9..ce0d65e74189bd049872cf8b414a8529a36f3348 100644 (file)
@@ -42,6 +42,10 @@ public class TestRunner
                public StreamWriter stdout, stderr;
        }
 
+       class TestInfo {
+               public string test, opt_set;
+       }
+
        public static int Main (String[] args) {
                // Defaults
                int concurrency = 1;
@@ -51,6 +55,7 @@ public class TestRunner
 
                string disabled_tests = null;
                string runtime = "mono";
+               var opt_sets = new List<string> ();
 
                // Process options
                int i = 0;
@@ -87,6 +92,14 @@ public class TestRunner
                                        }
                                        runtime = args [i + 1];
                                        i += 2;
+                               } else if (args [i] == "--opt-sets") {
+                                       if (i + i >= args.Length) {
+                                               Console.WriteLine ("Missing argument to --opt-sets command line option.");
+                                               return 1;
+                                       }
+                                       foreach (var s in args [i + 1].Split ())
+                                               opt_sets.Add (s);
+                                       i += 2;
                                } else {
                                        Console.WriteLine ("Unknown command line option: '" + args [i] + "'.");
                                        return 1;
@@ -123,7 +136,18 @@ public class TestRunner
                if (concurrency != 1)
                        Console.WriteLine ("Running tests: ");
 
-               foreach (string test in tests) {
+               var test_info = new List<TestInfo> ();
+               if (opt_sets.Count == 0) {
+                       foreach (string s in tests)
+                               test_info.Add (new TestInfo { test = s });
+               } else {
+                       foreach (string opt in opt_sets) {
+                               foreach (string s in tests)
+                                       test_info.Add (new TestInfo { test = s, opt_set = opt });
+                       }
+               }               
+
+               foreach (TestInfo ti in test_info) {
                        lock (monitor) {
                                while (processes.Count == concurrency) {
                                        /* Wait for one process to terminate */
@@ -142,11 +166,19 @@ public class TestRunner
                                terminated.Clear ();
                        }
 
+                       string test = ti.test;
+                       string opt_set = ti.opt_set;
+
                        if (concurrency == 1)
                                Console.Write ("Testing " + test + "... ");
 
                        /* Spawn a new process */
-                       ProcessStartInfo info = new ProcessStartInfo (runtime, test);
+                       string process_args;
+                       if (opt_set == null)
+                               process_args = test;
+                       else
+                               process_args = "-O=" + opt_set + " " + test;
+                       ProcessStartInfo info = new ProcessStartInfo (runtime, process_args);
                        info.UseShellExecute = false;
                        info.RedirectStandardOutput = true;
                        info.RedirectStandardError = true;
@@ -183,9 +215,13 @@ public class TestRunner
                                }
                        };
 
-                       data.stdout = new StreamWriter (new FileStream (test + ".stdout", FileMode.Create));
+                       string log_prefix = "";
+                       if (opt_set != null)
+                               log_prefix = "." + opt_set.Replace ("-", "no").Replace (",", "_");
+
+                       data.stdout = new StreamWriter (new FileStream (test + log_prefix + ".stdout", FileMode.Create));
 
-                       data.stderr = new StreamWriter (new FileStream (test + ".stderr", FileMode.Create));
+                       data.stderr = new StreamWriter (new FileStream (test + log_prefix + ".stderr", FileMode.Create));
 
                        p.OutputDataReceived += delegate (object sender, DataReceivedEventArgs e) {
                                Process p2 = (Process)sender;
index 6b7ad8fd0ac8bfaae568289d8c2d923e8df4688a..ade8d6f53f327350da1ea4b71aa44c8d75a898f2 100644 (file)
@@ -1,3 +1,43 @@
+2010-03-26  Zoltan Varga  <vargaz@gmail.com>
+
+       * mono-proclib.c mono-semaphore.c: Apply some openbsd changes from openbsd
+       ports.
+
+2010-03-25 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * mono-semaphore.[hc]: make sure the semaphore calls are restarted if
+       interrupted. Return 0 on success and -1 on failure on windows.
+
+2010-03-25  Mark Probst  <mark.probst@gmail.com>
+
+       * mono-hash.c, mono-ehash.c: Fix rehashing with regard to moving
+       GC.  Register root for ehash.
+
+2010-03-24  Andrés G. Aragoneses  <knocte@gmail.com>
+
+       * mono-dl.c: (mono_dl_build_path) Take in account the suffix
+       variable assigned wrt the prefix comparison to concat the final
+       path for dlopen. Fixes BNC#588143. r:vargaz
+
+2010-03-23 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * mono-semaphore.h: MONO_SEM_WAIT() return value inverted when using
+       the windows API.
+       * mono-semaphore.c: handle INFINITE timeout.
+
+2010-03-22  Zoltan Varga  <vargaz@gmail.com>
+
+       * mono-sigcontext.h: Define UCONTEXT accessors for openbsd/amd64.
+
+2010-03-22  Zoltan Varga  <vargaz@gmail.com>
+
+       * mono-sigcontext.h: Applied patch from Robert Nagy (Robert@openbsd.org).
+       Add OpenBSD definitions.
+
+2010-03-17 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * mono-semaphore.c: _timedwait takes an absolute time.
+
 2010-03-04  Zoltan Varga  <vargaz@gmail.com>
 
        * strtod.c: Get rid of locking so this works with eglib.
index 7b68e7aee24d4a4e4a70e108a9ff3b7ac4eb4e6f..9d45ddfc4982de1ad0e2ddc30f36f1d1ab2db0f6 100644 (file)
@@ -453,9 +453,9 @@ mono_dl_build_path (const char *directory, const char *name, void **iter)
        else
                suffix = suffixes [idx];
        if (directory && *directory)
-               res = g_strconcat (directory, G_DIR_SEPARATOR_S, prefix, name, suffixes [idx], NULL);
+               res = g_strconcat (directory, G_DIR_SEPARATOR_S, prefix, name, suffix, NULL);
        else
-               res = g_strconcat (prefix, name, suffixes [idx], NULL);
+               res = g_strconcat (prefix, name, suffix, NULL);
        ++idx;
        *iter = GUINT_TO_POINTER (idx);
        return res;
index 1e6370c8cc063542c99867f2f93a98c45044ced0..e4c42c3070dff71cea26cad77014dde238d67383 100644 (file)
@@ -73,6 +73,33 @@ static const int prime_tbl[] = {
        6153409, 9230113, 13845163
 };
 
+#ifdef HAVE_SGEN_GC
+static void *table_hash_descr = NULL;
+
+static void mono_g_hash_mark (void *addr, MonoGCCopyFunc mark_func);
+
+static Slot*
+new_slot (MonoGHashTable *hash)
+{
+       if (hash->gc_type == MONO_HASH_CONSERVATIVE_GC)
+               return mono_gc_alloc_fixed (sizeof (Slot), NULL);
+       else
+               return mg_new (Slot, 1);
+}
+
+static void
+free_slot (MonoGHashTable *hash, Slot *slot)
+{
+       if (hash->gc_type == MONO_HASH_CONSERVATIVE_GC)
+               mono_gc_free_fixed (slot);
+       else
+               mg_free (slot);
+}
+#else
+#define new_slot(h)    mg_new(Slot,1)
+#define free_slot(h,s) mg_free((s))
+#endif
+
 static gboolean
 test_prime (int x)
 {
@@ -106,7 +133,20 @@ mono_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, Mono
        MonoGHashTable *hash = mono_g_hash_table_new (hash_func, key_equal_func);
 
        hash->gc_type = type;
-       
+
+#ifdef HAVE_SGEN_GC
+       if (type < 0 || type > MONO_HASH_KEY_VALUE_GC)
+               g_error ("wrong type for gc hashtable");
+       /*
+        * We use a user defined marking function to avoid having to register a GC root for
+        * each hash node.
+        */
+       if (!table_hash_descr)
+               table_hash_descr = mono_gc_make_root_descr_user (mono_g_hash_mark);
+       if (type != MONO_HASH_CONSERVATIVE_GC)
+               mono_gc_register_root_wbarrier ((char*)hash, sizeof (MonoGHashTable), table_hash_descr);
+#endif
+
        return hash;
 }
 
@@ -145,20 +185,28 @@ mono_g_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func,
        return hash;
 }
 
-static void
-do_rehash (MonoGHashTable *hash)
+typedef struct {
+       MonoGHashTable *hash;
+       int new_size;
+       Slot **table;
+} RehashData;
+
+static void*
+do_rehash (void *_data)
 {
+       RehashData *data = _data;
+       MonoGHashTable *hash = data->hash;
        int current_size, i;
        Slot **table;
 
        /* printf ("Resizing diff=%d slots=%d\n", hash->in_use - hash->last_rehash, hash->table_size); */
        hash->last_rehash = hash->table_size;
        current_size = hash->table_size;
-       hash->table_size = g_spaced_primes_closest (hash->in_use);
+       hash->table_size = data->new_size;
        /* printf ("New size: %d\n", hash->table_size); */
        table = hash->table;
-       hash->table = mg_new0 (Slot *, hash->table_size);
-       
+       hash->table = data->table;
+
        for (i = 0; i < current_size; i++){
                Slot *s, *next;
 
@@ -170,20 +218,26 @@ do_rehash (MonoGHashTable *hash)
                        hash->table [hashcode] = s;
                }
        }
-       mg_free (table);
+       return table;
 }
 
 static void
 rehash (MonoGHashTable *hash)
 {
        int diff = ABS (hash->last_rehash - hash->in_use);
+       RehashData data;
 
        /* These are the factors to play with to change the rehashing strategy */
        /* I played with them with a large range, and could not really get */
        /* something that was too good, maybe the tests are not that great */
        if (!(diff * 0.75 > hash->table_size * 2))
                return;
-       do_rehash (hash);
+
+       data.hash = hash;
+       data.new_size = g_spaced_primes_closest (hash->in_use);
+       data.table = mg_new0 (Slot *, data.new_size);
+
+       mg_free (mono_gc_invoke_with_gc_lock (do_rehash, &data));
 }
 
 guint
@@ -283,7 +337,7 @@ mono_g_hash_table_remove (MonoGHashTable *hash, gconstpointer key)
                                hash->table [hashcode] = s->next;
                        else
                                last->next = s->next;
-                       mg_free (s);
+                       free_slot (hash, s);
                        hash->in_use--;
                        return TRUE;
                }
@@ -320,7 +374,7 @@ mono_g_hash_table_foreach_remove (MonoGHashTable *hash, GHRFunc func, gpointer u
                                        last->next = s->next;
                                        n = last->next;
                                }
-                               mg_free (s);
+                               free_slot (hash, s);
                                hash->in_use--;
                                count++;
                                s = n;
@@ -342,6 +396,10 @@ mono_g_hash_table_destroy (MonoGHashTable *hash)
        
        g_return_if_fail (hash != NULL);
 
+#ifdef HAVE_SGEN_GC
+       mono_gc_deregister_root ((char*)hash);
+#endif
+
        for (i = 0; i < hash->table_size; i++){
                Slot *s, *next;
 
@@ -352,7 +410,7 @@ mono_g_hash_table_destroy (MonoGHashTable *hash)
                                (*hash->key_destroy_func)(s->key);
                        if (hash->value_destroy_func != NULL)
                                (*hash->value_destroy_func)(s->value);
-                       mg_free (s);
+                       free_slot (hash, s);
                }
        }
        mg_free (hash->table);
@@ -386,7 +444,7 @@ mono_g_hash_table_insert_replace (MonoGHashTable *hash, gpointer key, gpointer v
                        return;
                }
        }
-       s = mg_new (Slot, 1);
+       s = new_slot (hash);
        s->key = key;
        s->value = value;
        s->next = hash->table [hashcode];
@@ -406,3 +464,40 @@ mono_g_hash_table_replace(MonoGHashTable *h, gpointer k, gpointer v)
        mono_g_hash_table_insert_replace (h, k, v, TRUE);
 }
 
+#ifdef HAVE_SGEN_GC
+
+/* GC marker function */
+static void
+mono_g_hash_mark (void *addr, MonoGCCopyFunc mark_func)
+{
+       MonoGHashTable *table = (MonoGHashTable*)addr;
+       Slot *node;
+       int i;
+
+       if (table->gc_type == MONO_HASH_KEY_GC) {
+               for (i = 0; i < table->table_size; i++) {
+                       for (node = table->table [i]; node; node = node->next) {
+                               if (node->key)
+                                       node->key = mark_func (node->key);
+                       }
+               }
+       } else if (table->gc_type == MONO_HASH_VALUE_GC) {
+               for (i = 0; i < table->table_size; i++) {
+                       for (node = table->table [i]; node; node = node->next) {
+                               if (node->value)
+                                       node->value = mark_func (node->value);
+                       }
+               }
+       } else if (table->gc_type == MONO_HASH_KEY_VALUE_GC) {
+               for (i = 0; i < table->table_size; i++) {
+                       for (node = table->table [i]; node; node = node->next) {
+                               if (node->key)
+                                       node->key = mark_func (node->key);
+                               if (node->value)
+                                       node->value = mark_func (node->value);
+                       }
+               }
+       }
+}
+
+#endif
index c6c947b9f2a72e38fb46165e4493669d20bd847d..5b1c7c13e07203eb3636bb0c3ef9647ca10638ac 100644 (file)
@@ -788,25 +788,25 @@ mono_g_hash_table_remap (MonoGHashTable *hash_table,
          }
 }
 
-static void
-g_hash_table_resize (MonoGHashTable *hash_table)
+typedef struct {
+       MonoGHashTable *hash;
+       gint new_size;
+       MonoGHashNode **nodes;
+} ResizeData;
+
+static void*
+do_resize (void *_data)
 {
-  MonoGHashNode **new_nodes;
+  ResizeData *data = _data;
+  MonoGHashTable *hash_table = data->hash;
+  MonoGHashNode **new_nodes = data->nodes;
   MonoGHashNode *node;
   MonoGHashNode *next;
   guint hash_val;
-  gint new_size;
+  gint new_size = data->new_size;
   gint i;
+  void *old_nodes = hash_table->nodes;
 
-  new_size = g_spaced_primes_closest (hash_table->nnodes);
-  new_size = CLAMP (new_size, HASH_TABLE_MIN_SIZE, HASH_TABLE_MAX_SIZE);
-#if HAVE_BOEHM_GC
-  new_nodes              = GC_MALLOC (sizeof (MonoGHashNode*) * new_size);
-#else
-  new_nodes              = g_new0 (MonoGHashNode*, new_size);
-#endif
-  
   for (i = 0; i < hash_table->size; i++)
     for (node = hash_table->nodes[i]; node; node = next)
       {
@@ -817,13 +817,35 @@ g_hash_table_resize (MonoGHashTable *hash_table)
        node->next = new_nodes[hash_val];
        new_nodes[hash_val] = node;
       }
-  
+
+  hash_table->nodes = new_nodes;
+  hash_table->size = new_size;
+
+  return old_nodes;
+}
+
+static void
+g_hash_table_resize (MonoGHashTable *hash_table)
+{
+       ResizeData data;
+       void *old_nodes;
+
+       data.hash = hash_table;
+       data.new_size = g_spaced_primes_closest (hash_table->nnodes);
+       data.new_size = CLAMP (data.new_size, HASH_TABLE_MIN_SIZE, HASH_TABLE_MAX_SIZE);
+
 #if HAVE_BOEHM_GC
+       data.nodes = GC_MALLOC (sizeof (MonoGHashNode*) * data.new_size);
 #else
-  g_free (hash_table->nodes);
+       data.nodes = g_new0 (MonoGHashNode*, data.new_size);
+#endif
+
+       old_nodes = mono_gc_invoke_with_gc_lock (do_resize, &data);
+
+#if HAVE_BOEHM_GC
+#else
+       g_free (old_nodes);
 #endif
-  hash_table->nodes = new_nodes;
-  hash_table->size = new_size;
 }
 
 static void
index 528330442490b3c5bff2a13fb66f588d5d60bb9a..4565b0e0149648716356bcae4ca7bb3fc89671ae 100644 (file)
@@ -14,6 +14,7 @@
 
 /* FIXME: bsds untested */
 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <sys/proc.h>
@@ -41,9 +42,14 @@ gpointer*
 mono_process_list (int *size)
 {
 #if USE_SYSCTL
-       int mib [4];
        int res, i;
+#ifdef KERN_PROC2
+       int mib [6];
+       size_t data_len = sizeof (struct kinfo_proc2) * 400;
+#else
+       int mib [4];
        size_t data_len = sizeof (struct kinfo_proc) * 400;
+#endif /* KERN_PROC2 */
        struct kinfo_proc *processes = malloc (data_len);
        void **buf = NULL;
 
@@ -52,17 +58,33 @@ mono_process_list (int *size)
        if (!processes)
                return NULL;
 
+#ifdef KERN_PROC2
+       mib [0] = CTL_KERN;
+       mib [1] = KERN_PROC2;
+       mib [2] = KERN_PROC_ALL;
+       mib [3] = 0;
+       mib [4] = sizeof(struct kinfo_proc2);
+       mib [5] = 400; /* XXX */
+
+       res = sysctl (mib, 6, processes, &data_len, NULL, 0);
+#else
        mib [0] = CTL_KERN;
        mib [1] = KERN_PROC;
        mib [2] = KERN_PROC_ALL;
        mib [3] = 0;
        
        res = sysctl (mib, 4, processes, &data_len, NULL, 0);
+#endif /* KERN_PROC2 */
+
        if (res < 0) {
                free (processes);
                return NULL;
        }
+#ifdef KERN_PROC2
+       res = data_len/sizeof (struct kinfo_proc2);
+#else
        res = data_len/sizeof (struct kinfo_proc);
+#endif /* KERN_PROC2 */
        buf = g_realloc (buf, res * sizeof (void*));
        for (i = 0; i < res; ++i)
                buf [i] = GINT_TO_POINTER (processes [i].kinfo_pid_member);
@@ -155,13 +177,32 @@ char*
 mono_process_get_name (gpointer pid, char *buf, int len)
 {
 #if USE_SYSCTL
-       int mib [4];
        int res;
+#ifdef KERN_PROC2
+       int mib [6];
+       size_t data_len = sizeof (struct kinfo_proc2);
+#else
+       int mib [4];
        size_t data_len = sizeof (struct kinfo_proc);
+#endif /* KERN_PROC2 */
        struct kinfo_proc processi;
 
        memset (buf, 0, len);
 
+#ifdef KERN_PROC2
+       mib [0] = CTL_KERN;
+       mib [1] = KERN_PROC2;
+       mib [2] = KERN_PROC_PID;
+       mib [3] = GPOINTER_TO_UINT (pid);
+       mib [4] = sizeof(struct kinfo_proc2);
+       mib [5] = 400; /* XXX */
+
+       res = sysctl (mib, 6, &processi, &data_len, NULL, 0);
+
+       if (res < 0 || data_len != sizeof (struct kinfo_proc2)) {
+               return buf;
+       }
+#else
        mib [0] = CTL_KERN;
        mib [1] = KERN_PROC;
        mib [2] = KERN_PROC_PID;
@@ -171,6 +212,7 @@ mono_process_get_name (gpointer pid, char *buf, int len)
        if (res < 0 || data_len != sizeof (struct kinfo_proc)) {
                return buf;
        }
+#endif /* KERN_PROC2 */
        strncpy (buf, processi.kinfo_name_member, len - 1);
        return buf;
 #else
index dd60db469c043e8b34a1eab9e5c92165018b1b13..7363a7f78c2e8f6fda54d5f6b872846bed4b6e2c 100644 (file)
@@ -8,9 +8,13 @@
  */
 
 #include <config.h>
+#include <errno.h>
 #include "utils/mono-semaphore.h"
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
 
-#if defined(HAVE_SEMAPHORE_H) || defined(USE_MACH_SEMA)
+#if (defined(HAVE_SEMAPHORE_H) || defined(USE_MACH_SEMA)) && !defined(__OpenBSD__)
 /* sem_* or semaphore_* functions in use */
 #  ifdef USE_MACH_SEMA
 #    define TIMESPEC mach_timespec_t
 #    define WAIT_BLOCK(a,b) sem_timedwait (a, b)
 #  endif
 
-gboolean
+int
 mono_sem_timedwait (MonoSemType *sem, guint32 timeout_ms)
 {
-       TIMESPEC tv;
+       TIMESPEC ts, copy;
+       struct timeval t;
+       int res;
 
 #ifndef USE_MACH_SEMA
        if (timeout_ms == 0)
                return (!sem_trywait (sem));
 #endif
+       if (timeout_ms == (guint32) 0xFFFFFFFF)
+               return mono_sem_wait (sem);
+
+       gettimeofday (&t, NULL);
+       ts.tv_sec = timeout_ms / 1000 + t.tv_sec;
+       ts.tv_nsec = (timeout_ms % 1000) * 1000000 + t.tv_usec * 1000;
+       while (ts.tv_nsec > 1000000000) {
+               ts.tv_nsec -= 1000000000;
+               ts.tv_sec++;
+       }
+       copy = ts;
+       while ((res = WAIT_BLOCK (sem, &ts) == -1) && errno == EINTR)
+               ts = copy;
+       return res;
+}
 
-       tv.tv_sec = timeout_ms / 1000;
-       tv.tv_nsec = (timeout_ms % 1000) * 1000000;
-       return (!WAIT_BLOCK (sem, &tv));
+int
+mono_sem_wait (MonoSemType *sem)
+{
+       int res;
+#ifndef USE_MACH_SEMA
+       while ((res = sem_wait (sem) == -1) && errno == EINTR);
+#else
+       while ((res = semaphore_wait (*sem) == -1) && errno == EINTR);
+#endif
+       return res;
+}
+
+int
+mono_sem_post (MonoSemType *sem)
+{
+       int res;
+#ifndef USE_MACH_SEMA
+       while ((res = sem_post (sem) == -1) && errno == EINTR);
+#else
+       while ((res = semaphore_signal (*sem) == -1) && errno == EINTR);
+#endif
+       return res;
 }
 
 #else
 /* Windows or io-layer functions in use */
-gboolean
+int
+mono_sem_wait (MonoSemType *sem)
+{
+       return mono_sem_timedwait (sem, INFINITE);
+}
+
+int
 mono_sem_timedwait (MonoSemType *sem, guint32 timeout_ms)
 {
-       return WaitForSingleObjectEx (*sem, timeout_ms, TRUE);
+       gboolean res;
+
+       res = WaitForSingleObjectEx (*sem, timeout_ms, FALSE);
+       if (!res)
+               return -1;
+       return 0;
 }
 
+int
+mono_sem_post (MonoSemType *sem)
+{
+       if (!ReleaseSemaphore (*sem, 1, NULL))
+               return -1;
+       return 0;
+}
 #endif
 
index 7218210ae5f944484173e234ae0cd1015fa4476b..04748a813b82e265f6d53ef09d192f35de02146c 100644 (file)
 #    include <mach/semaphore.h>
 typedef semaphore_t MonoSemType;
 #    define MONO_SEM_INIT(addr,value) semaphore_create (current_task (), (addr), SYNC_POLICY_FIFO, (value))
-#    define MONO_SEM_WAIT(sem) semaphore_wait (*(sem))
-#    define MONO_SEM_POST(sem) semaphore_signal (*(sem))
+#    define MONO_SEM_WAIT(sem) mono_sem_wait ((sem))
+#    define MONO_SEM_POST(sem) mono_sem_post (*(sem))
 #    define MONO_SEM_DESTROY(sem) semaphore_destroy (current_task (), *(sem))
 #  else
 typedef sem_t MonoSemType;
 #    define MONO_SEM_INIT(addr,value) sem_init ((addr), 0, (value))
-#    define MONO_SEM_WAIT(sem) sem_wait ((sem))
-#    define MONO_SEM_POST(sem) sem_post ((sem))
+#    define MONO_SEM_WAIT(sem) mono_sem_wait ((sem))
+#    define MONO_SEM_POST(sem) mono_sem_post ((sem))
 #    define MONO_SEM_DESTROY(sem) sem_destroy ((sem))
 #  endif
 #elif defined(HOST_WIN32) || defined(_WAPI_SEMAPHORES_H)
 #  define MONO_HAS_SEMAPHORES
 typedef HANDLE MonoSemType;
 #    define MONO_SEM_INIT(addr,initial) do {*(addr) = CreateSemaphore ( NULL,(initial),0x7FFFFFFF,NULL);} while(0)
-#    define MONO_SEM_WAIT(sem) WaitForSingleObjectEx (*(sem),INFINITE, TRUE)
-#    define MONO_SEM_POST(sem) (!(ReleaseSemaphore (*(sem),1,NULL)))
+#    define MONO_SEM_WAIT(sem) mono_sem_wait (sem)
+#    define MONO_SEM_POST(sem) mono_sem_post (sem)
 #    define MONO_SEM_DESTROY(sem) CloseHandle (*(sem))
 #endif
 
@@ -49,7 +49,9 @@ typedef HANDLE MonoSemType;
 
 G_BEGIN_DECLS
 
-gboolean mono_sem_timedwait (MonoSemType *sem, guint32 timeout_ms);
+int mono_sem_wait (MonoSemType *sem);
+int mono_sem_timedwait (MonoSemType *sem, guint32 timeout_ms);
+int mono_sem_post (MonoSemType *sem);
 
 G_END_DECLS
 #endif /* _MONO_SEMAPHORE_H_ */
index 0a767dbc72f1debb0335e1b8213e32f9585369ce..d5dfffb5e38d70e7821101c722d2e9be32799f73 100644 (file)
        #define UCONTEXT_REG_ESI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_ESI])
        #define UCONTEXT_REG_EDI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_EDI])
        #define UCONTEXT_REG_EIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_EIP])
+#elif defined(__OpenBSD__)
+       #define UCONTEXT_REG_EAX(ctx) ((ctx)->sc_eax)
+       #define UCONTEXT_REG_EBX(ctx) ((ctx)->sc_ebx)
+       #define UCONTEXT_REG_ECX(ctx) ((ctx)->sc_ecx)
+       #define UCONTEXT_REG_EDX(ctx) ((ctx)->sc_edx)
+       #define UCONTEXT_REG_EBP(ctx) ((ctx)->sc_ebp)
+       #define UCONTEXT_REG_ESP(ctx) ((ctx)->sc_esp)
+       #define UCONTEXT_REG_ESI(ctx) ((ctx)->sc_esi)
+       #define UCONTEXT_REG_EDI(ctx) ((ctx)->sc_edi)
+       #define UCONTEXT_REG_EIP(ctx) ((ctx)->sc_eip)
 #else
        #define UCONTEXT_REG_EAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.gregs [REG_EAX])
        #define UCONTEXT_REG_EBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.gregs [REG_EBX])
 
 #ifdef __FreeBSD__
 #define UCONTEXT_GREGS(ctx)    &(((ucontext_t*)(ctx))->uc_mcontext)
+#elif defined(__OpenBSD__)
+    /* OpenBSD/amd64 has no gregs array, ucontext_t == sigcontext */
+       #define UCONTEXT_REG_RAX(ctx) ((ctx)->sc_rax)
+       #define UCONTEXT_REG_RBX(ctx) ((ctx)->sc_rbx)
+       #define UCONTEXT_REG_RCX(ctx) ((ctx)->sc_rcx)
+       #define UCONTEXT_REG_RDX(ctx) ((ctx)->sc_rdx)
+       #define UCONTEXT_REG_RBP(ctx) ((ctx)->sc_rbp)
+       #define UCONTEXT_REG_RSP(ctx) ((ctx)->sc_rsp)
+       #define UCONTEXT_REG_RSI(ctx) ((ctx)->sc_rsi)
+       #define UCONTEXT_REG_RDI(ctx) ((ctx)->sc_rdi)
+       #define UCONTEXT_REG_RIP(ctx) ((ctx)->sc_rip)
+       #define UCONTEXT_REG_R12(ctx) ((ctx)->sc_r12)
+       #define UCONTEXT_REG_R13(ctx) ((ctx)->sc_r13)
+       #define UCONTEXT_REG_R14(ctx) ((ctx)->sc_r14)
+       #define UCONTEXT_REG_R15(ctx) ((ctx)->sc_r15)
 #else
 #define UCONTEXT_GREGS(ctx)    &(((ucontext_t*)(ctx))->uc_mcontext.gregs)
 #endif
index 7f804f0250f9c0e9fac4cc058b7fd6004e3b20e8..8b1aa4bbfe398eb7cf0dfb6a50540bcdfeead1e1 100755 (executable)
@@ -1,3 +1,8 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * scripts/monowrap.cs, scripts/genproj.cs: rename
+       the net_2_1 profile to moonlight.
+
 2010-03-01  Robert Jordan  <robertj@gmx.net>
 
        * libmono.vcproj: Track changes.
index 92210d4c3a8890e23b30d8a029384309cd2cd403..6e882e4d199168b37b62c793ab9d277f227b89fb 100644 (file)
                                RelativePath="..\mono\utils\mono-error.h"\r
                                >\r
                        </File>\r
-                       <File\r
+      <File RelativePath="..\mono\utils\mono-semaphore.c"></File>\r
+      <File RelativePath="..\mono\utils\mono-semaphore.h"></File>\r
+      <File\r
                                RelativePath="..\mono\utils\mono-filemap.c"\r
                                >\r
                        </File>\r
index ad27791b0368e267275029de3775d48269481157..a42fb3ec64b0555121b171dfbaa496daa16a6ec9 100644 (file)
@@ -612,10 +612,10 @@ class MsbuildGenerator {
                        compiler = "net_2_0_bootstrap";
                else if (compiler.EndsWith ("mcs/gmcs.exe"))
                        compiler = "gmcs";
-               else if (compiler.EndsWith ("class/lib/net_2_1_bootstrap/smcs.exe"))
-                       compiler = "net_2_1_bootstrap";
-               else if (compiler.EndsWith ("class/lib/net_2_1_raw/smcs.exe"))
-                       compiler = "net_2_1_raw";
+               else if (compiler.EndsWith ("class/lib/moonlight_bootstrap/smcs.exe"))
+                       compiler = "moonlight_bootstrap";
+               else if (compiler.EndsWith ("class/lib/moonlight_raw/smcs.exe"))
+                       compiler = "moonlight_raw";
                else if (compiler.EndsWith ("class/lib/net_4_0_bootstrap/dmcs.exe"))
                        compiler = "net_4_0_bootstrap";
                else if (compiler.EndsWith ("class/lib/net_4_0/dmcs.exe"))
@@ -743,7 +743,7 @@ public class Driver {
                        // Do not do 2.1, it is not working yet
                        // Do not do basic, as there is no point (requires a system mcs to be installed).
                        //
-                       if (library.Contains ("net_2_1") || library.Contains ("-basic"))
+                       if (library.Contains ("moonlight") || library.Contains ("-basic"))
                                continue;
                        
                        var gen = new MsbuildGenerator (dir);
index dc0261231c211a50d0771b30721cfeced09bcc09..5b476832433169e16ecca284337b9e78da22ab42 100755 (executable)
 //    net_1_1           -> class/lib/net_1_1/mcs.exe
 //    net_2_0_bootstrap -> class/lib/net_2_0_bootstrap/gmcs.exe
 //    gmcs              -> mcs/gmcs.exe
-//    net_2_1_bootstrap -> class/lib/net_2_1_bootstrap/smcs.exe
-//    net_2_1_raw       -> class/lib/net_2_1_raw/smcs.exe
+//    moonlight_bootstrap -> class/lib/moonlight_bootstrap/smcs.exe
+//    moonlight_raw       -> class/lib/moonlight_raw/smcs.exe
 //
 // So for example:
-// net_2_1_bootstrap-net_2_0-net_2_1_bootstrap
+// moonlight_bootstrap-net_2_0-moonlight_bootstrap
 //
-// Will set MONO_PATH to "%MCS_ROOT%\class\lib\net_2_1_bootstrap;%MCS_ROOT\class\lib\net_2_0"
-// and run the compiler in %MCS_ROOT%\class\lib\net_2_1_bootstrap
+// Will set MONO_PATH to "%MCS_ROOT%\class\lib\moonlight_bootstrap;%MCS_ROOT\class\lib\net_2_0"
+// and run the compiler in %MCS_ROOT%\class\lib\moonlight_bootstrap
 //
 
 using System;
@@ -94,12 +94,12 @@ namespace csc
                                compiler = root_mcs + "\\mcs\\gmcs.exe";
                                break;
                                
-                       case "net_2_1_bootstrap":
-                               compiler = root_mcs + "\\class\\lib\\net_2_1_bootstrap\\smcs.exe";
+                       case "moonlight_bootstrap":
+                               compiler = root_mcs + "\\class\\lib\\moonlight_bootstrap\\smcs.exe";
                                break;
                                
-                       case "net_2_1_raw":
-                               compiler = root_mcs + "\\class\\lib\\net_2_1_raw\\smcs.exe";
+                       case "moonlight_raw":
+                               compiler = root_mcs + "\\class\\lib\\moonlight_raw\\smcs.exe";
                                break;
 
                        default:
index 9db9f74c8d86c8d46ea5e797795dd6b6879bff78..d542b32675ca62592966618695cfa9cd9c0fa937 100755 (executable)
@@ -1,3 +1,7 @@
+2010-03-16  Jb Evain  <jbevain@novell.com>
+
+       * setup-solution.bat: rename the net_2_1 profile to moonlight.
+
 2010-01-18  Bill Holmes  <billholmes54@gmail.com>
 
        * libmono.vcproj : Adding a link to Mswsock.lib and adding files
index e9f0ff0c80520868601b26a2799ab0985e90cf4f..2e7941a2cc68832f17980584e2afe23fc5e4a77e 100755 (executable)
@@ -2,7 +2,7 @@
 mkdir scripts\net_1_1_bootstrap > nul 2> nul\r
 mkdir scripts\net_1_1 > nul 2> nul\r
 mkdir scripts\net_2_0 > nul 2> nul\r
-mkdir scripts\net_2_1 > nul 2> nul\r
+mkdir scripts\moonlight > nul 2> nul\r
 \r
 csc -debug -out:scripts\monowrap.exe scripts\monowrap.cs \r
 copy scripts\monowrap.exe scripts\net_1_1_bootstrap\csc.exe\r
@@ -14,8 +14,8 @@ copy scripts\monowrap.pdb scripts\net_1_1\csc.pdb
 copy scripts\monowrap.exe scripts\net_2_0\csc.exe\r
 copy scripts\monowrap.pdb scripts\net_2_0\csc.pdb\r
 \r
-copy scripts\monowrap.exe scripts\net_2_1\csc.exe\r
-copy scripts\monowrap.pdb scripts\net_2_1\csc.pdb\r
+copy scripts\monowrap.exe scripts\moonlight\csc.exe\r
+copy scripts\monowrap.pdb scripts\moonlight\csc.pdb\r
 \r
 echo Setup complete, you can now use build the solution\r
 \r
index 71e3b83c799a7a51e2470bd7c869dbce06ab488e..596c61b844b276585dc3fdafa971545a712c262a 100644 (file)
@@ -25,8 +25,8 @@ $(symlinks):
 SUPPORT_FILES = $(symlinks) mono-wrapper etc/mono/config
 
 if MOONLIGHT
-build_profiles = net_2_1_raw
-test_profiles = net_2_1_raw
+build_profiles = moonlight_raw
+test_profiles = moonlight_raw
 else
 build_profiles = net_2_0 net_3_5
 test_profiles = $(build_profiles)
@@ -105,7 +105,7 @@ endif
 mcs-compileall: mono-wrapper etc/mono/config
        save_MONO_PATH=$$MONO_PATH; mcs_topdir=`cd $(mcs_topdir) && $(cur_dir_cmd)`; ok=:; \
        for profile in $(test_profiles); do \
-         if [ "net_2_1" = "$$profile" ]; then \
+         if [ "moonlight" = "$$profile" ]; then \
           break; \
       fi; \
          if [ "net_3_5" = "$$profile" ]; then \
index 1eda6057a5a7e6cf3ef895b8af56747cfc205925..dd73ac3703fd75bc6bb06a0167b385c4fe1348c5 100644 (file)
@@ -1,3 +1,10 @@
+2010-03-23  Andreas Faerber  <andreas.faerber@web.de>
+
+       * old-map.c (map_Mono_Posix_Signals): Fix build for platforms where
+       SIGIO is not defined (Haiku).
+       
+       Code is contributed under MIT/X11 license.
+
 2010-02-23  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * serial.cs: Add 921600 to the list of possible baud rates, and
index bd26a675c870c8e9924dda3f4b5a442ebf2902ee..9b2a2e907d775a3710f1d1cadefd514196d69cd8 100644 (file)
@@ -159,8 +159,10 @@ int map_Mono_Posix_Signals (int x)
                 return SIGPROF;
        if (x == Mono_Posix_Signals_SIGWINCH)
                 return SIGWINCH;
+#ifdef SIGIO
        if (x == Mono_Posix_Signals_SIGIO)
                 return SIGIO;
+#endif
        if (x == Mono_Posix_Signals_SIGSYS)
                 return SIGSYS;
        return -1;
index 24b3575549c75875aebe87939c8ae9832d05141b..28a3ef12a77af37eb41da803198befc64de0b723 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-23  Geoff Norton  <gnorton@novell.com>
+
+       * da_DK.xml: The short format is day. month, not 
+       day month.  Fixes #588165
+
 2008-09-18  Atsushi Enomoto  <atsushi@ximian.com>
 
        * sv_SE.xml : fix bug #426942 (sv-SE time format was old).
index 566be9f5f93d1cd859b4b3bfe5ca8b521600e181..80e784c6a6f8e358cb63e1b2a90f90de5910a13e 100755 (executable)
                                                        <pattern>dd-MM-yyyy</pattern>
                                                </dateFormat>
                                        </dateFormatLength >
+                                        <dateFormatLength type="month_day">
+                                                <dateFormat>
+                                                        <pattern>dd. MMMM</pattern>
+                                                </dateFormat>
+                                        </dateFormatLength>
                                </dateFormats>
                                <timeFormats>
                                        <timeFormatLength type="long">
@@ -29,4 +34,4 @@
                        </calendar>
                </calendars>
        </dates>
-</ldml>
\ No newline at end of file
+</ldml>