Esempio n. 1
0
    /// <summary>
    /// Gets or creates a new instance of <see cref="CILAssembly"/> which will wrap the existing native <paramref name="assembly"/>.
    /// </summary>
    /// <param name="assembly">The native assembly which will serve as basis for the resulting <see cref="CILAssembly"/>.</param>
    /// <param name="ctx">The current reflection context.</param>
    /// <returns><see cref="CILAssembly"/> wrapping existing native <paramref name="assembly"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="assembly"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
    public static CILAssembly NewWrapper(this System.Reflection.Assembly assembly, CILReflectionContext ctx)
    {
        ArgumentValidator.ValidateNotNull("Assembly", assembly);
        ArgumentValidator.ValidateNotNull("Reflection context", ctx);

        return(((CILReflectionContextImpl)ctx).Cache.GetOrAdd(assembly));
    }
Esempio n. 2
0
    /// <summary>
    /// Gets or creates a new <see cref="CILModule"/> based on native <see cref="System.Reflection.Module"/>.
    /// </summary>
    /// <param name="module">The native module.</param>
    /// <param name="ctx">The current reflection context.</param>
    /// <returns><see cref="CILModule"/> wrapping existing native <see cref="System.Reflection.Module"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="module"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
    public static CILModule NewWrapper(this System.Reflection.Module module, CILReflectionContext ctx)
    {
        ArgumentValidator.ValidateNotNull("Module", module);
        ArgumentValidator.ValidateNotNull("Reflection context", ctx);

        return(((CILReflectionContextImpl)ctx).Cache.GetOrAdd(module));
    }
Esempio n. 3
0
        /// <summary>
        /// Creates a new <see cref="CILCustomAttributeTypedArgument"/> with specified value. The type of <paramref name="value"/> will be used as type for typed argument.
        /// </summary>
        /// <param name="value">The value of the typed argument. Can not be <c>null</c>.</param>
        /// <param name="ctx">The current reflection context.</param>
        /// <returns>A new <see cref="CILCustomAttributeTypedArgument"/> with specified value.</returns>
        public static CILCustomAttributeTypedArgument NewTypedArgument(Object value, CILReflectionContext ctx)
        {
            ArgumentValidator.ValidateNotNull("Value", value);
            ArgumentValidator.ValidateNotNull("Reflection context", ctx);

            return(NewTypedArgument(value.GetType().NewWrapperAsType(ctx), value));
        }
Esempio n. 4
0
    /// <summary>
    /// Gets or creates a new <see cref="CILMethod"/> based on native <see cref="System.Reflection.MethodInfo"/>.
    /// </summary>
    /// <param name="method">The native method.</param>
    /// <param name="ctx">The current reflection context.</param>
    /// <returns><see cref="CILMethod"/> wrapping existing native <see cref="System.Reflection.MethodInfo"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="method"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
    public static CILMethod NewWrapper(this System.Reflection.MethodInfo method, CILReflectionContext ctx)
    {
        ArgumentValidator.ValidateNotNull("Method", method);
        ArgumentValidator.ValidateNotNull("Reflection context", ctx);

        return(((CILReflectionContextImpl)ctx).Cache.GetOrAdd(method));
    }
Esempio n. 5
0
    /// <summary>
    /// Gets or creates a new <see cref="CILEvent"/> based on native <see cref="System.Reflection.EventInfo"/>.
    /// </summary>
    /// <param name="eInfo">The native event.</param>
    /// <param name="ctx">The current reflection context.</param>
    /// <returns><see cref="CILEvent"/> wrapping existing native <see cref="System.Reflection.EventInfo"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="eInfo"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
    public static CILEvent NewWrapper(this System.Reflection.EventInfo eInfo, CILReflectionContext ctx)
    {
        ArgumentValidator.ValidateNotNull("Event info", eInfo);
        ArgumentValidator.ValidateNotNull("Context", ctx);

        return(((CILReflectionContextImpl)ctx).Cache.GetOrAdd(eInfo));
    }
Esempio n. 6
0
    /// <summary>
    /// Gets or creates a new <see cref="CILField"/> based on native <see cref="System.Reflection.FieldInfo"/>.
    /// </summary>
    /// <param name="field">The native field.</param>
    /// <param name="ctx">The current reflection context.</param>
    /// <returns><see cref="CILField"/> wrapping existing native <see cref="System.Reflection.FieldInfo"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="field"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
    public static CILField NewWrapper(this System.Reflection.FieldInfo field, CILReflectionContext ctx)
    {
        ArgumentValidator.ValidateNotNull("Field", field);
        ArgumentValidator.ValidateNotNull("Reflection context", ctx);

        return(((CILReflectionContextImpl)ctx).Cache.GetOrAdd(field));
    }
    /// <summary>
    /// Creates a new, blank instance of <see cref="CILAssembly"/>.
    /// </summary>
    /// <param name="ctx">The current reflection context.</param>
    /// <param name="name">The name of the assembly.</param>
    /// <returns>New instance of <see cref="CILAssembly"/> with specified <paramref name="name"/> which will have no modules.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="ctx"/> is <c>null</c>.</exception>
    public static CILAssembly NewBlankAssembly(this CILReflectionContext ctx, String name)
    {
        ArgumentValidator.ValidateNotNull("Reflection context", ctx);

        var ass = ((CILReflectionContextImpl)ctx).Cache.NewBlankAssembly();

        ass.Name.Name = name;
        return(ass);
    }
Esempio n. 8
0
 /// <summary>
 /// This will create a new <see cref="CILAssemblyLoader"/> using <see cref="DotNETCILAssemblyLoaderCallbacks"/> as the callbacks object for <see cref="CILAssemblyLoader"/>.
 /// </summary>
 /// <param name="ctx">The <see cref="CILReflectionContext"/>.</param>
 /// <param name="referenceAssembliesDir">The optional directory containing reference assembly information. See <see cref="GetDefaultReferenceAssemblyPath"/> for more information. This method will use the value of <see cref="GetDefaultReferenceAssemblyPath"/> if this parameter is <c>null</c>.</param>
 /// <returns>A new <see cref="CILAssemblyLoader"/> bound to this <see cref="CILReflectionContext"/>.</returns>
 public static CILAssemblyLoader CreateAssemblyLoader(this CILReflectionContext ctx, String referenceAssembliesDir = null)
 {
     return(new CILAssemblyLoader(
                ctx,
                new DotNETCILAssemblyLoaderCallbacks(referenceAssembliesDir),
                Environment.OSVersion.Platform.FileNamesCaseSensitive() ?
                StringComparer.Ordinal :
                StringComparer.OrdinalIgnoreCase
                ));
 }
    /// <summary>
    /// Loads a new instance of <see cref="CILAssembly"/> from the contents of the <paramref name="stream"/>.
    /// </summary>
    /// <param name="ctx">The current reflection context.</param>
    /// <param name="stream">The stream to load assembly from.</param>
    /// <param name="eArgs">The <see cref="EmittingArguments"/> to be used during loading. After successful assembly load, this will contain some additional information about the loaded assembly.</param>
    /// <returns>A new instance of <see cref="CILAssembly"/> from the contents of the <paramref name="stream"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="ctx"/> or <paramref name="stream"/> or <paramref name="eArgs"/> is <c>null</c>.</exception>
    /// <exception cref="BadImageFormatException">If the headers or metadata section of the stream has invalid values, or stream contents are otherwise malformed.</exception>
    public static CILAssembly LoadAssembly(this CILReflectionContext ctx, Stream stream, EmittingArguments eArgs)
    {
        var result = LoadAssembly((CILReflectionContextImpl)ctx, stream, eArgs, null, null, null);

        if (!eArgs.LazyLoad)
        {
            ForceLoadAssembly(result);
        }
        return(result);
    }
