Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -0,0 +1,65 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Configuration.ConfigurationManager", "src\System.Configuration.ConfigurationManager.csproj", "{B7697463-7C98-4462-BA09-67B7BF3842B6}"
ProjectSection(ProjectDependencies) = postProject
{B65EE71E-2894-45E3-B0FD-FF34118E9F9A} = {B65EE71E-2894-45E3-B0FD-FF34118E9F9A}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6BF3AE2C-3EEE-42F0-8C62-BAAC04AE6897}"
ProjectSection(SolutionItems) = preProject
src\Configurations.props = src\Configurations.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{A6D1680E-20AB-4253-AD1F-AACC478A2510}"
ProjectSection(SolutionItems) = preProject
ref\Configurations.props = ref\Configurations.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{76C3F1E4-2EA8-4700-A9C0-EFEF909D7983}"
ProjectSection(SolutionItems) = preProject
tests\Configurations.props = tests\Configurations.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Configuration.ConfigurationManager.Tests", "tests\System.Configuration.ConfigurationManager.Tests.csproj", "{7669C397-C21C-4C08-83F1-BE6691911E88}"
ProjectSection(ProjectDependencies) = postProject
{B7697463-7C98-4462-BA09-67B7BF3842B6} = {B7697463-7C98-4462-BA09-67B7BF3842B6}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pkg", "pkg", "{CDDB4E69-37E9-4EE9-93A8-0B5DC240AC11}"
ProjectSection(SolutionItems) = preProject
pkg\System.Configuration.ConfigurationManager.builds = pkg\System.Configuration.ConfigurationManager.builds
pkg\System.Configuration.ConfigurationManager.pkgproj = pkg\System.Configuration.ConfigurationManager.pkgproj
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Configuration.ConfigurationManager", "ref\System.Configuration.ConfigurationManager.csproj", "{B65EE71E-2894-45E3-B0FD-FF34118E9F9A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
DebugNETCoreAppnetstandardnetstandard|AnyCPU = DebugNETCoreAppnetstandardnetstandard|AnyCPU
ReleaseNETCoreAppnetstandardnetstandard|AnyCPU = ReleaseNETCoreAppnetstandardnetstandard|AnyCPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B7697463-7C98-4462-BA09-67B7BF3842B6}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{B7697463-7C98-4462-BA09-67B7BF3842B6}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{B7697463-7C98-4462-BA09-67B7BF3842B6}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{B7697463-7C98-4462-BA09-67B7BF3842B6}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
{7669C397-C21C-4C08-83F1-BE6691911E88}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{7669C397-C21C-4C08-83F1-BE6691911E88}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{7669C397-C21C-4C08-83F1-BE6691911E88}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{7669C397-C21C-4C08-83F1-BE6691911E88}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
{B65EE71E-2894-45E3-B0FD-FF34118E9F9A}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = Debug|Any CPU
{B65EE71E-2894-45E3-B0FD-FF34118E9F9A}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = Debug|Any CPU
{B65EE71E-2894-45E3-B0FD-FF34118E9F9A}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = Debug|Any CPU
{B65EE71E-2894-45E3-B0FD-FF34118E9F9A}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B7697463-7C98-4462-BA09-67B7BF3842B6} = {6BF3AE2C-3EEE-42F0-8C62-BAAC04AE6897}
{7669C397-C21C-4C08-83F1-BE6691911E88} = {76C3F1E4-2EA8-4700-A9C0-EFEF909D7983}
{B65EE71E-2894-45E3-B0FD-FF34118E9F9A} = {A6D1680E-20AB-4253-AD1F-AACC478A2510}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.Configuration.ConfigurationManager.pkgproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<ProjectReference Include="..\ref\System.Configuration.ConfigurationManager.csproj">
<SupportedFramework>netcoreapp2.0;net461;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.Configuration.ConfigurationManager.builds" />
<InboxOnTargetFramework Include="net461" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.Configuration.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1 @@
2b328ec1492492f6fc4170d4560abc3a5031fee6

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard;
</BuildConfigurations>
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,258 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{B7697463-7C98-4462-BA09-67B7BF3842B6}</ProjectGuid>
</PropertyGroup>
<!-- Default configurations to help VS understand the options -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System\Configuration\DictionarySectionHandler.cs" />
<Compile Include="System\Configuration\DpapiProtectedConfigurationProvider.cs" />
<Compile Include="System\Configuration\IConfigurationSystem.cs" />
<Compile Include="System\Configuration\IdnElement.cs" />
<Compile Include="System\Configuration\Internal\DummyDisposable.cs" />
<Compile Include="System\Configuration\IPersistComponentSettings.cs" />
<Compile Include="System\Configuration\ApplicationSettingsBase.cs" />
<Compile Include="System\Configuration\ApplicationScopedSettingAttribute.cs" />
<Compile Include="System\Configuration\ApplicationSettingsGroup.cs" />
<Compile Include="System\Configuration\AppSettingsReader.cs" />
<Compile Include="System\Configuration\AppSettingsSection.cs" />
<Compile Include="System\Configuration\BaseConfigurationRecord.cs" />
<Compile Include="System\Configuration\CallbackValidator.cs" />
<Compile Include="System\Configuration\CallbackValidatorAttribute.cs" />
<Compile Include="System\Configuration\ClientConfigPaths.cs" />
<Compile Include="System\Configuration\ClientConfigurationHost.cs" />
<Compile Include="System\Configuration\ClientConfigurationSystem.cs" />
<Compile Include="System\Configuration\ClientSettingsSection.cs" />
<Compile Include="System\Configuration\ClientSettingsStore.cs" />
<Compile Include="System\Configuration\CommaDelimitedStringAttributeCollectionConverter.cs" />
<Compile Include="System\Configuration\CommonConfigurationStrings.cs" />
<Compile Include="System\Configuration\ConfigDefinitionUpdates.cs" />
<Compile Include="System\Configuration\ConfigPathUtility.cs" />
<Compile Include="System\Configuration\Configuration.cs" />
<Compile Include="System\Configuration\ConfigurationAllowDefinition.cs" />
<Compile Include="System\Configuration\ConfigurationAllowExeDefinition.cs" />
<Compile Include="System\Configuration\ConfigurationCollectionAttribute.cs" />
<Compile Include="System\Configuration\ConfigurationConverterBase.cs" />
<Compile Include="System\Configuration\ConfigurationElement.cs" />
<Compile Include="System\Configuration\ConfigurationElementCollection.cs" />
<Compile Include="System\Configuration\ConfigurationElementCollectionType.cs" />
<Compile Include="System\Configuration\ConfigurationElementProperty.cs" />
<Compile Include="System\Configuration\ConfigurationErrorsException.cs" />
<Compile Include="System\Configuration\ConfigurationException.cs" />
<Compile Include="System\Configuration\ConfigurationFileMap.cs" />
<Compile Include="System\Configuration\ConfigurationLocation.cs" />
<Compile Include="System\Configuration\ConfigurationLocationCollection.cs" />
<Compile Include="System\Configuration\ConfigurationLockCollection.cs" />
<Compile Include="System\Configuration\ConfigurationLockCollectionType.cs" />
<Compile Include="System\Configuration\ConfigurationManager.cs" />
<Compile Include="System\Configuration\ConfigurationManagerInternalFactory.cs" />
<Compile Include="System\Configuration\ConfigurationProperty.cs" />
<Compile Include="System\Configuration\ConfigurationPropertyAttribute.cs" />
<Compile Include="System\Configuration\ConfigurationPropertyCollection.cs" />
<Compile Include="System\Configuration\ConfigurationPropertyOptions.cs" />
<Compile Include="System\Configuration\ConfigurationSaveMode.cs" />
<Compile Include="System\Configuration\ConfigurationSchemaErrors.cs" />
<Compile Include="System\Configuration\ConfigurationSection.cs" />
<Compile Include="System\Configuration\ConfigurationSectionCollection.cs" />
<Compile Include="System\Configuration\ConfigurationSectionGroup.cs" />
<Compile Include="System\Configuration\ConfigurationSectionGroupCollection.cs" />
<Compile Include="System\Configuration\ConfigurationSettings.cs" />
<Compile Include="System\Configuration\ConfigurationUserLevel.cs" />
<Compile Include="System\Configuration\ConfigurationValidatorAttribute.cs" />
<Compile Include="System\Configuration\ConfigurationValidatorBase.cs" />
<Compile Include="System\Configuration\ConfigurationValue.cs" />
<Compile Include="System\Configuration\ConfigurationValueFlags.cs" />
<Compile Include="System\Configuration\ConfigurationValues.cs" />
<Compile Include="System\Configuration\ConfigXmlAttribute.cs" />
<Compile Include="System\Configuration\ConfigXmlCDataSection.cs" />
<Compile Include="System\Configuration\ConfigXmlComment.cs" />
<Compile Include="System\Configuration\ConfigXmlDocument.cs" />
<Compile Include="System\Configuration\ConfigXmlElement.cs" />
<Compile Include="System\Configuration\ConfigXmlReader.cs" />
<Compile Include="System\Configuration\ConfigXmlSignificantWhitespace.cs" />
<Compile Include="System\Configuration\ConfigXmlText.cs" />
<Compile Include="System\Configuration\ConfigXmlWhitespace.cs" />
<Compile Include="System\Configuration\ConnectionStringSettings.cs" />
<Compile Include="System\Configuration\ConnectionStringSettingsCollection.cs" />
<Compile Include="System\Configuration\ConnectionStringsSection.cs" />
<Compile Include="System\Configuration\ContextInformation.cs" />
<Compile Include="System\Configuration\DateTimeConfigurationCollection.cs" />
<Compile Include="System\Configuration\DateTimeConfigurationElement.cs" />
<Compile Include="System\Configuration\DeclarationUpdate.cs" />
<Compile Include="System\Configuration\DefaultSection.cs" />
<Compile Include="System\Configuration\DefaultSettingValueAttribute.cs" />
<Compile Include="System\Configuration\DefaultValidator.cs" />
<Compile Include="System\Configuration\DefinitionUpdate.cs" />
<Compile Include="System\Configuration\ElementInformation.cs" />
<Compile Include="System\Configuration\EmptyImpersonationContext.cs" />
<Compile Include="System\Configuration\ErrorInfoXmlDocument.cs" />
<Compile Include="System\Configuration\ErrorsHelper.cs" />
<Compile Include="System\Configuration\ExceptionAction.cs" />
<Compile Include="System\Configuration\ExceptionUtil.cs" />
<Compile Include="System\Configuration\ExeConfigurationFileMap.cs" />
<Compile Include="System\Configuration\ExeContext.cs" />
<Compile Include="System\Configuration\FactoryId.cs" />
<Compile Include="System\Configuration\FactoryRecord.cs" />
<Compile Include="System\Configuration\GenericEnumConverter.cs" />
<Compile Include="System\Configuration\HandlerBase.cs" />
<Compile Include="System\Configuration\IApplicationSettingsProvider.cs" />
<Compile Include="System\Configuration\IConfigurationSectionHandler.cs" />
<Compile Include="System\Configuration\IgnoreSection.cs" />
<Compile Include="System\Configuration\IgnoreSectionHandler.cs" />
<Compile Include="System\Configuration\ImplicitMachineConfigHost.cs" />
<Compile Include="System\Configuration\InfiniteIntConverter.cs" />
<Compile Include="System\Configuration\InfiniteTimeSpanConverter.cs" />
<Compile Include="System\Configuration\IntegerValidator.cs" />
<Compile Include="System\Configuration\IntegerValidatorAttribute.cs" />
<Compile Include="System\Configuration\Internal\ConfigSystem.cs" />
<Compile Include="System\Configuration\Internal\ConfigurationManagerInternal.cs" />
<Compile Include="System\Configuration\Internal\DelegatingConfigHost.cs" />
<Compile Include="System\Configuration\Internal\FileVersion.cs" />
<Compile Include="System\Configuration\HResults.cs" />
<Compile Include="System\Configuration\Internal\IConfigErrorInfo.cs" />
<Compile Include="System\Configuration\Internal\IConfigSystem.cs" />
<Compile Include="System\Configuration\Internal\IConfigurationManagerHelper.cs" />
<Compile Include="System\Configuration\Internal\IConfigurationManagerInternal.cs" />
<Compile Include="System\Configuration\Internal\IInternalConfigClientHost.cs" />
<Compile Include="System\Configuration\Internal\IInternalConfigConfigurationFactory.cs" />
<Compile Include="System\Configuration\Internal\IInternalConfigHost.cs" />
<Compile Include="System\Configuration\Internal\IInternalConfigHostPaths.cs" />
<Compile Include="System\Configuration\Internal\IInternalConfigRecord.cs" />
<Compile Include="System\Configuration\Internal\IInternalConfigRoot.cs" />
<Compile Include="System\Configuration\Internal\IInternalConfigSettingsFactory.cs" />
<Compile Include="System\Configuration\Internal\IInternalConfigSystem.cs" />
<Compile Include="System\Configuration\Internal\InternalConfigConfigurationFactory.cs" />
<Compile Include="System\Configuration\Internal\InternalConfigEventArgs.cs" />
<Compile Include="System\Configuration\Internal\InternalConfigEventHandler.cs" />
<Compile Include="System\Configuration\Internal\InternalConfigHost.cs" />
<Compile Include="System\Configuration\Internal\InternalConfigRoot.cs" />
<Compile Include="System\Configuration\Internal\InternalConfigSettingsFactory.cs" />
<Compile Include="System\Configuration\Internal\StreamChangeCallback.cs" />
<Compile Include="System\Configuration\Internal\WriteFileContext.cs" />
<Compile Include="System\Configuration\InvalidPropValue.cs" />
<Compile Include="System\Configuration\IriParsingElement.cs" />
<Compile Include="System\Configuration\ISettingsProviderService.cs" />
<Compile Include="System\Configuration\KeyValueConfigurationCollection.cs" />
<Compile Include="System\Configuration\KeyValueConfigurationElement.cs" />
<Compile Include="System\Configuration\KeyValueInternalCollection.cs" />
<Compile Include="System\Configuration\LocalFileSettingsProvider.cs" />
<Compile Include="System\Configuration\LocationSectionRecord.cs" />
<Compile Include="System\Configuration\LocationUpdates.cs" />
<Compile Include="System\Configuration\LongValidator.cs" />
<Compile Include="System\Configuration\LongValidatorAttribute.cs" />
<Compile Include="System\Configuration\MgmtConfigurationRecord.cs" />
<Compile Include="System\Configuration\NamespaceChange.cs" />
<Compile Include="System\Configuration\NameValueConfigurationCollection.cs" />
<Compile Include="System\Configuration\NameValueConfigurationElement.cs" />
<Compile Include="System\Configuration\NameValueFileSectionHandler.cs" />
<Compile Include="System\Configuration\NameValueSectionHandler.cs" />
<Compile Include="System\Configuration\OverrideMode.cs" />
<Compile Include="System\Configuration\OverrideModeSetting.cs" />
<Compile Include="System\Configuration\PositiveTimeSpanValidator.cs" />
<Compile Include="System\Configuration\PositiveTimeSpanValidatorAttribute.cs" />
<Compile Include="System\Configuration\PrivilegedConfigurationManager.cs" />
<Compile Include="System\Configuration\PropertyInformation.cs" />
<Compile Include="System\Configuration\PropertyInformationCollection.cs" />
<Compile Include="System\Configuration\PropertySourceInfo.cs" />
<Compile Include="System\Configuration\PropertyValueOrigin.cs" />
<Compile Include="System\Configuration\ProtectedConfiguration.cs" />
<Compile Include="System\Configuration\ProtectedConfigurationProvider.cs" />
<Compile Include="System\Configuration\ProtectedConfigurationProviderCollection.cs" />
<Compile Include="System\Configuration\ProtectedConfigurationSection.cs" />
<Compile Include="System\Configuration\ProtectedProviderSettings.cs" />
<Compile Include="System\Configuration\Provider\ProviderBase.cs" />
<Compile Include="System\Configuration\Provider\ProviderCollection.cs" />
<Compile Include="System\Configuration\Provider\ProviderException.cs" />
<Compile Include="System\Configuration\ProviderSettings.cs" />
<Compile Include="System\Configuration\ProviderSettingsCollection.cs" />
<Compile Include="System\Configuration\ReadOnlyNameValueCollection.cs" />
<Compile Include="System\Configuration\RegexStringValidator.cs" />
<Compile Include="System\Configuration\RegexStringValidatorAttribute.cs" />
<Compile Include="System\Configuration\RsaProtectedConfigurationProvider.cs" />
<Compile Include="System\Configuration\RuntimeConfigurationRecord.cs" />
<Compile Include="System\Configuration\SafeBitVector32.cs" />
<Compile Include="System\Configuration\SchemeSettingElement.cs" />
<Compile Include="System\Configuration\SchemeSettingElementCollection.cs" />
<Compile Include="System\Configuration\SchemeSettingInternal.cs" />
<Compile Include="System\Configuration\SectionInformation.cs" />
<Compile Include="System\Configuration\SectionInput.cs" />
<Compile Include="System\Configuration\SectionRecord.cs" />
<Compile Include="System\Configuration\SectionUpdates.cs" />
<Compile Include="System\Configuration\SectionXmlInfo.cs" />
<Compile Include="System\Configuration\SettingAttribute.cs" />
<Compile Include="System\Configuration\SettingChangingEventArgs.cs" />
<Compile Include="System\Configuration\SettingChangingEventHandler.cs" />
<Compile Include="System\Configuration\SettingElement.cs" />
<Compile Include="System\Configuration\SettingElementCollection.cs" />
<Compile Include="System\Configuration\SettingsAttributeDictionary.cs" />
<Compile Include="System\Configuration\SettingsBase.cs" />
<Compile Include="System\Configuration\SettingsContext.cs" />
<Compile Include="System\Configuration\SettingsDescriptionAttribute.cs" />
<Compile Include="System\Configuration\SettingsGroupDescriptionAttribute.cs" />
<Compile Include="System\Configuration\SettingsGroupNameAttribute.cs" />
<Compile Include="System\Configuration\SettingsLoadedEventArgs.cs" />
<Compile Include="System\Configuration\SettingsLoadedEventHandler.cs" />
<Compile Include="System\Configuration\SettingsManageability.cs" />
<Compile Include="System\Configuration\SettingsManageabilityAttribute.cs" />
<Compile Include="System\Configuration\SettingsPropertyCollection.cs" />
<Compile Include="System\Configuration\SettingsPropertyIsReadOnlyException.cs" />
<Compile Include="System\Configuration\SettingsPropertyNotFoundException.cs" />
<Compile Include="System\Configuration\SettingsPropertyValueCollection.cs" />
<Compile Include="System\Configuration\SettingsPropertyWrongTypeException.cs" />
<Compile Include="System\Configuration\SettingsProvider.cs" />
<Compile Include="System\Configuration\SettingsProviderAttribute.cs" />
<Compile Include="System\Configuration\SettingsProviderCollection.cs" />
<Compile Include="System\Configuration\SettingsSavingEventHandler.cs" />
<Compile Include="System\Configuration\SettingsSerializeAsAttribute.cs" />
<Compile Include="System\Configuration\SettingValueElement.cs" />
<Compile Include="System\Configuration\SimpleBitVector32.cs" />
<Compile Include="System\Configuration\SingleTagSectionHandler.cs" />
<Compile Include="System\Configuration\SpecialSetting.cs" />
<Compile Include="System\Configuration\SpecialSettingAttribute.cs" />
<Compile Include="System\Configuration\StreamInfo.cs" />
<Compile Include="System\Configuration\StreamUpdate.cs" />
<Compile Include="System\Configuration\StringAttributeCollection.cs" />
<Compile Include="System\Configuration\StringUtil.cs" />
<Compile Include="System\Configuration\StringValidator.cs" />
<Compile Include="System\Configuration\StringValidatorAttribute.cs" />
<Compile Include="System\Configuration\SubclassTypeValidator.cs" />
<Compile Include="System\Configuration\SubclassTypeValidatorAttribute.cs" />
<Compile Include="System\Configuration\TimeSpanMinutesConverter.cs" />
<Compile Include="System\Configuration\TimeSpanMinutesOrInfiniteConverter.cs" />
<Compile Include="System\Configuration\TimeSpanSecondsConverter.cs" />
<Compile Include="System\Configuration\TimeSpanSecondsOrInfiniteConverter.cs" />
<Compile Include="System\Configuration\TimeSpanValidator.cs" />
<Compile Include="System\Configuration\TimeSpanValidatorAttribute.cs" />
<Compile Include="System\Configuration\TypeNameConverter.cs" />
<Compile Include="System\Configuration\TypeUtil.cs" />
<Compile Include="System\Configuration\Update.cs" />
<Compile Include="System\Configuration\UpdateConfigHost.cs" />
<Compile Include="System\Configuration\UriSection.cs" />
<Compile Include="System\Configuration\UrlPath.cs" />
<Compile Include="System\Configuration\UserScopedSettingAttribute.cs" />
<Compile Include="System\Configuration\UserSettingsGroup.cs" />
<Compile Include="System\Configuration\ValidatorCallback.cs" />
<Compile Include="System\Configuration\ValidatorUtils.cs" />
<Compile Include="System\Configuration\WhiteSpaceTrimStringConverter.cs" />
<Compile Include="System\Configuration\XmlUtil.cs" />
<Compile Include="System\Configuration\XmlUtilWriter.cs" />
<Compile Include="$(CommonPath)\System\Security\IdentityHelper.cs">
<Link>Common\System\Security\IdentityHelper.cs</Link>
</Compile>
<Compile Include="System\Configuration\SettingsProperty.cs" />
<Compile Include="System\Configuration\SettingsPropertyValue.cs" />
<Compile Include="System\Configuration\SettingsSerializeAs.cs" />
<Compile Include="System\Configuration\NoSettingsVersionUpgradeAttribute.cs" />
<Compile Include="System\UriIdnScope.cs" />
<Compile Include="$(CommonPath)\System\IO\TempFileCollection.cs">
<Link>Common\System\IO\TempFileCollection.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="System.Security.Cryptography.ProtectedData" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,98 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Specialized;
using System.Globalization;
namespace System.Configuration
{
/// <summary>
/// The AppSettingsReader class provides a wrapper for System.Configuration.ConfigurationManager.AppSettings
/// which provides a single method for reading values from the config file of a particular type.
/// </summary>
public class AppSettingsReader
{
private NameValueCollection _map;
private static Type s_stringType = typeof(string);
private static Type[] _paramsArray = new Type[] { s_stringType };
private static string NullString = "None";
public AppSettingsReader()
{
_map = System.Configuration.ConfigurationManager.AppSettings;
}
/// <summary>
/// Gets the value for specified key from ConfigurationManager.AppSettings, and returns
/// an object of the specified type containing the value from the config file. If the key
/// isn't in the config file, or if it is not a valid value for the given type, it will
/// throw an exception with a descriptive message so the user can make the appropriate
/// change
/// </summary>
public object GetValue(string key, Type type)
{
if (key == null) throw new ArgumentNullException(nameof(key));
if (type == null) throw new ArgumentNullException(nameof(type));
string val = _map[key];
if (val == null) throw new InvalidOperationException(string.Format(SR.AppSettingsReaderNoKey, key));
if (type == s_stringType)
{
// It's a string, so we can ALMOST just return the value. The only
// tricky point is that if it's the string "(None)", then we want to
// return null. And of course we need a way to represent the string
// (None), so we use ((None)), and so on... so it's a little complicated.
int NoneNesting = GetNoneNesting(val);
if (NoneNesting == 0)
{
// val is not of the form ((..((None))..))
return val;
}
else if (NoneNesting == 1)
{
// val is (None)
return null;
}
else
{
// val is of the form ((..((None))..))
return val.Substring(1, val.Length - 2);
}
}
else
{
try
{
return Convert.ChangeType(val, type, CultureInfo.InvariantCulture);
}
catch (Exception)
{
string displayString = (val.Length == 0) ? SR.AppSettingsReaderEmptyString : val;
throw new InvalidOperationException(string.Format(SR.AppSettingsReaderCantParse, displayString, key, type.ToString()));
}
}
}
private int GetNoneNesting(string val)
{
int count = 0;
int len = val.Length;
if (len > 1)
{
while (val[count] == '(' && val[len - count - 1] == ')')
{
count++;
}
if (count > 0 && string.Compare(NullString, 0, val, count, len - 2 * count, StringComparison.Ordinal) != 0)
{
// the stuff between the parens is not "None"
count = 0;
}
}
return count;
}
}
}

