Ejemplo n.º 1
0
        private static IReadOnlyList <XElement> OtherProperties(AssemblyAttributes assemblyAttributes,
                                                                PackageConfiguration packageConfig, IProgress <string> progress)
        {
            var toReturn = new[]
            {
                CreateElementIfNotNull(assemblyAttributes.Title, "AssemblyTitle"),
                CreateElementIfNotNull(assemblyAttributes.Company, "Company"),
                CreateElementIfNotNull(assemblyAttributes.Product, "Product"),

                //And a couple of properties which can be superceded by the package config
                CreateElementIfNotNull(assemblyAttributes.Description, packageConfig?.Description, "Description", progress),
                CreateElementIfNotNull(assemblyAttributes.Copyright, packageConfig?.Copyright, "Copyright", progress),

                assemblyAttributes.Configuration != null
                                        ?
                //If it is included, chances are that the developer has used
                //preprocessor flags which we can't yet process
                //so just leave it in AssemblyInfo file
                new XElement("GenerateAssemblyConfigurationAttribute", false)
                                        : null
            }.Where(x => x != null).ToArray();

            assemblyAttributes.Title       = null;
            assemblyAttributes.Company     = null;
            assemblyAttributes.Description = null;
            assemblyAttributes.Product     = null;
            assemblyAttributes.Copyright   = null;

            return(toReturn);
        }
