Skip to content

Commit a14091b

Browse files
RazorCodeGenerationOptions: Remove LanguageVersion
This property is unused and it is less error-prone to only define it in a single place, i.e. RazorParserOptions.
1 parent acac158 commit a14091b

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineBuilderExtensionsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void SetCSharpLanguageVersion_ResolvesLatestCSharpLangVersions()
121121
});
122122

123123
var features = projectEngine.Engine.GetFeatures<IConfigureRazorCodeGenerationOptionsFeature>().OrderByAsArray(static x => x.Order);
124-
var builder = new RazorCodeGenerationOptions.Builder(RazorLanguageVersion.Latest);
124+
var builder = new RazorCodeGenerationOptions.Builder();
125125

126126
foreach (var feature in features)
127127
{

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorCodeGenerationOptions.Builder.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ public sealed partial class RazorCodeGenerationOptions
77
{
88
public sealed class Builder
99
{
10-
public RazorLanguageVersion LanguageVersion { get; }
11-
1210
private Flags _flags;
1311

1412
public int IndentSize { get; set; }
@@ -24,9 +22,8 @@ public sealed class Builder
2422
/// </summary>
2523
public string? SuppressUniqueIds { get; set; }
2624

27-
internal Builder(RazorLanguageVersion languageVersion)
25+
internal Builder()
2826
{
29-
LanguageVersion = languageVersion ?? DefaultLanguageVersion;
3027
IndentSize = DefaultIndentSize;
3128
NewLine = DefaultNewLine;
3229
}
@@ -157,6 +154,6 @@ public bool RemapLinePragmaPathsOnWindows
157154
}
158155

159156
public RazorCodeGenerationOptions ToOptions()
160-
=> new(LanguageVersion, IndentSize, NewLine, RootNamespace, SuppressUniqueIds, _flags);
157+
=> new(IndentSize, NewLine, RootNamespace, SuppressUniqueIds, _flags);
161158
}
162159
}

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorCodeGenerationOptions.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,23 @@ namespace Microsoft.AspNetCore.Razor.Language;
88

99
public sealed partial class RazorCodeGenerationOptions
1010
{
11-
private static RazorLanguageVersion DefaultLanguageVersion => RazorLanguageVersion.Latest;
1211
private static int DefaultIndentSize => 4;
1312
private static string DefaultNewLine => Environment.NewLine;
1413

1514
public static RazorCodeGenerationOptions Default { get; } = new(
16-
languageVersion: DefaultLanguageVersion,
1715
indentSize: DefaultIndentSize,
1816
newLine: DefaultNewLine,
1917
rootNamespace: null,
2018
suppressUniqueIds: null,
2119
flags: Flags.DefaultFlags);
2220

2321
public static RazorCodeGenerationOptions DesignTimeDefault { get; } = new(
24-
languageVersion: DefaultLanguageVersion,
2522
indentSize: DefaultIndentSize,
2623
newLine: DefaultNewLine,
2724
rootNamespace: null,
2825
suppressUniqueIds: null,
2926
flags: Flags.DefaultDesignTimeFlags);
3027

31-
public RazorLanguageVersion LanguageVersion { get; }
32-
3328
public int IndentSize { get; }
3429
public string NewLine { get; }
3530

@@ -46,14 +41,12 @@ public sealed partial class RazorCodeGenerationOptions
4641
private readonly Flags _flags;
4742

4843
private RazorCodeGenerationOptions(
49-
RazorLanguageVersion languageVersion,
5044
int indentSize,
5145
string newLine,
5246
string? rootNamespace,
5347
string? suppressUniqueIds,
5448
Flags flags)
5549
{
56-
LanguageVersion = languageVersion ?? DefaultLanguageVersion;
5750
IndentSize = indentSize;
5851
NewLine = newLine;
5952
RootNamespace = rootNamespace;
@@ -153,22 +146,22 @@ public bool RemapLinePragmaPathsOnWindows
153146
public RazorCodeGenerationOptions WithIndentSize(int value)
154147
=> IndentSize == value
155148
? this
156-
: new(LanguageVersion, value, NewLine, RootNamespace, SuppressUniqueIds, _flags);
149+
: new(value, NewLine, RootNamespace, SuppressUniqueIds, _flags);
157150

158151
public RazorCodeGenerationOptions WithNewLine(string value)
159152
=> NewLine == value
160153
? this
161-
: new(LanguageVersion, IndentSize, value, RootNamespace, SuppressUniqueIds, _flags);
154+
: new(IndentSize, value, RootNamespace, SuppressUniqueIds, _flags);
162155

163156
public RazorCodeGenerationOptions WithRootNamespace(string? value)
164157
=> RootNamespace == value
165158
? this
166-
: new(LanguageVersion, IndentSize, NewLine, value, SuppressUniqueIds, _flags);
159+
: new(IndentSize, NewLine, value, SuppressUniqueIds, _flags);
167160

168161
public RazorCodeGenerationOptions WithSuppressUniqueIds(string? value)
169162
=> RootNamespace == value
170163
? this
171-
: new(LanguageVersion, IndentSize, NewLine, RootNamespace, value, _flags);
164+
: new(IndentSize, NewLine, RootNamespace, value, _flags);
172165

173166
public RazorCodeGenerationOptions WithFlags(
174167
Optional<bool> designTime = default,
@@ -248,6 +241,6 @@ public RazorCodeGenerationOptions WithFlags(
248241

249242
return flags == _flags
250243
? this
251-
: new(LanguageVersion, IndentSize, NewLine, RootNamespace, SuppressUniqueIds, flags);
244+
: new(IndentSize, NewLine, RootNamespace, SuppressUniqueIds, flags);
252245
}
253246
}

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorProjectEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ private RazorParserOptions ComputeParserOptions(string fileKind, Action<RazorPar
266266
private RazorCodeGenerationOptions ComputeCodeGenerationOptions(Action<RazorCodeGenerationOptions.Builder>? configure)
267267
{
268268
var configuration = Configuration;
269-
var builder = new RazorCodeGenerationOptions.Builder(configuration.LanguageVersion)
269+
var builder = new RazorCodeGenerationOptions.Builder()
270270
{
271271
SuppressAddComponentParameter = configuration.SuppressAddComponentParameter
272272
};

0 commit comments

Comments
 (0)