Skip to content

Commit e70ae71

Browse files
committed
Modify constructor
1 parent f3ad1e3 commit e70ae71

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public sealed class CodeWriter
1818
private int _currentLineIndex;
1919
private int _currentLineCharacterIndex;
2020

21-
public CodeWriter() : this(Environment.NewLine, indentWithTabs: false, tabSize: 4)
21+
public CodeWriter() : this(Environment.NewLine, RazorCodeGenerationOptions.CreateDefault())
2222
{
2323
}
2424

25-
public CodeWriter(string newLine, bool indentWithTabs, int tabSize)
25+
public CodeWriter(string newLine, RazorCodeGenerationOptions options)
2626
{
2727
NewLine = newLine;
28-
IndentWithTabs = indentWithTabs;
29-
TabSize = tabSize;
28+
IndentWithTabs = options.IndentWithTabs;
29+
TabSize = options.IndentSize;
3030
_builder = new StringBuilder();
3131
}
3232

src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultDocumentWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public override RazorCSharpDocument WriteDocument(RazorCodeDocument codeDocument
3232
}
3333

3434
var context = new DefaultCodeRenderingContext(
35-
new CodeWriter(Environment.NewLine, _options.IndentWithTabs, _options.IndentSize),
35+
new CodeWriter(Environment.NewLine, _options),
3636
_codeTarget.CreateNodeWriter(),
3737
codeDocument,
3838
documentNode,

src/Razor/Microsoft.AspNetCore.Razor.Language/src/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter.IndentWithTabs.get
33
Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter.TabSize.get -> int
44
Microsoft.AspNetCore.Razor.Language.Intermediate.CascadingGenericTypeParameter
55
Microsoft.AspNetCore.Razor.Language.Intermediate.CascadingGenericTypeParameter.CascadingGenericTypeParameter() -> void
6-
~Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter.CodeWriter(string newLine, bool indentWithTabs, int tabSize) -> void
6+
~Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter.CodeWriter(string newLine, Microsoft.AspNetCore.Razor.Language.RazorCodeGenerationOptions options) -> void
77
~Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter.Indent(int size) -> Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter
88
~Microsoft.AspNetCore.Razor.Language.Intermediate.CascadingGenericTypeParameter.GenericTypeNames.get -> System.Collections.Generic.IReadOnlyCollection<string>
99
~Microsoft.AspNetCore.Razor.Language.Intermediate.CascadingGenericTypeParameter.GenericTypeNames.set -> void

src/Razor/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/CSharpCodeWriterTest.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,13 @@ public void WriteAutoPropertyDeclaration_WithModifiers_WritesPropertyDeclaration
364364
public void CSharpCodeWriter_RespectTabSetting()
365365
{
366366
// Arrange
367-
var writer = new CodeWriter(Environment.NewLine, indentWithTabs: true, tabSize: 4);
367+
var options = RazorCodeGenerationOptions.Create(o =>
368+
{
369+
o.IndentWithTabs = true;
370+
o.IndentSize = 4;
371+
});
372+
373+
var writer = new CodeWriter(Environment.NewLine, options);
368374

369375
// Act
370376
writer.BuildClassDeclaration(Array.Empty<string>(), "C", "", Array.Empty<string>(), Array.Empty<string>());
@@ -379,7 +385,13 @@ public void CSharpCodeWriter_RespectTabSetting()
379385
public void CSharpCodeWriter_RespectSpaceSetting()
380386
{
381387
// Arrange
382-
var writer = new CodeWriter(Environment.NewLine, indentWithTabs: false, tabSize: 4);
388+
var options = RazorCodeGenerationOptions.Create(o =>
389+
{
390+
o.IndentWithTabs = false;
391+
o.IndentSize = 4;
392+
});
393+
394+
var writer = new CodeWriter(Environment.NewLine, options);
383395

384396
// Act
385397
writer.BuildClassDeclaration(Array.Empty<string>(), "C", "", Array.Empty<string>(), Array.Empty<string>());

0 commit comments

Comments
 (0)