/// <inheritdoc/>
		public TypeDef Resolve(TypeRef typeRef) {
			if (typeRef == null)
				return null;

			var nonNestedTypeRef = TypeRef.GetNonNestedTypeRef(typeRef);
			if (nonNestedTypeRef == null)
				return null;

			var asmRef = nonNestedTypeRef.ResolutionScope as AssemblyRef;
			if (asmRef != null) {
				var asm = assemblyResolver.Resolve(asmRef, nonNestedTypeRef.Module);
				return asm == null ? null : asm.Find(typeRef);
			}

			var moduleDef = nonNestedTypeRef.ResolutionScope as ModuleDef;
			if (moduleDef != null)
				return moduleDef.Find(typeRef);

			var moduleRef = nonNestedTypeRef.ResolutionScope as ModuleRef;
			if (moduleRef != null) {
				if (nonNestedTypeRef.Module == null)
					return null;
				if (new SigComparer().Equals(moduleRef, nonNestedTypeRef.Module))
					return nonNestedTypeRef.Module.Find(typeRef);
				if (nonNestedTypeRef.Module.Assembly == null)
					return null;
				var resolvedModule = nonNestedTypeRef.Module.Assembly.FindModule(moduleRef.Name);
				return resolvedModule == null ? null : resolvedModule.Find(typeRef);
			}

			return null;
		}
 internal EmittedParameter(int index, string name, TypeRef type)
 {
     this.Index = index;
     this.Name = name;
     this.ParameterType = type;
     this.Attributes = ParameterAttributes.None;
 }
Example #3
0
        /*
        public static Uri ResolvingUri(TypeRef typeref)
        {
            if (typeref.ProfileUri == null)
            {
                return BaseProfileUriFor(typeref.Code);
            }
            else
            {
                return new Uri(typeref.ProfileUri);
            }
        }
        */

        public static Uri Identify(Structure structure, TypeRef typeref)
        {
            string name = typeref.Code;
            Uri uri;

            if ((name == "ResourceReference"))
            {
                uri = BaseProfileUriFor(name);
            }
            else if (typeref.ProfileUri != null)
            {
                
                if (typeref.ProfileUri.StartsWith("#"))
                {
                    uri = new Uri(structure.ProfileUri + typeref.ProfileUri);
                }
                else if (typeref.ProfileUri != null)
                {
                    uri = new Uri(typeref.ProfileUri);
                }
                else 
                {
                    uri = BaseProfileUriFor(name);
                }
            }
            else // typeref.profileuri == null
            {
                uri = BaseProfileUriFor(name);
            }

            return uri;
        }
        public void ValidateTypeRef(Element element, TypeRef typeref)
        {

            // Test if the Surrect was able to link to the target structure.
            if (typeref.Structure != null)
            {
                Log(Group.Reference, Status.Valid, "Type reference to structure [{0}] is valid", typeref.Code);
                
                // Genest structuren valideren hoeft niet. Want alle structures worden al op hoofdniveau gevalideerd
                //ValidateStructure(typeref.Structure);

            }

            // Test if there is a reference at all
            else if (typeref.Code == null)
            {
                Log(Group.Reference, Status.Failed, "Missing a reference to a structure in element [{0}]", element.Name);
            }

            // Test if code is itself valid? If so, the reference valid but the target is missing.
            else if (Regex.IsMatch(typeref.Code, "[A-Za-z][A-Za-z0-9]*"))
            {
                // Collect first to avoid duplicates
                missingStructureNames.Add(typeref.Code);
            }

            // The code contains invalid characters
            else
            {
                Log(Group.Reference, Status.Failed, "Invalid structure reference '{0}' in {1}", typeref.Code, element.Path);
            }
        }
Example #5
0
		/// <summary>
		/// Internal constructor.
		/// </summary>
		internal ExtensionPointInfo(TypeRef extensionPointClass, TypeRef extensionInterface, string name, string description)
		{
			_extensionPointClass = extensionPointClass;
			_extensionInterface = extensionInterface;
			_name = name;
			_description = description;
		}
        public EmittedProperty(EmittedClass type, string name, TypeRef propertyType, bool isStatic)
            : base(type, name)
        {
            Contracts.Require.IsNotNull("propertyType", propertyType);

            this.PropertyType = propertyType;
            this._isStatic = isStatic;
        }
Example #7
0
		public ExtensionInfo(TypeRef extensionClass, TypeRef pointExtended, string name, string description, bool enabled, string featureToken)
		{
			_extensionClass = extensionClass;
			_pointExtended = pointExtended;
			_name = name;
			_description = description;
			_enabled = enabled;
			_featureToken = featureToken;
		}
        public EmittedField(EmittedClass type, string name, TypeRef fieldType)
            : base(type, name)
        {
            Contracts.Require.IsNotNull("type", type);
            Contracts.Require.IsNotNull("name", name);

            this.FieldType = fieldType;
            this.Attributes = FieldAttributes.Private;
        }
 public static void AddExtensionElement(Structure structure, Element parent = null)
 {
     parent = parent  ?? structure.Root;
     string path = string.Format("{0}.extension", parent.Path); 
     Element element = new Element();
     element.Path = new Path(path);
     element.Name = "extension";
     element.Cardinality = new Cardinality { Min = "0", Max = "*" };
     TypeRef typeref = new TypeRef("Extension");
     UriHelper.SetTypeRefIdentification(structure, typeref);
     element.TypeRefs.Add(typeref);
     structure.Elements.Add(element);
 }
Example #10
0
            protected TranslationContext(TranslationContext parent, int start)
            {
                Parent = parent;
                Start = start;

                ResultType = parent.ResultType;
                Instructions = parent.Instructions;
                OffsetToIndex = parent.OffsetToIndex;
                TryOffsets = parent.TryOffsets;
                IndexToHandler = parent.IndexToHandler;
                IndexToFilter = parent.IndexToFilter;
                Handlers = parent.Handlers;
            }
Example #11
0
        // ----------------------------------------------------------------------
        // Type references
        // ----------------------------------------------------------------------

        private PE.Row TypeDefOrRefRowFromTypeRef(DllSaveContext ctxt, TypeRef typeRef)
        {
            var row = default(PE.Row);
            if (!ctxt.TypeRefToRowCache.TryGetValue(typeRef, out row))
            {
                if (typeRef.Arguments.Count == 0)
                    row = TypeDefOrRefRowFromQualifiedTypeName(ctxt, typeRef.QualifiedTypeName);
                else
                    row = new PE.TypeSpecRow { Signature = { Value = TypeSigFromTypeRef(ctxt, typeRef) } };
                ctxt.TypeRefToRowCache.Add(typeRef, row);
            }
            return row;
        }