Esempio n. 10
0
        internal CILParameterSignatureImpl(CILReflectionContext ctx, CILMethodSignature method, Int32 position, CILTypeBase pType, ListProxy <CILCustomModifier> mods)
            : base(ctx)
        {
            ArgumentValidator.ValidateNotNull("Method", method);
            ArgumentValidator.ValidateNotNull("Parameter type", pType);

            this._mods     = (mods ?? this._ctx.CollectionsFactory.NewListProxy <CILCustomModifier>()).CQ;
            this._method   = method;
            this._position = position;
            this._pType    = pType;
        }
    /// <summary>
    /// Creates a new <see cref="CILMethodSignature"/> which has all its information specified from the parameters of this method.
    /// </summary>
    /// <param name="ctx">The current <see cref="CILReflectionContext"/>.</param>
    /// <param name="currentModule">The current <see cref="CILModule"/>.</param>
    /// <param name="callingConventions">The <see cref="UnmanagedCallingConventions"/> for the method signature.</param>
    /// <param name="returnType">The return type for the method signature.</param>
    /// <param name="returnParamMods">The <see cref="CILCustomModifier"/>s for the method signature. May be <c>null</c> if no modifiers should be used.</param>
    /// <param name="parameters">The parameter information for the method signature. Each element is a tuple containing <see cref="CILCustomModifier"/>s and type for the parameter. Custom modifiers array may be <c>null</c> if no modifiers should be used.</param>
    /// <returns>A new <see cref="CILMethodSignature"/>.</returns>
    /// <exception cref="NullReferenceException">If <paramref name="ctx"/> is <c>null</c>.</exception>
    /// <exception cref="ArgumentNullException">If <paramref name="currentModule"/>, <paramref name="returnType"/> or any of the types within <paramref name="parameters"/> is <c>null</c>.</exception>
    /// <seealso cref="CILMethodSignature"/>
    public static CILMethodSignature NewMethodSignature(this CILReflectionContext ctx, CILModule currentModule, UnmanagedCallingConventions callingConventions, CILTypeBase returnType, CILCustomModifier[] returnParamMods, params Tuple <CILCustomModifier[], CILTypeBase>[] parameters)
    {
        if (ctx == null)
        {
            // Throw nullref explicitly for consistency (since it is 'this' parameter)
            // Because CILMethodSignatureImpl ctor throws ArgumentNullException
            throw new NullReferenceException();
        }
        var cctx = (CILReflectionContextImpl)ctx;

        return(new CILMethodSignatureImpl(ctx, currentModule, callingConventions, returnParamMods == null ? null : cctx.CollectionsFactory.NewListProxyFromParams(returnParamMods), returnType, parameters.Select(t => Tuple.Create(t.Item1 == null ? null : cctx.CollectionsFactory.NewListProxyFromParams(t.Item1), t.Item2)).ToList(), null));
    }
Esempio n. 12
0
        /// <summary>
        /// Creates a new instance of <see cref="CILAssemblyLoader"/> which will be bound to a given <see cref="CILReflectionContext"/>.
        /// </summary>
        /// <param name="ctx">The <see cref="CILReflectionContext"/>.</param>
        /// <param name="callbacks">The object implementing required callback methods.</param>
        /// <param name="resourceEqualityComparer">The equality comparer to use when comparing resources (file names). Defaults to system's default string equality comparer (case-sensitive).</param>
        /// <exception cref="ArgumentNullException">If <paramref name="ctx"/> or <paramref name="callbacks"/> are <c>null</c>.</exception>
        public CILAssemblyLoader(CILReflectionContext ctx, CILAssemblyLoaderCallbacks callbacks, IEqualityComparer <String> resourceEqualityComparer)
        {
            ArgumentValidator.ValidateNotNull("Reflection context", ctx);
            ArgumentValidator.ValidateNotNull("Callbacks", callbacks);

            this._ctx             = ctx;
            this._callbacks       = callbacks;
            this._allModules      = new Dictionary <String, CILModule>(resourceEqualityComparer);
            this._loadingArgs     = new Dictionary <CILModule, EmittingArguments>();
            this._moduleResources = new Dictionary <CILModule, String>();
            this._modulesLock     = new Object();
        }
 public CompositeEmittingInfo(CILReflectionContext ctx, IEnumerable <CompositeModel> models)
 {
     this._ctx = ctx;
     this._publicCompositeGenerationInfo    = new ConcurrentDictionary <Tuple <Assembly, CompositeModel>, CompositeTypeGenerationInfo>(EqualityComparer <Tuple <Assembly, CompositeModel> > .Default);
     this._compositeTypeGenerationInfos     = new ConcurrentDictionary <TypeBindingInformation, Tuple <IList <CompositeTypeGenerationInfo>, Object> >(ReferenceEqualityComparer <TypeBindingInformation> .ReferenceBasedComparer);
     this._fragmentTypeGenerationInfos      = new ConcurrentDictionary <TypeBindingInformation, Tuple <IList <FragmentTypeGenerationInfo>, Object> >(ReferenceEqualityComparer <TypeBindingInformation> .ReferenceBasedComparer);
     this._concernInvocationTypeGenInfos    = new ConcurrentDictionary <TypeBindingInformation, Tuple <IList <CompositeTypeGenerationInfo>, Object> >(ReferenceEqualityComparer <TypeBindingInformation> .ReferenceBasedComparer);
     this._sideEffectInvocationTypeGenInfos = new ConcurrentDictionary <TypeBindingInformation, Tuple <IList <CompositeTypeGenerationInfo>, Object> >(ReferenceEqualityComparer <TypeBindingInformation> .ReferenceBasedComparer);
     this._fragmentCreationMethods          = new ConcurrentDictionary <FragmentTypeGenerationInfo, CompositeMethodGenerationInfo>();
     this._idInfos = models.ToDictionary(model => model, model => new CompositeEmittingIDInfo());
     this._typesWithExtraMethods          = new ConcurrentDictionary <CompositeTypeGenerationInfo, CompositeTypeGenerationInfo>(ReferenceEqualityComparer <CompositeTypeGenerationInfo> .ReferenceBasedComparer);
     this._typesWithCtors                 = new ConcurrentDictionary <CompositeTypeGenerationInfo, CompositeTypeGenerationInfo>(ReferenceEqualityComparer <CompositeTypeGenerationInfo> .ReferenceBasedComparer);
     this._typesWithCompositeMethods      = new ConcurrentDictionary <CompositeTypeGenerationInfo, CompositeTypeGenerationInfo>(ReferenceEqualityComparer <CompositeTypeGenerationInfo> .ReferenceBasedComparer);
     this._allGenerationInfos             = new ConcurrentDictionary <CompositeModel, ConcurrentDictionary <Int32, TypeGenerationInfo> >();
     this._emulatedFragmentTypeInfos      = new ConcurrentDictionary <CompositeTypeModel, IDictionary <CILType, TypeBindingInformation> >();
     this._compositeMethodGenerationInfos = new ConcurrentDictionary <CompositeMethodModel, CompositeMethodGenerationInfo>();
 }
