Exemple #1
0
        void SetContext()
        {
            this.usingScope = rootUsingScope;
            string ns = currentMember?.Namespace ?? context.DecompiledTypeDefinition?.Namespace;

            if (ns != null)
            {
                foreach (var name in ns.Split('.'))
                {
                    usingScope = new UsingScope(usingScope, name);
                }
            }
            resolveContext = new CSharpTypeResolveContext(
                context.DecompiledAssembly,
                usingScope.Resolve(context.TypeSystem.Compilation),
                currentMember?.DeclaringTypeDefinition ?? context.DecompiledTypeDefinition,
                currentMember);
            resolver = new CSharpResolver(resolveContext);
        }
Exemple #2
0
        public override void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
        {
            var previousContext = resolveContextStack.Peek();
            var usingScope      = previousContext.CurrentUsingScope.UnresolvedUsingScope;

            foreach (string ident in namespaceDeclaration.Identifiers)
            {
                usingScope = new UsingScope(usingScope, ident);
            }
            var currentContext = new CSharpTypeResolveContext(previousContext.CurrentModule, usingScope.Resolve(previousContext.Compilation));

            resolveContextStack.Push(currentContext);
            try {
                this.resolver = new CSharpResolver(currentContext);
                base.VisitNamespaceDeclaration(namespaceDeclaration);
            } finally {
                this.resolver = new CSharpResolver(previousContext);
                resolveContextStack.Pop();
            }
        }
 void SetContext()
 {
     this.usingScope = rootUsingScope;
     foreach (var name in currentMember.Namespace.Split('.'))
     {
         usingScope = new UsingScope(usingScope, name);
     }
     resolveContext = new CSharpTypeResolveContext(currentMember.ParentAssembly, usingScope.Resolve(context.TypeSystem.Compilation), currentMember.DeclaringTypeDefinition, currentMember);
     resolver       = new CSharpResolver(resolveContext);
 }
        TypeSystemAstBuilder CreateBuilder(ITypeDefinition currentTypeDef = null)
        {
            UsingScope usingScope = currentTypeDef != null?parsedFile.GetUsingScope(currentTypeDef.Region.Begin) : parsedFile.RootUsingScope;

            return(new TypeSystemAstBuilder(new CSharpResolver(
                                                new CSharpTypeResolveContext(compilation.MainAssembly, usingScope.Resolve(compilation), currentTypeDef))));
        }
            public override void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
            {
                var previousContext = context.Peek();
                var usingScope      = previousContext.CurrentUsingScope.UnresolvedUsingScope;

                foreach (string ident in namespaceDeclaration.Identifiers)
                {
                    usingScope = new UsingScope(usingScope, ident);
                }
                var currentContext = new CSharpTypeResolveContext(previousContext.CurrentAssembly, usingScope.Resolve(previousContext.Compilation));

                context.Push(currentContext);
                try {
                    astBuilder = CreateAstBuilder(currentContext);
                    base.VisitNamespaceDeclaration(namespaceDeclaration);
                } finally {
                    astBuilder = CreateAstBuilder(previousContext);
                    context.Pop();
                }
            }
            public FullyQualifyAmbiguousTypeNamesVisitor(TransformContext context, UsingScope usingScope)
            {
                this.context = new Stack <CSharpTypeResolveContext>();
                var currentContext = new CSharpTypeResolveContext(context.TypeSystem.MainAssembly, usingScope.Resolve(context.TypeSystem.Compilation));

                this.context.Push(currentContext);
                this.astBuilder = CreateAstBuilder(currentContext);
            }