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

The value unset is not supported by the csharp_style_namespace_declarations option #69392

Open
flipZomb opened this issue Aug 3, 2023 · 1 comment
Assignees
Labels
Area-IDE IDE-Formatter Code formatter and/or smart indent
Milestone

Comments

@flipZomb
Copy link

flipZomb commented Aug 3, 2023

Originally reported at dotnet/format#1926.

Getting the below exception when running "dotnet format" with the following installed :

  1. dotnet SDK 7.0.306 (windows x64)
  2. C# v2.0.320
  3. EditorConfig for VS Code v0.16.4

Going back to dotnet SDK 7.0.203 (windows x64), stops this from happenening (sorry, didn't try the intermediate versions).

Unhandled exception: System.NotSupportedException: Specified method is not supported.
   at Microsoft.CodeAnalysis.CSharp.CodeStyle.CSharpCodeStyleOptions.ParseNamespaceDeclaration(String optionString, CodeStyleOption2`1 default)
   at Microsoft.CodeAnalysis.CSharp.CodeStyle.CSharpCodeStyleOptions.<>c__DisplayClass75_2.<.cctor>b__7(String str)
   at Microsoft.CodeAnalysis.Options.EditorConfigValueSerializer`1.TryParseValue(String value, T& result)
   at Microsoft.CodeAnalysis.Options.EditorConfigValueSerializer`1.Microsoft.CodeAnalysis.Options.IEditorConfigValueSerializer.TryParse(String value, Object& result)
   at Microsoft.CodeAnalysis.Options.DocumentOptionSet.TryGetAnalyzerConfigOption(OptionKey optionKey, Object& value)
   at Microsoft.CodeAnalysis.Options.DocumentOptionSet.GetInternalOptionValue(OptionKey optionKey)
   at Microsoft.CodeAnalysis.Options.OptionSet.Microsoft.CodeAnalysis.Options.IOptionsReader.TryGetOption[T](OptionKey2 optionKey, T& value)
   at Microsoft.CodeAnalysis.Options.Extensions.GetOption[T](IOptionsReader options, Option2`1 option, T defaultValue)
   at Microsoft.CodeAnalysis.CSharp.Formatting.CSharpSyntaxFormattingOptions..ctor(IOptionsReader options, CSharpSyntaxFormattingOptions 
fallbackOptions)
   at Microsoft.CodeAnalysis.CSharp.Formatting.CSharpSyntaxFormatting.GetFormattingOptions(IOptionsReader options, SyntaxFormattingOptions fallbackOptions)
   at Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattingOptionsAsync(Document document, OptionSet optionSet, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Formatting.Formatter.FormatAsync(Document document, IEnumerable`1 spans, OptionSet options, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Formatters.WhitespaceFormatter.GetFormattedDocument(Document document, OptionSet optionSet, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Formatters.WhitespaceFormatter.FormatFileAsync(Document document, SourceText sourceText, OptionSet optionSet, AnalyzerConfigOptions analyzerConfigOptions, FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken)   
   at Microsoft.CodeAnalysis.Tools.Formatters.DocumentFormatter.GetFormattedSourceTextAsync(Document document, OptionSet optionSet, AnalyzerConfigOptions analyzerConfigOptions, FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Formatters.DocumentFormatter.<>c__DisplayClass8_1.<<FormatFiles>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.Tools.Formatters.DocumentFormatter.ApplyFileChangesAsync(Solution solution, ImmutableArray`1 formattedDocuments, FormatOptions formatOptions, ILogger logger, List`1 formattedFiles, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Formatters.DocumentFormatter.FormatAsync(Solution solution, ImmutableArray`1 formattableDocuments, FormatOptions formatOptions, ILogger logger, List`1 formattedFiles, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.RunCodeFormattersAsync(Solution solution, ImmutableArray`1 formattableDocuments, FormatOptions formatOptions, ILogger logger, List`1 formattedFiles, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
   at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass21_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass18_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__17_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__4_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass7_0.<<UseExceptionHandler>b__0>d.MoveNext()

.editorconfig contains the following

...
# CSharp formatting rules:
[*.cs]
dotnet_style_object_initializer = false
dotnet_style_collection_initializer = false
csharp_style_namespace_declarations = file_scoped:warning
...
# Ignore paths
[{*_mig?.cs,*_mig??.cs}]
csharp_style_namespace_declarations = unset
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 4, 2023
@JoeRobich
Copy link
Member

JoeRobich commented Aug 4, 2023

After several failed attempts to have GitHub transfer this issue, I am just going to leave this one open. See dotnet/format#1926 for more context.

@JoeRobich JoeRobich changed the title Crashing under dotnet SDK 7.0.306 in vscode The value unset is not supported by the csharp_style_namespace_declarations option Aug 4, 2023
@arkalyanms arkalyanms added the IDE-Formatter Code formatter and/or smart indent label Aug 15, 2023
@arkalyanms arkalyanms added this to the 18.0 milestone Aug 15, 2023
@arkalyanms arkalyanms removed the untriaged Issues and PRs which have not yet been triaged by a lead label Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE IDE-Formatter Code formatter and/or smart indent
Projects
None yet
Development

No branches or pull requests

4 participants