Esempio n. 14
0
        internal AssemblyLoaderFromBasePath(CILReflectionContext ctx, String fwLibDirectory, Func <String, Stream> streamOpener, String corLibName)
        {
            ArgumentValidator.ValidateNotNull("Reflection context", ctx);
            ArgumentValidator.ValidateNotNull("Assembly directory", fwLibDirectory);
            ArgumentValidator.ValidateNotNull("Stream opener callback", streamOpener);

            if (corLibName == null)
            {
                corLibName = Consts.MSCORLIB_NAME;
            }

            this._ctx = ctx;
            this._loadedAssemblies     = new ConcurrentDictionary <String, CILAssembly>();
            this._portableLibDirectory = fwLibDirectory; // fwLibDirectory.EndsWith( "\\" ) ? fwLibDirectory : ( fwLibDirectory + "\\" );
            this._streamOpener         = streamOpener;
            this._loadArgs             = EmittingArguments.CreateForLoadingModule(this.LoadFunction);
            this._loadArgs.CorLibName  = corLibName;
        }
    /// <summary>
    /// Creates a new <see cref="EmittingAssemblyMapper"/> to be used to redirect references from currently loaded runtime to other runtime.
    /// The assemblies of other runtime should be located in given <paramref name="assemblyDirectory"/>.
    /// </summary>
    /// <param name="ctx">The <see cref="CILReflectionContext"/>.</param>
    /// <param name="thisRuntimeRoot">The directory containing assemblies of currently loaded runtime.</param>
    /// <param name="assemblyDirectory">The directory where moniker assemblies reside. This should have its last character as the directory separator of the current operating system.</param>
    /// <param name="streamOpener">The callback to open a file given a specific path.</param>
    /// <param name="monikerInfo">The information about framework moniker.</param>
    /// <returns>A new <see cref="EmittingAssemblyMapper"/> that will redirect references from currently loaded runtime to other runtime.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="thisRuntimeRoot"/>, <paramref name="assemblyDirectory"/>, <paramref name="monikerInfo"/> or <paramref name="streamOpener"/> is <c>null</c>.</exception>
    /// <exception cref="NullReferenceException">If <paramref name="ctx"/> is <c>null</c>.</exception>
    public static EmittingAssemblyMapper CreateMapperForFrameworkMoniker(this CILReflectionContext ctx, String thisRuntimeRoot, String assemblyDirectory, Func <String, Stream> streamOpener, FrameworkMonikerInfo monikerInfo)
    {
        if (ctx == null)
        {
            throw new NullReferenceException();
        }

        ArgumentValidator.ValidateNotNull("This runtime root directory", thisRuntimeRoot);
        ArgumentValidator.ValidateNotNull("Moniker information.", monikerInfo);

        var loader = new AssemblyLoaderFromBasePath(ctx, assemblyDirectory, streamOpener, monikerInfo.MsCorLibAssembly);

        return(new CachingEmittingAssemblyMapper(monikerInfo.Assemblies.ToDictionary(
                                                     kvp => new CILAssemblyName(kvp.Key, kvp.Value.Item1.Major, kvp.Value.Item1.Minor, kvp.Value.Item1.Build, kvp.Value.Item1.Revision),
                                                     kvp => new Lazy <CILAssembly>(() => loader.LoadFromStreamFunction(assemblyDirectory + "\\" + kvp.Key + ".dll")),
                                                     ASSEMBLY_NAME_COMPARER),
                                                 monikerInfo.Assemblies.ToDictionary(
                                                     kvp => new CILAssemblyName(kvp.Key, kvp.Value.Item1.Major, kvp.Value.Item1.Minor, kvp.Value.Item1.Build, kvp.Value.Item1.Revision),
                                                     kvp => new Lazy <CILAssembly>(() => loader.LoadFromStreamFunction(thisRuntimeRoot + "\\" + kvp.Key + ".dll")),
                                                     ASSEMBLY_NAME_COMPARER)
                                                 ));
    }
    /// <summary>
    /// Loads a new instance of <see cref="CILModule"/> with a contents from <paramref name="stream"/>.
    /// Useful for multi-module assemblies when one doesn't want to load whole assembly.
    /// </summary>
    /// <param name="ctx">The current <see cref="CILReflectionContext"/>.</param>
    /// <param name="stream">The stream to load module from.</param>
    /// <param name="eArgs">The <see cref="EmittingArguments"/> during loading. After successful module load, the additional information about the module will be available in this object.</param>
    /// <returns>A new instance of <see cref="CILModule"/> form the contents of the <paramref name="stream"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="ctx"/> or <paramref name="stream"/> or <paramref name="eArgs"/> is <c>null</c>.</exception>
    /// <exception cref="BadImageFormatException">If the headers or metadata section of the stream has invalid values, or stream contents are otherwise malformed.</exception>
    /// <remarks>
    /// If the module returned by this method is main module, that is, its <c>Assembly</c> table has exactly one row, then the <see cref="EmittingArguments.ModuleAssemblyLoader"/> callback of <paramref name="eArgs"/> will never be used.
    /// Therefore it is ok to pass <c>null</c> as the callback to <paramref name="eArgs"/> if the caller is certain the module will always be the main module.
    /// However, when the module is not the main module, the callback will be used.
    /// If in that situation the callback is <c>null</c>, <see cref="InvalidOperationException"/> is thrown.
    /// The callback may be invoked only by accessing the <see cref="CILModule.Assembly"/> property of the returned <see cref="CILModule"/>.
    /// </remarks>
    public static CILModule LoadModule(this CILReflectionContext ctx, Stream stream, EmittingArguments eArgs)
    {
        ModuleReader mr = null; MetaDataReader md = null;
        var          ownerAssembly = eArgs.ModuleAssemblyLoader;
        var          result        = LoadModule((CILReflectionContextImpl)ctx, stream, eArgs, mod =>
        {
            CILAssemblyImpl ass;
            if (md.assembly.Length == 1)
            {
                ass = LoadAssembly((CILReflectionContextImpl)ctx, null, eArgs, mr, md, mod);
            }
            else
            {
                if (ownerAssembly == null)
                {
                    throw new InvalidOperationException("The callback to get assembly of this module was not provided.");
                }
                ass      = (CILAssemblyImpl)ownerAssembly(mod);
                var mods = ass.InternalModules;
                lock (mods.Lock)
                {
                    if (!mods.Value.CQ.Contains(mod))
                    {
                        mods.Value.Add(mod);
                    }
                }
            }
            return(ass);
        }, out mr, out md);

        if (!eArgs.LazyLoad)
        {
            ForceLoadModule(result);
        }
        return(result);
    }
 public ServiceModelTypeCodeGenerator(Boolean isSilverlight, CILReflectionContext ctx)
     : base(isSilverlight, ctx)
 {
     this.SERVICE_COMPOSITE_ACTIVATE_IF_NEEDED_METHOD = SERVICE_COMPOSITE_ACTIVATE_IF_NEEDED_METHOD_NATIVE.NewWrapper(this.ctx);
     this.METHOD_GENERIC_ARGUMENTS_INFO_CTOR          = METHOD_GENERIC_ARGUMENTS_INFO_CTOR_NATIVE.NewWrapper(this.ctx);
 }
