public Resolve ( ICompilation compilation ) : ICSharpCode.NRefactory.CSharp.TypeSystem.ResolvedUsingScope | ||
compilation | ICompilation | |
return | ICSharpCode.NRefactory.CSharp.TypeSystem.ResolvedUsingScope |
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)); } }
/// <summary> /// Resolves the namespace represented by this using scope. /// </summary> public ResolvedUsingScope Resolve(ICompilation compilation) { CacheManager cache = compilation.CacheManager; ResolvedUsingScope resolved = (ResolvedUsingScope)cache.GetShared(this); if (resolved == null) { var csContext = new CSharpTypeResolveContext(compilation.MainAssembly, parent != null ? parent.Resolve(compilation) : null); resolved = (ResolvedUsingScope)cache.GetOrAddShared(this, new ResolvedUsingScope(csContext, this)); } return(resolved); }
public void AliasToImportedType2() { UsingScope mainUsingScope = new UsingScope(); mainUsingScope.Usings.Add(MakeReference("System")); UsingScope nestedUsingScope = new UsingScope(mainUsingScope, "SomeNamespace"); nestedUsingScope.UsingAliases.Add(new KeyValuePair<string, TypeOrNamespaceReference>("x", MakeReference("String"))); var resolverWithUsing = resolver.WithCurrentUsingScope(nestedUsingScope.Resolve(compilation)); TypeResolveResult trr = (TypeResolveResult)resolverWithUsing.ResolveSimpleName("x", new IType[0]); Assert.AreEqual("System.String", trr.Type.FullName); }
public override ITypeResolveContext CreateResolveContext(ITypeResolveContext parentContext) { return(new CSharpTypeResolveContext(parentContext.CurrentAssembly, usingScope.Resolve(parentContext.Compilation), parentContext.CurrentTypeDefinition)); }