StyleCop.CSharp by StyleCop contributors, Andy Reeves, Chris Dahlberg

<PackageReference Include="StyleCop.CSharp" Version="6.2.0" />

.NET API 245,760 bytes

 FileHeader

public class FileHeader : ICodePart
Describes the header at the top of a C# file.
using System.Collections.Specialized; using System.Globalization; using System.Linq; using System.Xml; namespace StyleCop.CSharp { public class FileHeader : ICodePart { private readonly bool generated; private readonly string headerText; private readonly string headerXml; private readonly CodeLocation location; private readonly Reference<ICodePart> parent; private readonly CsTokenList tokens; public CodePartType CodePartType => CodePartType.FileHeader; public bool Generated => generated; public string HeaderText => headerText; public string HeaderXml => headerXml; public int LineNumber { get { CodeLocation val = location; return val.get_LineNumber(); } } public CodeLocation Location => location; public ICodePart Parent => parent.Target; public CsTokenList Tokens => tokens; public bool UnStyled { get; set; } internal FileHeader(string headerText, CsTokenList tokens, Reference<ICodePart> parent) { this.headerText = headerText; this.tokens = tokens; this.parent = parent; location = ((this.tokens.get_First() != null) ? CsToken.JoinLocations(this.tokens.get_First(), this.tokens.get_Last()) : CodeLocation.Empty); try { if (this.headerText.Length > 0) { headerXml = string.Format(CultureInfo.InvariantCulture, "<root>{0}</root>", new object[1] { HtmlEncode(this.headerText) }); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(headerXml); if (xmlDocument.DocumentElement != null) { XmlNode xmlNode2 = xmlDocument.DocumentElement["autogenerated"]; if (xmlNode2 != null) generated = true; else { xmlNode2 = xmlDocument.DocumentElement["auto-generated"]; if (xmlNode2 != null) generated = true; } StringCollection unstyledElements = new StringCollection(); unstyledElements.AddRange(new string[3] { "unstyled", "stylecopoff", "nostyle" }); XmlNodeList childNodes = xmlDocument.DocumentElement.ChildNodes; if (childNodes.Cast<XmlNode>().Any((XmlNode xmlNode) => unstyledElements.Contains(xmlNode.Name.ToLowerInvariant()))) UnStyled = true; } } } catch (XmlException) { } } public static string HtmlEncode(string value) { return value.Replace("&", "&amp;"); } } }