Skip to content

Commit 8dbe230

Browse files
committed
Refactor: Make IndexHtmlFragments properties immutable
1 parent 77e87c5 commit 8dbe230

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

BlazorWasmPreRendering.Build.Shared/IndexHtmlFragments.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
public class IndexHtmlFragments
44
{
5-
public string FirstPart { get; set; } = "";
6-
public string MiddlePart { get; set; } = "";
7-
public string LastPart { get; set; } = "";
5+
public string FirstPart { get; }
6+
7+
public string MiddlePart { get; }
8+
9+
public string LastPart { get; }
810

911
public IndexHtmlFragments(string firstPart, string middlePart, string lastPart)
1012
{

BlazorWasmPreRendering.Build.Shared/ServerSideRenderingOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ServerSideRenderingOptions
2222

2323
public RenderMode RenderMode { get; init; }
2424

25-
public IndexHtmlFragments IndexHtmlFragments { get; set; } = new("", "", "");
25+
public IndexHtmlFragments IndexHtmlFragments { get; init; } = new("", "", "");
2626

2727
public bool DeleteLoadingContents { get; init; }
2828

BlazorWasmPreRendering.Build.Test/BuildProgramTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ public void StoreOptionsToEnvironment_Test()
7373
DeleteLoadingContents = true,
7474
Environment = "Production",
7575
EmulateAuthMe = false,
76-
IndexHtmlFragments = {
77-
FirstPart = "<html>\r\n<head>\r\n",
78-
LastPart = "</body>\r\n</html>",
79-
MiddlePart = "</head>\r\n<body>\r\n",
80-
},
76+
IndexHtmlFragments = new(
77+
firstPart: "<html>\r\n<head>\r\n",
78+
lastPart: "</body>\r\n</html>",
79+
middlePart: "</head>\r\n<body>\r\n"
80+
),
8181
Locales = { "en", "ja" },
8282
MiddlewareDllsDir = "C:\\project\\obj\\Release\\net6.0\\middleware",
8383
MiddlewarePackages = {
@@ -126,11 +126,11 @@ public void StoreOptionsToEnvironment_NoMiddlewarePackages_Test()
126126
DeleteLoadingContents = false,
127127
Environment = "Development",
128128
EmulateAuthMe = true,
129-
IndexHtmlFragments = {
130-
FirstPart = "<html>\r\n<head>\r\n",
131-
LastPart = "</body>\r\n</html>",
132-
MiddlePart = "</head>\r\n<body>\r\n"
133-
},
129+
IndexHtmlFragments = new(
130+
firstPart: "<html>\r\n<head>\r\n",
131+
lastPart: "</body>\r\n</html>",
132+
middlePart: "</head>\r\n<body>\r\n"
133+
),
134134
MiddlewareDllsDir = "C:\\project\\obj\\Release\\net6.0\\middleware",
135135
RenderMode = RenderMode.Static,
136136
RootComponentTypeName = "Project.App",

0 commit comments

Comments
 (0)