Open
Description
In @AaronRobinsonMSFT's PR dotnet/runtime#113715, we started to see SA1518 false-positives followed by ArgumentOutOfRangeException. From dotnet build -v:diag:
16.55.32.912 9>CSC : error AD0001: Analyzer 'StyleCop.Analyzers.LayoutRules.SA1518UseLineEndingsCorrectlyAtEndOfFile' threw an exception of type 'System.ArgumentOutOfRangeException' with message 'Specified argument was out of the range of valid values. (Parameter 'span')'. [/Users/adeel/projects/runtime5/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
Exception occurred with following context: (TaskId:448)
Compilation: System.Private.CoreLib (TaskId:448)
SyntaxTree: /Users/adeel/projects/runtime5/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs (TaskId:448)
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'span') (TaskId:448)
at Microsoft.CodeAnalysis.Text.SourceText.CheckSubSpan(TextSpan span) (TaskId:448)
at Microsoft.CodeAnalysis.Text.SourceText.ToString(TextSpan span) (TaskId:448)
at StyleCop.Analyzers.LayoutRules.SA1518UseLineEndingsCorrectlyAtEndOfFile.HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopSettings settings) (TaskId:448)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteSyntaxTreeActions>b__50_1(ValueTuple`2 data) (TaskId:448)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) (TaskId:448)
----- (TaskId:448)
which seems likely to be coming from:
(there are no debug symbols for line info, so it's a guess)
The workaround was to apply this patch:
diff --git a/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
index 7654b65dec4..184ce80f44b 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
@@ -2,14 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
/*============================================================
-**
-**
-**
** Purpose: Exposes features of the Garbage Collector through
** the class libraries. This is a class which cannot be
** instantiated.
-**
-**
===========================================================*/
on top of this version of the file: https://github.com/dotnet/runtime/blob/e608b893b83672efcf4dec4ebf3d0e0ac6c1ba2e/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
Metadata
Metadata
Assignees
Labels
No labels