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,96 @@
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.CodeDom.Tests", "tests\System.CodeDom.Tests.csproj", "{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}"
ProjectSection(ProjectDependencies) = postProject
{53D09AF4-0C13-4197-B8AD-9746F0374E88} = {53D09AF4-0C13-4197-B8AD-9746F0374E88}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{350C956A-B4ED-4376-9B04-2908528D10FF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.CodeDom", "ref\System.CodeDom.csproj", "{14FAFC3A-8266-45C7-8604-8C2CB567E50D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827B5CCD-073A-4A75-9661-73D54F0A3528}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{096E7AD0-17A2-4EAF-9AC5-2F0FC67A4112}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.CodeDom", "src\System.CodeDom.csproj", "{53D09AF4-0C13-4197-B8AD-9746F0374E88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AnyCPU = Debug|AnyCPU
DebugNETCoreAppnet461netstandard|AnyCPU = DebugNETCoreAppnet461netstandard|AnyCPU
DebugNETCoreAppnetstandardnetstandard|AnyCPU = DebugNETCoreAppnetstandardnetstandard|AnyCPU
net461-Debug|AnyCPU = net461-Debug|AnyCPU
net461-Release|AnyCPU = net461-Release|AnyCPU
netstandard-Debug|AnyCPU = netstandard-Debug|AnyCPU
netstandard-Release|AnyCPU = netstandard-Release|AnyCPU
ReleaseNETCoreAppnet461netstandard|AnyCPU = ReleaseNETCoreAppnet461netstandard|AnyCPU
ReleaseNETCoreAppnetstandardnetstandard|AnyCPU = ReleaseNETCoreAppnetstandardnetstandard|AnyCPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.Debug|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.Debug|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnet461netstandard|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnet461netstandard|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.net461-Debug|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.net461-Debug|AnyCPU.Build.0 = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.net461-Release|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.net461-Release|AnyCPU.Build.0 = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.netstandard-Debug|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.netstandard-Debug|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.netstandard-Release|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.netstandard-Release|AnyCPU.Build.0 = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnet461netstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnet461netstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.DebugNETCoreAppnet461netstandard|AnyCPU.ActiveCfg = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.DebugNETCoreAppnet461netstandard|AnyCPU.Build.0 = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.net461-Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.net461-Debug|AnyCPU.Build.0 = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.net461-Release|AnyCPU.ActiveCfg = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.net461-Release|AnyCPU.Build.0 = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.netstandard-Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.netstandard-Debug|AnyCPU.Build.0 = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.netstandard-Release|AnyCPU.ActiveCfg = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.netstandard-Release|AnyCPU.Build.0 = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.ReleaseNETCoreAppnet461netstandard|AnyCPU.ActiveCfg = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.ReleaseNETCoreAppnet461netstandard|AnyCPU.Build.0 = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = Debug|Any CPU
{14FAFC3A-8266-45C7-8604-8C2CB567E50D}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.Debug|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.Debug|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnet461netstandard|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnet461netstandard|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.net461-Debug|AnyCPU.ActiveCfg = net461-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.net461-Debug|AnyCPU.Build.0 = net461-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.net461-Release|AnyCPU.ActiveCfg = net461-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.net461-Release|AnyCPU.Build.0 = net461-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.netstandard-Debug|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.netstandard-Debug|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.netstandard-Release|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.netstandard-Release|AnyCPU.Build.0 = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnet461netstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnet461netstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726} = {096E7AD0-17A2-4EAF-9AC5-2F0FC67A4112}
{14FAFC3A-8266-45C7-8604-8C2CB567E50D} = {350C956A-B4ED-4376-9B04-2908528D10FF}
{53D09AF4-0C13-4197-B8AD-9746F0374E88} = {827B5CCD-073A-4A75-9661-73D54F0A3528}
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.CodeDom.pkgproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -0,0 +1,11 @@
<?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.CodeDom.csproj">
<SupportedFramework>net461;netcoreapp2.0;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.CodeDom.builds" />
</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>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
<?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" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.CodeDom.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\System.Security.Permissions\ref\System.Security.Permissions.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

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

View File

@@ -0,0 +1,17 @@
// 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;
using System.CodeDom.Compiler;
namespace Microsoft.CSharp
{
internal sealed partial class CSharpCodeGenerator
{
private CompilerResults FromFileBatch(CompilerParameters options, string[] fileNames)
{
throw new PlatformNotSupportedException();
}
}
}

View File

@@ -0,0 +1 @@
242a60a2e88b9c75624608ae9b14ba1bef696784

View File

@@ -0,0 +1,50 @@
// 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;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Reflection;
namespace Microsoft.CSharp
{
public class CSharpCodeProvider : CodeDomProvider
{
private readonly CSharpCodeGenerator _generator;
public CSharpCodeProvider()
{
_generator = new CSharpCodeGenerator();
}
public CSharpCodeProvider(IDictionary<string, string> providerOptions)
{
if (providerOptions == null)
{
throw new ArgumentNullException(nameof(providerOptions));
}
_generator = new CSharpCodeGenerator(providerOptions);
}
public override string FileExtension => "cs";
[Obsolete("Callers should not use the ICodeGenerator interface and should instead use the methods directly on the CodeDomProvider class.")]
public override ICodeGenerator CreateGenerator() => _generator;
[Obsolete("Callers should not use the ICodeCompiler interface and should instead use the methods directly on the CodeDomProvider class.")]
public override ICodeCompiler CreateCompiler() => _generator;
public override TypeConverter GetConverter(Type type) =>
type == typeof(MemberAttributes) ? CSharpMemberAttributeConverter.Default :
type == typeof(TypeAttributes) ? CSharpTypeAttributeConverter.Default :
base.GetConverter(type);
public override void GenerateCodeFromMember(CodeTypeMember member, TextWriter writer, CodeGeneratorOptions options) =>
_generator.GenerateCodeFromMember(member, writer, options);
}
}

View File

@@ -0,0 +1,22 @@
// 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.CodeDom;
namespace Microsoft.CSharp
{
internal sealed class CSharpMemberAttributeConverter : CSharpModifierAttributeConverter
{
private CSharpMemberAttributeConverter() { } // no need to create an instance; use Default
public static CSharpMemberAttributeConverter Default { get; } = new CSharpMemberAttributeConverter();
protected override string[] Names { get; } = new[] { "Public", "Protected", "Protected Internal", "Internal", "Private" };
protected override object[] Values { get; } =
new object[] { MemberAttributes.Public, MemberAttributes.Family, MemberAttributes.FamilyOrAssembly, MemberAttributes.Assembly, MemberAttributes.Private };
protected override object DefaultValue => MemberAttributes.Private;
}
}

View File

@@ -0,0 +1,68 @@
// 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;
using System.ComponentModel;
using System.Globalization;
namespace Microsoft.CSharp
{
internal abstract class CSharpModifierAttributeConverter : TypeConverter
{
protected abstract object[] Values { get; }
protected abstract string[] Names { get; }
protected abstract object DefaultValue { get; }
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) =>
sourceType == typeof(string) ? true : base.CanConvertFrom(context, sourceType);
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
string name = value as string;
if (name != null)
{
string[] names = Names;
for (int i = 0; i < names.Length; i++)
{
if (names[i].Equals(name))
{
return Values[i];
}
}
}
return DefaultValue;
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == null)
{
throw new ArgumentNullException(nameof(destinationType));
}
if (destinationType == typeof(string))
{
object[] modifiers = Values;
for (int i = 0; i < modifiers.Length; i++)
{
if (modifiers[i].Equals(value))
{
return Names[i];
}
}
return SR.toStringUnknown;
}
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => true;
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true;
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) => new StandardValuesCollection(Values);
}
}

