public CustomAttributeDataWrapper(AttributeData a, MetadataLoadContextInternal metadataLoadContext)
        {
            var namedArguments = new List <CustomAttributeNamedArgument>();

            foreach (KeyValuePair <string, TypedConstant> na in a.NamedArguments)
            {
                var member = a.AttributeClass !.GetMembers(na.Key).First();

                MemberInfo memberInfo = member is IPropertySymbol
                    ? new PropertyInfoWrapper((IPropertySymbol)member, metadataLoadContext)
                    : new FieldInfoWrapper((IFieldSymbol)member, metadataLoadContext);

                namedArguments.Add(new CustomAttributeNamedArgument(memberInfo, na.Value.Value));
            }

            var constructorArguments = new List <CustomAttributeTypedArgument>();

            foreach (TypedConstant ca in a.ConstructorArguments)
            {
                constructorArguments.Add(new CustomAttributeTypedArgument(ca.Type.AsType(metadataLoadContext), ca.Value));
            }
            Constructor          = new ConstructorInfoWrapper(a.AttributeConstructor !, metadataLoadContext);
            NamedArguments       = namedArguments;
            ConstructorArguments = constructorArguments;
        }
Exemplo n.º 2
0
 public TypeWrapper(ITypeSymbol namedTypeSymbol, MetadataLoadContextInternal metadataLoadContext)
 {
     _typeSymbol          = namedTypeSymbol;
     _metadataLoadContext = metadataLoadContext;
     _namedTypeSymbol     = _typeSymbol as INamedTypeSymbol;
     _arrayTypeSymbol     = _typeSymbol as IArrayTypeSymbol;
 }
Exemplo n.º 3
0
        public FieldInfoWrapper(IFieldSymbol parameter, MetadataLoadContextInternal metadataLoadContext)
        {
            _field = parameter;
            _metadataLoadContext = metadataLoadContext;

            NeedsAtSign = SyntaxFacts.GetKeywordKind(_field.Name) != SyntaxKind.None || SyntaxFacts.GetContextualKeywordKind(_field.Name) != SyntaxKind.None;
        }
Exemplo n.º 4
0
        public PropertyInfoWrapper(IPropertySymbol property, MetadataLoadContextInternal metadataLoadContext)
        {
            _property            = property;
            _metadataLoadContext = metadataLoadContext;

            NeedsAtSign = SyntaxFacts.GetKeywordKind(_property.Name) != SyntaxKind.None || SyntaxFacts.GetContextualKeywordKind(_property.Name) != SyntaxKind.None;
        }
Exemplo n.º 5
0
        public CustomAttributeDataWrapper(AttributeData a, MetadataLoadContextInternal metadataLoadContext)
        {
            Debug.Assert(a.AttributeConstructor != null);

            var namedArguments = new List <CustomAttributeNamedArgument>();

            foreach (KeyValuePair <string, TypedConstant> na in a.NamedArguments)
            {
                var member = a.AttributeClass.BaseTypes().SelectMany(t => t.GetMembers(na.Key)).First();

                MemberInfo memberInfo = member is IPropertySymbol
                    ? new PropertyInfoWrapper((IPropertySymbol)member, metadataLoadContext)
                    : new FieldInfoWrapper((IFieldSymbol)member, metadataLoadContext);

                namedArguments.Add(new CustomAttributeNamedArgument(memberInfo, na.Value.Value));
            }

            var constructorArguments = new List <CustomAttributeTypedArgument>();

            foreach (TypedConstant ca in a.ConstructorArguments)
            {
                if (ca.Kind == TypedConstantKind.Error)
                {
                    continue;
                }

                object value = ca.Kind == TypedConstantKind.Array ? ca.Values : ca.Value;
                constructorArguments.Add(new CustomAttributeTypedArgument(ca.Type.AsType(metadataLoadContext), value));
            }

            Constructor          = new ConstructorInfoWrapper(a.AttributeConstructor, metadataLoadContext);
            NamedArguments       = namedArguments;
            ConstructorArguments = constructorArguments;
        }
Exemplo n.º 6
0
        public static Type AsType(this ITypeSymbol typeSymbol, MetadataLoadContextInternal metadataLoadContext)
        {
            if (typeSymbol == null)
            {
                return(null);
            }

            return(new TypeWrapper(typeSymbol, metadataLoadContext));
        }
Exemplo n.º 7
0
 public ConstructorInfoWrapper(IMethodSymbol ctor, MetadataLoadContextInternal metadataLoadContext)
 {
     Debug.Assert(ctor != null);
     _ctor = ctor;
     _metadataLoadContext = metadataLoadContext;
 }
Exemplo n.º 8
0
 public static MethodInfo AsMethodInfo(this IMethodSymbol methodSymbol, MetadataLoadContextInternal metadataLoadContext) => (methodSymbol == null ? null : new MethodInfoWrapper(methodSymbol, metadataLoadContext)) !;
Exemplo n.º 9
0
 public ParameterInfoWrapper(IParameterSymbol parameter, MetadataLoadContextInternal metadataLoadContext)
 {
     _parameter           = parameter;
     _metadataLoadContext = metadataLoadContext;
 }
Exemplo n.º 10
0
 public AssemblyWrapper(IAssemblySymbol assembly, MetadataLoadContextInternal metadataLoadContext)
 {
     Symbol = assembly;
     _metadataLoadContext = metadataLoadContext;
 }
Exemplo n.º 11
0
 public MemberInfoWrapper(ISymbol member, MetadataLoadContextInternal metadataLoadContext)
 {
     _member = member;
     _metadataLoadContext = metadataLoadContext;
 }
Exemplo n.º 12
0
 public PropertyInfoWrapper(IPropertySymbol property, MetadataLoadContextInternal metadataLoadContext)
 {
     _property            = property;
     _metadataLoadContext = metadataLoadContext;
 }
Exemplo n.º 13
0
 public MethodInfoWrapper(IMethodSymbol method, MetadataLoadContextInternal metadataLoadContext)
 {
     _method = method;
     _metadataLoadContext = metadataLoadContext;
 }
Exemplo n.º 14
0
 public FieldInfoWrapper(IFieldSymbol parameter, MetadataLoadContextInternal metadataLoadContext)
 {
     _field = parameter;
     _metadataLoadContext = metadataLoadContext;
 }
Exemplo n.º 15
0
 public ConstructorInfoWrapper(IMethodSymbol ctor, MetadataLoadContextInternal metadataLoadContext)
 {
     _ctor = ctor;
     _metadataLoadContext = metadataLoadContext;
 }