提交 fa4049eb 编写于 作者: J Jared Parsons

Moved CSharp and Visual Basic Desktop to Portable

This moves the contents of the CSharp and Visual Basic Desktop
Projects to the Portable counterparts.

closes #2587
上级 9c308f74
......@@ -78,13 +78,6 @@
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CSharpFileSystemExtensions.cs" />
<Compile Include="CommandLine\CommandLineArguments.cs" />
<Compile Include="CommandLine\CommandLineDiagnosticFormatter.cs" />
<Compile Include="CommandLine\CommandLineParser.cs" />
<Compile Include="CommandLine\CSharpCompiler.cs" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler" />
<InternalsVisibleTo Include="csc" />
......@@ -104,9 +97,6 @@
<InternalsVisibleToTest Include="Roslyn.Services.Editor.CSharp.UnitTests" />
</ItemGroup>
<ItemGroup>
<None Include="..\CSharpCodeAnalysisRules.ruleset">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<PublicAPI Include="PublicAPI.txt" />
</ItemGroup>
......
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments.CompilationOptions.get -> Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments.ParseOptions.get -> Microsoft.CodeAnalysis.CSharp.CSharpParseOptions
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.Parse(System.Collections.Generic.IEnumerable<string> args, string baseDirectory, string sdkDirectory, string additionalReferenceDirectories = null) -> Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments
Microsoft.CodeAnalysis.CSharp.CSharpFileSystemExtensions
override Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments.CompilationOptionsCore.get -> Microsoft.CodeAnalysis.CompilationOptions
override Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments.ParseOptionsCore.get -> Microsoft.CodeAnalysis.ParseOptions
override Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.RegularFileExtension.get -> string
override Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.ScriptFileExtension.get -> string
static Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.ParseConditionalCompilationSymbols(string value, out System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Diagnostic> diagnostics) -> System.Collections.Generic.IEnumerable<string>
static Microsoft.CodeAnalysis.CSharp.CSharpFileSystemExtensions.Emit(this Microsoft.CodeAnalysis.CSharp.CSharpCompilation compilation, string outputPath, string pdbPath = null, string xmlDocumentationPath = null, string win32ResourcesPath = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.ResourceDescription> manifestResources = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.Emit.EmitResult
static readonly Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.Default -> Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser
static readonly Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.Interactive -> Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser
\ No newline at end of file
......@@ -224,6 +224,10 @@
<Compile Include="CodeGen\EmitOperators.cs" />
<Compile Include="CodeGen\EmitStatement.cs" />
<Compile Include="CodeGen\Optimizer.cs" />
<Compile Include="CommandLine\CommandLineArguments.cs" />
<Compile Include="CommandLine\CommandLineDiagnosticFormatter.cs" />
<Compile Include="CommandLine\CommandLineParser.cs" />
<Compile Include="CommandLine\CSharpCompiler.cs" />
<Compile Include="Compilation\AttributeSemanticModel.cs" />
<Compile Include="Compilation\AwaitExpressionInfo.cs" />
<Compile Include="Compilation\BuiltInOperators.cs" />
......@@ -260,6 +264,7 @@
<Compile Include="Compiler\UnprocessedDocumentationCommentFinder.cs" />
<Compile Include="CSharpCompilationOptions.cs" />
<Compile Include="CSharpExtensions.cs" />
<Compile Include="CSharpFileSystemExtensions.cs" />
<Compile Include="CSharpParseOptions.cs" />
<Compile Include="CSharpResources.Designer.cs">
<AutoGen>True</AutoGen>
......
......@@ -97,7 +97,7 @@ public override Compilation CreateCompilation(TextWriter consoleOutput, TouchedF
{
try
{
using (var appConfigStream = new FileStream(appConfigPath, FileMode.Open, FileAccess.Read))
using (var appConfigStream = PortableShim.FileStream.Create(appConfigPath, PortableShim.FileMode.Open, PortableShim.FileAccess.Read))
{
assemblyIdentityComparer = DesktopAssemblyIdentityComparer.LoadFromXml(appConfigStream);
}
......
......@@ -262,7 +262,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
try
{
preferredUILang = new CultureInfo(value);
if ((preferredUILang.CultureTypes & CultureTypes.UserCustomCulture) != 0)
if (CorLightup.Desktop.IsUserCustomCulture(preferredUILang) ?? false)
{
// Do not use user custom cultures.
preferredUILang = null;
......@@ -1132,7 +1132,7 @@ private static void ParseAndResolveReferencePaths(string switchName, string swit
{
AddDiagnostic(diagnostics, ErrorCode.WRN_InvalidSearchPathDir, path, origin.Localize(), MessageID.IDS_DirectoryHasInvalidPath.Localize());
}
else if (!Directory.Exists(resolvedPath))
else if (!PortableShim.Directory.Exists(resolvedPath))
{
AddDiagnostic(diagnostics, ErrorCode.WRN_InvalidSearchPathDir, path, origin.Localize(), MessageID.IDS_DirectoryDoesNotExist.Localize());
}
......@@ -1524,7 +1524,7 @@ private static void ValidateWin32Settings(string win32ResourceFile, string win32
{
// Use FileShare.ReadWrite because the file could be opened by the current process.
// For example, it is an XML doc file produced by the build.
return new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
return PortableShim.FileStream.Create(fullPath, PortableShim.FileMode.Open, PortableShim.FileAccess.Read, PortableShim.FileShare.ReadWrite);
};
return new ResourceDescription(resourceName, fileName, dataProvider, isPublic, embedded, checkArgs: false);
}
......
......@@ -4435,3 +4435,17 @@ virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.VisitLeadingTrivia(Micr
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.VisitToken(Microsoft.CodeAnalysis.SyntaxToken token) -> void
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.VisitTrailingTrivia(Microsoft.CodeAnalysis.SyntaxToken token) -> void
virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.VisitTrivia(Microsoft.CodeAnalysis.SyntaxTrivia trivia) -> void
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments.CompilationOptions.get -> Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments.ParseOptions.get -> Microsoft.CodeAnalysis.CSharp.CSharpParseOptions
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser
Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.Parse(System.Collections.Generic.IEnumerable<string> args, string baseDirectory, string sdkDirectory, string additionalReferenceDirectories = null) -> Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments
Microsoft.CodeAnalysis.CSharp.CSharpFileSystemExtensions
override Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments.CompilationOptionsCore.get -> Microsoft.CodeAnalysis.CompilationOptions
override Microsoft.CodeAnalysis.CSharp.CSharpCommandLineArguments.ParseOptionsCore.get -> Microsoft.CodeAnalysis.ParseOptions
override Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.RegularFileExtension.get -> string
override Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.ScriptFileExtension.get -> string
static Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.ParseConditionalCompilationSymbols(string value, out System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Diagnostic> diagnostics) -> System.Collections.Generic.IEnumerable<string>
static Microsoft.CodeAnalysis.CSharp.CSharpFileSystemExtensions.Emit(this Microsoft.CodeAnalysis.CSharp.CSharpCompilation compilation, string outputPath, string pdbPath = null, string xmlDocumentationPath = null, string win32ResourcesPath = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.ResourceDescription> manifestResources = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.Emit.EmitResult
static readonly Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.Default -> Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser
static readonly Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.Interactive -> Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser
\ No newline at end of file
......@@ -133,6 +133,8 @@
<Compile Include="Compilation.EmitStreamProvider.cs" />
<Compile Include="Compilation\SymbolFilter.cs" />
<Compile Include="CompilerPathUtilities.cs" />
<Compile Include="ReflectionUtil.cs" />
<Compile Include="CorLightup.cs" />
<Compile Include="Desktop\AssemblyPortabilityPolicy.cs" />
<Compile Include="Desktop\AssemblyVersion.cs" />
<Compile Include="Desktop\DesktopAssemblyIdentityComparer.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
namespace Roslyn.Utilities
{
/// <summary>
/// This type contains the light up scenarios for various platform and runtimes. Any function
/// in this type can, and is expected to, fail on various platforms. These are light up sceanrios
/// only.
/// </summary>
internal static class CorLightup
{
internal static class Desktop
{
private static class CultureInfo
{
internal static readonly Type Type = typeof(CultureInfo);
internal static readonly PropertyInfo CultureTypes = Type
.GetTypeInfo()
.GetDeclaredProperty(nameof(CultureTypes));
}
private static class CultureTypes
{
internal const int UserCustomCulture = 8;
}
internal static bool? IsUserCustomCulture(System.Globalization.CultureInfo cultureInfo)
{
if (CultureInfo.CultureTypes == null)
{
return null;
}
try
{
var value = (int)CultureInfo.CultureTypes.GetValue(cultureInfo);
return (value & CultureTypes.UserCustomCulture) != 0;
}
catch (Exception ex)
{
Debug.Assert(false, ex.Message);
return null;
}
}
}
}
}
......@@ -28,6 +28,8 @@ namespace Roslyn.Utilities
///
/// This is an unfortunate situation but it will all be removed fairly quickly after RTM and converted
/// to the proper 4.6 portable contracts.
///
/// Note: Only portable APIs should be present here.
/// </summary>
internal static class PortableShim
{
......@@ -37,74 +39,18 @@ internal static class PortableShim
private const string System_Runtime_Extensions_Name = "System.Runtime.Extensions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
private const string System_Threading_Thread_Name = "System.Threading.Thread, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
/// <summary>
/// Find a <see cref="Type"/> instance by first probing the contract name and then the name as it
/// would exist in mscorlib. This helps satisfy both the CoreCLR and Desktop scenarios.
/// </summary>
private static Type GetTypeFromEither(string contractName, string desktopName)
{
var type = Type.GetType(contractName, throwOnError: false);
if (type == null)
{
type = Type.GetType(desktopName, throwOnError: false);
}
return type;
}
private static T FindItem<T>(IEnumerable<T> collection, params Type[] paramTypes)
where T : MethodBase
{
foreach (var current in collection)
{
var p = current.GetParameters();
if (p.Length != paramTypes.Length)
{
continue;
}
bool allMatch = true;
for (int i = 0; i < paramTypes.Length; i++)
{
if (p[i].ParameterType != paramTypes[i])
{
allMatch = false;
break;
}
}
if (allMatch)
{
return current;
}
}
return null;
}
private static MethodInfo GetDeclaredMethod(this TypeInfo typeInfo, string name, params Type[] paramTypes)
{
return FindItem(typeInfo.GetDeclaredMethods(name), paramTypes);
}
private static ConstructorInfo GetDeclaredConstructor(this TypeInfo typeInfo, params Type[] paramTypes)
{
return FindItem(typeInfo.DeclaredConstructors, paramTypes);
}
internal static class Environment
{
internal const string TypeName = "System.Environment";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_Runtime_Extensions_Name}",
desktopName: TypeName);
internal static Func<string, string> ExpandEnvironmentVariables = (Func<string, string>)Type
internal static Func<string, string> ExpandEnvironmentVariables = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(ExpandEnvironmentVariables), paramTypes: new[] { typeof(string) })
.CreateDelegate(typeof(Func<string, string>));
.CreateDelegate<Func<string, string>>();
internal static Func<string, string> GetEnvironmentVariable = (Func<string, string>)Type
.GetTypeInfo()
......@@ -116,7 +62,7 @@ internal static class Path
{
internal const string TypeName = "System.IO.Path";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_Runtime_Extensions_Name}",
desktopName: TypeName);
......@@ -130,10 +76,10 @@ internal static class Path
.GetDeclaredField(nameof(AltDirectorySeparatorChar))
.GetValue(null);
internal static readonly Func<string, string> GetFullPath = (Func<string, string>)Type
internal static readonly Func<string, string> GetFullPath = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(GetFullPath), paramTypes: new[] { typeof(string) })
.CreateDelegate(typeof(Func<string, string>));
.CreateDelegate<Func<string, string>>();
internal static readonly Func<string> GetTempFileName = (Func<string>)Type
.GetTypeInfo()
......@@ -145,46 +91,46 @@ internal static class File
{
internal const string TypeName = "System.IO.File";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_IO_FileSystem_Name}",
desktopName: TypeName);
internal static readonly Func<string, DateTime> GetLastWriteTimeUtc = (Func<string, DateTime>)Type
internal static readonly Func<string, DateTime> GetLastWriteTimeUtc = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(GetLastWriteTimeUtc), new[] { typeof(string) })
.CreateDelegate(typeof(Func<string, DateTime>));
.CreateDelegate<Func<string, DateTime>>();
internal static readonly Func<string, Stream> Create = (Func<string, Stream>)Type
internal static readonly Func<string, Stream> Create = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(Create), paramTypes: new[] { typeof(string) })
.CreateDelegate(typeof(Func<string, Stream>));
.CreateDelegate<Func<string, Stream>>();
internal static readonly Func<string, Stream> OpenRead = (Func<string, Stream>)Type
internal static readonly Func<string, Stream> OpenRead = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(OpenRead), paramTypes: new[] { typeof(string) })
.CreateDelegate(typeof(Func<string, Stream>));
.CreateDelegate<Func<string, Stream>>();
internal static readonly Func<string, bool> Exists = (Func<string, bool>)Type
internal static readonly Func<string, bool> Exists = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(Exists), new[] { typeof(string) })
.CreateDelegate(typeof(Func<string, bool>));
.CreateDelegate<Func<string, bool>>();
internal static readonly Action<string> Delete = (Action<string>)Type
internal static readonly Action<string> Delete = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(Delete), new[] { typeof(string) })
.CreateDelegate(typeof(Action<string>));
.CreateDelegate<Action<string>>();
internal static readonly Func<string, byte[]> ReadAllBytes = (Func<string, byte[]>)Type
internal static readonly Func<string, byte[]> ReadAllBytes = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(ReadAllBytes), paramTypes: new[] { typeof(string) })
.CreateDelegate(typeof(Func<string, byte[]>));
.CreateDelegate<Func<string, byte[]>>();
}
internal static class Directory
{
internal const string TypeName = "System.IO.Directory";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_IO_FileSystem_Name}",
desktopName: TypeName);
......@@ -201,6 +147,11 @@ internal static IEnumerable<string> EnumerateDirectories(string path, string sea
return (IEnumerable<string>)s_enumerateDirectories.Invoke(null, new object[] { path, searchPattern, searchOption });
}
internal static readonly Func<string, bool> Exists = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(Exists), new[] { typeof(string) })
.CreateDelegate<Func<string, bool>>();
internal static IEnumerable<string> EnumerateFiles(string path, string searchPattern, object searchOption)
{
return (IEnumerable<string>)s_enumerateFiles.Invoke(null, new object[] { path, searchPattern, searchOption });
......@@ -211,7 +162,7 @@ internal static class FileMode
{
internal const string TypeName = "System.IO.FileMode";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_IO_FileSystem_Primitives_Name}",
desktopName: TypeName);
......@@ -232,7 +183,7 @@ internal static class FileAccess
{
internal const string TypeName = "System.IO.FileAccess";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_IO_FileSystem_Primitives_Name}",
desktopName: TypeName);
......@@ -247,7 +198,7 @@ internal static class FileShare
{
internal const string TypeName = "System.IO.FileShare";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_IO_FileSystem_Primitives_Name}",
desktopName: TypeName);
......@@ -270,7 +221,7 @@ internal static class FileOptions
{
internal const string TypeName = "System.IO.FileOptions";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_IO_FileSystem_Name}",
desktopName: TypeName);
......@@ -283,7 +234,7 @@ internal static class SearchOption
{
internal const string TypeName = "System.IO.SearchOption";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_IO_FileSystem_Name}",
desktopName: TypeName);
......@@ -296,7 +247,7 @@ internal static class FileStream
{
internal const string TypeName = "System.IO.FileStream";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"${TypeName}, ${System_IO_FileSystem_Name}",
desktopName: TypeName);
......@@ -334,27 +285,27 @@ private static Stream InvokeConstructor(ConstructorInfo constructorInfo, object[
}
}
public static Stream Create(string path, object mode)
internal static Stream Create(string path, object mode)
{
return InvokeConstructor(s_Ctor_String_FileMode, new[] { path, mode });
}
public static Stream Create(string path, object mode, object access)
internal static Stream Create(string path, object mode, object access)
{
return InvokeConstructor(s_Ctor_String_FileMode_FileAccess, new[] { path, mode, access });
}
public static Stream Create(string path, object mode, object access, object share)
internal static Stream Create(string path, object mode, object access, object share)
{
return InvokeConstructor(s_Ctor_String_FileMode_FileAccess_FileShare, new[] { path, mode, access, share });
}
public static Stream Create(string path, object mode, object access, object share, int bufferSize, object options)
internal static Stream Create(string path, object mode, object access, object share, int bufferSize, object options)
{
return InvokeConstructor(s_Ctor_String_FileMode_FileAccess_FileShare_Int32_FileOptions, new[] { path, mode, access, share, bufferSize, options });
}
public static Stream Create_String_FileMode_FileAccess_FileShare(string path, object mode, object access, object share)
internal static Stream Create_String_FileMode_FileAccess_FileShare(string path, object mode, object access, object share)
{
return Create(path, mode, access, share);
}
......@@ -366,14 +317,14 @@ internal static class FileVersionInfo
internal static readonly string DesktopName = $"{TypeName}, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"{TypeName}, {System_Diagnotsics_FileVersionInfo_Name}",
desktopName: DesktopName);
internal static readonly Func<string, object> GetVersionInfo = (Func<string, object>)Type
internal static readonly Func<string, object> GetVersionInfo = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(GetVersionInfo), new[] { typeof(string) })
.CreateDelegate(typeof(Func<string, object>));
.CreateDelegate<Func<string, object>>();
internal static readonly PropertyInfo FileVersion = Type
.GetTypeInfo()
......@@ -384,7 +335,7 @@ internal static class Thread
{
internal const string TypeName = "System.Threading.Thread";
internal static readonly Type Type = GetTypeFromEither(
internal static readonly Type Type = ReflectionUtil.GetTypeFromEither(
contractName: $"${TypeName}, ${System_Threading_Thread_Name}",
desktopName: TypeName);
......@@ -401,10 +352,10 @@ internal static class Encoding
{
internal static readonly Type Type = typeof(System.Text.Encoding);
internal static readonly Func<int, System.Text.Encoding> GetEncoding = (Func<int, System.Text.Encoding>)Type
internal static readonly Func<int, System.Text.Encoding> GetEncoding = Type
.GetTypeInfo()
.GetDeclaredMethod(nameof(GetEncoding), paramTypes: new[] { typeof(int) })
.CreateDelegate(typeof(Func<int, System.Text.Encoding>));
.CreateDelegate<Func<int, System.Text.Encoding>>();
}
internal static class MemoryStream
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Roslyn.Utilities
{
internal static class ReflectionUtil
{
/// <summary>
/// Find a <see cref="Type"/> instance by first probing the contract name and then the name as it
/// would exist in mscorlib. This helps satisfy both the CoreCLR and Desktop scenarios.
/// </summary>
public static Type GetTypeFromEither(string contractName, string desktopName)
{
var type = Type.GetType(contractName, throwOnError: false);
if (type == null)
{
type = Type.GetType(desktopName, throwOnError: false);
}
return type;
}
public static T FindItem<T>(IEnumerable<T> collection, params Type[] paramTypes)
where T : MethodBase
{
foreach (var current in collection)
{
var p = current.GetParameters();
if (p.Length != paramTypes.Length)
{
continue;
}
bool allMatch = true;
for (int i = 0; i < paramTypes.Length; i++)
{
if (p[i].ParameterType != paramTypes[i])
{
allMatch = false;
break;
}
}
if (allMatch)
{
return current;
}
}
return null;
}
internal static MethodInfo GetDeclaredMethod(this TypeInfo typeInfo, string name, params Type[] paramTypes)
{
return FindItem(typeInfo.GetDeclaredMethods(name), paramTypes);
}
internal static ConstructorInfo GetDeclaredConstructor(this TypeInfo typeInfo, params Type[] paramTypes)
{
return FindItem(typeInfo.DeclaredConstructors, paramTypes);
}
public static T CreateDelegate<T>(this MethodInfo methodInfo)
{
return (T)(object)methodInfo.CreateDelegate(typeof(T));
}
}
}
......@@ -81,13 +81,6 @@
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet>..\BasicCodeAnalysisRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Compile Include="CommandLine\CommandLineArguments.vb" />
<Compile Include="CommandLine\CommandLineDiagnosticFormatter.vb" />
<Compile Include="CommandLine\CommandLineParser.vb" />
<Compile Include="CommandLine\VisualBasicCompiler.vb" />
<Compile Include="VisualBasicFileSystemExtensions.vb" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=$(SystemCollectionsImmutableAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
......@@ -120,9 +113,6 @@
<Folder Include="My Project\" />
</ItemGroup>
<ItemGroup>
<None Include="..\BasicCodeAnalysisRules.ruleset">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
......
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineArguments
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.New(isInteractive As Boolean = False) -> Void
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.Parse(args As System.Collections.Generic.IEnumerable(Of String), baseDirectory As String, sdkDirectory As String, additionalReferenceDirectories As String = Nothing) -> Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineArguments
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineArguments.CompilationOptionsCore() -> Microsoft.CodeAnalysis.CompilationOptions
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineArguments.ParseOptionsCore() -> Microsoft.CodeAnalysis.ParseOptions
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.RegularFileExtension() -> String
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.ScriptFileExtension() -> String
Shared Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.ParseConditionalCompilationSymbols(symbolList As String, ByRef diagnostics As System.Collections.Generic.IEnumerable(Of Microsoft.CodeAnalysis.Diagnostic), symbols As System.Collections.Generic.IEnumerable(Of System.Collections.Generic.KeyValuePair(Of String, Object)) = Nothing) -> System.Collections.Generic.IReadOnlyDictionary(Of String, Object)
Shared ReadOnly Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.Default -> Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser
Shared ReadOnly Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.Interactive -> Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser
\ No newline at end of file
......@@ -321,6 +321,10 @@
<Compile Include="CodeGen\Optimizer\StackScheduler.LocalDefUseSpan.vb" />
<Compile Include="CodeGen\Optimizer\StackScheduler.Rewriter.vb" />
<Compile Include="CodeGen\Optimizer\StackScheduler.vb" />
<Compile Include="CommandLine\CommandLineArguments.vb" />
<Compile Include="CommandLine\CommandLineDiagnosticFormatter.vb" />
<Compile Include="CommandLine\CommandLineParser.vb" />
<Compile Include="CommandLine\VisualBasicCompiler.vb" />
<Compile Include="Compilation\AwaitExpressionInfo.vb" />
<Compile Include="Compilation\BoundNodeSummary.vb" />
<Compile Include="Compilation\ClsComplianceChecker.vb" />
......@@ -946,6 +950,7 @@
</Compile>
<Compile Include="VisualBasicCompilationOptions.vb" />
<Compile Include="VisualBasicExtensions.vb" />
<Compile Include="VisualBasicFileSystemExtensions.vb" />
<Compile Include="VisualBasicParseOptions.vb" />
<EmbeddedResource Include="Symbols\EmbeddedSymbols\Embedded.vb" />
<EmbeddedResource Include="Symbols\EmbeddedSymbols\InternalXmlHelper.vb" />
......
......@@ -356,7 +356,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Try
preferredUILang = New CultureInfo(value)
If (preferredUILang.CultureTypes And CultureTypes.UserCustomCulture) <> 0 Then
If (CorLightup.Desktop.IsUserCustomCulture(preferredUILang)) Then
' Do not use user custom cultures.
preferredUILang = Nothing
End If
......@@ -1265,7 +1265,7 @@ lVbRuntimePlus:
Dim absolutePath = FileUtilities.ResolveRelativePath(If(path, sdkDirectory), baseDirectory)
If absolutePath IsNot Nothing Then
Dim filePath = PathUtilities.CombineAbsoluteAndRelativePaths(absolutePath, fileName)
If File.Exists(filePath) Then
If PortableShim.File.Exists(filePath) Then
Return filePath
End If
End If
......@@ -1449,7 +1449,7 @@ lVbRuntimePlus:
Dim dataProvider As Func(Of Stream) = Function()
' Use FileShare.ReadWrite because the file could be opened by the current process.
' For example, it Is an XML doc file produced by the build.
Return New FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
Return PortableShim.FileStream.Create(fullPath, PortableShim.FileMode.Open, PortableShim.FileAccess.Read, PortableShim.FileShare.ReadWrite)
End Function
Return New ResourceDescription(resourceName, fileName, dataProvider, isPublic, embedded, checkArgs:=False)
End Function
......
......@@ -5911,3 +5911,14 @@ Shared ReadOnly Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.Tab -> Microsof
Shared ReadOnly Microsoft.CodeAnalysis.VisualBasic.SyntaxFacts.EqualityComparer -> System.Collections.Generic.IEqualityComparer(Of Microsoft.CodeAnalysis.VisualBasic.SyntaxKind)
Shared ReadOnly Microsoft.CodeAnalysis.VisualBasic.VisualBasicDiagnosticFormatter.Instance -> Microsoft.CodeAnalysis.VisualBasic.VisualBasicDiagnosticFormatter
Shared ReadOnly Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions.Default -> Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineArguments
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.New(isInteractive As Boolean = False) -> Void
Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.Parse(args As System.Collections.Generic.IEnumerable(Of String), baseDirectory As String, sdkDirectory As String, additionalReferenceDirectories As String = Nothing) -> Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineArguments
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineArguments.CompilationOptionsCore() -> Microsoft.CodeAnalysis.CompilationOptions
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineArguments.ParseOptionsCore() -> Microsoft.CodeAnalysis.ParseOptions
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.RegularFileExtension() -> String
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.ScriptFileExtension() -> String
Shared Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.ParseConditionalCompilationSymbols(symbolList As String, ByRef diagnostics As System.Collections.Generic.IEnumerable(Of Microsoft.CodeAnalysis.Diagnostic), symbols As System.Collections.Generic.IEnumerable(Of System.Collections.Generic.KeyValuePair(Of String, Object)) = Nothing) -> System.Collections.Generic.IReadOnlyDictionary(Of String, Object)
Shared ReadOnly Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.Default -> Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser
Shared ReadOnly Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser.Interactive -> Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser
\ No newline at end of file
......@@ -71,6 +71,9 @@
<Compile Include="..\..\..\Compilers\Core\Portable\FileKey.cs">
<Link>InternalUtilities\FileKey.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\ReflectionUtil.cs">
<Link>InternalUtilities\ReflectionUtil.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\PortableShim.cs">
<Link>InternalUtilities\PortableShim.cs</Link>
</Compile>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册