コード例 #1
0
 public MetadataNamedArgument(ISymbol entity, Cci.ITypeReference type, Cci.IMetadataExpression value)
 {
     // entity must be one of INamedEntity or IFieldDefinition or IPropertyDefinition
     this.entity = entity;
     this.type = type;
     this.value = value;
 }
コード例 #2
0
ファイル: MetadataNamedArgument.cs プロジェクト: zuvys/roslyn
 public MetadataNamedArgument(ISymbolInternal entity, Cci.ITypeReference type, Cci.IMetadataExpression value)
 {
     // entity must be one of INamedEntity or IFieldDefinition or IPropertyDefinition
     _entity = entity;
     _type   = type;
     _value  = value;
 }
コード例 #3
0
        public static IType ExtractType(Cci.ITypeReference typeref)
        {
            IType result = null;

            if (typeref is Cci.IArrayTypeReference)
            {
                var atyperef = typeref as Cci.IArrayTypeReference;
                result = TypesExtractor.ExtractType(atyperef);
            }
            else if (typeref is Cci.IPointerTypeReference)
            {
                var ptyperef = typeref as Cci.IPointerTypeReference;
                result = TypesExtractor.ExtractType(ptyperef);
            }
            else if (typeref is Cci.IGenericParameterReference)
            {
                var gptyperef = typeref as Cci.IGenericParameterReference;
                result = TypesExtractor.ExtractType(gptyperef);
            }
            else if (typeref is Cci.IGenericTypeInstanceReference)
            {
                var gtyperef = typeref as Cci.IGenericTypeInstanceReference;
                result = TypesExtractor.ExtractType(gtyperef);
            }
            else if (typeref is Cci.INamedTypeReference)
            {
                var ntyperef = typeref as Cci.INamedTypeReference;
                result = TypesExtractor.ExtractType(ntyperef);
            }

            return(result);
        }
コード例 #4
0
 public MetadataCreateArray(
     Cci.IArrayTypeReference arrayType,
     Cci.ITypeReference elementType,
     ImmutableArray <Cci.IMetadataExpression> initializers
     )
 {
     ArrayType   = arrayType;
     ElementType = elementType;
     Elements    = initializers;
 }
コード例 #5
0
 private string ParseTypeName(cci.ITypeReference type)
 {
     cci.INamedTypeReference namedType = type as cci.INamedTypeReference;
     if (namedType != null)
     {
         return(namedType.Name.Value);
     }
     else
     {
         return("[?]");
     }
 }
コード例 #6
0
        /// <summary>
        /// Zero or more named arguments that specify values for fields and properties of the attribute.
        /// </summary>
        public ImmutableArray <Cci.IMetadataNamedArgument> GetNamedArguments(Microsoft.CodeAnalysis.Emit.Context context)
        {
            // Perform fixup
            Cci.ITypeReference stringType = context.Module.GetPlatformType(Cci.PlatformType.SystemString, context);

#if DEBUG
            // Must have exactly 1 named argument.
            var namedArgs = this.sourceAttribute.GetNamedArguments(context);
            Debug.Assert(namedArgs.Count() == 1);

            // Named argument must be 'File' property of string type
            var fileArg = namedArgs.First();
            Debug.Assert(fileArg.ArgumentName == FilePropertyName);
            Debug.Assert(context.Module.IsPlatformType(fileArg.Type, Cci.PlatformType.SystemString));

            // Named argument value must be a non-empty string
            Debug.Assert(fileArg.ArgumentValue is Cci.IMetadataConstant);
            var fileName = (string)((Cci.IMetadataConstant)fileArg.ArgumentValue).Value;
            Debug.Assert(!String.IsNullOrEmpty(fileName));

            // PermissionSetAttribute type must have a writable public string type property member 'Hex'
            Debug.Assert(((INamedTypeSymbol)this.sourceAttribute.GetType(context)).GetMembers(HexPropertyName).Any(
                             member => member.Kind == SymbolKind.Property && ((IPropertySymbol)member).Type.SpecialType == SpecialType.System_String));
#endif

            string hexFileContent;

            // Read the file contents at the resolved file path into a byte array.
            // May throw PermissionSetFileReadException, which is handled in Compilation.Emit.
            var resolver = context.ModuleBuilder.CommonCompilation.Options.XmlReferenceResolver;

            // If the resolver isn't available we won't get here since we had to use it to resolve the path.
            Debug.Assert(resolver != null);

            try
            {
                using (Stream stream = resolver.OpenReadChecked(resolvedPermissionSetFilePath))
                {
                    // Convert the byte array contents into a string in hexa-decimal format.
                    hexFileContent = ConvertToHex(stream);
                }
            }
            catch (IOException e)
            {
                throw new PermissionSetFileReadException(e.Message, resolvedPermissionSetFilePath);
            }

            // Synthesize a named attribute argument "Hex = hexFileContent".
            return(ImmutableArray.Create <Cci.IMetadataNamedArgument>(new HexPropertyMetadataNamedArgument(stringType, new MetadataConstant(stringType, hexFileContent))));
        }
