示例#1
0
 public ResolvedUsingScope(VSharpTypeResolveContext context, UsingScope usingScope)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (usingScope == null)
     {
         throw new ArgumentNullException("usingScope");
     }
     this.parentContext = context;
     this.usingScope    = usingScope;
     if (usingScope.Parent != null)
     {
         if (context.CurrentUsingScope == null)
         {
             throw new InvalidOperationException();
         }
     }
     else
     {
         if (context.CurrentUsingScope != null)
         {
             throw new InvalidOperationException();
         }
     }
 }
示例#2
0
        /// <summary>
        /// Resolves the namespace represented by this using scope.
        /// </summary>
        public ResolvedUsingScope ResolveScope(ICompilation compilation)
        {
            CacheManager       cache    = compilation.CacheManager;
            ResolvedUsingScope resolved = cache.GetShared(this) as ResolvedUsingScope;

            if (resolved == null)
            {
                var csContext = new VSharpTypeResolveContext(compilation.MainAssembly, parent != null ? parent.ResolveScope(compilation) : null);
                resolved = (ResolvedUsingScope)cache.GetOrAddShared(this, new ResolvedUsingScope(csContext, this));
            }
            return(resolved);
        }
示例#3
0
        IList <IAttribute> GetAttributes(ref IList <IAttribute> field, bool assemblyAttributes)
        {
            IList <IAttribute> result = LazyInit.VolatileRead(ref field);

            if (result != null)
            {
                return(result);
            }
            else
            {
                result = new List <IAttribute>();
                foreach (var unresolvedFile in projectContent.Files.OfType <CompilationSourceFile>())
                {
                    var attributes = assemblyAttributes ? unresolvedFile.AssemblyAttributes : unresolvedFile.ModuleAttributes;
                    var context    = new VSharpTypeResolveContext(this, unresolvedFile.RootUsingScope.ResolveScope(compilation));
                    foreach (var unresolvedAttr in attributes)
                    {
                        result.Add(unresolvedAttr.CreateResolvedAttribute(context));
                    }
                }
                return(LazyInit.GetOrSet(ref field, result));
            }
        }