Skip to content

Commit

Permalink
BH0003 Page
Browse files Browse the repository at this point in the history
  • Loading branch information
na1307 committed Jan 1, 2025
1 parent 19584c8 commit fbc35de
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Bluehill.Analyzers.Pages/Pages/BH0001.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
Console.WriteLine("Test");
}
}

public class AnotherClass;

public class InheritedClass : AnotherClass;
</CodeHighlight>

Expand Down
6 changes: 3 additions & 3 deletions Bluehill.Analyzers.Pages/Pages/BH0002.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
public TestClass(string name) {
this.name = name;
}

public void TestMethod() {
Console.WriteLine(name);
}

private readonly string name;
}
</CodeHighlight>
Expand All @@ -25,7 +25,7 @@
<CodeHighlight>
public class TestClass {
private readonly string name;

public TestClass(string name) {
this.name = name;
}
Expand Down
27 changes: 27 additions & 0 deletions Bluehill.Analyzers.Pages/Pages/BH0003.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@page "/BH0003"

<h1>BH0003: Prohibit reassignment of primary constructor parameters</h1>

<p>The parameters of the primary constructor must not be reassigned.</p>

<h2>Code with violation</h2>

<CodeHighlight>
public class TestClass(int i) {
public void TestMethod() {
i = 10;
}
}
</CodeHighlight>

<h2>Fixed Code</h2>

<CodeHighlight>
public class TestClass(int i) {
private int I = i;

public void TestMethod() {
I = 10;
}
}
</CodeHighlight>
1 change: 1 addition & 0 deletions Bluehill.Analyzers.Pages/Pages/Rules.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<ul>
<li><NavLink href="BH0001">BH0001</NavLink></li>
<li><NavLink href="BH0002">BH0002</NavLink></li>
<li><NavLink href="BH0003">BH0003</NavLink></li>
</ul>

0 comments on commit fbc35de

Please sign in to comment.