Example #12
0
            public TranslationContext(TypeRef resultType, PE.Instruction[] instructions, IImSeq<PE.ExceptionHandlingClause> handlers)
            {
                Parent = null;
                Start = 0;

                ResultType = resultType;
                Instructions = instructions;
                Handlers = handlers;

                var offsetToIndex = new Map<int, int>();
                for (var i = 0; i < instructions.Length; i++)
                {
                    if (offsetToIndex.ContainsKey(instructions[i].Offset))
                        throw new InvalidOperationException("instructions share same offset");
                    offsetToIndex.Add(instructions[i].Offset, i);
                }
                OffsetToIndex = offsetToIndex;

                var tryOffsets = new Set<int>();
                var indexToHandler = new Map<int, PE.ExceptionHandlingClause>();
                var indexToFilter = new Map<int, PE.ExceptionHandlingClause>();
                foreach (var ehc in handlers)
                {
                    if (!tryOffsets.Contains(ehc.TryOffset))
                        tryOffsets.Add(ehc.TryOffset);
                    var i = OffsetToIndex[ehc.HandlerOffset];
                    indexToHandler.Add(i, ehc);
                    if (ehc.Flags == PE.CorILExceptionClause.Filter)
                    {
                        var j = OffsetToIndex[ehc.FilterOffset];
                        indexToHandler.Add(j, ehc);
                    }
                }
                TryOffsets = tryOffsets;
                IndexToHandler = indexToHandler;
                IndexToFilter = indexToFilter;
            }
Example #13
0
        public void Unify(RootEnvironment rootEnv, StackEntryState other, BoolRef changed)
        {
            var type = Type.Lub(rootEnv, other.Type, changed);

            var upperBound = default(TypeRef);
            if (UpperBound != null && other.UpperBound != null)
                upperBound = UpperBound.Glb(rootEnv, other.UpperBound, changed);
            else if (other.UpperBound != null)
            {
                upperBound = other.UpperBound;
                changed.Set();
            }
            else
                upperBound = UpperBound;

            if (upperBound != null && !type.IsAssignableTo(rootEnv, upperBound))
                throw new InvalidOperationException("stack entries are not unifiable");

            var pointsTo = PointsTo.Lub(other.PointsTo, changed);

            UpperBound = upperBound;
            Type = type;
            PointsTo = pointsTo;
        }
Example #14
0
 public unsafe static ValueRef ConstRealOfString(TypeRef RealTy, string Text) {
   ValueRef ret = new ValueRef(LLVMPINVOKE.ConstRealOfString(RealTy.Value, Text));
   return ret;
 }
Example #15
0
 public unsafe static ValueRef ConstIntOfStringAndSize(TypeRef IntTy, string Text, uint SLen, byte Radix) {
   ValueRef ret = new ValueRef(LLVMPINVOKE.ConstIntOfStringAndSize(IntTy.Value, Text, SLen, Radix));
   return ret;
 }
        internal InputValueEvaluator GetInputValueEvaluator(InputValueDef inputDef, ValueSource valueSource, TypeRef valueTypeRef)
        {
            if (valueSource.IsConstNull())
            {
                return(CreateConstantInputValue(inputDef, valueSource, valueTypeRef, null));
            }
            var eval = GetInputValueEvaluatorImpl(inputDef, valueSource, valueTypeRef);

            // replace with constant if it does not depend on vars
            if (eval.IsConst())
            {
                var value = eval.GetValue(_requestContext);
                eval = CreateConstantInputValue(inputDef, valueSource, valueTypeRef, value);
            }
            return(eval);
        }
 public InputObjectEvaluator(InputValueDef inputDef, TypeRef resultTypeRef, RequestObjectBase anchor,
                             IList <InputFieldEvalInfo> fields)  : base(inputDef, resultTypeRef, anchor)
 {
     Fields = fields;
 }
Example #18
0
 /// <summary>
 /// Checks whether a <see cref="TypeDef"/> exists. <paramref name="typeRef"/>'s scope (i.e.,
 /// module or assembly) is ignored when looking up the type.
 /// </summary>
 /// <param name="self">this</param>
 /// <param name="typeRef">The type ref</param>
 /// <returns><c>true</c> if the <see cref="TypeDef"/> exists, <c>false</c> otherwise</returns>
 public static bool TypeExists(this ITypeDefFinder self, TypeRef typeRef) => !(self.Find(typeRef) is null);
Example #19
0
        static void Inspection(ConfuserContext context)
        {
            context.Logger.Info("Resolving dependencies...");
            foreach (var dependency in context.Modules
                     .SelectMany(module => module.GetAssemblyRefs().Select(asmRef => Tuple.Create(asmRef, module))))
            {
                try {
                    AssemblyDef assembly = context.Resolver.ResolveThrow(dependency.Item1, dependency.Item2);
                }
                catch (AssemblyResolveException ex) {
                    context.Logger.ErrorException("Failed to resolve dependency of '" + dependency.Item2.Name + "'.", ex);
                    throw new ConfuserException(ex);
                }
            }

            context.Logger.Debug("Checking Strong Name...");
            foreach (ModuleDefMD module in context.Modules)
            {
                var snKey = context.Annotations.Get <StrongNameKey>(module, Marker.SNKey);
                if (snKey == null && module.IsStrongNameSigned)
                {
                    context.Logger.WarnFormat("[{0}] SN Key is not provided for a signed module, the output may not be working.", module.Name);
                }
                else if (snKey != null && !module.IsStrongNameSigned)
                {
                    context.Logger.WarnFormat("[{0}] SN Key is provided for an unsigned module, the output may not be working.", module.Name);
                }
                else if (snKey != null && module.IsStrongNameSigned &&
                         !module.Assembly.PublicKey.Data.SequenceEqual(snKey.PublicKey))
                {
                    context.Logger.WarnFormat("[{0}] Provided SN Key and signed module's public key do not match, the output may not be working.", module.Name);
                }
            }

            var marker = context.Registry.GetService <IMarkerService>();

            context.Logger.Debug("Creating global .cctors...");
            foreach (ModuleDefMD module in context.Modules)
            {
                TypeDef modType = module.GlobalType;
                if (modType == null)
                {
                    modType            = new TypeDefUser("", "<Module>", null);
                    modType.Attributes = TypeAttributes.AnsiClass;
                    module.Types.Add(modType);
                    marker.Mark(modType, null);
                }
                MethodDef cctor = modType.FindOrCreateStaticConstructor();
                if (!marker.IsMarked(cctor))
                {
                    marker.Mark(cctor, null);
                }
            }

            context.Logger.Debug("Watermarking...");
            foreach (ModuleDefMD module in context.Modules)
            {
                TypeRef attrRef  = module.CorLibTypes.GetTypeRef("System", "Attribute");
                var     attrType = new TypeDefUser("", "ConfusedByAttribute", attrRef);
                module.Types.Add(attrType);
                marker.Mark(attrType, null);

                var ctor = new MethodDefUser(
                    ".ctor",
                    MethodSig.CreateInstance(module.CorLibTypes.Void, module.CorLibTypes.String),
                    MethodImplAttributes.Managed,
                    MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName);
                ctor.Body          = new CilBody();
                ctor.Body.MaxStack = 1;
                ctor.Body.Instructions.Add(OpCodes.Ldarg_0.ToInstruction());
                ctor.Body.Instructions.Add(OpCodes.Call.ToInstruction(new MemberRefUser(module, ".ctor", MethodSig.CreateInstance(module.CorLibTypes.Void), attrRef)));
                ctor.Body.Instructions.Add(OpCodes.Ret.ToInstruction());
                attrType.Methods.Add(ctor);
                marker.Mark(ctor, null);

                var attr = new CustomAttribute(ctor);
                attr.ConstructorArguments.Add(new CAArgument(module.CorLibTypes.String, Version));

                module.CustomAttributes.Add(attr);
            }
        }
