Skip to content

Several analyzers throw ArgumentNullException when they encounter an <include> doc comment #3150

Closed
@AArnott

Description

The ElementDocumentationBase.HandleDeclaration method seems to pass null to XElement.Parse leading to ArgumentNullException being thrown.

The syntax where the AD0001 diagnostic is raised takes this form:

        /// <include file='doc\NativeMethods.uex' path='docs/doc[@for="NativeMethods.IID_IUnknown"]/*' />
        public static readonly Guid IID_IUnknown = new Guid("{00000000-0000-0000-C000-000000000046}");

The referenced file does not exist.

This leads to a great many AD0001 warnings in the project build:

CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1608ElementDocumentationMustNotHaveDefaultSummary' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1608ElementDocumentationMustNotHaveDefaultSummary' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1629DocumentationTextMustEndWithAPeriod' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1629DocumentationTextMustEndWithAPeriod' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1613ElementParameterDocumentationMustDeclareParameterName' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1613ElementParameterDocumentationMustDeclareParameterName' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1608ElementDocumentationMustNotHaveDefaultSummary' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1611ElementParametersMustBeDocumented' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1611ElementParametersMustBeDocumented' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1629DocumentationTextMustEndWithAPeriod' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1614ElementParameterDocumentationMustHaveText' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1613ElementParameterDocumentationMustDeclareParameterName' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1614ElementParameterDocumentationMustHaveText' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1616ElementReturnValueDocumentationMustHaveText' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1625ElementDocumentationMustNotBeCopiedAndPasted' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1616ElementReturnValueDocumentationMustHaveText' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1611ElementParametersMustBeDocumented' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1625ElementDocumentationMustNotBeCopiedAndPasted' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1612ElementParameterDocumentationMustMatchElementParameters' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1614ElementParameterDocumentationMustHaveText' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1612ElementParameterDocumentationMustMatchElementParameters' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1616ElementReturnValueDocumentationMustHaveText' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1625ElementDocumentationMustNotBeCopiedAndPasted' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]
CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1612ElementParameterDocumentationMustMatchElementParameters' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. [D:\VS\src\env\shell\PackageFramework\Framework\Microsoft.VisualStudio.Shell.Framework.csproj]

Details that appear in the Error List reveal the callstack:

Severity	Code	Description	Project	File	Line	Suppression State	Tool
Warning	AD0001	Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1613ElementParameterDocumentationMustDeclareParameterName' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null.
Parameter name: s'.
Exception occurred with following context:
Compilation: Microsoft.VisualStudio.Shell.Framework
SyntaxTree: D:\VS\src\env\shell\PackageFramework\Framework\NativeMethods.cs
SyntaxNode: public static readonly Guid IID_IUnknown ... [FieldDeclarationSyntax]@[1349..1443) (27,8)-(27,102)

System.ArgumentNullException: Value cannot be null.
Parameter name: s
   at System.IO.StringReader..ctor(String s)
   at System.Xml.Linq.XElement.Parse(String text, LoadOptions options)
   at StyleCop.Analyzers.DocumentationRules.ElementDocumentationBase.HandleDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings, Boolean needsComment, SyntaxNode node, Location[] locations)
   at StyleCop.Analyzers.DocumentationRules.ElementDocumentationBase.HandleFieldDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings)
   at StyleCop.Analyzers.AnalyzerExtensions.<>c__DisplayClass3_0`1.<RegisterSyntaxNodeAction>b__0(SyntaxNodeAnalysisContext c)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__58`1.<ExecuteSyntaxNodeAction>b__58_0(ValueTuple`2 data)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
-----

Suppress the following diagnostics to disable this analyzer: SA1613	Microsoft.VisualStudio.Shell.Framework (net472)		1	Active	StyleCop.Analyzers

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions