From a32bab46901b98e6c20d7fcbdde4d0caeb29608d Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Thu, 2 Dec 2021 15:14:06 -0600 Subject: [PATCH] don't keep this value in two places (#504) --- Src/CSharpier/CodeFormatter.cs | 5 +++-- Src/CSharpier/SyntaxNodeComparer.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Src/CSharpier/CodeFormatter.cs b/Src/CSharpier/CodeFormatter.cs index 9be26e937..9b126d433 100644 --- a/Src/CSharpier/CodeFormatter.cs +++ b/Src/CSharpier/CodeFormatter.cs @@ -6,6 +6,8 @@ namespace CSharpier; public class CodeFormatter { + public static LanguageVersion LanguageVersion = LanguageVersion.CSharp10; + public static string Format(string code, CodeFormatterOptions? options = null) { return FormatAsync(code, options).Result; @@ -43,8 +45,7 @@ SyntaxTree ParseText(string codeToFormat, params string[] preprocessorSymbols) return CSharpSyntaxTree.ParseText( codeToFormat, new CSharpParseOptions( - // this also exists in SyntaxNodeComparer - LanguageVersion.CSharp10, + LanguageVersion, DocumentationMode.Diagnose, preprocessorSymbols: preprocessorSymbols ), diff --git a/Src/CSharpier/SyntaxNodeComparer.cs b/Src/CSharpier/SyntaxNodeComparer.cs index 39bfe04c7..26d9cec56 100644 --- a/Src/CSharpier/SyntaxNodeComparer.cs +++ b/Src/CSharpier/SyntaxNodeComparer.cs @@ -20,7 +20,7 @@ CancellationToken cancellationToken this.OriginalSourceCode = originalSourceCode; this.NewSourceCode = newSourceCode; - var cSharpParseOptions = new CSharpParseOptions(LanguageVersion.CSharp10); + var cSharpParseOptions = new CSharpParseOptions(CodeFormatter.LanguageVersion); this.OriginalSyntaxTree = CSharpSyntaxTree.ParseText( this.OriginalSourceCode, cSharpParseOptions,