Example #20
0
 /// <summary>
 /// Resolves a type
 /// </summary>
 /// <param name="self">this</param>
 /// <param name="typeRef">The type</param>
 /// <returns>A <see cref="TypeDef"/> instance</returns>
 /// <exception cref="TypeResolveException">If the type couldn't be resolved</exception>
 public static TypeDef ResolveThrow(this ITypeResolver self, TypeRef typeRef) => self.ResolveThrow(typeRef, null);
Example #21
0
 public DeclaredMemberDef(TypeRef declaringType)
 {
     DeclaringType = declaringType;
 }
Example #22
0
 public Instructions Emit(OpCode opCode, TypeRef value)
 {
     return(Insert(Instruction.Create(opCode, value)));
 }
Example #23
0
 public TypeRefInfo(TypeRef tr)
 {
     this.TypeRef       = tr;
     this.OrigNamespace = tr.Namespace;
     this.OrigName      = tr.Name;
 }
Example #24
0
            public RuntimeExport(string contractName, TypeRef declaringTypeRef, MemberRef memberRef, TypeRef exportedValueTypeRef, IReadOnlyDictionary <string, object> metadata)
            {
                Requires.NotNull(metadata, nameof(metadata));
                Requires.NotNullOrEmpty(contractName, nameof(contractName));

                this.ContractName         = contractName;
                this.DeclaringTypeRef     = declaringTypeRef;
                this.MemberRef            = memberRef;
                this.ExportedValueTypeRef = exportedValueTypeRef;
                this.Metadata             = metadata;
            }
Example #25
0
 public RuntimeImport(ParameterRef importingParameterRef, TypeRef importingSiteTypeRef, TypeRef importingSiteTypeWithoutCollectionRef, ImportCardinality cardinality, IReadOnlyList <RuntimeExport> satisfyingExports, bool isNonSharedInstanceRequired, bool isExportFactory, IReadOnlyDictionary <string, object> metadata, IReadOnlyCollection <string> exportFactorySharingBoundaries)
     : this(importingSiteTypeRef, importingSiteTypeWithoutCollectionRef, cardinality, satisfyingExports, isNonSharedInstanceRequired, isExportFactory, metadata, exportFactorySharingBoundaries)
 {
     this.ImportingParameterRef = importingParameterRef;
 }
Example #26
0
        public RuntimePart GetPart(TypeRef partType)
        {
            Requires.NotNull(partType, nameof(partType));

            return(this.partsByType[partType]);
        }
Example #27
0
 /// <summary>
 /// Tries to relocate <see cref="TypeRef"/>.
 /// </summary>
 /// <param name="typeRef">The type reference.</param>
 /// <returns></returns>
 protected abstract ITypeDefOrRef TryRelocateTypeRef(TypeRef typeRef);
        private InputObjectEvaluator GetInputObjectEvaluator(InputValueDef inputDef, ValueSource valueSource, TypeRef typeRef)
        {
            var inpObjTypeDef = (InputObjectTypeDef)typeRef.TypeDef;

            // valueSource is not null (its value), we already checked it before coming here
            if (!(valueSource is ObjectValueSource parsedInputObj))
            {
                throw new InvalidInputException($"Value is not InputObject, expected value of type '{typeRef.Name}'.", valueSource);
            }
            var fields = new List <InputFieldEvalInfo>();

            foreach (var fldDef in inpObjTypeDef.Fields)
            {
                InputValueEvaluator fldEval;
                if (parsedInputObj.Fields.TryGetValue(fldDef.Name, out var inpValue))
                {
                    fldEval = GetInputValueEvaluator(fldDef, inpValue, fldDef.TypeRef);
                }
                else if (fldDef.HasDefaultValue)
                {
                    fldEval = CreateConstantInputValue(fldDef, valueSource, typeRef, fldDef.DefaultValue);
                }
                else if (!fldDef.TypeRef.IsNotNull)
                {
                    fldEval = CreateConstantInputValue(fldDef, valueSource, typeRef, null);
                }
                else
                {
                    throw new InvalidInputException($"Missing value for field '{fldDef.Name}'.", valueSource);
                }
                fields.Add(new InputFieldEvalInfo()
                {
                    FieldDef = fldDef, ValueEvaluator = fldEval
                });
                // TODO: add check that there are no 'extra' members in parsed object
            }
            var result = new InputObjectEvaluator(inputDef, typeRef, valueSource, fields);

            return(result);
        }
