Exemple #1
0
        public IList <IAttribute> Resolve(IAssembly currentAssembly)
        {
            // TODO: make this a per-assembly cache
            //				CacheManager cache = currentAssembly.Compilation.CacheManager;
            //				IList<IAttribute> result = (IList<IAttribute>)cache.GetShared(this);
            //				if (result != null)
            //					return result;

            ITypeResolveContext context = new SimpleTypeResolveContext(currentAssembly);
            BlobReader          reader  = new BlobReader(blob, currentAssembly);

            if (reader.ReadByte() != '.')
            {
                // should not use UnresolvedSecurityDeclaration for XML secdecls
                throw new InvalidOperationException();
            }
            ResolveResult securityActionRR = securityAction.Resolve(context);
            uint          attributeCount   = reader.ReadCompressedUInt32();

            IAttribute[] attributes = new IAttribute[attributeCount];
            try
            {
                ReadSecurityBlob(reader, attributes, context, securityActionRR);
            }
            catch (NotSupportedException ex)
            {
                // ignore invalid blobs
                Debug.WriteLine(ex.ToString());
            }
            for (int i = 0; i < attributes.Length; i++)
            {
                if (attributes[i] == null)
                {
                    attributes[i] = new CecilResolvedAttribute(context, SpecialType.UnknownType);
                }
            }
            return(attributes);
            //				return (IList<IAttribute>)cache.GetOrAddShared(this, attributes);
        }
Exemple #2
0
            public IList<IAttribute> Resolve(IAssembly currentAssembly)
            {
                // TODO: make this a per-assembly cache
                //				CacheManager cache = currentAssembly.Compilation.CacheManager;
                //				IList<IAttribute> result = (IList<IAttribute>)cache.GetShared(this);
                //				if (result != null)
                //					return result;

                var context = new SimpleTypeResolveContext(currentAssembly);
                var reader = new BlobReader(blob, currentAssembly);
                if (reader.ReadByte() != '.') {
                    // should not use UnresolvedSecurityDeclaration for XML secdecls
                    throw new InvalidOperationException();
                }
                var securityActionRR = securityAction.Resolve(context);
                uint attributeCount = reader.ReadCompressedUInt32();
                var attributes = new IAttribute[attributeCount];
                try {
                    ReadSecurityBlob(reader, attributes, context, securityActionRR);
                } catch (NotSupportedException ex) {
                    // ignore invalid blobs
                    Debug.WriteLine(ex.ToString());
                }
                for (int i = 0; i < attributes.Length; i++) {
                    if (attributes[i] == null)
                        attributes[i] = new CecilResolvedAttribute(context, SpecialType.UnknownType);
                }
                return attributes;
                //				return (IList<IAttribute>)cache.GetOrAddShared(this, attributes);
            }