Esempio n. 18
0
        protected AbstractCompositeModelTypeCodeGenerator(Boolean isSilverlight, CILReflectionContext aCtx)
        {
            this.isSilverLight = isSilverlight;
            this.ctx           = aCtx;

            this.COMPOSITE_CTOR_PROPERTIES_PARAM_TYPE = COMPOSITE_CTOR_PROPERTIES_PARAM_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.COMPOSITE_CTOR_EVENTS_PARAM_TYPE     = COMPOSITE_CTOR_EVENTS_PARAM_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.ACTION_REF_TYPE       = ACTION_REF_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.ACTION_REF_TYPES_1    = ACTION_REF_TYPES_1_NATIVE.Select(t => t.NewWrapperAsType(ctx)).ToArray();
            this.ACTION_REF_TYPES_2    = ACTION_REF_TYPES_2_NATIVE.Select(t => t.NewWrapperAsType(ctx)).ToArray();
            this.CHECK_STATE_FUNC_TYPE = CHECK_STATE_FUNC_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.PUBLIC_COMPOSITE_CTOR_ADDITTIONAL_PARAM_TYPES = PUBLIC_COMPOSITE_CTOR_ADDITTIONAL_PARAM_TYPES_NATIVE.Select(t => t.NewWrapperAsType(ctx)).ToArray();
            this.ACTION_TYPE                 = ACTION_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.FRAGMENT_DEPENDANT_TYPE     = FRAGMENT_DEPENDANT_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.FIELD_MODEL_TYPE            = FIELD_MODEL_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.CONSTRUCTOR_MODEL_TYPE      = CONSTRUCTOR_MODEL_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.PARAMETER_MODEL_TYPE        = PARAMETER_MODEL_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.SPECIAL_METHOD_MODEL_TYPE   = SPECIAL_METHOD_MODEL_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.COMPOSITE_METHOD_MODEL_TYPE = COMPOSITE_METHOD_MODEL_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.CONSTRAINT_MODEL_TYPE       = CONSTRAINT_MODEL_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.VOID_TYPE      = VOID_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.OBJECT_TYPE    = OBJECT_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.ATTRIBUTE_TYPE = ATTRIBUTE_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.TYPE_TYPE      = TYPE_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.ABSTRACT_INJECTABLE_MODEL_TYPE = ABSTRACT_INJECTABLE_MODEL_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.CONSTRAINT_TYPE = CONSTRAINT_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.INT32_TYPE      = INT32_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.UINT32_TYPE     = UINT32_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.INT64_TYPE      = INT64_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.BOOLEAN_TYPE    = BOOLEAN_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.SINGLE_TYPE     = SINGLE_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.DOUBLE_TYPE     = DOUBLE_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.INT_PTR_TYPE    = INT_PTR_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.STRING_TYPE     = STRING_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.EXCEPTION_TYPE  = EXCEPTION_TYPE_NATIVE.NewWrapperAsType(ctx);
            //this.WEAK_EVENT_WRAPPER_TYPE = WEAK_EVENT_WRAPPER_TYPE_NATIVE.NewWrapperAsType( ctx );
            //this.STRONG_EVENT_WRAPPER_TYPE = STRONG_EVENT_WRAPPER_TYPE_NATIVE.NewWrapperAsType( ctx );
            this.IENUMERABLE_GDEF_TYPE       = IENUMERABLE_GDEF_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.IENUMERABLE_NO_GDEF_TYPE    = IENUMERABLE_NO_GDEF_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.USE_DEFAULTS_ATTRIBUTE_TYPE = USE_DEFAULTS_ATTRIBUTE_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.COMPOSITE_FACTORY_TYPE      = COMPOSITE_FACTORY_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.REF_ACTION_TYPE             = REF_ACTION_TYPE_NATIVE.NewWrapperAsType(ctx);
            this.REF_FUNCTION_TYPE           = REF_FUNCTION_TYPE_NATIVE.NewWrapperAsType(ctx);

            this.APPLICATION_GETTER_METHOD                = APPLICATION_GETTER_METHOD_NATIVE.NewWrapper(ctx);
            this.STRUCTURE_OWNER_GETTER_METHOD            = STRUCTURE_OWNER_GETTER_METHOD_NATIVE.NewWrapper(ctx);
            this.APPLICATION_IS_PASSIVE_GETTER_METHOD     = APPLICATION_IS_PASSIVE_GETTER_METHOD_NATIVE.NewWrapper(ctx);
            this.INJECTION_SERVICE_GETTER_METHOD          = INJECTION_SERVICE_GETTER_METHOD_NATIVE.NewWrapper(ctx);
            this.COMPOSITE_METHOD_MODEL_PARAMETERS_GETTER = COMPOSITE_METHOD_MODEL_PARAMETERS_GETTER_NATIVE.NewWrapper(ctx);
            this.COMPOSITE_METHOD_RESULT_GETTER           = COMPOSITE_METHOD_RESULT_GETTER_NATIVE.NewWrapper(ctx);
            //this.INJECTABLE_MODEL_INJECTION_SCOPES_GETTER = INJECTABLE_MODEL_INJECTION_SCOPES_GETTER_NATIVE.NewWrapper( ctx );
            this.INJECTION_CONTEXT_PROVIDER_METHOD = INJECTION_CONTEXT_PROVIDER_METHOD_NATIVE.NewWrapper(ctx);
            this.OPTIONAL_ATTRIBUTE_FIELD          = OPTIONAL_ATTRIBUTE_FIELD_NATIVE.NewWrapper(ctx);
            this.CONSTRAINT_MODELS_GETTER          = CONSTRAINT_MODELS_GETTER_NATIVE.NewWrapper(ctx);
            this.CONSTRAINT_ATTRIBUTE_GETTER       = CONSTRAINT_ATTRIBUTE_GETTER_NATIVE.NewWrapper(ctx);
            this.VIOLATIONS_LIST_COUNT_GETTER      = VIOLATIONS_LIST_COUNT_GETTER_NATIVE.NewWrapper(ctx);
            this.METHOD_INFO_NATIVE_GETTER         = METHOD_INFO_NATIVE_GETTER_NATIVE.NewWrapper(ctx);
            this.MODEL_INFO_GETTER = MODEL_INFO_GETTER_NATIVE.NewWrapper(ctx);
            this.MODEL_GETTER      = MODEL_GETTER_NATIVE.NewWrapper(ctx);
            this.C_METHODS_GETTER  = C_METHODS_GETTER_NATIVE.NewWrapper(ctx);
            this.GET_FRAGMENT_INSTANCE_POOL_METHOD = GET_FRAGMENT_INSTANCE_POOL_METHOD_NATIVE.NewWrapper(ctx);
            this.GET_FRAGMENT_INSTANCE_METHOD      = GET_FRAGMENT_INSTANCE_METHOD_NATIVE.NewWrapper(ctx);
            this.TAKE_FRAGMENT_INSTANCE_METHOD     = TAKE_FRAGMENT_INSTANCE_METHOD_NATIVE.NewWrapper(ctx);
            this.RETURN_FRAGMENT_INSTANCE_METHOD   = RETURN_FRAGMENT_INSTANCE_METHOD_NATIVE.NewWrapper(ctx);
            this.SPECIAL_METHODS_GETTER            = SPECIAL_METHODS_GETTER_NATIVE.NewWrapper(ctx);
            this.FRAGMENT_GETTER                              = FRAGMENT_GETTER_NATIVE.NewWrapper(ctx);
            this.FRAGMENT_SETTER                              = FRAGMENT_SETTER_NATIVE.NewWrapper(ctx);
            this.COMPOSITES_GETTER                            = COMPOSITES_GETTER_NATIVE.NewWrapper(ctx);
            this.COMPOSITES_GETTER_INDEXER                    = COMPOSITES_GETTER_INDEXER_NATIVE.NewWrapper(ctx);
            this.TYPE_OBJECT_DICTIONARY_GET_METHOD            = TYPE_OBJECT_DICTIONARY_GET_METHOD_NATIVE.NewWrapper(ctx);
            this.GENERIC_FRAGMENT_METHOD                      = GENERIC_FRAGMENT_METHOD_NATIVE.NewWrapper(ctx);
            this.CONSTRAINT_VIOLATION_CONSTRUCTOR             = CONSTRAINT_VIOLATION_CONSTRUCTOR_NATIVE.NewWrapper(ctx);
            this.ADD_CONSTRAINT_VIOLATION_METHOD              = ADD_CONSTRAINT_VIOLATION_METHOD_NATIVE.NewWrapper(ctx);
            this.F_INSTANCE_SET_NEXT_INFO_METHOD              = F_INSTANCE_SET_NEXT_INFO_METHOD_NATIVE.NewWrapper(ctx);
            this.F_INSTANCE_SET_METHOD_RESULT_METHOD          = F_INSTANCE_SET_METHOD_RESULT_METHOD_NATIVE.NewWrapper(ctx);
            this.F_INSTANCE_GET_NEXT_INFO_METHOD              = F_INSTANCE_GET_NEXT_INFO_METHOD_NATIVE.NewWrapper(ctx);
            this.F_INSTANCE_GET_METHOD_RESULT_METHOD          = F_INSTANCE_GET_METHOD_RESULT_METHOD_NATIVE.NewWrapper(ctx);
            this.STRING_CONCAT_METHOD_3                       = STRING_CONCAT_METHOD_3_NATIVE.NewWrapper(ctx);
            this.STRING_CONCAT_METHOD_2                       = STRING_CONCAT_METHOD_2_NATIVE.NewWrapper(ctx);
            this.METHOD_INFO_GET_GARGS_METHOD                 = METHOD_INFO_GET_GARGS_METHOD_NATIVE.NewWrapper(ctx);
            this.MAKE_GENERIC_METHOD_METHOD                   = MAKE_GENERIC_METHOD_METHOD_NATIVE.NewWrapper(ctx);
            this.INVOKE_METHOD_METHOD                         = INVOKE_METHOD_METHOD_NATIVE.NewWrapper(ctx);
            this.GET_METHDO_GDEF                              = GET_METHDO_GDEF_NATIVE.NewWrapper(ctx);
            this.GET_CTOR_INDEX_METHOD                        = GET_CTOR_INDEX_METHOD_NATIVE.NewWrapper(ctx);
            this.APPLICATION_NOT_ACTIVE_EXCEPTION_CONSTRUCTOR = APPLICATION_NOT_ACTIVE_EXCEPTION_CONSTRUCTOR_NATIVE.NewWrapper(ctx);
            this.GET_CONSTRAINT_INSTANCE_POOL_METHOD          = GET_CONSTRAINT_INSTANCE_POOL_METHOD_NATIVE.NewWrapper(ctx);
            this.TAKE_CONSTRAINT_INSTANCE_METHOD              = TAKE_CONSTRAINT_INSTANCE_METHOD_NATIVE.NewWrapper(ctx);
            this.RETURN_CONSTRAINT_INSTANCE_METHOD            = RETURN_CONSTRAINT_INSTANCE_METHOD_NATIVE.NewWrapper(ctx);
            this.IS_VALID_METHOD                              = IS_VALID_METHOD_NATIVE.NewWrapper(ctx);
            this.TO_STRING_METHOD                             = TO_STRING_METHOD_NATIVE.NewWrapper(ctx);
            this.RETURN_CONCERN_INVOCATION_METHOD             = RETURN_CONCERN_INVOCATION_METHOD_NATIVE.NewWrapper(ctx);
            this.RETURN_SIDE_EFFECT_INVOCATION_METHOD         = RETURN_SIDE_EFFECT_INVOCATION_METHOD_NATIVE.NewWrapper(ctx);
            this.EMPTY_OBJECTS_FIELD                          = EMPTY_OBJECTS_FIELD_NATIVE.NewWrapper(ctx);
            this.LIST_QUERY_ITEM_GETTER                       = LIST_QUERY_ITEM_GETTER_NATIVE.NewWrapper(ctx);
            this.FIELDS_GETTER                                = FIELDS_GETTER_NATIVE.NewWrapper(ctx);
            this.FIELD_SET_VALUE_METHOD                       = FIELD_SET_VALUE_METHOD_NATIVE.NewWrapper(ctx);
            this.PROTOTYPE_ACTION_CONSTRUCTOR                 = PROTOTYPE_ACTION_CONSTRUCTOR_NATIVE.NewWrapper(ctx);
            this.EQUALS_METHOD                                = EQUALS_METHOD_NATIVE.NewWrapper(ctx);
            this.HASH_CODE_METHOD                             = HASH_CODE_METHOD_NATIVE.NewWrapper(ctx);
            this.REFERENCE_EQUALS_METHOD                      = REFERENCE_EQUALS_METHOD_NATIVE.NewWrapper(ctx);
            this.GET_TYPE_METHOD                              = GET_TYPE_METHOD_NATIVE.NewWrapper(ctx);
            this.DELEGATE_COMBINE_METHOD                      = DELEGATE_COMBINE_METHOD_NATIVE.NewWrapper(ctx);
            this.DELEGATE_REMOVE_METHOD                       = DELEGATE_REMOVE_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_COMPARE_EXCHANGE_METHOD_GDEF     = INTERLOCKED_COMPARE_EXCHANGE_METHOD_GDEF_NATIVE.NewWrapper(ctx);
            this.GET_EVENT_INFO_METHOD                        = GET_EVENT_INFO_METHOD_NATIVE.NewWrapper(ctx);
            this.COMPOSITE_EVENT_CTOR                         = COMPOSITE_EVENT_CTOR_NATIVE.NewWrapper(ctx);
            this.INVALID_OPERATION_EXCEPTION_CTOR_WITH_STRING = INVALID_OPERATION_EXCEPTION_CTOR_WITH_STRING_NATIVE.NewWrapper(ctx);
            this.QNAME_FROM_TYPE_AND_NAME                     = QNAME_FROM_TYPE_AND_NAME_NATIVE.NewWrapper(ctx);
            this.IS_PROTOTYPE_GETTER                          = IS_PROTOTYPE_GETTER_NATIVE.NewWrapper(ctx);
            this.GET_PROPERTY_INFO_METHOD                     = GET_PROPERTY_INFO_METHOD_NATIVE.NewWrapper(ctx);
            this.COMPOSITE_METHODS_INDEXER                    = COMPOSITE_METHODS_INDEXER_NATIVE.NewWrapper(ctx);
            this.EVENT_MODEL_GETTER                           = EVENT_MODEL_GETTER_NATIVE.NewWrapper(ctx);
            this.PROPERTY_MODEL_GETTER                        = PROPERTY_MODEL_GETTER_NATIVE.NewWrapper(ctx);
            this.COMPOSITE_PROPERTY_CTOR                      = COMPOSITE_PROPERTY_CTOR_NATIVE.NewWrapper(ctx);
            this.INVOCATION_INFO_GETTER                       = INVOCATION_INFO_GETTER_NATIVE.NewWrapper(ctx);
            this.INVOCATION_INFO_SETTER                       = INVOCATION_INFO_SETTER_NATIVE.NewWrapper(ctx);
            this.INVOCATION_INFO_CREATOR_CTOR                 = INVOCATION_INFO_CREATOR_CTOR_NATIVE.NewWrapper(ctx);
            this.INVOCATION_INFO_METHOD_GETTER                = INVOCATION_INFO_METHOD_GETTER_NATIVE.NewWrapper(ctx);
            this.INVOCATION_INFO_FRAGMENT_METHOD_MODEL_GETTER = INVOCATION_INFO_FRAGMENT_METHOD_MODEL_GETTER_NATIVE.NewWrapper(ctx);
            this.INVOCATION_INFO_FRAGMENT_METHOD_MODEL_SETTER = INVOCATION_INFO_FRAGMENT_METHOD_MODEL_SETTER_NATIVE.NewWrapper(ctx);
            this.CONCERN_MODELS_GETTER                        = CONCERN_MODELS_GETTER_NATIVE.NewWrapper(ctx);
            this.CONCERN_MODELS_INDEXER                       = CONCERN_MODELS_INDEXER_NATIVE.NewWrapper(ctx);
            this.MIXIN_MODEL_GETTER                           = MIXIN_MODEL_GETTER_NATIVE.NewWrapper(ctx);
            this.SIDE_EFFECT_MODELS_GETTER                    = SIDE_EFFECT_MODELS_GETTER_NATIVE.NewWrapper(ctx);
            this.SIDE_EFFECT_MODELS_INDEXER                   = SIDE_EFFECT_MODELS_INDEXER_NATIVE.NewWrapper(ctx);
            this.COLLECTION_ADD_ONLY_ADD_METHOD               = COLLECTION_ADD_ONLY_ADD_METHOD_NATIVE.NewWrapper(ctx);
            this.ACTION_0_CTOR                                = ACTION_0_CTOR_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_EXCHANGE_METHOD_GDEF             = INTERLOCKED_EXCHANGE_METHOD_GDEF_NATIVE.NewWrapper(ctx);
            this.GET_INVOCATION_LIST_METHOD                   = GET_INVOCATION_LIST_METHOD_NATIVE.NewWrapper(ctx);
            this.ADD_LAST_METHOD                              = ADD_LAST_METHOD_NATIVE.NewWrapper(ctx);
            //this.WEAK_EVENT_ARRAY_WRAPPER_ARRAY_GETTER = WEAK_EVENT_ARRAY_WRAPPER_ARRAY_GETTER_NATIVE.NewWrapper( ctx );
            //this.WEAK_EVENT_ARRAY_WRAPPER_COUNT_GETTER = WEAK_EVENT_ARRAY_WRAPPER_COUNT_GETTER_NATIVE.NewWrapper( ctx );
            //this.WEAK_EVENT_ARRAY_CLEANUP_METHOD = WEAK_EVENT_ARRAY_CLEANUP_METHOD_NATIVE.NewWrapper( ctx );
            //this.WEAK_EVENT_ARRAY_COMBINE_METHOD = WEAK_EVENT_ARRAY_COMBINE_METHOD_NATIVE.NewWrapper( ctx );
            //this.WEAK_EVENT_ARRAY_REMOVE_METHOD = WEAK_EVENT_ARRAY_REMOVE_METHOD_NATIVE.NewWrapper( ctx );
            //this.IS_EVENT_INFO_DEAD_METHOD = IS_EVENT_INFO_DEAD_METHOD_NATIVE.NewWrapper( ctx );
            //this.EVENT_INFO_TARGET_GETTER = EVENT_INFO_TARGET_GETTER_NATIVE.NewWrapper( ctx );
            //this.EVENT_INFO_METHOD_GETTER = EVENT_INFO_METHOD_GETTER_NATIVE.NewWrapper( ctx );
            //this.EVENT_INFO_CTOR = EVENT_INFO_CTOR_NATIVE.NewWrapper( ctx );
            this.Q_NAME_GET_BARE_TYPE_NAME_METHOD       = Q_NAME_GET_BARE_TYPE_NAME_METHOD_NATIVE.NewWrapper(ctx);
            this.Q_NAME_FROM_MEMBER_INFO_METHOD         = Q_NAME_FROM_MEMBER_INFO_METHOD_NATIVE.NewWrapper(ctx);
            this.INJECTION_EXCEPTION_CTOR               = INJECTION_EXCEPTION_CTOR_NATIVE.NewWrapper(ctx);
            this.CHECK_STATE_METHOD_SIG                 = CHECK_STATE_METHOD_SIG_NATIVE.NewWrapper(ctx);
            this.CONSTRAINT_EXCEPTION_VIOLATIONS_GETTER = CONSTRAINT_EXCEPTION_VIOLATIONS_GETTER_NATIVE.NewWrapper(ctx);
            this.CONSTRAINT_VIOLATIONS_DIC_ADD_METHOD   = CONSTRAINT_VIOLATIONS_DIC_ADD_METHOD_NATIVE.NewWrapper(ctx);
            this.CONSTRAINT_VIOLATIONS_DIC_CTOR         = CONSTRAINT_VIOLATIONS_DIC_CTOR_NATIVE.NewWrapper(ctx);
            this.CHECK_ACTION_FUNC_CTOR                 = CHECK_ACTION_FUNC_CTOR_NATIVE.NewWrapper(ctx);
            this.SET_DEFAULTS_METHOD_SIG                = SET_DEFAULTS_METHOD_SIG_NATIVE.NewWrapper(ctx);
            this.CONSTRAINT_VIOLATIONS_LIST_CTOR        = CONSTRAINT_VIOLATIONS_LIST_CTOR_NATIVE.NewWrapper(ctx);
            this.EXCEPTION_LIST_CTOR = EXCEPTION_LIST_CTOR_NATIVE.NewWrapper(ctx);
            this.FUNC_1_CTOR         = FUNC_1_CTOR_NATIVE.NewWrapper(ctx);
            this.FUNC_2_CTOR         = FUNC_2_CTOR_NATIVE.NewWrapper(ctx);
            this.FUNC_3_CTOR         = FUNC_3_CTOR_NATIVE.NewWrapper(ctx);
            this.ACTION_1_CTOR       = ACTION_1_CTOR_NATIVE.NewWrapper(ctx);
            this.LAZY_GDEF_CTOR      = LAZY_GDEF_CTOR_NATIVE.NewWrapper(ctx);
            this.FRAGMENT_INSTANCE_CTOR_NO_PARAMS   = FRAGMENT_INSTANCE_CTOR_NO_PARAMS_NATIVE.NewWrapper(ctx);
            this.FRAGMENT_INSTANCE_CTOR_WITH_PARAMS = FRAGMENT_INSTANCE_CTOR_WITH_PARAMS_NATIVE.NewWrapper(ctx);
            this.MODEL_CTORS_GETTER                 = MODEL_CTORS_GETTER_NATIVE.NewWrapper(ctx);
            this.FRAGMENT_DEPENDANT_GETTER          = FRAGMENT_DEPENDANT_GETTER_NATIVE.NewWrapper(ctx);
            this.FRAGMENT_DEPENDANT_SETTER          = FRAGMENT_DEPENDANT_SETTER_NATIVE.NewWrapper(ctx);
            this.FRAGMENT_DEPENDANT_PROPERTY        = FRAGMENT_DEPENDANT_PROPERTY_NATIVE.NewWrapper(ctx);
            this.CONCERN_INVOCATION_INFO_ITEM_1     = CONCERN_INVOCATION_INFO_ITEM_1_NATIVE.NewWrapper(ctx);
            this.CONCERN_INVOCATION_INFO_ITEM_2     = CONCERN_INVOCATION_INFO_ITEM_2_NATIVE.NewWrapper(ctx);
            this.SIDE_EFFECT_INVOCATION_INFO_ITEM_1 = SIDE_EFFECT_INVOCATION_INFO_ITEM_1_NATIVE.NewWrapper(ctx);
            this.SIDE_EFFECT_INVOCATION_INFO_ITEM_2 = SIDE_EFFECT_INVOCATION_INFO_ITEM_2_NATIVE.NewWrapper(ctx);
            this.SIDE_EFFECT_INVOCATION_INFO_ITEM_3 = SIDE_EFFECT_INVOCATION_INFO_ITEM_3_NATIVE.NewWrapper(ctx);
            this.OBJECT_CTOR             = OBJECT_CTOR_NATIVE.NewWrapper(ctx);
            this.NULLABLE_CTOR           = NULLABLE_CTOR_NATIVE.NewWrapper(ctx);
            this.DEFAULT_CREATOR_GETTER  = DEFAULT_CREATOR_GETTER_NATIVE.NewWrapper(ctx);
            this.DEFAULT_CREATOR_INVOKER = DEFAULT_CREATOR_INVOKER_NATIVE.NewWrapper(ctx);
            this.NO_POOL_ATTRIBUTE_CTOR  = NO_POOL_ATTRIBUTE_CTOR_NATIVE.NewWrapper(ctx);
            this.MAIN_PUBLIC_COMPOSITE_TYPE_ATTRIBUTE_CTOR = MAIN_PUBLIC_COMPOSITE_TYPE_ATTRIBUTE_CTOR_NATIVE.NewWrapper(ctx);
            this.CONSTRAINT_VIOLATION_LIST_CTOR            = CONSTRAINT_VIOLATION_LIST_CTOR_NATIVE.NewWrapper(ctx);
            this.CONSTRAINT_VIOLATION_EXCEPTION_CTOR       = CONSTRAINT_VIOLATION_EXCEPTION_CTOR_NATIVE.NewWrapper(ctx);
            this.INTERNAL_EXCEPTION_CTOR = INTERNAL_EXCEPTION_CTOR_NATIVE.NewWrapper(ctx);
            this.AGGREGATE_EXCEPTION_EXCEPTION_ENUMERABLE_CTOR = AGGREGATE_EXCEPTION_EXCEPTION_ENUMERABLE_CTOR_NATIVE.NewWrapper(ctx);
            this.DEBUGGER_DISPLAY_ATTRIBUTE_STRING_CTOR        = DEBUGGER_DISPLAY_ATTRIBUTE_STRING_CTOR_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_READ_I64_METHOD                 = INTERLOCKED_READ_I64_METHOD_NATIVE == null ? null : INTERLOCKED_READ_I64_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_EXCHANGE_I32_METHOD             = INTERLOCKED_EXCHANGE_I32_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_EXCHANGE_I64_METHOD             = INTERLOCKED_EXCHANGE_I64_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_EXCHANGE_R32_METHOD             = INTERLOCKED_EXCHANGE_R32_METHOD_NATIVE == null ? null : INTERLOCKED_EXCHANGE_R32_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_EXCHANGE_R64_METHOD             = INTERLOCKED_EXCHANGE_R64_METHOD_NATIVE == null ? null : INTERLOCKED_EXCHANGE_R64_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_EXCHANGE_INT_PTR_METHOD         = INTERLOCKED_EXCHANGE_INT_PTR_METHOD_NATIVE == null ? null : INTERLOCKED_EXCHANGE_INT_PTR_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_EXCHANGE_OBJECT_METHOD          = INTERLOCKED_EXCHANGE_OBJECT_METHOD_NATIVE == null ? null : INTERLOCKED_EXCHANGE_OBJECT_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_COMPARE_EXCHANGE_I32_METHOD     = INTERLOCKED_COMPARE_EXCHANGE_I32_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_COMPARE_EXCHANGE_I64_METHOD     = INTERLOCKED_COMPARE_EXCHANGE_I64_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_COMPARE_EXCHANGE_R32_METHOD     = INTERLOCKED_COMPARE_EXCHANGE_R32_METHOD_NATIVE == null ? null : INTERLOCKED_COMPARE_EXCHANGE_R32_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_COMPARE_EXCHANGE_R64_METHOD     = INTERLOCKED_COMPARE_EXCHANGE_R64_METHOD_NATIVE == null ? null : INTERLOCKED_COMPARE_EXCHANGE_R64_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_COMPARE_EXCHANGE_INT_PTR_METHOD = INTERLOCKED_COMPARE_EXCHANGE_INT_PTR_METHOD_NATIVE == null ? null : INTERLOCKED_COMPARE_EXCHANGE_INT_PTR_METHOD_NATIVE.NewWrapper(ctx);
            this.INTERLOCKED_COMPARE_EXCHANGE_OBJECT_METHOD  = INTERLOCKED_COMPARE_EXCHANGE_OBJECT_METHOD_NATIVE.NewWrapper(ctx);
            this.COMPOSITE_TYPE_ID_CTOR   = COMPOSITE_TYPE_ID_CTOR_NATIVE.NewWrapper(ctx);
            this.COMPOSITE_FACTORY_METHOD = COMPOSITE_FACTORY_METHOD_NATIVE.NewWrapper(ctx);
            this.COMPOSITE_CALLBACK_GET_COMPOSITE_METHOD_METHOD = COMPOSITE_CALLBACK_GET_COMPOSITE_METHOD_METHOD_NATIVE.NewWrapper(ctx);
            this.ARGUMENT_EXCEPTION_STRING_CTOR         = ARGUMENT_EXCEPTION_STRING_CTOR_NATIVE.NewWrapper(ctx);
            this.MAKE_GENERIC_TYPE_METHOD               = MAKE_GENERIC_TYPE_METHOD_NATIVE.NewWrapper(ctx);
            this.GET_FIRST_INSTANCE_CTOR                = GET_FIRST_INSTANCE_CTOR_NATIVE.NewWrapper(ctx);
            this.CONSTRUCTOR_INVOKE_METHOD              = CONSTRUCTOR_INVOKE_METHOD_NATIVE.NewWrapper(ctx);
            this.INT_PTR_SIZE_GETTER                    = INT_PTR_SIZE_GETTER_NATIVE.NewWrapper(ctx);
            this.REF_ACTION_INVOKER                     = REF_ACTION_INVOKER_NATIVE.NewWrapper(ctx);
            this.REF_FUNCTION_INVOKER                   = REF_FUNCTION_INVOKER_NATIVE.NewWrapper(ctx);
            this.REF_INVOKER_CALLBACK_CTOR              = REF_INVOKER_CALLBACK_CTOR_NATIVE.NewWrapper(ctx);
            this.COMPOSITE_METHOD_MODEL_INDEX_ATTRIBUTE = COMPOSITE_METHOD_MODEL_INDEX_ATTRIBUTE_NATIVE.NewWrapper(ctx);
            this.SPECIAL_METHOD_MODEL_INDEX_ATTRIBUTE   = SPECIAL_METHOD_MODEL_INDEX_ATTRIBUTE_NATIVE.NewWrapper(ctx);
            this.CONSTRUCTOR_MODEL_INDEX_ATTRIBUTE      = CONSTRUCTOR_MODEL_INDEX_ATTRIBUTE_NATIVE.NewWrapper(ctx);
            this.DOUBLE_BITS_TO_INT64                   = DOUBLE_BITS_TO_INT64_NATIVE.NewWrapper(ctx);
            this.INT64_BITS_TO_DOUBLE                   = INT64_BITS_TO_DOUBLE_NATIVE.NewWrapper(ctx);
            this.GET_BYTES_INT32  = GET_BYTES_INT32_NATIVE.NewWrapper(ctx);
            this.GET_BYTES_SINGLE = GET_BYTES_INT32_NATIVE.NewWrapper(ctx);
            this.BYTES_TO_INT32   = GET_BYTES_INT32_NATIVE.NewWrapper(ctx);
            this.BYTES_TO_SINGLE  = GET_BYTES_INT32_NATIVE.NewWrapper(ctx);
        }