Example #29
0
 public CustomModAnnotation(bool isRequired, TypeRef type)
 {
     IsRequired = isRequired;
     Type = type;
 }
        private InputValueEvaluator GetInputValueEvaluatorImpl(InputValueDef inputDef, ValueSource valueSource, TypeRef resultTypeRef)
        {
            if (valueSource is VariableValueSource vref)
            {
                return(GetVariableRefEvaluator(inputDef, resultTypeRef, vref));
            }
            if (resultTypeRef.IsList)
            {
                return(GetInputListEvaluator(inputDef, valueSource, resultTypeRef));
            }

            switch (resultTypeRef.TypeDef)
            {
            case ScalarTypeDef stdef:
                if (valueSource is TokenValueSource tknIv)
                {
                    var constValue = stdef.Scalar.ParseToken(_requestContext, tknIv.TokenData);
                    return(CreateConstantInputValue(inputDef, valueSource, resultTypeRef, constValue));
                }
                else
                {
                    throw new InvalidInputException("invalid input value, expected scalar", valueSource);
                }

            case EnumTypeDef etdef:
                if (etdef.IsFlagSet && valueSource is ListValueSource)
                {
                    return(GetInputListEvaluator(inputDef, valueSource, resultTypeRef));
                }
                if (valueSource is TokenValueSource tknValueSrc)
                {
                    if (tknValueSrc.TokenData.TermName != TermNames.Name)
                    {
                        throw new InvalidInputException($"Invalid value '{tknValueSrc.TokenData.Text}', expected Enum value.", valueSource);
                    }
                    var vname   = tknValueSrc.TokenData.Text;
                    var enumVal = etdef.EnumValues.FirstOrDefault(ev => ev.Name == vname);
                    if (enumVal == null)
                    {
                        throw new InvalidInputException($"Invalid value '{vname}' for enum '{etdef.ClrType.Name}'.", valueSource);
                    }
                    return(CreateConstantInputValue(inputDef, tknValueSrc, resultTypeRef, enumVal.ClrValue));
                }
                else
                {
                    throw new InvalidInputException($"Invalid input value, expected enum value.", valueSource);
                }

            case InputObjectTypeDef inpObjDef:
                return(GetInputObjectEvaluator(inputDef, valueSource, resultTypeRef));

            default:
                return(null); //never happens
            }
        }