コード例 #7
0
            internal ScopeInfo OpenScope(ScopeType scopeType, Cci.ITypeReference exceptionType)
            {
                ScopeInfo scope = CurrentScope.OpenScope(scopeType, exceptionType, _enclosingExceptionHandler);

                _scopes.Push(scope);

                if (scope.IsExceptionHandler)
                {
                    _enclosingExceptionHandler = (ExceptionHandlerScope)scope;
                }

                Debug.Assert(_enclosingExceptionHandler == GetEnclosingExceptionHandler());
                return(scope);
            }
コード例 #8
0
            public override ScopeInfo OpenScope(
                ScopeType scopeType,
                Cci.ITypeReference exceptionType,
                ExceptionHandlerScope currentExceptionHandler)
            {
                ScopeInfo scope = base.OpenScope(scopeType, exceptionType, currentExceptionHandler);

                if (_nestedScopes == null)
                {
                    _nestedScopes = ImmutableArray.CreateBuilder <ScopeInfo>(1);
                }
                _nestedScopes.Add(scope);
                return(scope);
            }
コード例 #9
0
            private void ExtractClass(Cci.INamedTypeDefinition typedef)
            {
                var name = typedef.Name.Value;
                var type = new ClassDefinition(name);

                Cci.ITypeReference basedef = Cci.TypeHelper.BaseClass(typedef);

                if (basedef == null)
                {
                    basedef = host.PlatformType.SystemObject;
                }

                type.Base = TypesExtractor.ExtractType(basedef) as BasicType;

                this.ExtractGenericParameters(type.GenericParameters, typedef.GenericParameters);
                this.ExtractInterfaces(type.Interfaces, typedef.Interfaces);
                this.ExtractFields(type.Fields, typedef.Fields);
                this.ExtractMethods(type.Methods, typedef.Methods);

                types.Add(name, type);
            }
コード例 #10
0
ファイル: MetadataTypeOf.cs プロジェクト: Rickinio/roslyn
 public MetadataTypeOf(Cci.ITypeReference typeToGet, Cci.ITypeReference systemType)
 {
     _typeToGet = typeToGet;
     _systemType = systemType;
 }
コード例 #11
0
 public HexPropertyMetadataNamedArgument(Cci.ITypeReference type, Cci.IMetadataExpression value)
 {
     this.type  = type;
     this.value = value;
 }
コード例 #12
0
 public HexPropertyMetadataNamedArgument(Cci.ITypeReference type, Cci.IMetadataExpression value)
 {
     this.type = type;
     this.value = value;
 }
コード例 #13
0
ファイル: MetadataTypeOf.cs プロジェクト: lachbaer/roslyn1612
 public MetadataTypeOf(Cci.ITypeReference typeToGet, Cci.ITypeReference systemType)
 {
     _typeToGet  = typeToGet;
     _systemType = systemType;
 }
コード例 #14
0
 public MetadataTypeOf(Cci.ITypeReference typeToGet, Cci.ITypeReference systemType)
 {
     this.typeToGet = typeToGet;
     this.systemType = systemType;
 }
コード例 #15
0
        private static string GetTypeName(Cci.ITypeReference typeref)
        {
            var name = Cci.TypeHelper.GetTypeName(typeref, Cci.NameFormattingOptions.OmitContainingType | Cci.NameFormattingOptions.PreserveSpecialNames);

            return(name);
        }
コード例 #16
0
 public MetadataCreateArray(Cci.IArrayTypeReference arrayType, Cci.ITypeReference elementType, ImmutableArray<Cci.IMetadataExpression> initializers)
 {
     _arrayType = arrayType;
     _elementType = elementType;
     _initializers = initializers;
 }
コード例 #17
0
 public MetadataTypeOf(Cci.ITypeReference typeToGet, Cci.ITypeReference systemType)
 {
     this.typeToGet  = typeToGet;
     this.systemType = systemType;
 }