private void _FillWithModuleInfo(Module module)
        {
            this._assembly           = module.Assembly;
            this._name               = module.Name;
            this._fullyQualifiedName = module.FullyQualifiedName;
            this._versionIDAsGUID    = module.ModuleVersionId;
            this._versionID          = this._versionIDAsGUID.ToString();
            this._metadataVersion    = module.MDStreamVersion.ToString();

            PortableExecutableKinds PEKinds;
            ImageFileMachine        imageFileMachine;

            module.GetPEKind(out PEKinds, out imageFileMachine);

            this._PEKindName           = PEKinds.ToString();
            this._imageFileMachineName = imageFileMachine.ToString();

            if (this._versionIDAsGUID == this._assembly.ManifestModule.ModuleVersionId)
            {
                this._manifestModule = module;
            }

            return;
        }
Exemplo n.º 2
0
        private void _FillWithAssemblyInfoForAsync(TypeInfo type)
        {
            /*
             *
             * https://github.com/dotnet/coreclr/pull/9491/commits/49d2d8f711286bf4ab3ffcd7b9f89a2ec80725bd
             *
             * => Avoid the use of Assembly.GetExecutingAssembly().
             *
             * The Assembly.GetExecutingAssembly() is no inlined because of the way that it was implemented. So we have a loss on performance.
             *
             * => Typically, to get a reference to the instance of the assembly in execution, using the following:
             *
             * Assembly assembly = typeof( Program ).Assembly;
             *
             * Better yet, since .NET Framework 4.5 and .NET Core 1.0, we have the System.Reflection.TypeInfo abstract .net class that is is based on System.Type and System.Reflection.IReflectableType. This new types includes a series of improvements that are explained in the book material.
             *
             * public abstract class TypeInfo : Type, System.Reflection.IReflectableType{...}
             *
             */

            if (type == null)
            {
                type = IntrospectionExtensions.GetTypeInfo(typeof(RVJ.Core.AssemblyInfoView));
            }

            this._assembly = IntrospectionExtensions.GetTypeInfo(type).Assembly;

            this._assemblyName = this._assembly.GetName();
            this._version      = this._assemblyName.Version;

            this._manifestModule = this._assembly.ManifestModule;

            PortableExecutableKinds PEKinds;
            ImageFileMachine        imageFileMachine;

            this._manifestModule.GetPEKind(out PEKinds, out imageFileMachine);


            this._PEKindName           = PEKinds.ToString();
            this._imageFileMachineName = imageFileMachine.ToString();

            this._FillWithInfoOfDefinedTypesForAsync(this._assembly);

            /*
             * Add all modules to the module list. The ModuleInfoView instances of collection will be filled using the information in these instances of Module, referenced by this._modules list.
             */
            this._manifestModule = this._assembly.ManifestModule;

            /*
             * Check for not duplicate manifest module information.
             * If collection of modules already has the instance of the manifest module, start from the second module in the colletion returned by GetModules() method.
             */

            this._modules.AddRange(this._assembly.GetModules());

            foreach (Module module in this._modules)
            {
                IModuleInfoView item = new ModuleInfoView(module);
                this._moduleInfoViewCollection.Add(item);
            }


            return;
        }