Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AArnott opened this issue May 8, 2020 · 1 comment · Fixed by #3315
Closed
Assignees

Comments

@AArnott
Copy link
Contributor

AArnott commented May 8, 2020

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
@sharwell
Copy link
Member

sharwell commented Mar 9, 2021

The issue here is actually related to fields having an <include> element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants