Skip to content

Commit 437fe15

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

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
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, FileKinds.Legacy);
124+
var builder = new RazorCodeGenerationOptions.Builder(RazorLanguageVersion.Latest);
125125

126126
foreach (var feature in features)
127127
{

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public sealed partial class RazorCodeGenerationOptions
88
public sealed class Builder
99
{
1010
public RazorLanguageVersion LanguageVersion { get; }
11-
public string FileKind { get; }
1211

1312
private Flags _flags;
1413

@@ -25,10 +24,9 @@ public sealed class Builder
2524
/// </summary>
2625
public string? SuppressUniqueIds { get; set; }
2726

28-
internal Builder(RazorLanguageVersion languageVersion, string fileKind)
27+
internal Builder(RazorLanguageVersion languageVersion)
2928
{
3029
LanguageVersion = languageVersion ?? DefaultLanguageVersion;
31-
FileKind = fileKind ?? DefaultFileKind;
3230
IndentSize = DefaultIndentSize;
3331
NewLine = DefaultNewLine;
3432
}
@@ -159,6 +157,6 @@ public bool RemapLinePragmaPathsOnWindows
159157
}
160158

161159
public RazorCodeGenerationOptions ToOptions()
162-
=> new(LanguageVersion, FileKind, IndentSize, NewLine, RootNamespace, SuppressUniqueIds, _flags);
160+
=> new(LanguageVersion, IndentSize, NewLine, RootNamespace, SuppressUniqueIds, _flags);
163161
}
164162
}

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ namespace Microsoft.AspNetCore.Razor.Language;
99
public sealed partial class RazorCodeGenerationOptions
1010
{
1111
private static RazorLanguageVersion DefaultLanguageVersion => RazorLanguageVersion.Latest;
12-
private static string DefaultFileKind => FileKinds.Legacy;
1312
private static int DefaultIndentSize => 4;
1413
private static string DefaultNewLine => Environment.NewLine;
1514

1615
public static RazorCodeGenerationOptions Default { get; } = new(
1716
languageVersion: DefaultLanguageVersion,
18-
fileKind: DefaultFileKind,
1917
indentSize: DefaultIndentSize,
2018
newLine: DefaultNewLine,
2119
rootNamespace: null,
@@ -24,15 +22,13 @@ public sealed partial class RazorCodeGenerationOptions
2422

2523
public static RazorCodeGenerationOptions DesignTimeDefault { get; } = new(
2624
languageVersion: DefaultLanguageVersion,
27-
fileKind: DefaultFileKind,
2825
indentSize: DefaultIndentSize,
2926
newLine: DefaultNewLine,
3027
rootNamespace: null,
3128
suppressUniqueIds: null,
3229
flags: Flags.DefaultDesignTimeFlags);
3330

3431
public RazorLanguageVersion LanguageVersion { get; }
35-
internal string FileKind { get; }
3632

3733
public int IndentSize { get; }
3834
public string NewLine { get; }
@@ -51,15 +47,13 @@ public sealed partial class RazorCodeGenerationOptions
5147

5248
private RazorCodeGenerationOptions(
5349
RazorLanguageVersion languageVersion,
54-
string fileKind,
5550
int indentSize,
5651
string newLine,
5752
string? rootNamespace,
5853
string? suppressUniqueIds,
5954
Flags flags)
6055
{
6156
LanguageVersion = languageVersion ?? DefaultLanguageVersion;
62-
FileKind = fileKind ?? DefaultFileKind;
6357
IndentSize = indentSize;
6458
NewLine = newLine;
6559
RootNamespace = rootNamespace;
@@ -159,22 +153,22 @@ public bool RemapLinePragmaPathsOnWindows
159153
public RazorCodeGenerationOptions WithIndentSize(int value)
160154
=> IndentSize == value
161155
? this
162-
: new(LanguageVersion, FileKind, value, NewLine, RootNamespace, SuppressUniqueIds, _flags);
156+
: new(LanguageVersion, value, NewLine, RootNamespace, SuppressUniqueIds, _flags);
163157

164158
public RazorCodeGenerationOptions WithNewLine(string value)
165159
=> NewLine == value
166160
? this
167-
: new(LanguageVersion, FileKind, IndentSize, value, RootNamespace, SuppressUniqueIds, _flags);
161+
: new(LanguageVersion, IndentSize, value, RootNamespace, SuppressUniqueIds, _flags);
168162

169163
public RazorCodeGenerationOptions WithRootNamespace(string? value)
170164
=> RootNamespace == value
171165
? this
172-
: new(LanguageVersion, FileKind, IndentSize, NewLine, value, SuppressUniqueIds, _flags);
166+
: new(LanguageVersion, IndentSize, NewLine, value, SuppressUniqueIds, _flags);
173167

174168
public RazorCodeGenerationOptions WithSuppressUniqueIds(string? value)
175169
=> RootNamespace == value
176170
? this
177-
: new(LanguageVersion, FileKind, IndentSize, NewLine, RootNamespace, value, _flags);
171+
: new(LanguageVersion, IndentSize, NewLine, RootNamespace, value, _flags);
178172

179173
public RazorCodeGenerationOptions WithFlags(
180174
Optional<bool> designTime = default,
@@ -254,6 +248,6 @@ public RazorCodeGenerationOptions WithFlags(
254248

255249
return flags == _flags
256250
? this
257-
: new(LanguageVersion, FileKind, IndentSize, NewLine, RootNamespace, SuppressUniqueIds, flags);
251+
: new(LanguageVersion, IndentSize, NewLine, RootNamespace, SuppressUniqueIds, flags);
258252
}
259253
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private RazorCodeDocument CreateCodeDocumentCore(
191191
Action<RazorCodeGenerationOptions.Builder>? configureCodeGeneration)
192192
{
193193
var parserOptions = ComputeParserOptions(fileKind, configureParser);
194-
var codeGenerationOptions = ComputeCodeGenerationOptions(fileKind, configureCodeGeneration);
194+
var codeGenerationOptions = ComputeCodeGenerationOptions(configureCodeGeneration);
195195

196196
var codeDocument = RazorCodeDocument.Create(source, importSources, parserOptions, codeGenerationOptions);
197197

@@ -233,7 +233,7 @@ private RazorCodeDocument CreateCodeDocumentDesignTimeCore(
233233
configureParser?.Invoke(builder);
234234
});
235235

236-
var codeGenerationOptions = ComputeCodeGenerationOptions(fileKind, builder =>
236+
var codeGenerationOptions = ComputeCodeGenerationOptions(builder =>
237237
{
238238
builder.DesignTime = true;
239239
builder.SuppressChecksum = true;
@@ -263,10 +263,10 @@ private RazorParserOptions ComputeParserOptions(string fileKind, Action<RazorPar
263263
return builder.ToOptions();
264264
}
265265

266-
private RazorCodeGenerationOptions ComputeCodeGenerationOptions(string fileKind, Action<RazorCodeGenerationOptions.Builder>? configure)
266+
private RazorCodeGenerationOptions ComputeCodeGenerationOptions(Action<RazorCodeGenerationOptions.Builder>? configure)
267267
{
268268
var configuration = Configuration;
269-
var builder = new RazorCodeGenerationOptions.Builder(configuration.LanguageVersion, fileKind)
269+
var builder = new RazorCodeGenerationOptions.Builder(configuration.LanguageVersion)
270270
{
271271
SuppressAddComponentParameter = configuration.SuppressAddComponentParameter
272272
};

0 commit comments

Comments
 (0)