Ejemplo n.º 2
0
        private static string AssemblyAttributesAsString(AssemblyAttributes assemblyAttributes)
        {
            if (assemblyAttributes != null)
            {
                var attributesTrace = new
                                      StringBuilder($"Contents of {assemblyAttributes.GetType().Name} assemblyAttributes:\n");

                attributesTrace.AppendLine($"     AssemblyDisplayName: {assemblyAttributes.AssemblyDisplayName}");
                attributesTrace.AppendLine($"        AssemblyLocation: {assemblyAttributes.AssemblyLocation}");
                attributesTrace.AppendLine($"                Commpany: {assemblyAttributes.Commpany}");
                attributesTrace.AppendLine($"           Configuration: {assemblyAttributes.Configuration}");
                attributesTrace.AppendLine($"               Copyright: {assemblyAttributes.Copyright}");
                attributesTrace.AppendLine($"             Description: {assemblyAttributes.Description}");
                attributesTrace.AppendLine($"     AssemblyFileVersion: {assemblyAttributes.AssemblyFileVersion}");
                attributesTrace.AppendLine($"    InformationalVersion: {assemblyAttributes.InformationalVersion}");
                attributesTrace.AppendLine($"                 Product: {assemblyAttributes.Product}");
                attributesTrace.AppendLine($"           AssemblyTitle: {assemblyAttributes.AssemblyTitle}");
                attributesTrace.AppendLine($"         AssemblyVersion: {assemblyAttributes.AssemblyVersion}");

                return(attributesTrace.ToString());
            }

            else
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 3
0
        private static void ShowAssemblyAttributes(AssemblyAttributes assemblyAttributes)
        {
            var trace = AssemblyAttributesAsString(assemblyAttributes);

            Console.WriteLine();
            Console.WriteLine(trace);
        }
Ejemplo n.º 4
0
        public ReferenceItem(string assemblyPath, string rootpath, string assembly, string name, Version version, AssemblyAttributes attributes, string culture, byte[] publicKey, byte[] publicKeyToken)
        {
            FilterString       = DisplayName = name;
            _assembly          = assembly;
            _assemblyPath      = assemblyPath;
            _version           = version.ToString();
            _attributes        = attributes;
            _culture           = string.IsNullOrEmpty(culture) ? "Neutral" : culture;
            _publicKey         = getToken(publicKey);
            _publicKeyToken    = getToken(publicKeyToken);
            _assemblyDirectory = rootpath;
            _relativePath      = assemblyPath.Substring(rootpath.Length);
            _relativePath      = assemblyPath.Substring(rootpath.Length);
            var target = System.IO.Path.Combine(_assemblyDirectory, name + ".dll");

            if (File.Exists(target))
            {
                _targetPath = target;
                Path        = target;
                void a()
                {
                    Thumbnail = new NativeFileInfo(target).Icon;
                    Thumbnail.Freeze();
                }

                Task.Factory.StartNew(a);
                ItemType = ItemType.Container;
            }
        }
Ejemplo n.º 5
0
        private void AddAssemblyAttributeNodes(XElement mainPropertyGroup, AssemblyAttributes assemblyAttributes)
        {
            if (assemblyAttributes == null)
            {
                return;
            }

            var attributes = new[]
            {
                new KeyValuePair <string, string>("GenerateAssemblyTitleAttribute", assemblyAttributes.Title),
                new KeyValuePair <string, string>("GenerateAssemblyCompanyAttribute", assemblyAttributes.Company),
                new KeyValuePair <string, string>("GenerateAssemblyDescriptionAttribute", assemblyAttributes.Description),
                new KeyValuePair <string, string>("GenerateAssemblyProductAttribute", assemblyAttributes.Product),
                new KeyValuePair <string, string>("GenerateAssemblyCopyrightAttribute", assemblyAttributes.Copyright),
                new KeyValuePair <string, string>("GenerateAssemblyInformationalVersionAttribute", assemblyAttributes.InformationalVersion),
                new KeyValuePair <string, string>("GenerateAssemblyVersionAttribute", assemblyAttributes.Version),
                new KeyValuePair <string, string>("GenerateAssemblyFileVersionAttribute", assemblyAttributes.FileVersion),
                new KeyValuePair <string, string>("GenerateAssemblyConfigurationAttribute", assemblyAttributes.Configuration)
            };

            var childNodes = attributes
                             .Where(x => x.Value != null)
                             .Select(x => new XElement(x.Key, "false"))
                             .ToArray();

            if (childNodes.Length == 0)
            {
                mainPropertyGroup.Add(new XElement("GenerateAssemblyInfo", "false"));
            }
            else
            {
                mainPropertyGroup.Add(childNodes);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Set or clear flags in <see cref="attributes"/>
        /// </summary>
        /// <param name="set"><c>true</c> if flags should be set, <c>false</c> if flags should
        /// be cleared</param>
        /// <param name="flags">Flags to set or clear</param>
        void ModifyAttributes(bool set, AssemblyAttributes flags)
        {
#if THREAD_SAFE
            int origVal, newVal;
            do
            {
                origVal = attributes;
                if (set)
                {
                    newVal = origVal | (int)flags;
                }
                else
                {
                    newVal = origVal & ~(int)flags;
                }
            } while (Interlocked.CompareExchange(ref attributes, newVal, origVal) != origVal);
#else
            if (set)
            {
                attributes |= (int)flags;
            }
            else
            {
                attributes &= ~(int)flags;
            }
#endif
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Returns a value of custom attribute for the currant assembly.
        /// </summary>
        public static string GetAssemblyAttribute(this Assembly assembly, AssemblyAttributes attributeType)
        {
            var value = string.Empty;

            try
            {
                if (attributeType == AssemblyAttributes.Title)
                {
                    var attr = assembly.GetAssemblyAttribute(typeof(AssemblyTitleAttribute));
                    value = ((AssemblyTitleAttribute)attr).Title;
                }
                else if (attributeType == AssemblyAttributes.Product)
                {
                    var attr = assembly.GetAssemblyAttribute(typeof(AssemblyProductAttribute));
                    value = ((AssemblyProductAttribute)attr).Product;
                }
                else if (attributeType == AssemblyAttributes.Description)
                {
                    var attr = assembly.GetAssemblyAttribute(typeof(AssemblyDescriptionAttribute));
                    value = ((AssemblyDescriptionAttribute)attr).Description;
                }
                else if (attributeType == AssemblyAttributes.Configuration)
                {
                    var attr = assembly.GetAssemblyAttribute(typeof(AssemblyConfigurationAttribute));
                    value = ((AssemblyConfigurationAttribute)attr).Configuration;
                }
                else if (attributeType == AssemblyAttributes.Company)
                {
                    var attr = assembly.GetAssemblyAttribute(typeof(AssemblyCompanyAttribute));
                    value = ((AssemblyCompanyAttribute)attr).Company;
                }
                else if (attributeType == AssemblyAttributes.Copyright)
                {
                    var attr = assembly.GetAssemblyAttribute(typeof(AssemblyCopyrightAttribute));
                    value = ((AssemblyCopyrightAttribute)attr).Copyright;
                }
                else if (attributeType == AssemblyAttributes.Trademark)
                {
                    var attr = assembly.GetAssemblyAttribute(typeof(AssemblyTrademarkAttribute));
                    value = ((AssemblyTrademarkAttribute)attr).Trademark;
                }
                else if (attributeType == AssemblyAttributes.Culture)
                {
                    var attr = assembly.GetAssemblyAttribute(typeof(AssemblyCultureAttribute));
                    value = ((AssemblyCultureAttribute)attr).Culture;
                }
                else if (attributeType == AssemblyAttributes.Version)
                {
                    var attr = assembly.GetAssemblyAttribute(typeof(AssemblyFileVersionAttribute));
                    value = ((AssemblyFileVersionAttribute)attr).Version;
                }
            }

            catch (Exception)
            {
            }
            return(value);
        }
Ejemplo n.º 8
0
		/// <summary>
		/// Modify <see cref="attributes"/> property: <see cref="attributes"/> =
		/// (<see cref="attributes"/> &amp; <paramref name="andMask"/>) | <paramref name="orMask"/>.
		/// </summary>
		/// <param name="andMask">Value to <c>AND</c></param>
		/// <param name="orMask">Value to OR</param>
		void ModifyAttributes(AssemblyAttributes andMask, AssemblyAttributes orMask) {
#if THREAD_SAFE
			int origVal, newVal;
			do {
				origVal = attributes;
				newVal = (origVal & (int)andMask) | (int)orMask;
			} while (Interlocked.CompareExchange(ref attributes, newVal, origVal) != origVal);
#else
			attributes = (attributes & (int)andMask) | (int)orMask;
#endif
		}
Ejemplo n.º 9
0
 void SetFlagValue(AssemblyAttributes flag, bool value)
 {
     if (value)
     {
         Flags |= flag;
     }
     else
     {
         Flags &= ~flag;
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Set or clear flags in <see cref="Attributes"/>
 /// </summary>
 /// <param name="set"><c>true</c> if flags should be set, <c>false</c> if flags should
 /// be cleared</param>
 /// <param name="flags">Flags to set or clear</param>
 void ModifyAttributes(bool set, AssemblyAttributes flags)
 {
     if (set)
     {
         Attributes |= flags;
     }
     else
     {
         Attributes &= ~flags;
     }
 }
        public void PackagePropertiesOverrideAssemblyInfo()
        {
            var project = new Project
            {
                AssemblyAttributes   = BaseAssemblyAttributes(),
                PackageConfiguration = new PackageConfiguration()
                {
                    Copyright   = "Some different copyright",
                    Description = "Some other description",
                    Version     = "1.5.2-otherVersion"
                },
                Deletions      = new List <FileSystemInfo>(),
                PropertyGroups = ProjectPropertyGroups
            };

            var transform = new AssemblyAttributeTransformation(NoopLogger.Instance);

            transform.Transform(project);

            var expectedProperties = new[]
            {
                new XElement("AssemblyTitle", "The Title"),
                new XElement("Company", "TheCompany Inc."),
                new XElement("Description", "Some other description"),
                new XElement("Product", "The Product"),
                new XElement("Copyright", "Some different copyright"),
                new XElement("GenerateAssemblyConfigurationAttribute", false),
                new XElement("Version", "1.5.2-otherVersion"),
                new XElement("AssemblyVersion", "1.0.4.2"),
                new XElement("FileVersion", "1.1.7.9"),
                new XElement("NeutralLanguage", "someLanguage"),
                new XElement("SignAssembly", "true"),
                new XElement("DelaySign", "true"),
                new XElement("AssemblyOriginatorKeyFile", "PublicKey.snk")
            }
            .Select(x => x.ToString())
            .ToList();

            var actualProperties = project.AssemblyAttributeProperties
                                   .Select(x => x.ToString())
                                   .ToList();

            CollectionAssert.AreEquivalent(expectedProperties, actualProperties);

            var expectedAttributes = new AssemblyAttributes
            {
                Configuration = "SomeConfiguration",
                Trademark     = "A trademark",
                Culture       = "A culture"
            };

            Assert.IsTrue(expectedAttributes.Equals(project.AssemblyAttributes));
            CollectionAssert.DoesNotContain(project.Deletions?.ToList(), BaseAssemblyAttributes().File);
        }
Ejemplo n.º 12
0
		public AssemblyOptions(AssemblyDef asm) {
			HashAlgorithm = asm.HashAlgorithm;
			Version = asm.Version;
			Attributes = asm.Attributes;
			PublicKey = asm.PublicKey;
			Name = asm.Name;
			Culture = asm.Culture;
			ClrVersion = Module.ClrVersion.DefaultVersion;
			CustomAttributes.AddRange(asm.CustomAttributes);
			DeclSecurities.AddRange(asm.DeclSecurities);
		}
Ejemplo n.º 13
0
 public AssemblyReference(string name, AssemblyAttributes attributes, Version version, AssemblyHashAlgorithm hashAlgorithm, uint publicKey, string culture)
     : base(new MetaDataRow(
         (byte)version.Major, (byte)version.Minor, (byte)version.Build, (byte)version.Revision,
         (uint)attributes,
         publicKey,
         0U,
         0U,
         (uint)hashAlgorithm))
 {
     this._name = name;
     this._culture = culture;
 }
Ejemplo n.º 14
0
 public AssemblyOptions(AssemblyDef asm)
 {
     this.HashAlgorithm = asm.HashAlgorithm;
     this.Version       = asm.Version;
     this.Attributes    = asm.Attributes;
     this.PublicKey     = asm.PublicKey;
     this.Name          = asm.Name;
     this.Culture       = asm.Culture;
     this.ClrVersion    = Module.ClrVersion.DefaultVersion;
     this.CustomAttributes.AddRange(asm.CustomAttributes);
     this.DeclSecurities.AddRange(asm.DeclSecurities);
 }
Ejemplo n.º 15
0
 public AssemblyReference(string name, AssemblyAttributes attributes, Version version, AssemblyHashAlgorithm hashAlgorithm, uint publicKey, string culture)
     : base(new MetaDataRow(
                (byte)version.Major, (byte)version.Minor, (byte)version.Build, (byte)version.Revision,
                (uint)attributes,
                publicKey,
                0U,
                0U,
                (uint)hashAlgorithm))
 {
     this.name    = name;
     this.culture = culture;
 }
        public void BlankEntriesGetDeleted()
        {
            var baseAssemblyAttributes = BaseAssemblyAttributes();

            baseAssemblyAttributes.Company         = "";
            baseAssemblyAttributes.Copyright       = "";
            baseAssemblyAttributes.Description     = "";
            baseAssemblyAttributes.Trademark       = "";
            baseAssemblyAttributes.Culture         = "";
            baseAssemblyAttributes.NeutralLanguage = "";

            var project = new Project
            {
                AssemblyAttributes = baseAssemblyAttributes,
                Deletions          = new List <FileSystemInfo>(),
                PropertyGroups     = ProjectPropertyGroups
            };

            var transform = new AssemblyAttributeTransformation(NoopLogger.Instance);

            transform.Transform(project);

            var expectedProperties = new[]
            {
                new XElement("AssemblyTitle", "The Title"),
                new XElement("Product", "The Product"),
                new XElement("GenerateAssemblyConfigurationAttribute", false),
                new XElement("Version", "1.8.4.3-beta.1"),
                new XElement("AssemblyVersion", "1.0.4.2"),
                new XElement("FileVersion", "1.1.7.9"),
                new XElement("SignAssembly", "true"),
                new XElement("DelaySign", "true"),
                new XElement("AssemblyOriginatorKeyFile", "PublicKey.snk")
            }
            .Select(x => x.ToString())
            .ToList();

            var actualProperties = project.AssemblyAttributeProperties
                                   .Select(x => x.ToString())
                                   .ToList();

            CollectionAssert.AreEquivalent(expectedProperties, actualProperties);

            var expectedAttributes = new AssemblyAttributes
            {
                Configuration = "SomeConfiguration"
            };

            Assert.IsTrue(expectedAttributes.Equals(project.AssemblyAttributes));

            CollectionAssert.DoesNotContain(project.Deletions?.ToList(), BaseAssemblyAttributes().File);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Creates a new row for the assembly reference table.
 /// </summary>
 /// <param name="majorVersion">The major version number of the assembly.</param>
 /// <param name="minorVersion">The minor version number of the assembly.</param>
 /// <param name="buildNumber">The build version number of the assembly.</param>
 /// <param name="revisionNumber">The revision version number of the assembly.</param>
 /// <param name="attributes">The attributes associated to the assembly.</param>
 /// <param name="publicKeyOrToken">The index into the #Blob stream referencing the public key or token of the
 /// assembly to use for verification of a signature, or 0 if the assembly was not signed.</param>
 /// <param name="name">The index into the #Strings stream referencing the name of the assembly.</param>
 /// <param name="culture">The index into the #Strings stream referencing the locale string of the assembly.</param>
 /// <param name="hashValue">The index into the #Blob stream referencing the hash value of the assembly reference.</param>
 public AssemblyReferenceRow(ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revisionNumber,
                             AssemblyAttributes attributes, uint publicKeyOrToken, uint name, uint culture, uint hashValue)
 {
     MajorVersion     = majorVersion;
     MinorVersion     = minorVersion;
     BuildNumber      = buildNumber;
     RevisionNumber   = revisionNumber;
     Attributes       = attributes;
     PublicKeyOrToken = publicKeyOrToken;
     Name             = name;
     Culture          = culture;
     HashValue        = hashValue;
 }
Ejemplo n.º 18
0
        public AboutBox()
        {
            InitializeComponent();

            var attributes = new AssemblyAttributes(Assembly.GetExecutingAssembly());

            Text = Resources.AboutBox_About + attributes.Title;
            labelProductName.Text = attributes.Product;
            labelVersion.Text = Resources.AboutBox_Version + attributes.Version;
            labelCopyright.Text = attributes.Copyright;
            labelCompanyName.Text = attributes.Company;
            textBoxDescription.Text = attributes.Description;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="assembly">Assembly</param>
        public AssemblyRefUser(IAssembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("asmName");
            }

            this.version          = assembly.Version ?? new Version(0, 0, 0, 0);
            this.publicKeyOrToken = assembly.PublicKeyOrToken;
            this.name             = UTF8String.IsNullOrEmpty(assembly.Name) ? UTF8String.Empty : assembly.Name;
            this.locale           = assembly.Culture;
            this.flags            = publicKeyOrToken is PublicKey ? AssemblyAttributes.PublicKey : AssemblyAttributes.None;
        }
        public void MovesAttributesToCsProj()
        {
            var project = new Project
            {
                AssemblyAttributes = BaseAssemblyAttributes(),
                Deletions          = new List <FileSystemInfo>(),
                PropertyGroups     = ProjectPropertyGroups
            };

            var transform = new AssemblyAttributeTransformation(NoopLogger.Instance);

            transform.Transform(project);

            var expectedProperties = new[]
            {
                new XElement("AssemblyTitle", "The Title"),
                new XElement("Company", "TheCompany Inc."),
                new XElement("Description", "A description"),
                new XElement("Product", "The Product"),
                new XElement("Copyright", "A Copyright notice  ©"),
                new XElement("GenerateAssemblyConfigurationAttribute", false),
                new XElement("Version", "1.8.4.3-beta.1"),
                new XElement("AssemblyVersion", "1.0.4.2"),
                new XElement("FileVersion", "1.1.7.9"),
                new XElement("NeutralLanguage", "someLanguage"),
                new XElement("SignAssembly", "true"),
                new XElement("DelaySign", "true"),
                new XElement("AssemblyOriginatorKeyFile", "PublicKey.snk"),
            }
            .Select(x => x.ToString())
            .ToList();

            var actualProperties = project.AssemblyAttributeProperties
                                   .Select(x => x.ToString())
                                   .ToList();

            CollectionAssert.AreEquivalent(expectedProperties, actualProperties);

            var expectedAttributes = new AssemblyAttributes
            {
                Configuration = "SomeConfiguration",
                Trademark     = "A trademark",
                Culture       = "A culture"
            };

            Assert.IsTrue(expectedAttributes.Equals(project.AssemblyAttributes));

            CollectionAssert.AreEqual(project.AssemblyAttributeProperties.ToList(), project.PrimaryPropertyGroup().Elements().ToArray());

            CollectionAssert.DoesNotContain(project.Deletions?.ToList(), BaseAssemblyAttributes().File);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="asmName">Assembly name info</param>
 /// <exception cref="ArgumentNullException">If <paramref name="asmName"/> is <c>null</c></exception>
 public AssemblyDefUser(AssemblyNameInfo asmName)
 {
     if (asmName == null)
     {
         throw new ArgumentNullException("asmName");
     }
     this.modules   = new LazyList <ModuleDef>(this);
     this.name      = asmName.Name;
     this.version   = asmName.Version ?? new Version(0, 0, 0, 0);
     this.publicKey = asmName.PublicKeyOrToken as PublicKey ?? new PublicKey();
     this.locale    = asmName.Locale;
     this.flags     = AssemblyAttributes.None;
     this.hashAlgId = AssemblyHashAlgorithm.SHA1;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyRefRow"/> struct.
 /// </summary>
 /// <param name="majorVersion">The major version.</param>
 /// <param name="minorVersion">The minor version.</param>
 /// <param name="buildNumber">The build number.</param>
 /// <param name="revisionNumber">The revision number.</param>
 /// <param name="flags">The flags.</param>
 /// <param name="publicKeyOrToken">The public key or token.</param>
 /// <param name="name">The name.</param>
 /// <param name="culture">The culture.</param>
 /// <param name="hashValue">The hash value.</param>
 public AssemblyRefRow(ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revisionNumber,
                       AssemblyAttributes flags, HeapIndexToken publicKeyOrToken, HeapIndexToken name,
                       HeapIndexToken culture, HeapIndexToken hashValue)
 {
     this.majorVersion     = majorVersion;
     this.minorVersion     = minorVersion;
     this.buildNumber      = buildNumber;
     this.revisionNumber   = revisionNumber;
     this.flags            = flags;
     this.publicKeyOrToken = publicKeyOrToken;
     this.name             = name;
     this.culture          = culture;
     this.hashValue        = hashValue;
 }
Ejemplo n.º 23
0
        public AssemblyAttributes Read(Project project, IProgress <string> progress)
        {
            var projectPath = project.ProjectFolder.FullName;

            var compileElements = project.IncludeItems
                                  .SelectMany(x => x.Elements(Project.XmlNamespace + "Compile"))
                                  .ToList();

            var assemblyInfoFiles = compileElements
                                    .Attributes("Include")
                                    .Select(x => x.Value.ToString())
                                    .Where(x => !x.Contains("*"))
                                    .Select(x =>
            {
                var filePath = Path.IsPathRooted(x) ? x : Path.GetFullPath(Path.Combine(projectPath, x));
                return(new FileInfo(filePath));
            }
                                            )
                                    .Where(x => x.Name.ToLower() == "assemblyinfo.cs")
                                    .ToList();

            if (assemblyInfoFiles.Count == 1)
            {
                var assemblyInfoFile     = assemblyInfoFiles[0];
                var assemblyInfoFileName = assemblyInfoFile.FullName;

                progress.Report($"Reading assembly info from {assemblyInfoFileName}.");

                var text = File.ReadAllText(assemblyInfoFileName);

                var tree = CSharpSyntaxTree.ParseText(text);

                var root = (CompilationUnitSyntax)tree.GetRoot();

                var assemblyAttributes = new AssemblyAttributes
                {
                    File         = assemblyInfoFile,
                    FileContents = root
                };

                return(assemblyAttributes);
            }
            else
            {
                progress.Report($@"Could not read from assemblyinfo, multiple assemblyinfo files found: 
{string.Join(Environment.NewLine, assemblyInfoFiles.Select(x => x.FullName))}.");
            }

            return(null);
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyRow"/> struct.
 /// </summary>
 /// <param name="hashAlgId">The hash alg id.</param>
 /// <param name="majorVersion">The major version.</param>
 /// <param name="minorVersion">The minor version.</param>
 /// <param name="buildNumber">The build number.</param>
 /// <param name="revision">The revision.</param>
 /// <param name="flags">The flags.</param>
 /// <param name="publicKey">The public key.</param>
 /// <param name="name">The name.</param>
 /// <param name="culture">The culture.</param>
 public AssemblyRow(AssemblyHashAlgorithm hashAlgId,
                    ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revision,
                    AssemblyAttributes flags, HeapIndexToken publicKey, HeapIndexToken name, HeapIndexToken culture)
 {
     this.hashAlgId      = hashAlgId;
     this.majorVersion   = majorVersion;
     this.minorVersion   = minorVersion;
     this.buildNumber    = buildNumber;
     this.revisionNumber = revision;
     this.flags          = flags;
     this.publicKey      = publicKey;
     this.name           = name;
     this.culture        = culture;
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyRefRow"/> struct.
 /// </summary>
 /// <param name="majorVersion">The major version.</param>
 /// <param name="minorVersion">The minor version.</param>
 /// <param name="buildNumber">The build number.</param>
 /// <param name="revisionNumber">The revision number.</param>
 /// <param name="flags">The flags.</param>
 /// <param name="publicKeyOrToken">The public key or token.</param>
 /// <param name="name">The name.</param>
 /// <param name="culture">The culture.</param>
 /// <param name="hashValue">The hash value.</param>
 public AssemblyRefRow(ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revisionNumber,
                       AssemblyAttributes flags, HeapIndexToken publicKeyOrToken, HeapIndexToken name,
                       HeapIndexToken culture, HeapIndexToken hashValue)
 {
     MajorVersion     = majorVersion;
     MinorVersion     = minorVersion;
     BuildNumber      = buildNumber;
     RevisionNumber   = revisionNumber;
     Flags            = flags;
     PublicKeyOrToken = publicKeyOrToken;
     Name             = name;
     Culture          = culture;
     HashValue        = hashValue;
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="asmName">Assembly name info</param>
 public AssemblyNameInfo(AssemblyName asmName)
 {
     if (asmName == null)
     {
         return;
     }
     this.hashAlgId        = (AssemblyHashAlgorithm)asmName.HashAlgorithm;
     this.version          = asmName.Version ?? new Version(0, 0, 0, 0);
     this.flags            = (AssemblyAttributes)asmName.Flags;
     this.publicKeyOrToken = (PublicKeyBase)PublicKeyBase.CreatePublicKey(asmName.GetPublicKey()) ??
                             PublicKeyBase.CreatePublicKeyToken(asmName.GetPublicKeyToken());
     this.name    = asmName.Name ?? string.Empty;
     this.culture = asmName.CultureInfo != null && asmName.CultureInfo.Name != null ? asmName.CultureInfo.Name : string.Empty;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyRow"/> struct.
        /// </summary>
        /// <param name="hashAlgId">The hash alg id.</param>
        /// <param name="majorVersion">The major version.</param>
        /// <param name="minorVersion">The minor version.</param>
        /// <param name="buildNumber">The build number.</param>
        /// <param name="revision">The revision.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="publicKey">The public key.</param>
        /// <param name="name">The name.</param>
        /// <param name="culture">The culture.</param>
        public AssemblyRow(AssemblyHashAlgorithm hashAlgId,
							ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revision,
							AssemblyAttributes flags, HeapIndexToken publicKey, HeapIndexToken name, HeapIndexToken culture)
        {
            HashAlgId = hashAlgId;
            MajorVersion = majorVersion;
            MinorVersion = minorVersion;
            BuildNumber = buildNumber;
            Revision = revision;
            Flags = flags;
            PublicKey = publicKey;
            Name = name;
            Culture = culture;
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyRow"/> struct.
        /// </summary>
        /// <param name="hashAlgId">The hash alg id.</param>
        /// <param name="majorVersion">The major version.</param>
        /// <param name="minorVersion">The minor version.</param>
        /// <param name="buildNumber">The build number.</param>
        /// <param name="revision">The revision.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="publicKey">The public key.</param>
        /// <param name="name">The name.</param>
        /// <param name="culture">The culture.</param>
        public AssemblyRow(AssemblyHashAlgorithm hashAlgId,
							ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revision,
							AssemblyAttributes flags, HeapIndexToken publicKey, HeapIndexToken name, HeapIndexToken culture)
        {
            this.hashAlgId = hashAlgId;
            this.majorVersion = majorVersion;
            this.minorVersion = minorVersion;
            this.buildNumber = buildNumber;
            this.revisionNumber = revision;
            this.flags = flags;
            this.publicKey = publicKey;
            this.name = name;
            this.culture = culture;
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyRow"/> struct.
 /// </summary>
 /// <param name="hashAlgId">The hash alg id.</param>
 /// <param name="majorVersion">The major version.</param>
 /// <param name="minorVersion">The minor version.</param>
 /// <param name="buildNumber">The build number.</param>
 /// <param name="revision">The revision.</param>
 /// <param name="flags">The flags.</param>
 /// <param name="publicKey">The public key.</param>
 /// <param name="name">The name.</param>
 /// <param name="culture">The culture.</param>
 public AssemblyRow(AssemblyHashAlgorithm hashAlgId,
                    ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revision,
                    AssemblyAttributes flags, HeapIndexToken publicKey, HeapIndexToken name, HeapIndexToken culture)
 {
     HashAlgId    = hashAlgId;
     MajorVersion = majorVersion;
     MinorVersion = minorVersion;
     BuildNumber  = buildNumber;
     Revision     = revision;
     Flags        = flags;
     PublicKey    = publicKey;
     Name         = name;
     Culture      = culture;
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyRefRow"/> struct.
        /// </summary>
        /// <param name="majorVersion">The major version.</param>
        /// <param name="minorVersion">The minor version.</param>
        /// <param name="buildNumber">The build number.</param>
        /// <param name="revisionNumber">The revision number.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="publicKeyOrToken">The public key or token.</param>
        /// <param name="name">The name.</param>
        /// <param name="culture">The culture.</param>
        /// <param name="hashValue">The hash value.</param>
        public AssemblyRefRow(ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revisionNumber,
								AssemblyAttributes flags, HeapIndexToken publicKeyOrToken, HeapIndexToken name,
								HeapIndexToken culture, HeapIndexToken hashValue)
        {
            MajorVersion = majorVersion;
            MinorVersion = minorVersion;
            BuildNumber = buildNumber;
            RevisionNumber = revisionNumber;
            Flags = flags;
            PublicKeyOrToken = publicKeyOrToken;
            Name = name;
            Culture = culture;
            HashValue = hashValue;
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyRefRow"/> struct.
        /// </summary>
        /// <param name="majorVersion">The major version.</param>
        /// <param name="minorVersion">The minor version.</param>
        /// <param name="buildNumber">The build number.</param>
        /// <param name="revisionNumber">The revision number.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="publicKeyOrToken">The public key or token.</param>
        /// <param name="name">The name.</param>
        /// <param name="culture">The culture.</param>
        /// <param name="hashValue">The hash value.</param>
        public AssemblyRefRow(ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revisionNumber,
								AssemblyAttributes flags, HeapIndexToken publicKeyOrToken, HeapIndexToken name,
								HeapIndexToken culture, HeapIndexToken hashValue)
        {
            this.majorVersion = majorVersion;
            this.minorVersion = minorVersion;
            this.buildNumber = buildNumber;
            this.revisionNumber = revisionNumber;
            this.flags = flags;
            this.publicKeyOrToken = publicKeyOrToken;
            this.name = name;
            this.culture = culture;
            this.hashValue = hashValue;
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Creates a new row for the assembly definition table.
 /// </summary>
 /// <param name="hashAlgorithm">The hashing algorithm used to sign the assembly.</param>
 /// <param name="majorVersion">The major version number of the assembly.</param>
 /// <param name="minorVersion">The minor version number of the assembly.</param>
 /// <param name="buildNumber">The build version number of the assembly.</param>
 /// <param name="revisionNumber">The revision version number of the assembly.</param>
 /// <param name="attributes">The attributes associated to the assembly.</param>
 /// <param name="publicKey">The index into the #Blob stream referencing the public key of the assembly to use
 /// for verification of a signature, or 0 if the assembly was not signed.</param>
 /// <param name="name">The index into the #Strings stream referencing the name of the assembly.</param>
 /// <param name="culture">The index into the #Strings stream referencing the locale string of the assembly.</param>
 public AssemblyDefinitionRow(AssemblyHashAlgorithm hashAlgorithm,
                              ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revisionNumber,
                              AssemblyAttributes attributes, uint publicKey, uint name, uint culture)
 {
     HashAlgorithm  = hashAlgorithm;
     MajorVersion   = majorVersion;
     MinorVersion   = minorVersion;
     BuildNumber    = buildNumber;
     RevisionNumber = revisionNumber;
     Attributes     = attributes;
     PublicKey      = publicKey;
     Name           = name;
     Culture        = culture;
 }
        private static IReadOnlyList <XElement> OtherProperties(AssemblyAttributes assemblyAttributes, PackageConfiguration packageConfig, ILogger logger)
        {
            var configCanBeStripped = string.IsNullOrEmpty(assemblyAttributes.Configuration);

            var toReturn = new[]
            {
                CreateElementIfNotNullOrEmpty(assemblyAttributes.Title, "AssemblyTitle"),
                CreateElementIfNotNullOrEmpty(assemblyAttributes.Company, "Company"),
                CreateElementIfNotNullOrEmpty(assemblyAttributes.Product, "Product"),
                CreateElementIfNotNullOrEmpty(assemblyAttributes.NeutralLanguage, "NeutralLanguage"),


                //And a couple of properties which can be superceded by the package config
                CreateElementIfNotNullOrEmpty(assemblyAttributes.Description, packageConfig?.Description, "Description", logger),
                CreateElementIfNotNullOrEmpty(assemblyAttributes.Copyright, packageConfig?.Copyright, "Copyright", logger),

                !configCanBeStripped
                                        ?
                //If it is included, chances are that the developer has used
                //preprocessor flags which we can't yet process
                //so just leave it in AssemblyInfo file
                new XElement("GenerateAssemblyConfigurationAttribute", false)
                                        : null
            }.Where(x => x != null).ToArray();

            assemblyAttributes.Title           = null;
            assemblyAttributes.Company         = null;
            assemblyAttributes.Description     = null;
            assemblyAttributes.Product         = null;
            assemblyAttributes.Copyright       = null;
            assemblyAttributes.NeutralLanguage = null;

            if (assemblyAttributes.Culture == string.Empty)
            {
                assemblyAttributes.Culture = null;
            }

            if (assemblyAttributes.Trademark == string.Empty)
            {
                assemblyAttributes.Trademark = null;
            }

            if (configCanBeStripped)
            {
                assemblyAttributes.Configuration = null;
            }

            return(toReturn);
        }
        private static IReadOnlyList <XElement> SigningProperties(AssemblyAttributes assemblyAttributes,
                                                                  PackageConfiguration packageConfig, ILogger logger)
        {
            var toReturn = new[]
            {
                assemblyAttributes.IsSigned ? new XElement("SignAssembly", true) : null,
                assemblyAttributes.KeyFile != null?CreateElementIfNotNullOrEmpty(assemblyAttributes.DelaySign, "DelaySign") : null,
                    CreateElementIfNotNullOrEmpty(assemblyAttributes.KeyFile, "AssemblyOriginatorKeyFile")
            }.Where(x => x != null).ToArray();

            assemblyAttributes.DelaySign = null;
            assemblyAttributes.KeyFile   = null;

            return(toReturn);
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="asm">The assembly</param>
        public AssemblyNameInfo(IAssembly asm)
        {
            if (asm == null)
            {
                return;
            }
            var asmDef = asm as AssemblyDef;

            this.hashAlgId        = asmDef == null ? 0 : asmDef.HashAlgorithm;
            this.version          = asm.Version ?? new Version(0, 0, 0, 0);
            this.flags            = asm.Attributes;
            this.publicKeyOrToken = asm.PublicKeyOrToken;
            this.name             = UTF8String.IsNullOrEmpty(asm.Name) ? UTF8String.Empty : asm.Name;
            this.culture          = UTF8String.IsNullOrEmpty(asm.Culture) ? UTF8String.Empty : asm.Culture;
        }
        private string ReadValueAndReplace(XElement metadata, XName elementName, AssemblyAttributes assemblyAttributes)
        {
            var value = metadata.Element(elementName)?.Value;

            if (value != null && assemblyAttributes != null)
            {
                value = value
                        .Replace("$id$", assemblyAttributes.AssemblyName ?? "$id$")
                        .Replace("$version$", assemblyAttributes.InformationalVersion ?? assemblyAttributes.Version ?? "$version$")
                        .Replace("$author$", assemblyAttributes.Company ?? "$author$")
                        .Replace("$description$", assemblyAttributes.Description ?? "$description$")
                        .Replace("$copyright$", assemblyAttributes.Copyright ?? "$copyright$");
            }

            return(value);
        }
Ejemplo n.º 37
0
 private static void checkCache()
 {
     if (byName == null)
     {
         byName          = new Dictionary <string, ModuleAttribute>();
         byType          = new Dictionary <Type, ModuleAttribute>();
         byInterfaceType = new Dictionary <Type, ModuleAttribute>();
         var attrs = AssemblyAttributes.GetAttributes(typeof(ModuleAttribute));
         foreach (ModuleAttribute attr in attrs)
         {
             byName.Add(attr.Name, attr);
             byType.Add(attr.Type, attr);
             byInterfaceType.Add(attr.InterfaceType, attr);
         }
     }
 }
		internal static string ToString(AssemblyAttributes flags) {
			if (flags == AssemblyAttributes.None)
				return "None";

			var sb = new StringBuilder();

			switch ((flags & AssemblyAttributes.PA_Mask)) {
			case AssemblyAttributes.PA_None: sb.Append("PA_None"); break;
			case AssemblyAttributes.PA_MSIL: sb.Append("PA_MSIL"); break;
			case AssemblyAttributes.PA_x86: sb.Append("PA_x86"); break;
			case AssemblyAttributes.PA_IA64: sb.Append("PA_IA64"); break;
			case AssemblyAttributes.PA_AMD64: sb.Append("PA_AMD64"); break;
			case AssemblyAttributes.PA_ARM: sb.Append("PA_ARM"); break;
			case AssemblyAttributes.PA_NoPlatform: sb.Append("PA_NoPlatform"); break;
			default: sb.Append("PA_UNKNOWN"); break;
			}

			if ((flags & AssemblyAttributes.PA_Specified) != 0)
				sb.Append(" | PA_Specified");

			if ((flags & AssemblyAttributes.PublicKey) != 0)
				sb.Append(" | PublicKey");

			if ((flags & AssemblyAttributes.EnableJITcompileTracking) != 0)
				sb.Append(" | EnableJITcompileTracking");

			if ((flags & AssemblyAttributes.DisableJITcompileOptimizer) != 0)
				sb.Append(" | DisableJITcompileOptimizer");

			if ((flags & AssemblyAttributes.Retargetable) != 0)
				sb.Append(" | Retargetable");

			switch ((flags & AssemblyAttributes.ContentType_Mask)) {
			case AssemblyAttributes.ContentType_Default: sb.Append(" | ContentType_Default"); break;
			case AssemblyAttributes.ContentType_WindowsRuntime: sb.Append(" | ContentType_WindowsRuntime"); break;
			default: sb.Append(" | ContentType_UNKNOWN"); break;
			}

			return sb.ToString();
		}
Ejemplo n.º 39
0
		bool GetFlagValue(AssemblyAttributes flag) => (Flags & flag) != 0;
Ejemplo n.º 40
0
		public unsafe static PublicKeyBase GetAssemblyRefPublicKeyOrToken(IMetaDataAssemblyImport mdai, uint token, out AssemblyAttributes attrs) {
			attrs = 0;
			if (mdai == null)
				return null;
			IntPtr pbPublicKeyOrToken;
			uint cbPublicKeyOrToken, dwAssemblyFlags;
			int hr = mdai.GetAssemblyRefProps(token, new IntPtr(&pbPublicKeyOrToken), new IntPtr(&cbPublicKeyOrToken), IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, new IntPtr(&dwAssemblyFlags));
			if (hr != 0)
				return null;
			attrs = (AssemblyAttributes)dwAssemblyFlags;
			if (pbPublicKeyOrToken == IntPtr.Zero)
				return null;
			var data = new byte[cbPublicKeyOrToken];
			Marshal.Copy(pbPublicKeyOrToken, data, 0, data.Length);
			if ((dwAssemblyFlags & (uint)AssemblyAttributes.PublicKey) != 0)
				return new PublicKey(data);
			return new PublicKeyToken(data);
		}
Ejemplo n.º 41
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="asmName">Assembly name info</param>
		/// <exception cref="ArgumentNullException">If <paramref name="asmName"/> is <c>null</c></exception>
		public AssemblyRefUser(AssemblyName asmName)
			: this(new AssemblyNameInfo(asmName)) {
			this.flags = (AssemblyAttributes)asmName.Flags;
		}
Ejemplo n.º 42
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="assembly">Assembly</param>
		public AssemblyRefUser(IAssembly assembly) {
			if (assembly == null)
				throw new ArgumentNullException("asmName");

			this.version = assembly.Version ?? new Version(0, 0, 0, 0);
			this.publicKeyOrToken = assembly.PublicKeyOrToken;
			this.name = UTF8String.IsNullOrEmpty(assembly.Name) ? UTF8String.Empty : assembly.Name;
			this.locale = assembly.Culture;
			this.flags = publicKeyOrToken is PublicKey ? AssemblyAttributes.PublicKey : AssemblyAttributes.None;
		}
Ejemplo n.º 43
0
 void SetFlagValue(AssemblyAttributes flag, bool value)
 {
     if (value)
         Flags |= flag;
     else
         Flags &= ~flag;
 }
Ejemplo n.º 44
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="name">Simple name</param>
		/// <param name="version">Version</param>
		/// <param name="publicKey">Public key or public key token</param>
		/// <param name="locale">Locale</param>
		/// <exception cref="ArgumentNullException">If any of the args is invalid</exception>
		public AssemblyRefUser(UTF8String name, Version version, PublicKeyBase publicKey, UTF8String locale) {
			if ((object)name == null)
				throw new ArgumentNullException("name");
			if (version == null)
				throw new ArgumentNullException("version");
			if ((object)locale == null)
				throw new ArgumentNullException("locale");
			this.name = name;
			this.version = version;
			this.publicKeyOrToken = publicKey;
			this.locale = locale;
			this.flags = publicKey is PublicKey ? AssemblyAttributes.PublicKey : AssemblyAttributes.None;
		}
Ejemplo n.º 45
0
 /// <summary>
 /// Set or clear flags in <see cref="attributes"/>
 /// </summary>
 /// <param name="set"><c>true</c> if flags should be set, <c>false</c> if flags should
 /// be cleared</param>
 /// <param name="flags">Flags to set or clear</param>
 void ModifyAttributes(bool set, AssemblyAttributes flags)
 {
     #if THREAD_SAFE
     int origVal, newVal;
     do {
         origVal = attributes;
         if (set)
             newVal = origVal | (int)flags;
         else
             newVal = origVal & ~(int)flags;
     } while (Interlocked.CompareExchange(ref attributes, newVal, origVal) != origVal);
     #else
     if (set)
         attributes |= (int)flags;
     else
         attributes &= ~(int)flags;
     #endif
 }
Ejemplo n.º 46
0
 bool GetFlagValue(AssemblyAttributes flag)
 {
     return (Flags & flag) != 0;
 }
Ejemplo n.º 47
0
 /// <summary>
 /// Modify <see cref="attributes"/> property: <see cref="attributes"/> =
 /// (<see cref="attributes"/> &amp; <paramref name="andMask"/>) | <paramref name="orMask"/>.
 /// </summary>
 /// <param name="andMask">Value to <c>AND</c></param>
 /// <param name="orMask">Value to OR</param>
 void ModifyAttributes(AssemblyAttributes andMask, AssemblyAttributes orMask)
 {
     #if THREAD_SAFE
     int origVal, newVal;
     do {
         origVal = attributes;
         newVal = (origVal & (int)andMask) | (int)orMask;
     } while (Interlocked.CompareExchange(ref attributes, newVal, origVal) != origVal);
     #else
     attributes = (attributes & (int)andMask) | (int)orMask;
     #endif
 }
Ejemplo n.º 48
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="asmName">Assembly name info</param>
		public AssemblyNameInfo(AssemblyName asmName) {
			if (asmName == null)
				return;
			this.hashAlgId = (AssemblyHashAlgorithm)asmName.HashAlgorithm;
			this.version = asmName.Version ?? new Version(0, 0, 0, 0);
			this.flags = (AssemblyAttributes)asmName.Flags;
			this.publicKeyOrToken = (PublicKeyBase)PublicKeyBase.CreatePublicKey(asmName.GetPublicKey()) ??
							PublicKeyBase.CreatePublicKeyToken(asmName.GetPublicKeyToken());
			this.name = asmName.Name ?? string.Empty;
			this.culture = asmName.CultureInfo != null && asmName.CultureInfo.Name != null ? asmName.CultureInfo.Name : string.Empty;
		}
Ejemplo n.º 49
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="asm">The assembly</param>
		public AssemblyNameInfo(IAssembly asm) {
			if (asm == null)
				return;
			var asmDef = asm as AssemblyDef;
			this.hashAlgId = asmDef == null ? 0 : asmDef.HashAlgorithm;
			this.version = asm.Version ?? new Version(0, 0, 0, 0);
			this.flags = asm.Attributes;
			this.publicKeyOrToken = asm.PublicKeyOrToken;
			this.name = UTF8String.IsNullOrEmpty(asm.Name) ? UTF8String.Empty : asm.Name;
			this.culture = UTF8String.IsNullOrEmpty(asm.Culture) ? UTF8String.Empty : asm.Culture;
		}
Ejemplo n.º 50
0
		/// <summary>
		/// Set or clear flags in <see cref="Attributes"/>
		/// </summary>
		/// <param name="set"><c>true</c> if flags should be set, <c>false</c> if flags should
		/// be cleared</param>
		/// <param name="flags">Flags to set or clear</param>
		void ModifyAttributes(bool set, AssemblyAttributes flags) {
			if (set)
				Attributes |= flags;
			else
				Attributes &= ~flags;
		}
Ejemplo n.º 51
0
		/// <summary>
		/// Modify <see cref="Attributes"/> property: <see cref="Attributes"/> =
		/// (<see cref="Attributes"/> &amp; <paramref name="andMask"/>) | <paramref name="orMask"/>.
		/// </summary>
		/// <param name="andMask">Value to <c>AND</c></param>
		/// <param name="orMask">Value to OR</param>
		void ModifyAttributes(AssemblyAttributes andMask, AssemblyAttributes orMask) {
			Attributes = (Attributes & andMask) | orMask;
		}