private static string?TryReadAttributeValue(AssemblyMetadataParser.AttributeInfo attribute) { // Skip InternalsVisibleToAttribute if (attribute.FullTypeName.Equals(typeof(InternalsVisibleToAttribute).FullName, StringComparison.Ordinal)) { return(null); } // Handle the metadata attrib if (attribute.FullTypeName.Equals(typeof(AssemblyMetadataAttribute).FullName, StringComparison.Ordinal)) { return($"Key = {attribute.FixedArguments[0].Value}, Value = {attribute.FixedArguments[1].Value}"); } if (attribute.FixedArguments.Length != 1 || attribute.NamedArguments.Length > 0) { return(null); } var singleCtorParameter = attribute.FixedArguments[0]; if (singleCtorParameter.Type.Equals(typeof(string).FullName, StringComparison.Ordinal)) { var strValue = singleCtorParameter.Value !.ToString(); return(string.IsNullOrEmpty(strValue) ? null : strValue); } return(null); }
private static string ReadAttributeDisplayName(AssemblyMetadataParser.AttributeInfo attribute) { var shortName = attribute.FullTypeName.Split(".+".ToCharArray()).Last(); const string attributeSuffix = "Attribute"; return(shortName.EndsWith(attributeSuffix, StringComparison.Ordinal) ? shortName.Substring(0, shortName.Length - attributeSuffix.Length) : shortName); }