Esempio n. 19
0
 /// <summary>
 /// Gets or creates a new <see cref="CILMethodBase"/> based on native <see cref="System.Reflection.MethodBase"/>. The actual return value will be either <see cref="CILMethod"/> or <see cref="CILConstructor"/>.
 /// </summary>
 /// <param name="methodBase">The native method base.</param>
 /// <param name="ctx">The current reflection context.</param>
 /// <returns><see cref="CILMethodBase"/> wrapping existing native <see cref="System.Reflection.MethodBase"/>.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="methodBase"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
 public static CILMethodBase NewWrapperFromBase(this System.Reflection.MethodBase methodBase, CILReflectionContext ctx)
 {
     return(methodBase is System.Reflection.ConstructorInfo ? (CILMethodBase)((System.Reflection.ConstructorInfo)methodBase).NewWrapper(ctx) : ((System.Reflection.MethodInfo)methodBase).NewWrapper(ctx));
 }
Esempio n. 20
0
    /// <summary>
    /// Gets or creates a new <see cref="CILParameter"/> based on native <see cref="System.Reflection.ParameterInfo"/>.
    /// </summary>
    /// <param name="param">The native parameter.</param>
    /// <param name="ctx">The current reflection context.</param>
    /// <returns><see cref="CILParameter"/> wrapping existing native <see cref="System.Reflection.ParameterInfo"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="param"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
    public static CILParameter NewWrapper(this System.Reflection.ParameterInfo param, CILReflectionContext ctx)
    {
        ArgumentValidator.ValidateNotNull("Module", param);
        ArgumentValidator.ValidateNotNull("Reflection context", ctx);

        return(((CILReflectionContextImpl)ctx).Cache.GetOrAdd(param));
    }