Example #31
0
 public unsafe static uint GetVectorSize(TypeRef VectorTy) {
   uint ret = LLVMPINVOKE.GetVectorSize(VectorTy.Value);
   return ret;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ComposablePartDefinition"/> class.
 /// </summary>
 /// <param name="partType">Type of the part.</param>
 /// <param name="metadata">The metadata discovered on the part.</param>
 /// <param name="exportedTypes">The exported types.</param>
 /// <param name="exportingMembers">The exporting members.</param>
 /// <param name="importingMembers">The importing members.</param>
 /// <param name="sharingBoundary">The sharing boundary that this part is shared within.</param>
 /// <param name="onImportsSatisfied">The method to invoke after satisfying imports, if any.</param>
 /// <param name="importingConstructorRef">The constructor to invoke to construct the part.</param>
 /// <param name="importingConstructorImports">The importing arguments taken by the importing constructor. <c>null</c> if the part cannot be instantiated.</param>
 /// <param name="partCreationPolicy">The creation policy for this part.</param>
 /// <param name="extraInputAssemblies">A sequence of extra assemblies to be added to the set for <see cref="GetInputAssemblies(ISet{AssemblyName})"/></param>
 /// <param name="isSharingBoundaryInferred">A value indicating whether the part does not have an explicit sharing boundary, and therefore can obtain its sharing boundary based on its imports.</param>
 public ComposablePartDefinition(TypeRef partType, IReadOnlyDictionary <string, object> metadata, IReadOnlyCollection <ExportDefinition> exportedTypes, IReadOnlyDictionary <MemberRef, IReadOnlyCollection <ExportDefinition> > exportingMembers, IEnumerable <ImportDefinitionBinding> importingMembers, string sharingBoundary, MethodRef onImportsSatisfied, ConstructorRef importingConstructorRef, IReadOnlyList <ImportDefinitionBinding> importingConstructorImports, CreationPolicy partCreationPolicy, IEnumerable <AssemblyName> extraInputAssemblies, bool isSharingBoundaryInferred = false)
     : this(partType, metadata, exportedTypes, exportingMembers, importingMembers, sharingBoundary, onImportsSatisfied, importingConstructorRef, importingConstructorImports, partCreationPolicy, isSharingBoundaryInferred)
 {
     Requires.NotNull(extraInputAssemblies, nameof(extraInputAssemblies));
     this.ExtraInputAssemblies = extraInputAssemblies;
 }
Example #33
0
        protected override ComposablePartDefinition CreatePart(Type partType, bool typeExplicitlyRequested)
        {
            Requires.NotNull(partType, nameof(partType));

            // We want to ignore abstract classes, but we want to consider static classes.
            // Static classes claim to be both abstract and sealed. So to ignore just abstract
            // ones, we check that they are not sealed.
            if (partType.IsAbstract && !partType.IsSealed)
            {
                return(null);
            }

            BindingFlags everythingLocal = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
            BindingFlags instanceLocal   = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            // If the type is abstract only find local static exports
            var exportBindingFlags = everythingLocal;

            if (partType.IsAbstract)
            {
                exportBindingFlags &= ~BindingFlags.Instance;
            }

            var declaredMethods    = partType.GetMethods(exportBindingFlags); // methods can only export, not import
            var declaredProperties = partType.GetProperties(everythingLocal);
            var declaredFields     = partType.GetFields(everythingLocal);

            var allLocalMembers  = declaredMethods.Concat <MemberInfo>(declaredProperties).Concat(declaredFields);
            var exportingMembers = from member in allLocalMembers
                                   from export in member.GetAttributes <ExportAttribute>()
                                   select new KeyValuePair <MemberInfo, ExportAttribute>(member, export);
            var exportedTypes = from export in partType.GetAttributes <ExportAttribute>()
                                select new KeyValuePair <MemberInfo, ExportAttribute>(partType, export);
            var inheritedExportedTypes = from baseTypeOrInterface in partType.GetInterfaces().Concat(partType.EnumTypeAndBaseTypes().Skip(1))
                                         where baseTypeOrInterface != typeof(object)
                                         from export in baseTypeOrInterface.GetAttributes <InheritedExportAttribute>()
                                         select new KeyValuePair <MemberInfo, ExportAttribute>(baseTypeOrInterface, export);

            var exportsByMember = (from export in exportingMembers.Concat(exportedTypes).Concat(inheritedExportedTypes)
                                   group export.Value by export.Key into exportsByType
                                   select exportsByType).Select(g => new KeyValuePair <MemberInfo, ExportAttribute[]>(g.Key, g.ToArray())).ToArray();

            if (exportsByMember.Length == 0)
            {
                return(null);
            }

            // Check for PartNotDiscoverable only after we've established it's an interesting part.
            // This optimizes for the fact that most types have no exports, in which case it's not a discoverable
            // part anyway. Checking for the PartNotDiscoverableAttribute first, which is rarely defined,
            // doesn't usually pay for itself in terms of short-circuiting. But it does add an extra
            // attribute to look for that we don't need to find for all the types that have no export attributes either.
            if (!typeExplicitlyRequested && partType.IsAttributeDefined <PartNotDiscoverableAttribute>())
            {
                return(null);
            }

            TypeRef partTypeRef = TypeRef.Get(partType, this.Resolver);
            Type    partTypeAsGenericTypeDefinition = partType.IsGenericType ? partType.GetGenericTypeDefinition() : null;

            // Collect information for all imports.
            var imports = ImmutableList.CreateBuilder <ImportDefinitionBinding>();

            this.AddImportsFromMembers(declaredProperties, declaredFields, partTypeRef, imports);
            Type baseType = partType.BaseType;

            while (baseType != null && baseType != typeof(object))
            {
                this.AddImportsFromMembers(baseType.GetProperties(instanceLocal), baseType.GetFields(instanceLocal), partTypeRef, imports);
                baseType = baseType.BaseType;
            }

            var partCreationPolicy          = CreationPolicy.Any;
            var partCreationPolicyAttribute = partType.GetFirstAttribute <PartCreationPolicyAttribute>();

            if (partCreationPolicyAttribute != null)
            {
                partCreationPolicy = (CreationPolicy)partCreationPolicyAttribute.CreationPolicy;
            }

            var allExportsMetadata = ImmutableDictionary.CreateRange(PartCreationPolicyConstraint.GetExportMetadata(partCreationPolicy));
            var inheritedExportContractNamesFromNonInterfaces = ImmutableHashSet.CreateBuilder <string>();
            var exportDefinitions = ImmutableList.CreateBuilder <KeyValuePair <MemberInfo, ExportDefinition> >();

            foreach (var export in exportsByMember)
            {
                var memberExportMetadata = allExportsMetadata.AddRange(GetExportMetadata(export.Key));

                if (export.Key is MethodInfo)
                {
                    var method           = export.Key as MethodInfo;
                    var exportAttributes = export.Value;
                    if (exportAttributes.Any())
                    {
                        foreach (var exportAttribute in exportAttributes)
                        {
                            Type   exportedType   = exportAttribute.ContractType ?? ReflectionHelpers.GetContractTypeForDelegate(method);
                            string contractName   = string.IsNullOrEmpty(exportAttribute.ContractName) ? GetContractName(exportedType) : exportAttribute.ContractName;
                            var    exportMetadata = memberExportMetadata
                                                    .Add(CompositionConstants.ExportTypeIdentityMetadataName, ContractNameServices.GetTypeIdentity(exportedType));
                            var exportDefinition = new ExportDefinition(contractName, exportMetadata);
                            exportDefinitions.Add(new KeyValuePair <MemberInfo, ExportDefinition>(export.Key, exportDefinition));
                        }
                    }
                }
                else
                {
                    MemberInfo exportingTypeOrPropertyOrField = export.Key;
                    Verify.Operation(export.Key is Type || !partType.IsGenericTypeDefinition, Strings.ExportsOnMembersNotAllowedWhenDeclaringTypeGeneric);
                    Type exportSiteType = ReflectionHelpers.GetMemberType(exportingTypeOrPropertyOrField);
                    foreach (var exportAttribute in export.Value)
                    {
                        Type   exportedType = exportAttribute.ContractType ?? partTypeAsGenericTypeDefinition ?? exportSiteType;
                        string contractName = string.IsNullOrEmpty(exportAttribute.ContractName) ? GetContractName(exportedType) : exportAttribute.ContractName;
                        if (export.Key is Type && exportAttribute is InheritedExportAttribute)
                        {
                            if (inheritedExportContractNamesFromNonInterfaces.Contains(contractName))
                            {
                                // We already have an export with this contract name on this type (from a more derived type)
                                // using InheritedExportAttribute.
                                continue;
                            }

                            if (!((Type)export.Key).IsInterface)
                            {
                                inheritedExportContractNamesFromNonInterfaces.Add(contractName);
                            }
                        }

                        var exportMetadata = memberExportMetadata
                                             .Add(CompositionConstants.ExportTypeIdentityMetadataName, ContractNameServices.GetTypeIdentity(exportedType));
                        var exportDefinition = new ExportDefinition(contractName, exportMetadata);
                        exportDefinitions.Add(new KeyValuePair <MemberInfo, ExportDefinition>(export.Key, exportDefinition));
                    }
                }
            }

            MethodInfo onImportsSatisfied = null;

            if (typeof(IPartImportsSatisfiedNotification).IsAssignableFrom(partType))
            {
                onImportsSatisfied = OnImportsSatisfiedMethodInfo;
            }

            var importingConstructorParameters = ImmutableList.CreateBuilder <ImportDefinitionBinding>();
            var importingCtor = GetImportingConstructor <ImportingConstructorAttribute>(partType, publicOnly: false);

            if (importingCtor != null) // some parts have exports merely for metadata -- they can't be instantiated
            {
                foreach (var parameter in importingCtor.GetParameters())
                {
                    var import = this.CreateImport(parameter);
                    if (import.ImportDefinition.Cardinality == ImportCardinality.ZeroOrMore)
                    {
                        Verify.Operation(PartDiscovery.IsImportManyCollectionTypeCreateable(import), Strings.CollectionMustBePublicAndPublicCtorWhenUsingImportingCtor);
                    }

                    importingConstructorParameters.Add(import);
                }
            }

            var partMetadata = ImmutableDictionary.CreateBuilder <string, object>();

            foreach (var partMetadataAttribute in partType.GetAttributes <PartMetadataAttribute>())
            {
                partMetadata[partMetadataAttribute.Name] = partMetadataAttribute.Value;
            }

            var exportsOnType    = exportDefinitions.Where(kv => kv.Key is Type).Select(kv => kv.Value).ToArray();
            var exportsOnMembers = (from kv in exportDefinitions
                                    where !(kv.Key is Type)
                                    group kv.Value by kv.Key into byMember
                                    select byMember).ToDictionary(g => MemberRef.Get(g.Key, this.Resolver), g => (IReadOnlyCollection <ExportDefinition>)g.ToArray());

            var assemblyNamesForMetadataAttributes = ImmutableHashSet.CreateBuilder <AssemblyName>();

            foreach (var export in exportsByMember)
            {
                GetAssemblyNamesFromMetadataAttributes <MetadataAttributeAttribute>(export.Key, assemblyNamesForMetadataAttributes);
            }

            return(new ComposablePartDefinition(
                       TypeRef.Get(partType, this.Resolver),
                       partMetadata.ToImmutable(),
                       exportsOnType,
                       exportsOnMembers,
                       imports.ToImmutable(),
                       partCreationPolicy != CreationPolicy.NonShared ? string.Empty : null,
                       MethodRef.Get(onImportsSatisfied, this.Resolver),
                       ConstructorRef.Get(importingCtor, this.Resolver),
                       importingCtor != null ? importingConstructorParameters.ToImmutable() : null, // some MEF parts are only for metadata
                       partCreationPolicy,
                       assemblyNamesForMetadataAttributes,
                       partCreationPolicy != CreationPolicy.NonShared));
        }
Example #34
0
        private void AddImportsFromMembers(PropertyInfo[] declaredProperties, FieldInfo[] declaredFields, TypeRef partTypeRef, IList <ImportDefinitionBinding> imports)
        {
            Requires.NotNull(declaredProperties, nameof(declaredProperties));
            Requires.NotNull(declaredFields, nameof(declaredFields));
            Requires.NotNull(partTypeRef, nameof(partTypeRef));
            Requires.NotNull(imports, nameof(imports));

            foreach (var member in declaredFields.Concat <MemberInfo>(declaredProperties))
            {
                if (!member.IsStatic())
                {
                    ImportDefinition importDefinition;
                    if (this.TryCreateImportDefinition(ReflectionHelpers.GetMemberType(member), member, out importDefinition))
                    {
                        imports.Add(new ImportDefinitionBinding(importDefinition, partTypeRef, MemberRef.Get(member, this.Resolver)));
                    }
                }
            }
        }
Example #35
0
 public unsafe static TypeRef VoidType() {
   TypeRef ret = new TypeRef(LLVMPINVOKE.VoidType());
   return ret;
 }
        private ConstInputValue CreateConstantInputValue(InputValueDef inputDef, RequestObjectBase anchor, TypeRef resultTypeRef, object value)
        {
            // We convert const value upfront to target typeRef
            var convValue = _requestContext.ValidateConvert(value, resultTypeRef, anchor);
            var constEval = new ConstInputValue(inputDef, resultTypeRef, anchor, convValue);

            return(constEval);
        }
Example #37
0
 public unsafe static TypeRef X86MMXType() {
   TypeRef ret = new TypeRef(LLVMPINVOKE.X86MMXType());
   return ret;
 }
Example #38
0
 public unsafe static ValueRef ConstAllOnes(TypeRef Ty) {
   ValueRef ret = new ValueRef(LLVMPINVOKE.ConstAllOnes(Ty.Value));
   return ret;
 }
 public ConstInputValue(InputValueDef inputDef, TypeRef resultTypeRef, RequestObjectBase anchor, object value)
     : base(inputDef, resultTypeRef, anchor)
 {
     Value = value;
 }
Example #40
0
 public unsafe static ValueRef ConstPointerNull(TypeRef Ty) {
   ValueRef ret = new ValueRef(LLVMPINVOKE.ConstPointerNull(Ty.Value));
   return ret;
 }
Example #41
0
 /// <summary>
 /// Initialises a new instance of the CRefPath class.
 /// </summary>
 /// <param name="type">The TypRef to initialise the path with.</param>
 public CRefPath(TypeRef type)
     : this(CRefTypes.Type, type, string.Empty)
 {
 }
        private InputValueEvaluator GetInputListEvaluator(InputValueDef inputDef, ValueSource valueSource, TypeRef listTypeRef)
        {
            if (valueSource.IsConstNull())
            {
                if (listTypeRef.IsNotNull)
                {
                    throw new InvalidInputException("Input type '{valueTypeRef.Name}' is not-null type, but null was encountered.",
                                                    valueSource);
                }
            }
            if (!(valueSource is ListValueSource arrValue))
            {
                throw new InvalidInputException($"Input type '{listTypeRef.Name}' is not list or array, expected array.", valueSource);
            }
            var elemTypeRef = listTypeRef.GetListElementTypeRef();

            if (elemTypeRef == null)
            {
                throw new InvalidInputException($"Invalid input value for type {listTypeRef.Name}, expected list", valueSource);
            }
            var elemEvalList = arrValue.Values.Select(v => GetInputValueEvaluator(inputDef, v, elemTypeRef)).ToArray();

            // it can be regular array or enum flag set (which is special)
            if (elemTypeRef.TypeDef.IsEnumFlagArray())
            {
                return(new FlagSetInputEvaluator(inputDef, listTypeRef, valueSource, elemEvalList));
            }
            else
            {
                return(new InputListEvaluator(inputDef, listTypeRef, valueSource, elemEvalList));
            }
        }
Example #43
0
 public unsafe static TypeRef X86MMXTypeInContext(ContextRef C) {
   TypeRef ret = new TypeRef(LLVMPINVOKE.X86MMXTypeInContext(C.Value));
   return ret;
 }
Example #44
0
        protected void WriteObject(object value)
        {
            if (value == null)
            {
                using (this.Trace("Object (null)"))
                {
                    this.Write(ObjectType.Null);
                }
            }
            else
            {
                Type valueType = value.GetType();
                using (this.Trace("Object (" + valueType.Name + ")"))
                {
                    if (valueType.IsArray)
                    {
                        Array array = (Array)value;
                        this.Write(ObjectType.Array);
                        TypeRef elementTypeRef = TypeRef.Get(valueType.GetElementType(), this.Resolver);
                        this.Write(elementTypeRef);
                        this.Write(array, this.WriteObject);
                    }
                    else if (valueType == typeof(bool))
                    {
                        this.Write((bool)value ? ObjectType.BoolTrue : ObjectType.BoolFalse);
                    }
                    else if (valueType == typeof(string))
                    {
                        this.Write(ObjectType.String);
                        this.Write((string)value);
                    }
                    else if (valueType == typeof(long))
                    {
                        this.Write(ObjectType.Int64);
                        this.writer.Write((long)value);
                    }
                    else if (valueType == typeof(ulong))
                    {
                        this.Write(ObjectType.UInt64);
                        this.writer.Write((ulong)value);
                    }
                    else if (valueType == typeof(int))
                    {
                        this.Write(ObjectType.Int32);
                        this.writer.Write((int)value);
                    }
                    else if (valueType == typeof(uint))
                    {
                        this.Write(ObjectType.UInt32);
                        this.writer.Write((uint)value);
                    }
                    else if (valueType == typeof(short))
                    {
                        this.Write(ObjectType.Int16);
                        this.writer.Write((short)value);
                    }
                    else if (valueType == typeof(ushort))
                    {
                        this.Write(ObjectType.UInt16);
                        this.writer.Write((ushort)value);
                    }
                    else if (valueType == typeof(byte))
                    {
                        this.Write(ObjectType.Byte);
                        this.writer.Write((byte)value);
                    }
                    else if (valueType == typeof(sbyte))
                    {
                        this.Write(ObjectType.SByte);
                        this.writer.Write((sbyte)value);
                    }
                    else if (valueType == typeof(float))
                    {
                        this.Write(ObjectType.Single);
                        this.writer.Write((float)value);
                    }
                    else if (valueType == typeof(double))
                    {
                        this.Write(ObjectType.Double);
                        this.writer.Write((double)value);
                    }
                    else if (valueType == typeof(char))
                    {
                        this.Write(ObjectType.Char);
                        this.writer.Write((char)value);
                    }
                    else if (valueType == typeof(Guid))
                    {
                        this.Write(ObjectType.Guid);
                        this.writer.Write(((Guid)value).ToByteArray());
                    }
                    else if (valueType == typeof(CreationPolicy)) // TODO: how do we handle arbitrary value types?
                    {
                        this.Write(ObjectType.CreationPolicy);
                        this.writer.Write((byte)(CreationPolicy)value);
                    }
                    else if (typeof(Type).GetTypeInfo().IsAssignableFrom(valueType))
                    {
                        this.Write(ObjectType.Type);
                        this.Write(TypeRef.Get((Type)value, this.Resolver));
                    }
                    else if (typeof(TypeRef) == valueType)
                    {
                        this.Write(ObjectType.TypeRef);
                        this.Write((TypeRef)value);
                    }
                    else if (typeof(LazyMetadataWrapper.Enum32Substitution) == valueType)
                    {
                        var substValue = (LazyMetadataWrapper.Enum32Substitution)value;
                        this.Write(ObjectType.Enum32Substitution);
                        this.Write(substValue.EnumType);
                        this.writer.Write(substValue.RawValue);
                    }
                    else if (typeof(LazyMetadataWrapper.TypeSubstitution) == valueType)
                    {
                        var substValue = (LazyMetadataWrapper.TypeSubstitution)value;
                        this.Write(ObjectType.TypeSubstitution);
                        this.Write(substValue.TypeRef);
                    }
                    else if (typeof(LazyMetadataWrapper.TypeArraySubstitution) == valueType)
                    {
                        var substValue = (LazyMetadataWrapper.TypeArraySubstitution)value;
                        this.Write(ObjectType.TypeArraySubstitution);
                        this.Write(substValue.TypeRefArray, this.Write);
                    }
                    else
                    {
#if NET45
                        Debug.WriteLine("Falling back to binary formatter for value of type: {0}", valueType);
                        this.Write(ObjectType.BinaryFormattedObject);
                        var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                        this.writer.Flush();
                        formatter.Serialize(this.writer.BaseStream, value);
#else
                        throw new NotSupportedException("Object of type " + valueType + " cannot be serialized on this platform.");
#endif
                    }
                }
            }
        }
Example #45
0
 public unsafe static TypeRef LabelType() {
   TypeRef ret = new TypeRef(LLVMPINVOKE.LabelType());
   return ret;
 }
Example #46
0
        protected object ReadObject()
        {
            using (this.Trace("Object"))
            {
                ObjectType objectType = this.ReadObjectType();
                switch (objectType)
                {
                case ObjectType.Null:
                    return(null);

                case ObjectType.Array:
                    Type elementType = this.ReadTypeRef().Resolve();
                    return(this.ReadArray(this.reader, this.ReadObject, elementType));

                case ObjectType.BoolTrue:
                    return(true);

                case ObjectType.BoolFalse:
                    return(false);

                case ObjectType.Int64:
                    return(this.reader.ReadInt64());

                case ObjectType.UInt64:
                    return(this.reader.ReadUInt64());

                case ObjectType.Int32:
                    return(this.reader.ReadInt32());

                case ObjectType.UInt32:
                    return(this.reader.ReadUInt32());

                case ObjectType.Int16:
                    return(this.reader.ReadInt16());

                case ObjectType.UInt16:
                    return(this.reader.ReadUInt16());

                case ObjectType.Byte:
                    return(this.reader.ReadByte());

                case ObjectType.SByte:
                    return(this.reader.ReadSByte());

                case ObjectType.Single:
                    return(this.reader.ReadSingle());

                case ObjectType.Double:
                    return(this.reader.ReadDouble());

                case ObjectType.String:
                    return(this.ReadString());

                case ObjectType.Char:
                    return(this.reader.ReadChar());

                case ObjectType.Guid:
                    return(new Guid(this.reader.ReadBytes(16)));

                case ObjectType.CreationPolicy:
                    return((CreationPolicy)this.reader.ReadByte());

                case ObjectType.Type:
                    return(this.ReadTypeRef().Resolve());

                case ObjectType.TypeRef:
                    return(this.ReadTypeRef());

                case ObjectType.Enum32Substitution:
                    TypeRef enumType = this.ReadTypeRef();
                    int     rawValue = this.reader.ReadInt32();
                    return(new LazyMetadataWrapper.Enum32Substitution(enumType, rawValue));

                case ObjectType.TypeSubstitution:
                    TypeRef typeRef = this.ReadTypeRef();
                    return(new LazyMetadataWrapper.TypeSubstitution(typeRef));

                case ObjectType.TypeArraySubstitution:
                    IReadOnlyList <TypeRef> typeRefArray = this.ReadList(this.reader, this.ReadTypeRef);
                    return(new LazyMetadataWrapper.TypeArraySubstitution(typeRefArray, this.Resolver));

                case ObjectType.BinaryFormattedObject:
#if NET45
                    var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    return(formatter.Deserialize(this.reader.BaseStream));
#else
                    throw new NotSupportedException("BinaryFormatter object cannot be deserialized on this platform.");
#endif
                default:
                    throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings.UnsupportedFormat, objectType));
                }
            }
        }
