本文整理汇总了C#中ICompilation类的典型用法代码示例。如果您正苦于以下问题:C# ICompilation类的具体用法?C# ICompilation怎么用?C# ICompilation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICompilation类属于命名空间,在下文中一共展示了ICompilation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MetadataImporter
public MetadataImporter(IErrorReporter errorReporter, ICompilation compilation, IAttributeStore attributeStore, CompilerOptions options) {
_errorReporter = errorReporter;
_compilation = compilation;
_attributeStore = attributeStore;
_minimizeNames = options.MinimizeScript;
_systemObject = compilation.MainAssembly.Compilation.FindType(KnownTypeCode.Object);
_typeSemantics = new Dictionary<ITypeDefinition, TypeSemantics>();
_delegateSemantics = new Dictionary<ITypeDefinition, DelegateScriptSemantics>();
_instanceMemberNamesByType = new Dictionary<ITypeDefinition, HashSet<string>>();
_staticMemberNamesByType = new Dictionary<ITypeDefinition, HashSet<string>>();
_methodSemantics = new Dictionary<IMethod, MethodScriptSemantics>();
_propertySemantics = new Dictionary<IProperty, PropertyScriptSemantics>();
_fieldSemantics = new Dictionary<IField, FieldScriptSemantics>();
_eventSemantics = new Dictionary<IEvent, EventScriptSemantics>();
_constructorSemantics = new Dictionary<IMethod, ConstructorScriptSemantics>();
_propertyBackingFieldNames = new Dictionary<IProperty, Tuple<string, bool>>();
_eventBackingFieldNames = new Dictionary<IEvent, Tuple<string, bool>>();
_backingFieldCountPerType = new Dictionary<ITypeDefinition, int>();
_internalTypeCountPerAssemblyAndNamespace = new Dictionary<Tuple<IAssembly, string>, int>();
_ignoredMembers = new HashSet<IMember>();
var sna = _attributeStore.AttributesFor(compilation.MainAssembly).GetAttribute<ScriptNamespaceAttribute>();
if (sna != null) {
if (sna.Name == null || (sna.Name != "" && !sna.Name.IsValidNestedJavaScriptIdentifier())) {
Message(Messages._7002, default(DomRegion), "assembly");
}
}
}
示例2: MetadataImporter
public MetadataImporter(IErrorReporter errorReporter, ICompilation compilation, CompilerOptions options) {
_errorReporter = errorReporter;
_compilation = compilation;
_minimizeNames = options.MinimizeScript;
_systemObject = compilation.MainAssembly.Compilation.FindType(KnownTypeCode.Object);
_typeSemantics = new Dictionary<ITypeDefinition, TypeSemantics>();
_delegateSemantics = new Dictionary<ITypeDefinition, DelegateScriptSemantics>();
_instanceMemberNamesByType = new Dictionary<ITypeDefinition, HashSet<string>>();
_staticMemberNamesByType = new Dictionary<ITypeDefinition, HashSet<string>>();
_methodSemantics = new Dictionary<IMethod, MethodScriptSemantics>();
_propertySemantics = new Dictionary<IProperty, PropertyScriptSemantics>();
_fieldSemantics = new Dictionary<IField, FieldScriptSemantics>();
_eventSemantics = new Dictionary<IEvent, EventScriptSemantics>();
_constructorSemantics = new Dictionary<IMethod, ConstructorScriptSemantics>();
_propertyBackingFieldNames = new Dictionary<IProperty, string>();
_eventBackingFieldNames = new Dictionary<IEvent, string>();
_backingFieldCountPerType = new Dictionary<ITypeDefinition, int>();
_internalTypeCountPerAssemblyAndNamespace = new Dictionary<Tuple<IAssembly, string>, int>();
_ignoredMembers = new HashSet<IMember>();
var sna = compilation.MainAssembly.AssemblyAttributes.SingleOrDefault(a => a.AttributeType.FullName == typeof(ScriptNamespaceAttribute).FullName);
if (sna != null) {
var data = AttributeReader.ReadAttribute<ScriptNamespaceAttribute>(sna);
if (data.Name == null || (data.Name != "" && !data.Name.IsValidNestedJavaScriptIdentifier())) {
Message(Messages._7002, sna.Region, "assembly");
}
}
}
示例3: GetGenericMethodConstraints
public static string GetGenericMethodConstraints(this IMethod method, ICompilation compilation)
{
var sb = new StringBuilder();
foreach (var typeParam in method.Parts.SelectMany(p =>
p.TypeParameters.OfType<DefaultUnresolvedTypeParameter>()))
{
var resolvedParts = new List<string>();
if (typeParam.HasDefaultConstructorConstraint)
resolvedParts.Add("new()");
if (typeParam.HasReferenceTypeConstraint)
resolvedParts.Add("class");
if (typeParam.HasValueTypeConstraint)
resolvedParts.Add("struct");
resolvedParts.AddRange(
typeParam.Constraints.Resolve(compilation.TypeResolveContext)
.Select(x => x.GetOriginalFullName()));
if (resolvedParts.Any())
sb.Append("where ").Append(typeParam.Name).Append(" : ").Append(string.Join(",", resolvedParts));
}
return sb.ToString();
}
示例4: IsDefinedInSource
/// <summary>
/// Determines if the given type is defined in source code, ie is part of the project
/// </summary>
public static bool IsDefinedInSource (this ITypeDefinition type, ICompilation compilation)
{
if (compilation == null)
return false;
return type.ParentAssembly.UnresolvedAssembly.Location == compilation.MainAssembly.UnresolvedAssembly.Location;
}
示例5: Resolve
public ResolveResult Resolve(ParseInformation parseInfo, TextLocation location, ICompilation compilation, CancellationToken cancellationToken)
{
var decompiledParseInfo = parseInfo as ILSpyFullParseInformation;
if (decompiledParseInfo == null)
throw new ArgumentException("ParseInfo does not have SyntaxTree");
return ResolveAtLocation.Resolve(compilation, null, decompiledParseInfo.SyntaxTree, location, cancellationToken);
}
示例6: TypeInference
public TypeInference(ICompilation compilation)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
this.compilation = compilation;
this.conversions = CSharpConversions.Get(compilation);
}
示例7: ResolveNamespaces
IEnumerable<INamespace> ResolveNamespaces(ICompilation compilation)
{
IType xmlnsDefinition = compilation.FindType(typeof(System.Windows.Markup.XmlnsDefinitionAttribute));
if (XmlNamespace.StartsWith("clr-namespace:", StringComparison.Ordinal)) {
string name = XmlNamespace.Substring("clr-namespace:".Length);
IAssembly asm = compilation.MainAssembly;
int asmIndex = name.IndexOf(";assembly=", StringComparison.Ordinal);
if (asmIndex >= 0) {
string asmName = name.Substring(asmIndex + ";assembly=".Length);
asm = compilation.ReferencedAssemblies.FirstOrDefault(a => a.AssemblyName == asmName) ?? compilation.MainAssembly;
name = name.Substring(0, asmIndex);
}
string[] parts = name.Split('.');
var @namespace = FindNamespace(asm, parts);
if (@namespace != null) yield return @namespace;
} else {
foreach (IAssembly asm in compilation.Assemblies) {
foreach (IAttribute attr in asm.AssemblyAttributes) {
if (xmlnsDefinition.Equals(attr.AttributeType) && attr.PositionalArguments.Count == 2) {
string xmlns = attr.PositionalArguments[0].ConstantValue as string;
if (xmlns != XmlNamespace) continue;
string ns = attr.PositionalArguments[1].ConstantValue as string;
if (ns == null) continue;
var @namespace = FindNamespace(asm, ns.Split('.'));
if (@namespace != null) yield return @namespace;
}
}
}
}
}
示例8: TypeInference
internal TypeInference(ICompilation compilation, CSharpConversions conversions)
{
Debug.Assert(compilation != null);
Debug.Assert(conversions != null);
this.compilation = compilation;
this.conversions = conversions;
}
示例9: AddUsings
public static void AddUsings(CodeElementsList<CodeElement> codeElements, UsingScope usingScope, ICompilation compilation)
{
var resolvedUsingScope = usingScope.Resolve(compilation);
foreach (var ns in resolvedUsingScope.Usings) {
codeElements.Add(new CodeImport(ns.FullName));
}
}
示例10: RuntimeLibrary
public RuntimeLibrary(IMetadataImporter metadataImporter, IErrorReporter errorReporter, ICompilation compilation, INamer namer) {
_metadataImporter = metadataImporter;
_errorReporter = errorReporter;
_compilation = compilation;
_namer = namer;
_omitDowncasts = MetadataUtils.OmitDowncasts(compilation);
_omitNullableChecks = MetadataUtils.OmitNullableChecks(compilation);
}
示例11: CreateEmulator
protected OOPEmulator CreateEmulator(ICompilation compilation, IErrorReporter errorReporter = null) {
var n = new Namer();
errorReporter = errorReporter ?? new MockErrorReporter();
var md = new MetadataImporter(errorReporter, compilation, new CompilerOptions());
md.Prepare(compilation.GetAllTypeDefinitions());
var rtl = new RuntimeLibrary(md, errorReporter, compilation, n);
return new OOPEmulator(compilation, md, rtl, n, new MockLinker(), errorReporter);
}
示例12: ExpressoResolver
public ExpressoResolver(ICompilation compilation)
{
if(compilation == null)
throw new ArgumentNullException("compilation");
this.compilation = compilation;
context = new ExpressoTypeResolveContext(compilation.MainAssembly);
}
示例13: Init
void Init(string program)
{
var pc = new CSharpProjectContent().AddAssemblyReferences(new[] { CecilLoaderTests.Mscorlib });
var cu = new CSharpParser().Parse(new StringReader(program), "program.cs");
compilation = pc.UpdateProjectContent(null, cu.ToTypeSystem()).CreateCompilation();
typeDefinition = compilation.MainAssembly.TopLevelTypeDefinitions.FirstOrDefault();
}
示例14: IndexerParameterDataProvider
public IndexerParameterDataProvider (int startOffset, CSharpCompletionTextEditorExtension ext, IType type, IEnumerable<IProperty> indexers, AstNode resolvedExpression) : base (ext, startOffset)
{
compilation = ext.UnresolvedFileCompilation;
file = ext.CSharpUnresolvedFile;
// this.resolvedExpression = resolvedExpression;
this.indexers = new List<IProperty> (indexers);
}
示例15: DelegateDataProvider
public DelegateDataProvider (int startOffset, CSharpCompletionTextEditorExtension ext, IType delegateType) : base (ext, startOffset)
{
compilation = ext.UnresolvedFileCompilation;
file = ext.CSharpUnresolvedFile;
// this.delegateType = delegateType;
this.delegateMethod = delegateType.GetDelegateInvokeMethod ();
}