dotnet/roslyn

Error message for invalid csharp_using_directive_placement is not clear

Aperta

#49.407 aperta il 16 nov 2020

 (7 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-AnalyzersBugConcept-Diagnostic Clarityhelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] Hi, when I run a CodeAnalysis on my . Net5 solution I see 72 warnings in the Error List (I think one for every file). All the warnings are AD0001:

Severity	Code	Description	Project	File	Line	Suppression State
Warning	AD0001	Analyzer 'Microsoft.CodeAnalysis.CSharp.MisplacedUsingDirectives.MisplacedUsingDirectivesDiagnosticAnalyzer' threw an exception of type 'System.NotSupportedException' with message 'Specified method is not supported.'.
Exception occurred with following context:
Compilation: Translator.Core
SyntaxTree: C:\Users\wvl\source\repos\KasparInternal.Tools.FlutterTranslationHelper\Translator.Core\TypeBuilder\EntryTypeBuilder.LanguagePropertyBuilder.cs
SyntaxNode: using System; using System.Linq ... [CompilationUnitSyntax]@[20..6103) (2,0)-(139,0)

System.NotSupportedException: Specified method is not supported.
   at Microsoft.CodeAnalysis.CSharp.CodeStyle.CSharpCodeStyleOptions.ParseUsingDirectivesPlacement(String optionString, CodeStyleOption2`1 default)
   at Microsoft.CodeAnalysis.CSharp.CodeStyle.CSharpCodeStyleOptions.<>c.<.cctor>b__46_9(String s)
   at Microsoft.CodeAnalysis.Options.EditorConfigStorageLocation`1.TryGetOption(String value, Type type, T& result)
   at Microsoft.CodeAnalysis.AnalyzerConfigOptionsExtensions.TryGetEditorConfigOption[T](AnalyzerConfigOptions analyzerConfigOptions, IOption option, Boolean useDefaultIfMissing, T& value)
   at Microsoft.CodeAnalysis.AnalyzerConfigOptionsExtensions.TryGetEditorConfigOption[T](AnalyzerConfigOptions analyzerConfigOptions, IOption option, T& value)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerHelper. <GetOptionAsync>d__24`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerHelper.GetOption[T](AnalyzerOptions analyzerOptions, ILanguageSpecificOption`1 option, SyntaxTree syntaxTree, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.MisplacedUsingDirectives.MisplacedUsingDirectivesDiagnosticAnalyzer.AnalyzeCompilationUnitNode(SyntaxNodeAnalysisContext context)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__62`1. <ExecuteSyntaxNodeAction>b__62_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: IDE0065	Translator.Core		1	Active


Original Comments

(no comments)


Original Solutions

(no solutions)

Guida contributor