Example #47
0
 public unsafe static TypeRef TypeOf(ValueRef Val) {
   TypeRef ret = new TypeRef(LLVMPINVOKE.TypeOf(Val.Value));
   return ret;
 }
Example #48
0
            internal TypeSubstitution(TypeRef typeRef)
            {
                Requires.NotNull(typeRef, nameof(typeRef));

                this.TypeRef = typeRef;
            }
Example #49
0
 public unsafe static ValueRef GetUndef(TypeRef Ty) {
   ValueRef ret = new ValueRef(LLVMPINVOKE.GetUndef(Ty.Value));
   return ret;
 }
Example #50
0
        private static ImmutableDictionary <string, MetadatumRequirement> GetRequiredMetadata(TypeRef metadataViewRef, Resolver resolver)
        {
            Requires.NotNull(metadataViewRef, nameof(metadataViewRef));
            Requires.NotNull(resolver, nameof(resolver));

            var  metadataView = metadataViewRef.Resolve();
            bool hasMetadataViewImplementation = MetadataViewImplProxy.HasMetadataViewImplementation(metadataView);

            if (metadataView.GetTypeInfo().IsInterface&& !metadataView.Equals(typeof(IDictionary <string, object>)) && !metadataView.Equals(typeof(IReadOnlyDictionary <string, object>)))
            {
                var requiredMetadata = ImmutableDictionary.CreateBuilder <string, MetadatumRequirement>();

                foreach (var property in metadataView.EnumProperties().WherePublicInstance())
                {
                    bool required = !property.IsAttributeDefined <DefaultValueAttribute>();

                    // Ignore properties that have a default value and have a metadataview implementation.
                    if (required || !hasMetadataViewImplementation)
                    {
                        requiredMetadata.Add(property.Name, new MetadatumRequirement(TypeRef.Get(ReflectionHelpers.GetMemberType(property), resolver), required));
                    }
                }

                return(requiredMetadata.ToImmutable());
            }

            return(ImmutableDictionary <string, MetadatumRequirement> .Empty);
        }