View File

@@ -0,0 +1,144 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Specialized;
using System.IO;
using System.Xml;
namespace System.Configuration
{
public sealed class AppSettingsSection : ConfigurationSection
{
private static volatile ConfigurationPropertyCollection s_properties;
private static volatile ConfigurationProperty s_propAppSettings;
private static volatile ConfigurationProperty s_propFile;
private KeyValueInternalCollection _keyValueCollection;
public AppSettingsSection()
{
EnsureStaticPropertyBag();
}
protected internal override ConfigurationPropertyCollection Properties => EnsureStaticPropertyBag();
internal NameValueCollection InternalSettings
=> _keyValueCollection ?? (_keyValueCollection = new KeyValueInternalCollection(this));
[ConfigurationProperty("", IsDefaultCollection = true)]
public KeyValueConfigurationCollection Settings => (KeyValueConfigurationCollection)base[s_propAppSettings];
[ConfigurationProperty("file", DefaultValue = "")]
public string File
{
get
{
string fileValue = (string)base[s_propFile];
return fileValue ?? string.Empty;
}
set { base[s_propFile] = value; }
}
private static ConfigurationPropertyCollection EnsureStaticPropertyBag()
{
if (s_properties != null) return s_properties;
ConfigurationProperty propAppSettings = new ConfigurationProperty(
name: null,
type: typeof(KeyValueConfigurationCollection),
defaultValue: null,
options: ConfigurationPropertyOptions.IsDefaultCollection);
ConfigurationProperty propFile = new ConfigurationProperty(
name: "file",
type: typeof(string),
defaultValue: string.Empty,
options: ConfigurationPropertyOptions.None);
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection
{
propAppSettings,
propFile
};
s_propAppSettings = propAppSettings;
s_propFile = propFile;
s_properties = properties;
return s_properties;
}
protected internal override object GetRuntimeObject()
{
SetReadOnly();
return InternalSettings; // return the read only object
}
protected internal override void Reset(ConfigurationElement parentSection)
{
_keyValueCollection = null;
base.Reset(parentSection);
if (!string.IsNullOrEmpty((string)base[s_propFile]))
{
// don't inherit from the parent by ignoring locks
SetPropertyValue(prop: s_propFile, value: null, ignoreLocks: true);
}
}
protected internal override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
{
string elementName = reader.Name;
base.DeserializeElement(reader, serializeCollectionKey);
if (!(File?.Length > 0)) return;
string sourceFileFullPath;
// Determine file location
string configFile = ElementInformation.Source;
sourceFileFullPath = string.IsNullOrEmpty(configFile)
? File
: Path.Combine(Path.GetDirectoryName(configFile), File);
if (!IO.File.Exists(sourceFileFullPath)) return;
int lineOffset;
string rawXml;
using (Stream sourceFileStream = new FileStream(sourceFileFullPath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (XmlUtil xmlUtil = new XmlUtil(sourceFileStream, sourceFileFullPath, true))
{
if (xmlUtil.Reader.Name != elementName)
throw new ConfigurationErrorsException(
string.Format(SR.Config_name_value_file_section_file_invalid_root, elementName),
xmlUtil);
lineOffset = xmlUtil.Reader.LineNumber;
rawXml = xmlUtil.CopySection();
// Detect if there is any XML left over after the section
while (!xmlUtil.Reader.EOF)
{
XmlNodeType t = xmlUtil.Reader.NodeType;
if (t != XmlNodeType.Comment)
throw new ConfigurationErrorsException(SR.Config_source_file_format, xmlUtil);
xmlUtil.Reader.Read();
}
}
ConfigXmlReader internalReader = new ConfigXmlReader(rawXml, sourceFileFullPath, lineOffset);
internalReader.Read();
if (internalReader.MoveToNextAttribute())
throw new ConfigurationErrorsException(
string.Format(SR.Config_base_unrecognized_attribute, internalReader.Name),
(XmlReader)internalReader);
internalReader.MoveToElement();
base.DeserializeElement(internalReader, serializeCollectionKey);
}
}
}

View File

@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Configuration
{
/// <summary>
/// Indicates that a setting is to be stored on a per-application basis.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public sealed class ApplicationScopedSettingAttribute : SettingAttribute
{
}
}

View File

@@ -0,0 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Configuration
{
public sealed class ApplicationSettingsGroup : ConfigurationSectionGroup
{
}
}

View File

@@ -0,0 +1 @@
425d1c45fa760e8eb561fd44fae6a4b598e56365

View File

@@ -0,0 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Configuration
{
public sealed class CallbackValidator : ConfigurationValidatorBase
{
private readonly ValidatorCallback _callback;
private readonly Type _type;
public CallbackValidator(Type type, ValidatorCallback callback) : this(callback)
{
if (type == null) throw new ArgumentNullException(nameof(type));
_type = type;
}
// Do not check for null type here to handle the callback attribute case
internal CallbackValidator(ValidatorCallback callback)
{
if (callback == null) throw new ArgumentNullException(nameof(callback));
_type = null;
_callback = callback;
}
public override bool CanValidate(Type type)
{
return (type == _type) || (_type == null);
}
public override void Validate(object value)
{
_callback(value);
}
}
}

View File

@@ -0,0 +1,66 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Reflection;
namespace System.Configuration
{
[AttributeUsage(AttributeTargets.Property)]
public sealed class CallbackValidatorAttribute : ConfigurationValidatorAttribute
{
private ValidatorCallback _callbackMethod;
private string _callbackMethodName = string.Empty;
private Type _type;
public override ConfigurationValidatorBase ValidatorInstance
{
get
{
if (_callbackMethod == null)
{
if (_type == null) throw new ArgumentNullException(nameof(Type));
if (!string.IsNullOrEmpty(_callbackMethodName))
{
MethodInfo methodInfo = _type.GetMethod(_callbackMethodName, BindingFlags.Public | BindingFlags.Static);
if (methodInfo != null)
{
ParameterInfo[] parameters = methodInfo.GetParameters();
if ((parameters.Length == 1) && (parameters[0].ParameterType == typeof(object)))
{
_callbackMethod = (ValidatorCallback)Delegate.CreateDelegate(typeof(ValidatorCallback), methodInfo);
}
}
}
}
if (_callbackMethod == null)
throw new ArgumentException(string.Format(SR.Validator_method_not_found, _callbackMethodName));
return new CallbackValidator(_callbackMethod);
}
}
public Type Type
{
get { return _type; }
set
{
_type = value;
_callbackMethod = null;
}
}
public string CallbackMethodName
{
get { return _callbackMethodName; }
set
{
_callbackMethodName = value;
_callbackMethod = null;
}
}
}
}

View File

@@ -0,0 +1,332 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Security;
namespace System.Configuration
{
internal class ClientConfigPaths
{
internal const string UserConfigFilename = "user.config";
private const string ConfigExtension = ".config";
private const int MaxLengthToUse = 25;
private const string HttpUri = "http://";
private const string StrongNameDesc = "StrongName";
private const string UrlDesc = "Url";
private const string PathDesc = "Path";
private static volatile ClientConfigPaths s_current;
private static volatile bool s_currentIncludesUserConfig;
private readonly bool _includesUserConfig;
private string _companyName;
private ClientConfigPaths(string exePath, bool includeUserConfig)
{
_includesUserConfig = includeUserConfig;
Assembly exeAssembly = null;
string applicationFilename = null;
if (exePath != null)
{
// Exe path was specified, use it
ApplicationUri = Path.GetFullPath(exePath);
if (!File.Exists(ApplicationUri))
{
throw ExceptionUtil.ParameterInvalid(nameof(exePath));
}
applicationFilename = ApplicationUri;
}
else
{
// Exe path wasn't specified, get it from the entry assembly
exeAssembly = Assembly.GetEntryAssembly();
if (exeAssembly == null)
throw new PlatformNotSupportedException();
HasEntryAssembly = true;
// The original NetFX (desktop) code tried to get the local path without using Uri.
// If we ever find a need to do this again be careful with the logic. "file:///" is
// used for local paths and "file://" for UNCs. Simply removing the prefix will make
// local paths relative on Unix (e.g. "file:///home" will become "home" instead of
// "/home").
Uri uri = new Uri(exeAssembly.CodeBase);
if (uri.IsFile)
{
ApplicationUri = uri.LocalPath;
applicationFilename = uri.LocalPath;
}
else
{
ApplicationUri = exeAssembly.EscapedCodeBase;
}
}
ApplicationConfigUri = ApplicationUri + ConfigExtension;
// In the case when exePath was explicitly supplied, we will not be able to
// construct user.config paths, so quit here.
if (exePath != null) return;
// Skip expensive initialization of user config file information if requested.
if (!_includesUserConfig) return;
bool isHttp = StringUtil.StartsWithOrdinalIgnoreCase(ApplicationConfigUri, HttpUri);
SetNamesAndVersion(applicationFilename, exeAssembly, isHttp);
if (isHttp) return;
// Create a directory suffix for local and roaming config of three parts:
// (1) Company name
string part1 = Validate(_companyName, limitSize: true);
// (2) Domain or product name & a application urit hash
string namePrefix = Validate(AppDomain.CurrentDomain.FriendlyName, limitSize: true);
if (string.IsNullOrEmpty(namePrefix))
namePrefix = Validate(ProductName, limitSize: true);
string applicationUriLower = !string.IsNullOrEmpty(ApplicationUri)
? ApplicationUri.ToLower(CultureInfo.InvariantCulture)
: null;
string hashSuffix = GetTypeAndHashSuffix(applicationUriLower);
string part2 = !string.IsNullOrEmpty(namePrefix) && !string.IsNullOrEmpty(hashSuffix)
? namePrefix + hashSuffix
: null;
// (3) The product version
string part3 = Validate(ProductVersion, limitSize: false);
string dirSuffix = CombineIfValid(CombineIfValid(part1, part2), part3);
string roamingFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
if (Path.IsPathRooted(roamingFolderPath))
{
RoamingConfigDirectory = CombineIfValid(roamingFolderPath, dirSuffix);
RoamingConfigFilename = CombineIfValid(RoamingConfigDirectory, UserConfigFilename);
}
string localFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
if (Path.IsPathRooted(localFolderPath))
{
LocalConfigDirectory = CombineIfValid(localFolderPath, dirSuffix);
LocalConfigFilename = CombineIfValid(LocalConfigDirectory, UserConfigFilename);
}
}
internal static ClientConfigPaths Current => GetPaths(null, true);
internal bool HasEntryAssembly { get; }
internal string ApplicationUri { get; }
internal string ApplicationConfigUri { get; }
internal string RoamingConfigFilename { get; }
internal string RoamingConfigDirectory { get; }
internal bool HasRoamingConfig => (RoamingConfigFilename != null) || !_includesUserConfig;
internal string LocalConfigFilename { get; }
internal string LocalConfigDirectory { get; }
internal bool HasLocalConfig => (LocalConfigFilename != null) || !_includesUserConfig;
internal string ProductName { get; private set; }
internal string ProductVersion { get; private set; }
internal static ClientConfigPaths GetPaths(string exePath, bool includeUserConfig)
{
ClientConfigPaths result;
if (exePath == null)
{
if ((s_current == null) || (includeUserConfig && !s_currentIncludesUserConfig))
{
s_current = new ClientConfigPaths(null, includeUserConfig);
s_currentIncludesUserConfig = includeUserConfig;
}
result = s_current;
}
else result = new ClientConfigPaths(exePath, includeUserConfig);
return result;
}
internal static void RefreshCurrent()
{
s_currentIncludesUserConfig = false;
s_current = null;
}
// Combines path2 with path1 if possible, else returns null.
private static string CombineIfValid(string path1, string path2)
{
if ((path1 == null) || (path2 == null)) return null;
try
{
return Path.Combine(path1, path2);
}
catch
{
return null;
}
}
// Returns a type and hash suffix based on what used to come from app domain evidence.
// The evidence we use, in priority order, is Strong Name, Url and Exe Path. If one of
// these is found, we compute a SHA1 hash of it and return a suffix based on that.
// If none is found, we return null.
private static string GetTypeAndHashSuffix(string exePath)
{
Assembly assembly = Assembly.GetEntryAssembly();
string suffix = null;
string typeName = null;
string hash = null;
if (assembly != null)
{
AssemblyName assemblyName = assembly.GetName();
Uri codeBase = new Uri(assembly.CodeBase);
hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName);
if (hash != null)
{
typeName = StrongNameDesc;
}
else
{
hash = IdentityHelper.GetNormalizedUriHash(codeBase);
typeName = UrlDesc;
}
}
else if (!string.IsNullOrEmpty(exePath))
{
// Fall back on the exe name
hash = IdentityHelper.GetStrongHashSuitableForObjectName(exePath);
typeName = PathDesc;
}
if (!string.IsNullOrEmpty(hash)) suffix = "_" + typeName + "_" + hash;
return suffix;
}
private void SetNamesAndVersion(string applicationFilename, Assembly exeAssembly, bool isHttp)
{
Type mainType = null;
// Get CompanyName, ProductName, and ProductVersion
// First try custom attributes on the assembly.
if (exeAssembly != null)
{
object[] attrs = exeAssembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
if ((attrs != null) && (attrs.Length > 0))
{
_companyName = ((AssemblyCompanyAttribute)attrs[0]).Company?.Trim();
}
attrs = exeAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
if ((attrs != null) && (attrs.Length > 0))
{
ProductName = ((AssemblyProductAttribute)attrs[0]).Product?.Trim();
}
ProductVersion = exeAssembly.GetName().Version.ToString().Trim();
}
// If we couldn't get custom attributes, fall back on the entry type namespace
if (!isHttp &&
(string.IsNullOrEmpty(_companyName) || string.IsNullOrEmpty(ProductName) ||
string.IsNullOrEmpty(ProductVersion)))
{
if (exeAssembly != null)
{
MethodInfo entryPoint = exeAssembly.EntryPoint;
if (entryPoint != null)
{
mainType = entryPoint.ReflectedType;
}
}
string ns = null;
if (mainType != null) ns = mainType.Namespace;
if (string.IsNullOrEmpty(ProductName))
{
// Try the remainder of the namespace
if (ns != null)
{
int lastDot = ns.LastIndexOf(".", StringComparison.Ordinal);
if ((lastDot != -1) && (lastDot < ns.Length - 1)) ProductName = ns.Substring(lastDot + 1);
else ProductName = ns;
ProductName = ProductName.Trim();
}
// Try the type of the entry assembly
if (string.IsNullOrEmpty(ProductName) && (mainType != null)) ProductName = mainType.Name.Trim();
// give up, return empty string
if (ProductName == null) ProductName = string.Empty;
}
if (string.IsNullOrEmpty(_companyName))
{
// Try the first part of the namespace
if (ns != null)
{
int firstDot = ns.IndexOf(".", StringComparison.Ordinal);
_companyName = firstDot != -1 ? ns.Substring(0, firstDot) : ns;
_companyName = _companyName.Trim();
}
// If that doesn't work, use the product name
if (string.IsNullOrEmpty(_companyName)) _companyName = ProductName;
}
}
// Desperate measures for product version - assume 1.0
if (string.IsNullOrEmpty(ProductVersion)) ProductVersion = "1.0.0.0";
}
// Makes the passed in string suitable to use as a path name by replacing illegal characters
// with underscores. Additionally, we do two things - replace spaces too with underscores and
// limit the resultant string's length to MaxLengthToUse if limitSize is true.
private static string Validate(string str, bool limitSize)
{
string validated = str;
if (string.IsNullOrEmpty(validated)) return validated;
// First replace all illegal characters with underscores
foreach (char c in Path.GetInvalidFileNameChars()) validated = validated.Replace(c, '_');
// Replace all spaces with underscores
validated = validated.Replace(' ', '_');
if (limitSize)
{
validated = validated.Length > MaxLengthToUse
? validated.Substring(0, MaxLengthToUse)
: validated;
}
return validated;
}
}
}

View File

@@ -0,0 +1,492 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Configuration.Internal;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
namespace System.Configuration
{
internal sealed class ClientConfigurationHost : DelegatingConfigHost, IInternalConfigClientHost
{
internal const string MachineConfigName = "MACHINE";
internal const string ExeConfigName = "EXE";
internal const string RoamingUserConfigName = "ROAMING_USER";
internal const string LocalUserConfigName = "LOCAL_USER";
internal const string MachineConfigPath = MachineConfigName;
internal const string ExeConfigPath = MachineConfigPath + "/" + ExeConfigName;
internal const string RoamingUserConfigPath = ExeConfigPath + "/" + RoamingUserConfigName;
internal const string LocalUserConfigPath = RoamingUserConfigPath + "/" + LocalUserConfigName;
private const string MachineConfigFilename = "machine.config";
private const string MachineConfigSubdirectory = "Config";
private static readonly object s_version = new object();
private static volatile string s_machineConfigFilePath;
private ClientConfigPaths _configPaths; // physical paths to client config files
private string _exePath; // the physical path to the exe being configured
private ExeConfigurationFileMap _fileMap; // optional file map
private bool _initComplete;
internal ClientConfigurationHost()
{
Host = new InternalConfigHost();
}
internal ClientConfigPaths ConfigPaths => _configPaths ?? (_configPaths = ClientConfigPaths.GetPaths(_exePath, _initComplete));
internal static string MachineConfigFilePath
{
get
{
if (s_machineConfigFilePath == null)
{
string directory = RuntimeEnvironment.GetRuntimeDirectory();
s_machineConfigFilePath = Path.Combine(Path.Combine(directory, MachineConfigSubdirectory),
MachineConfigFilename);
}
return s_machineConfigFilePath;
}
}
public override bool HasRoamingConfig
{
get
{
if (_fileMap != null) return !string.IsNullOrEmpty(_fileMap.RoamingUserConfigFilename);
else return ConfigPaths.HasRoamingConfig;
}
}
public override bool HasLocalConfig
{
get
{
if (_fileMap != null) return !string.IsNullOrEmpty(_fileMap.LocalUserConfigFilename);
else return ConfigPaths.HasLocalConfig;
}
}
public override bool IsAppConfigHttp => !IsFile(GetStreamName(ExeConfigPath));
public override bool SupportsRefresh => true;
public override bool SupportsPath => false;
// Do we support location tags?
public override bool SupportsLocation => false;
bool IInternalConfigClientHost.IsExeConfig(string configPath)
{
return StringUtil.EqualsIgnoreCase(configPath, ExeConfigPath);
}
bool IInternalConfigClientHost.IsRoamingUserConfig(string configPath)
{
return StringUtil.EqualsIgnoreCase(configPath, RoamingUserConfigPath);
}
bool IInternalConfigClientHost.IsLocalUserConfig(string configPath)
{
return StringUtil.EqualsIgnoreCase(configPath, LocalUserConfigPath);
}
string IInternalConfigClientHost.GetExeConfigPath()
{
return ExeConfigPath;
}
string IInternalConfigClientHost.GetRoamingUserConfigPath()
{
return RoamingUserConfigPath;
}
string IInternalConfigClientHost.GetLocalUserConfigPath()
{
return LocalUserConfigPath;
}
public override void RefreshConfigPaths()
{
// Refresh current config paths.
if ((_configPaths != null) && !_configPaths.HasEntryAssembly && (_exePath == null))
{
ClientConfigPaths.RefreshCurrent();
_configPaths = null;
}
}
// Return true if the config path is for a user.config file, false otherwise.
private bool IsUserConfig(string configPath)
{
return StringUtil.EqualsIgnoreCase(configPath, RoamingUserConfigPath) ||
StringUtil.EqualsIgnoreCase(configPath, LocalUserConfigPath);
}
public override void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
{
try
{
ConfigurationFileMap fileMap = (ConfigurationFileMap)hostInitParams[0];
_exePath = (string)hostInitParams[1];
Host.Init(configRoot, hostInitParams);
// Do not complete initialization in runtime config, to avoid expense of
// loading user.config files that may not be required.
_initComplete = configRoot.IsDesignTime;
if ((fileMap != null) && !string.IsNullOrEmpty(_exePath))
throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::Init");
if (string.IsNullOrEmpty(_exePath)) _exePath = null;
// Initialize the fileMap, if provided.
if (fileMap != null)
{
_fileMap = new ExeConfigurationFileMap();
if (!string.IsNullOrEmpty(fileMap.MachineConfigFilename))
_fileMap.MachineConfigFilename = Path.GetFullPath(fileMap.MachineConfigFilename);
ExeConfigurationFileMap exeFileMap = fileMap as ExeConfigurationFileMap;
if (exeFileMap != null)
{
if (!string.IsNullOrEmpty(exeFileMap.ExeConfigFilename))
_fileMap.ExeConfigFilename = Path.GetFullPath(exeFileMap.ExeConfigFilename);
if (!string.IsNullOrEmpty(exeFileMap.RoamingUserConfigFilename))
_fileMap.RoamingUserConfigFilename = Path.GetFullPath(exeFileMap.RoamingUserConfigFilename);
if (!string.IsNullOrEmpty(exeFileMap.LocalUserConfigFilename))
_fileMap.LocalUserConfigFilename = Path.GetFullPath(exeFileMap.LocalUserConfigFilename);
}
}
}
catch
{
throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::Init");
}
}
public override void InitForConfiguration(ref string locationSubPath, out string configPath,
out string locationConfigPath,
IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
{
locationSubPath = null;
configPath = (string)hostInitConfigurationParams[2];
locationConfigPath = null;
Init(configRoot, hostInitConfigurationParams);
}
// Delay init if we have not been asked to complete init, and it is a user.config file.
public override bool IsInitDelayed(IInternalConfigRecord configRecord)
{
return !_initComplete && IsUserConfig(configRecord.ConfigPath);
}
public override void RequireCompleteInit(IInternalConfigRecord record)
{
// Loading information about user.config files is expensive,
// so do it just once by locking.
lock (this)
{
if (!_initComplete)
{
// Note that all future requests for config must be complete.
_initComplete = true;
// Throw out the ConfigPath for this exe.
ClientConfigPaths.RefreshCurrent();
// Throw out our cached copy.
_configPaths = null;
// Force loading of user.config file information under lock.
ClientConfigPaths configPaths = ConfigPaths;
}
}
}
public override bool IsConfigRecordRequired(string configPath)
{
string configName = ConfigPathUtility.GetName(configPath);
switch (configName)
{
case MachineConfigName:
case ExeConfigName:
return true;
case RoamingUserConfigName:
// Makes the design easier even if we only have an empty Roaming config record.
return HasRoamingConfig || HasLocalConfig;
case LocalUserConfigName:
return HasLocalConfig;
default:
// should never get here
Debug.Fail("unexpected config name: " + configName);
return false;
}
}
public override string GetStreamName(string configPath)
{
string configName = ConfigPathUtility.GetName(configPath);
switch (configName)
{
case MachineConfigName:
return _fileMap?.MachineConfigFilename ?? MachineConfigFilePath;
case ExeConfigName:
return _fileMap?.ExeConfigFilename ?? ConfigPaths.ApplicationConfigUri;
case RoamingUserConfigName:
return _fileMap?.RoamingUserConfigFilename ?? ConfigPaths.RoamingConfigFilename;
case LocalUserConfigName:
return _fileMap?.LocalUserConfigFilename ?? ConfigPaths.LocalConfigFilename;
default:
// should never get here
Debug.Fail("unexpected config name: " + configName);
goto case MachineConfigName;
}
}
public override string GetStreamNameForConfigSource(string streamName, string configSource)
{
if (IsFile(streamName))
return Host.GetStreamNameForConfigSource(streamName, configSource);
int index = streamName.LastIndexOf('/');
if (index < 0)
return null;
string parentUri = streamName.Substring(0, index + 1);
string result = parentUri + configSource.Replace('\\', '/');
return result;
}
public override object GetStreamVersion(string streamName)
{
return IsFile(streamName) ? Host.GetStreamVersion(streamName) : s_version;
}
// default impl treats name as a file name
// null means stream doesn't exist for this name
public override Stream OpenStreamForRead(string streamName)
{
// the streamName can either be a file name, or a URI
if (IsFile(streamName)) return Host.OpenStreamForRead(streamName);
if (streamName == null) return null;
// scheme is http
WebClient client = new WebClient();
// Try using default credentials
try
{
client.Credentials = CredentialCache.DefaultCredentials;
}
catch { }
byte[] fileData = null;
try
{
fileData = client.DownloadData(streamName);
}
catch { }
if (fileData == null) return null;
MemoryStream stream = new MemoryStream(fileData);
return stream;
}
public override Stream OpenStreamForWrite(string streamName, string templateStreamName, ref object writeContext)
{
// only support files, not URIs
if (!IsFile(streamName)) throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::OpenStreamForWrite");
return Host.OpenStreamForWrite(streamName, templateStreamName, ref writeContext);
}
public override void DeleteStream(string streamName)
{
// only support files, not URIs
if (!IsFile(streamName)) throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::Delete");
Host.DeleteStream(streamName);
}
public override bool IsDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition,
ConfigurationAllowExeDefinition allowExeDefinition)
{
string allowedConfigPath;
switch (allowExeDefinition)
{
case ConfigurationAllowExeDefinition.MachineOnly:
allowedConfigPath = MachineConfigPath;
break;
case ConfigurationAllowExeDefinition.MachineToApplication:
allowedConfigPath = ExeConfigPath;
break;
case ConfigurationAllowExeDefinition.MachineToRoamingUser:
allowedConfigPath = RoamingUserConfigPath;
break;
// MachineToLocalUser does not current have any definition restrictions
case ConfigurationAllowExeDefinition.MachineToLocalUser:
return true;
default:
// If we have extended ConfigurationAllowExeDefinition
// make sure to update this switch accordingly
throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::IsDefinitionAllowed");
}
return configPath.Length <= allowedConfigPath.Length;
}
public override void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition,
ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
{
if (!IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition))
{
switch (allowExeDefinition)
{
case ConfigurationAllowExeDefinition.MachineOnly:
throw new ConfigurationErrorsException(
SR.Config_allow_exedefinition_error_machine, errorInfo);
case ConfigurationAllowExeDefinition.MachineToApplication:
throw new ConfigurationErrorsException(
SR.Config_allow_exedefinition_error_application, errorInfo);
case ConfigurationAllowExeDefinition.MachineToRoamingUser:
throw new ConfigurationErrorsException(
SR.Config_allow_exedefinition_error_roaminguser, errorInfo);
default:
// If we have extended ConfigurationAllowExeDefinition
// make sure to update this switch accordingly
throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::VerifyDefinitionAllowed");
}
}
}
// prefetch support
public override bool PrefetchAll(string configPath, string streamName)
{
// If it's a file, we don't need to. Otherwise (e.g. it's from the web), we'll prefetch everything.
return !IsFile(streamName);
}
public override bool PrefetchSection(string sectionGroupName, string sectionName)
{
return sectionGroupName == "system.net";
}
public override object CreateDeprecatedConfigContext(string configPath)
{
return null;
}
public override object
CreateConfigurationContext(string configPath,
string locationSubPath)
{
return new ExeContext(GetUserLevel(configPath), ConfigPaths.ApplicationUri);
}
private ConfigurationUserLevel GetUserLevel(string configPath)
{
ConfigurationUserLevel level;
switch (ConfigPathUtility.GetName(configPath))
{
case MachineConfigName:
level = ConfigurationUserLevel.None;
break;
case ExeConfigName:
level = ConfigurationUserLevel.None;
break;
case LocalUserConfigName:
level = ConfigurationUserLevel.PerUserRoamingAndLocal;
break;
case RoamingUserConfigName:
level = ConfigurationUserLevel.PerUserRoaming;
break;
default:
Debug.Fail("unrecognized configPath " + configPath);
level = ConfigurationUserLevel.None;
break;
}
return level;
}
internal static Configuration OpenExeConfiguration(ConfigurationFileMap fileMap, bool isMachine,
ConfigurationUserLevel userLevel, string exePath)
{
// validate userLevel argument
switch (userLevel)
{
case ConfigurationUserLevel.None:
case ConfigurationUserLevel.PerUserRoaming:
case ConfigurationUserLevel.PerUserRoamingAndLocal:
break;
default:
throw ExceptionUtil.ParameterInvalid(nameof(userLevel));
}
// validate fileMap arguments
if (fileMap != null)
{
if (string.IsNullOrEmpty(fileMap.MachineConfigFilename))
throw ExceptionUtil.ParameterNullOrEmpty(nameof(fileMap) + "." + nameof(fileMap.MachineConfigFilename));
ExeConfigurationFileMap exeFileMap = fileMap as ExeConfigurationFileMap;
if (exeFileMap != null)
{
switch (userLevel)
{
case ConfigurationUserLevel.None:
if (string.IsNullOrEmpty(exeFileMap.ExeConfigFilename))
throw ExceptionUtil.ParameterNullOrEmpty(nameof(fileMap) + "." + nameof(exeFileMap.ExeConfigFilename));
break;
case ConfigurationUserLevel.PerUserRoaming:
if (string.IsNullOrEmpty(exeFileMap.RoamingUserConfigFilename))
throw ExceptionUtil.ParameterNullOrEmpty(nameof(fileMap) + "." + nameof(exeFileMap.RoamingUserConfigFilename));
goto case ConfigurationUserLevel.None;
case ConfigurationUserLevel.PerUserRoamingAndLocal:
if (string.IsNullOrEmpty(exeFileMap.LocalUserConfigFilename))
throw ExceptionUtil.ParameterNullOrEmpty(nameof(fileMap) + "." + nameof(exeFileMap.LocalUserConfigFilename));
goto case ConfigurationUserLevel.PerUserRoaming;
}
}
}
string configPath = null;
if (isMachine) configPath = MachineConfigPath;
else
{
switch (userLevel)
{
case ConfigurationUserLevel.None:
configPath = ExeConfigPath;
break;
case ConfigurationUserLevel.PerUserRoaming:
configPath = RoamingUserConfigPath;
break;
case ConfigurationUserLevel.PerUserRoamingAndLocal:
configPath = LocalUserConfigPath;
break;
}
}
Configuration configuration = new Configuration(null, typeof(ClientConfigurationHost), fileMap, exePath, configPath);
return configuration;
}
}
}

Some files were not shown because too many files have changed in this diff Show More