本文整理汇总了C#中TypeInfoProvider类的典型用法代码示例。如果您正苦于以下问题:C# TypeInfoProvider类的具体用法?C# TypeInfoProvider怎么用?C# TypeInfoProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeInfoProvider类属于命名空间,在下文中一共展示了TypeInfoProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComparisonTest
public ComparisonTest(string filename, string[] stubbedAssemblies = null, TypeInfoProvider typeInfo = null)
{
Filename = Path.Combine(TestSourceFolder, filename);
var sourceCode = File.ReadAllText(Filename);
switch (Path.GetExtension(filename).ToLower()) {
case ".cs":
Assembly = CompilerUtil.CompileCS(sourceCode, out TemporaryFiles);
break;
case ".vb":
Assembly = CompilerUtil.CompileVB(sourceCode, out TemporaryFiles);
break;
default:
throw new ArgumentException("Unsupported source file type for test");
}
var program = Assembly.GetType("Program");
if (program == null)
throw new Exception("Test missing 'Program' main class");
TestMethod = program.GetMethod("Main");
if (TestMethod == null)
throw new Exception("Test missing 'Main' method of 'Program' main class");
StubbedAssemblies = stubbedAssemblies;
TypeInfo = typeInfo;
}
示例2: Analyze
public void Analyze(TypeInfoProvider typeInfoProvider) {
if (!Configuration.DeadCodeElimination.GetValueOrDefault(false))
return;
deadCodeInfo.TypeInfoProvider = typeInfoProvider;
stopwatchElapsed = new Stopwatch();
stopwatchElapsed.Start();
var foundEntrypoints = from assembly in assemblyDefinitions
from modules in assembly.Modules
where modules.EntryPoint != null
select modules.EntryPoint;
deadCodeInfo.AddAssemblies(assemblyDefinitions);
foreach (MethodDefinition method in foundEntrypoints)
{
deadCodeInfo.WalkMethod(method);
}
deadCodeInfo.ResolveVirtualMethodsCycle();
stopwatchElapsed.Stop();
Console.WriteLine("// Dead code analysis took {0} ms", stopwatchElapsed.ElapsedMilliseconds);
}
示例3: MakeDefaultProvider
protected TypeInfoProvider MakeDefaultProvider () {
if (DefaultTypeInfoProvider == null)
// Construct a type info provider with default proxies loaded (kind of a hack)
DefaultTypeInfoProvider = (new AssemblyTranslator(MakeConfiguration())).GetTypeInfoProvider();
return DefaultTypeInfoProvider.Clone();
}
示例4: Analyze
public void Analyze (AssemblyTranslator translator, AssemblyDefinition[] assemblies, TypeInfoProvider typeInfoProvider) {
if (!Configuration.DeadCodeElimination)
return;
assemblyDefinitions.Clear();
assemblyDefinitions.AddRange(assemblies);
deadCodeInfo.TypeInfoProvider = typeInfoProvider;
stopwatchElapsed = new Stopwatch();
stopwatchElapsed.Start();
var foundEntrypoints = from assembly in assemblyDefinitions
from modules in assembly.Modules
where modules.EntryPoint != null
select modules.EntryPoint;
deadCodeInfo.AddAssemblies(assemblyDefinitions);
foreach (MethodDefinition method in foundEntrypoints)
{
deadCodeInfo.WalkMethod(method);
}
deadCodeInfo.FinishProcessing();
stopwatchElapsed.Stop();
Console.WriteLine("// Dead code analysis took {0} ms", stopwatchElapsed.ElapsedMilliseconds);
}
示例5: EmulateStructAssignment
public EmulateStructAssignment(TypeSystem typeSystem, IFunctionSource functionSource, TypeInfoProvider typeInfo, CLRSpecialIdentifiers clr, bool optimizeCopies)
{
TypeSystem = typeSystem;
FunctionSource = functionSource;
TypeInfo = typeInfo;
CLR = clr;
OptimizeCopies = optimizeCopies;
}
示例6: EmulateStructAssignment
public EmulateStructAssignment(QualifiedMemberIdentifier member, IFunctionSource functionSource, TypeSystem typeSystem, TypeInfoProvider typeInfo, CLRSpecialIdentifiers clr, bool optimizeCopies)
: base(member, functionSource)
{
TypeSystem = typeSystem;
TypeInfo = typeInfo;
CLR = clr;
OptimizeCopies = optimizeCopies;
}
示例7: DecomposeMutationOperators
public DecomposeMutationOperators (
TypeSystem typeSystem, TypeInfoProvider typeInfo,
IFunctionSource functionSource, bool decomposeAllMutations
) {
TypeSystem = typeSystem;
TypeInfo = typeInfo;
FunctionSource = functionSource;
DecomposeAllMutations = decomposeAllMutations;
}
示例8: MakeTest
protected ComparisonTest MakeTest (
string filename, string[] stubbedAssemblies = null,
TypeInfoProvider typeInfo = null,
AssemblyCache assemblyCache = null
) {
return new ComparisonTest(
EvaluatorPool,
Portability.NormalizeDirectorySeparators(filename), stubbedAssemblies,
typeInfo, assemblyCache
);
}
示例9: Dispose
public void Dispose () {
if (EvaluatorPool != null) {
EvaluatorPool.Dispose();
EvaluatorPool = null;
}
if (DefaultTypeInfoProvider != null) {
DefaultTypeInfoProvider.Dispose();
DefaultTypeInfoProvider = null;
}
}
示例10: IntroduceEnumCasts
public IntroduceEnumCasts(TypeSystem typeSystem, TypeInfoProvider typeInfo)
{
TypeSystem = typeSystem;
TypeInfo = typeInfo;
LogicalOperators = new HashSet<JSOperator>() {
JSOperator.LogicalAnd,
JSOperator.LogicalOr,
JSOperator.LogicalNot
};
}
示例11: ComparisonTest
public ComparisonTest(string filename, Regex[] stubbedAssemblies = null, TypeInfoProvider typeInfo = null)
{
Filename = Path.Combine(TestSourceFolder, filename);
var sourceCode = File.ReadAllText(Filename);
Assembly = CSharpUtil.Compile(sourceCode, out TemporaryFiles);
TestMethod = Assembly.GetType("Program").GetMethod("Main");
StubbedAssemblies = stubbedAssemblies;
TypeInfo = typeInfo;
}
示例12: AssemblyTranslator
public AssemblyTranslator(TypeInfoProvider typeInfoProvider = null)
{
// Important to avoid preserving the proxy list from previous translations in this process
MemberIdentifier.ResetProxies();
if (typeInfoProvider != null) {
TypeInfoProvider = typeInfoProvider;
} else {
TypeInfoProvider = new JSIL.TypeInfoProvider();
AddProxyAssembly(typeof(JSIL.Proxies.ObjectProxy).Assembly, false);
}
}
示例13: ComparisonTest
public ComparisonTest(
EvaluatorPool pool,
IEnumerable<string> filenames, string outputPath,
string[] stubbedAssemblies = null, TypeInfoProvider typeInfo = null,
AssemblyCache assemblyCache = null
)
{
var started = DateTime.UtcNow.Ticks;
OutputPath = outputPath;
EvaluatorPool = pool;
var extensions = (from f in filenames select Path.GetExtension(f).ToLower()).Distinct().ToArray();
var absoluteFilenames = (from f in filenames select Path.Combine(TestSourceFolder, f));
if (extensions.Length != 1)
throw new InvalidOperationException("Mixture of different source languages provided.");
var assemblyNamePrefix = Path.GetDirectoryName(outputPath).Split(new char[] { '\\', '/' }).Last();
var assemblyName = Path.Combine(
assemblyNamePrefix,
Path.GetFileName(outputPath).Replace(".js", "")
);
switch (extensions[0]) {
case ".cs":
Assembly = CompilerUtil.CompileCS(absoluteFilenames, assemblyName);
break;
case ".vb":
Assembly = CompilerUtil.CompileVB(absoluteFilenames, assemblyName);
break;
case ".exe":
case ".dll":
var fns = absoluteFilenames.ToArray();
if (fns.Length > 1)
throw new InvalidOperationException("Multiple binary assemblies provided.");
Assembly = Assembly.LoadFile(fns[0]);
break;
default:
throw new ArgumentException("Unsupported source file type for test");
}
if (typeInfo != null)
typeInfo.ClearCaches();
StubbedAssemblies = stubbedAssemblies;
TypeInfo = typeInfo;
AssemblyCache = assemblyCache;
var ended = DateTime.UtcNow.Ticks;
CompilationElapsed = TimeSpan.FromTicks(ended - started);
}
示例14: IntroduceEnumCasts
public IntroduceEnumCasts (TypeSystem typeSystem, JSSpecialIdentifiers js, TypeInfoProvider typeInfo, MethodTypeFactory methodTypes) {
TypeSystem = typeSystem;
TypeInfo = typeInfo;
MethodTypes = methodTypes;
JS = js;
LogicalOperators = new HashSet<JSOperator>() {
JSOperator.LogicalAnd,
JSOperator.LogicalOr,
JSOperator.LogicalNot
};
BitwiseOperators = new HashSet<JSOperator>() {
JSOperator.BitwiseAnd,
JSOperator.BitwiseOr,
JSOperator.BitwiseXor
};
}
示例15: CreateTranslator
static AssemblyTranslator CreateTranslator(
Configuration configuration, AssemblyManifest manifest, AssemblyCache assemblyCache
)
{
TypeInfoProvider typeInfoProvider = null;
if (
configuration.ReuseTypeInfoAcrossAssemblies.GetValueOrDefault(true) &&
(CachedTypeInfoProvider != null)
) {
if (CachedTypeInfoProviderConfiguration.Assemblies.Equals(configuration.Assemblies))
typeInfoProvider = CachedTypeInfoProvider;
}
var translator = new AssemblyTranslator(configuration, typeInfoProvider, manifest, assemblyCache);
translator.Decompiling += MakeProgressHandler("Decompiling ");
translator.Optimizing += MakeProgressHandler ("Optimizing ");
translator.Writing += MakeProgressHandler ("Generating JS ");
translator.AssemblyLoaded += (fn) => {
Console.Error.WriteLine("// Loaded {0}", ShortenPath(fn));
};
translator.CouldNotLoadSymbols += (fn, ex) => {
};
translator.CouldNotResolveAssembly += (fn, ex) => {
Console.Error.WriteLine("// Could not load module {0}: {1}", fn, ex.Message);
};
translator.CouldNotDecompileMethod += (fn, ex) => {
Console.Error.WriteLine("// Could not decompile method {0}: {1}", fn, ex.Message);
};
if (typeInfoProvider == null) {
if (CachedTypeInfoProvider != null)
CachedTypeInfoProvider.Dispose();
CachedTypeInfoProvider = translator.GetTypeInfoProvider();
CachedTypeInfoProviderConfiguration = configuration;
}
return translator;
}