Example #51
0
 public unsafe static ValueRef ConstInt(TypeRef IntTy, ulong N, bool SignExtend) {
   ValueRef ret = new ValueRef(LLVMPINVOKE.ConstInt(IntTy.Value, N, SignExtend));
   return ret;
 }
Example #52
0
 public MetadatumRequirement(TypeRef valueType, bool required)
     : this()
 {
     this.MetadatumValueTypeRef     = valueType;
     this.IsMetadataumValueRequired = required;
 }
Example #53
0
 public unsafe static ValueRef ConstReal(TypeRef RealTy, double N) {
   ValueRef ret = new ValueRef(LLVMPINVOKE.ConstReal(RealTy.Value, N));
   return ret;
 }
Example #54
0
        public bool IsSatisfiedBy(ExportDefinition exportDefinition)
        {
            Requires.NotNull(exportDefinition, nameof(exportDefinition));

            // Fast path since immutable dictionaries are slow to enumerate.
            if (this.Requirements.IsEmpty)
            {
                return(true);
            }

            Assumes.NotNull(this.Resolver);
            foreach (var entry in this.Requirements)
            {
                object?value;
                if (!LazyMetadataWrapper.TryGetLoadSafeValueTypeRef(exportDefinition.Metadata, entry.Key, this.Resolver, out value))
                {
                    if (entry.Value.IsMetadataumValueRequired)
                    {
                        return(false);
                    }
                    else
                    {
                        // It's not required, and it's not present. No more validation necessary.
                        continue;
                    }
                }

                TypeRef metadatumValueTypeRef = entry.Value.MetadatumValueTypeRef;
                if (value == null)
                {
                    if (metadatumValueTypeRef.IsValueType)
                    {
                        // A null reference for a value type is not a compatible match.
                        return(false);
                    }
                    else
                    {
                        // Null is assignable to any reference type.
                        continue;
                    }
                }

                if (value is TypeRef valueTypeRef)
                {
                    if (!metadatumValueTypeRef.ElementTypeRef.IsAssignableFrom(valueTypeRef.ElementTypeRef))
                    {
                        return(false);
                    }

                    continue;
                }

                if (value is TypeRef[] valueTypeRefArray && metadatumValueTypeRef.ElementTypeRef != metadatumValueTypeRef)
                {
                    var receivingElementTypeRef = metadatumValueTypeRef.ElementTypeRef;
                    foreach (var item in valueTypeRefArray)
                    {
                        if (item == null)
                        {
                            if (receivingElementTypeRef.IsValueType)
                            {
                                return(false);
                            }
                            else
                            {
                                continue;
                            }
                        }

                        if (!receivingElementTypeRef.IsAssignableFrom(item))
                        {
                            return(false);
                        }
                    }

                    continue;
                }
            }

            return(true);
        }