Esempio n. 21
0
    /// <summary>
    /// Gets or creates a new <see cref="CILConstructor"/> based on native <see cref="System.Reflection.ConstructorInfo"/>.
    /// </summary>
    /// <param name="ctor">The native constructor.</param>
    /// <param name="ctx">The current reflection context.</param>
    /// <returns><see cref="CILConstructor"/> wrapping existing native <see cref="System.Reflection.ConstructorInfo"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="ctor"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
    public static CILConstructor NewWrapper(this System.Reflection.ConstructorInfo ctor, CILReflectionContext ctx)
    {
        ArgumentValidator.ValidateNotNull("Constructor", ctor);
        ArgumentValidator.ValidateNotNull("Reflection context", ctx);

        return(((CILReflectionContextImpl)ctx).Cache.GetOrAdd(ctor));
    }
Esempio n. 22
0
        internal AbstractSignatureElement(CILReflectionContext ctx)
        {
            ArgumentValidator.ValidateNotNull("Context", ctx);

            this._ctx = (CILReflectionContextImpl)ctx;
        }
        private IDictionary <Assembly, CILModule> PerformEmitting(Boolean isSilverlight, CILReflectionContext reflectionContext, out IDictionary <CompositeModel, CompositeEmittingInfo> cResultsOut)
        {
            var typeModelDic    = this._typeModelDic.Value;
            var assembliesArray = this._affectedAssemblies.Value.ToArray();
            var models          = this._models.CQ.Values.ToArray();
            var supports        = this._compositeModelTypeSupport;
            var cResults        = models.ToDictionary(muudel => muudel, muudel => new CompositeEmittingInfo(reflectionContext, models));

            cResultsOut = cResults;
            var codeGens = models
                           .Select(muudel => supports[muudel.ModelType])
                           .Distinct()
                           .ToDictionary(mt => mt.AssemblyScopeSupport.ModelType, mt => Tuple.Create(mt.NewCodeGenerator(isSilverlight, reflectionContext), mt.CodeGenerationInfo));

            var assemblyDic = new Dictionary <Assembly, CILModule>();

            foreach (var currentAssembly in assembliesArray)
            {
                if (!ReflectionHelper.QI4CS_ASSEMBLY.Equals(currentAssembly))
                {
                    var assemblyBareFileName = Qi4CSGeneratedAssemblyAttribute.GetGeneratedAssemblyName(currentAssembly);

                    var ass  = reflectionContext.NewBlankAssembly(assemblyBareFileName);
                    var eAss = currentAssembly.NewWrapper(reflectionContext);
                    ass.Name.MajorVersion = eAss.Name.MajorVersion;
                    ass.Name.MinorVersion = eAss.Name.MinorVersion;
                    ass.Name.BuildNumber  = eAss.Name.BuildNumber;
                    ass.Name.Revision     = eAss.Name.Revision;
                    ass.Name.Culture      = eAss.Name.Culture;

                    ass.AddNewCustomAttributeTypedParams(ASS_TITLE_ATTRIBUTE_CTOR.NewWrapper(reflectionContext), CILCustomAttributeFactory.NewTypedArgument(assemblyBareFileName, reflectionContext));
                    ass.AddNewCustomAttributeTypedParams(ASS_DESCRIPTION_ATTRIBUTE_CTOR.NewWrapper(reflectionContext), CILCustomAttributeFactory.NewTypedArgument((assemblyBareFileName + " Enhanced by Qi4CS."), reflectionContext));
                    //ass.AddNewCustomAttributeTypedParams( ASS_DEFAULT_ALIAS_ATTRIBUTE_CTOR.NewWrapper( reflectionContext ), CILCustomAttributeFactory.NewTypedArgument( assemblyBareFileName, reflectionContext ) );
                    ass.AddNewCustomAttributeTypedParams(QI4CS_GENERATED_ATTRIBUTE_CTOR.NewWrapper(reflectionContext));

                    var mod = ass.AddModule(assemblyBareFileName + ".dll");
                    assemblyDic.Add(currentAssembly, mod);
                }
            }

            // Phase 1: Emit empty types
            System.Threading.Tasks.Parallel.ForEach(assembliesArray, currentAssembly =>
            {
                foreach (var model in models)
                {
                    var tuple1 = codeGens[model.ModelType];
                    var tuple2 = cResults[model];
                    tuple1.Item1.EmitTypesForModel(model, typeModelDic[model], currentAssembly, GetEmittingModule(model, assemblyDic, currentAssembly), tuple1.Item2, tuple2);
                }
            });

            // Phase 2: Emit fragment methods
            System.Threading.Tasks.Parallel.ForEach(assembliesArray, currentAssembly =>
            {
                foreach (var model in models)
                {
                    var tuple1 = codeGens[model.ModelType];
                    var tuple2 = cResults[model];
                    tuple1.Item1.EmitFragmentMethods(model, typeModelDic[model], currentAssembly, tuple1.Item2, tuple2);
                }
            });

            // Phase 3: Emit composite methods and concern & side-effect invocation types
            System.Threading.Tasks.Parallel.ForEach(assembliesArray, currentAssembly =>
            {
                foreach (var model in models)
                {
                    var tuple1 = codeGens[model.ModelType];
                    var tuple2 = cResults[model];
                    tuple1.Item1.EmitCompositeMethosAndInvocationInfos(model, typeModelDic[model], currentAssembly, tuple1.Item2, tuple2);
                }
            });

            // Phase 4: Emit all composite extra methods (state check, pre-prototype, etc)
            System.Threading.Tasks.Parallel.ForEach(assembliesArray, currentAssembly =>
            {
                foreach (var model in models)
                {
                    var tuple1 = codeGens[model.ModelType];
                    var tuple2 = cResults[model];
                    tuple1.Item1.EmitCompositeExtraMethods(model, typeModelDic[model], currentAssembly, tuple1.Item2, tuple2);
                }
            });

            // Phase 5: Emit all composite constructors
            System.Threading.Tasks.Parallel.ForEach(assembliesArray, currentAssembly =>
            {
                foreach (var model in models)
                {
                    var tuple1 = codeGens[model.ModelType];
                    var tuple2 = cResults[model];
                    tuple1.Item1.EmitCompositeConstructors(model, typeModelDic[model], currentAssembly, tuple1.Item2, tuple2);
                }
            });

            // Phase 6: Emit all composite factory types
            System.Threading.Tasks.Parallel.ForEach(assembliesArray, currentAssembly =>
            {
                foreach (var model in models)
                {
                    var tuple1 = codeGens[model.ModelType];
                    var tuple2 = cResults[model];
                    tuple1.Item1.EmitCompositeFactory(model, currentAssembly, GetEmittingModule(model, assemblyDic, currentAssembly), tuple1.Item2, tuple2);
                }
            });

            return(assemblyDic);
        }
        public DictionaryQuery <Assembly, CILAssemblyManipulator.API.CILAssembly> GenerateCode(CILReflectionContext reflectionContext, Boolean isSilverlight)
        {
            var validationResult = this.ValidationResult;

            CheckValidation(validationResult, "Tried to emit code based on application model with validation errors.");

            IDictionary <CompositeModel, CompositeEmittingInfo> cResults;
            var assDic = this.PerformEmitting(isSilverlight, reflectionContext, out cResults);

            this.ApplicationCodeGenerationEvent.InvokeEventIfNotNull(evt => evt(this, new ApplicationCodeGenerationArgs(
                                                                                    this.CollectionsFactory.NewDictionaryProxy(cResults.ToDictionary(
                                                                                                                                   kvp => kvp.Key,
                                                                                                                                   kvp => this.CollectionsFactory.NewDictionaryProxy(
                                                                                                                                       kvp.Value.GetAllPublicComposites(kvp.Key).ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2.Builder)
                                                                                                                                       ).CQ
                                                                                                                                   )).CQ
                                                                                    )));

            return(this.CollectionsFactory.NewDictionaryProxy(assDic.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Assembly)).CQ);
        }
 /// <summary>
 /// Creates a new <see cref="CILMethodSignature"/> which has all its information specified from the parameters of this method.
 /// </summary>
 /// <param name="ctx">The current <see cref="CILReflectionContext"/>.</param>
 /// <param name="currentModule">The current <see cref="CILModule"/>.</param>
 /// <param name="callingConventions">The <see cref="UnmanagedCallingConventions"/> for the method signature.</param>
 /// <param name="returnType">The return type for the method signature.</param>
 /// <param name="paramTypes">The types of the parameters.</param>
 /// <returns>A new <see cref="CILMethodSignature"/>.</returns>
 /// <exception cref="NullReferenceException">If <paramref name="ctx"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentNullException">If <paramref name="currentModule"/>, <paramref name="returnType"/> or any of the types within <paramref name="paramTypes"/> is <c>null</c>.</exception>
 /// <seealso cref="CILMethodSignature"/>
 public static CILMethodSignature NewMethodSignature(this CILReflectionContext ctx, CILModule currentModule, UnmanagedCallingConventions callingConventions, CILTypeBase returnType, params CILTypeBase[] paramTypes)
 {
     return(NewMethodSignature(ctx, currentModule, callingConventions, returnType, null, paramTypes.Select(pt => Tuple.Create((CILCustomModifier[])null, pt)).ToArray()));
 }
Esempio n. 26
0
 public PlainCompositeModelTypeCodeGenerator(Boolean isSilverlight, CILReflectionContext ctx)
     : base(isSilverlight, ctx)
 {
 }
Esempio n. 27
0
    /// <summary>
    /// Gets or creates a new <see cref="CILProperty"/> based on native <see cref="System.Reflection.PropertyInfo"/>.
    /// </summary>
    /// <param name="property">The native property.</param>
    /// <param name="ctx">The current reflection context.</param>
    /// <returns><see cref="CILProperty"/> wrapping existing native <see cref="System.Reflection.PropertyInfo"/>.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="property"/> or <paramref name="ctx"/> is <c>null</c>.</exception>
    public static CILProperty NewWrapper(this System.Reflection.PropertyInfo property, CILReflectionContext ctx)
    {
        ArgumentValidator.ValidateNotNull("Property", property);
        ArgumentValidator.ValidateNotNull("Context", ctx);

        return(((CILReflectionContextImpl)ctx).Cache.GetOrAdd(property));
    }