View File

@@ -0,0 +1,21 @@
// 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 Microsoft.CSharp
{
internal sealed class CSharpTypeAttributeConverter : CSharpModifierAttributeConverter
{
private CSharpTypeAttributeConverter() { } // no need to create an instance; use Default
public static CSharpTypeAttributeConverter Default { get; } = new CSharpTypeAttributeConverter();
protected override string[] Names { get; } = new[] { "Public", "Internal" };
protected override object[] Values { get; } = new object[] { TypeAttributes.Public, TypeAttributes.NotPublic };
protected override object DefaultValue => TypeAttributes.NotPublic;
}
}

View File

@@ -0,0 +1,17 @@
// 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;
using System.CodeDom.Compiler;
namespace Microsoft.VisualBasic
{
internal sealed partial class VBCodeGenerator
{
protected override CompilerResults FromFileBatch(CompilerParameters options, string[] fileNames)
{
throw new PlatformNotSupportedException();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
// 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;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Reflection;
namespace Microsoft.VisualBasic
{
public class VBCodeProvider : CodeDomProvider
{
private VBCodeGenerator _generator;
public VBCodeProvider()
{
_generator = new VBCodeGenerator();
}
public VBCodeProvider(IDictionary<string, string> providerOptions)
{
if (providerOptions == null)
{
throw new ArgumentNullException(nameof(providerOptions));
}
_generator = new VBCodeGenerator(providerOptions);
}
public override string FileExtension => "vb";
public override LanguageOptions LanguageOptions => LanguageOptions.CaseInsensitive;
[Obsolete("Callers should not use the ICodeGenerator interface and should instead use the methods directly on the CodeDomProvider class.")]
public override ICodeGenerator CreateGenerator() => _generator;
[Obsolete("Callers should not use the ICodeCompiler interface and should instead use the methods directly on the CodeDomProvider class.")]
public override ICodeCompiler CreateCompiler() => _generator;
public override TypeConverter GetConverter(Type type) =>
type == typeof(MemberAttributes) ? VBMemberAttributeConverter.Default :
type == typeof(TypeAttributes) ? VBTypeAttributeConverter.Default :
base.GetConverter(type);
public override void GenerateCodeFromMember(CodeTypeMember member, TextWriter writer, CodeGeneratorOptions options) =>
_generator.GenerateCodeFromMember(member, writer, options);
}
}

View File

@@ -0,0 +1,22 @@
// 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.CodeDom;
namespace Microsoft.VisualBasic
{
internal sealed class VBMemberAttributeConverter : VBModifierAttributeConverter
{
private VBMemberAttributeConverter() { } // no need to create an instance; use Default
public static VBMemberAttributeConverter Default { get; } = new VBMemberAttributeConverter();
protected override string[] Names { get; } = new[] { "Public", "Protected", "Protected Friend", "Friend", "Private" };
protected override object[] Values { get; } =
new object[] { MemberAttributes.Public, MemberAttributes.Family, MemberAttributes.FamilyOrAssembly, MemberAttributes.Assembly, MemberAttributes.Private };
protected override object DefaultValue => MemberAttributes.Private;
}
}

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;
using System.ComponentModel;
using System.Globalization;
namespace Microsoft.VisualBasic
{
internal abstract class VBModifierAttributeConverter : TypeConverter
{
protected abstract object[] Values { get; }
protected abstract string[] Names { get; }
protected abstract object DefaultValue { get; }
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) =>
sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
string name = value as string;
if (name != null)
{
string[] names = Names;
for (int i = 0; i < names.Length; i++)
{
if (names[i].Equals(name, StringComparison.OrdinalIgnoreCase))
{
return Values[i];
}
}
}
return DefaultValue;
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == null)
{
throw new ArgumentNullException(nameof(destinationType));
}
if (destinationType == typeof(string))
{
object[] modifiers = Values;
for (int i = 0; i < modifiers.Length; i++)
{
if (modifiers[i].Equals(value))
{
return Names[i];
}
}
return SR.toStringUnknown;
}
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => true;
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true;
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) => new StandardValuesCollection(Values);
}
}

View File

@@ -0,0 +1,18 @@
// 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 Microsoft.VisualBasic
{
internal sealed class VBTypeAttributeConverter : VBModifierAttributeConverter
{
private VBTypeAttributeConverter() { } // no need to create an instance; use Default
public static VBTypeAttributeConverter Default { get; } = new VBTypeAttributeConverter();
protected override string[] Names { get; } = new[] { "Public", "Friend" };
protected override object[] Values { get; } = new object[] { TypeAttributes.Public, TypeAttributes.NotPublic };
protected override object DefaultValue => TypeAttributes.Public;
}
}

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