Example #55
0
 public unsafe static ValueRef ConstRealOfStringAndSize(TypeRef RealTy, string Text, uint SLen) {
   ValueRef ret = new ValueRef(LLVMPINVOKE.ConstRealOfStringAndSize(RealTy.Value, Text, SLen));
   return ret;
 }
Example #56
0
 public AssemblyRef FindAssemblyRef(TypeRef nonNestedTypeRef)
 {
     return(assemblyDef.ToAssemblyRef());
 }
Example #57
0
 public Key( TypeRef vmd,
             Toolkit tk,
             ControlKind ck)
 {
     this.vmd = vmd.ExportGuid;
     this.tk = tk;
     this.ck = ck != null ? ck.ExportGuid : Guid.Empty;
 }
Example #58
0
 /// <summary>
 /// Resolves a type
 /// </summary>
 /// <param name="self">this</param>
 /// <param name="typeRef">The type</param>
 /// <returns>A <see cref="TypeDef"/> instance</returns>
 /// <exception cref="TypeResolveException">If the type couldn't be resolved</exception>
 public static TypeDef ResolveThrow(this ITypeResolver self, TypeRef typeRef)
 {
     return(self.ResolveThrow(typeRef, null));
 }
Example #59
0
 public CustomAttribute(TypeRef typeRef, ISeq<object> positionalProperties, IMap<string, object> namedProperties)
 {
     Type = typeRef;
     PositionalProperties = positionalProperties ?? new Seq<object>();
     NamedProperties = namedProperties ?? new Map<string, object>();
 }
 public TypeRefReference(TypeRef typeRef, TypeDef typeDef)
 {
     this.typeRef = typeRef;
     this.typeDef = typeDef;
 }