Skip to content

Commit c24c14d

Browse files
Copilotlinkdotnet
andcommitted
docs: Fix documentation style per review feedback
- Remove "you" form from documentation (use passive voice) - Remove emojis from code examples - Change RenderComponent to Render in examples - Update test method names: RenderedFragment -> RenderedComponent Co-authored-by: linkdotnet <[email protected]>
1 parent 0873523 commit c24c14d

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

docs/site/docs/extensions/bunit-analyzers.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,42 @@ The analyzers will automatically run during compilation and provide warnings or
2626
**Severity**: Info
2727
**Category**: Usage
2828

29-
This analyzer detects when you cast the result of `Find(selector)` and suggests using the generic `Find<T>(selector)` method instead. Using the generic method is more concise, type-safe, and expresses intent more clearly.
29+
This analyzer detects when a cast is applied to the result of `Find(selector)` and suggests using the generic `Find<T>(selector)` method instead. Using the generic method is more concise, type-safe, and expresses intent more clearly.
3030

3131
#### Examples
3232

33-
**Incorrect** - triggers BUNIT0002:
33+
**Incorrect** - triggers BUNIT0002:
3434
```csharp
3535
using AngleSharp.Dom;
3636

37-
var cut = RenderComponent<MyComponent>();
37+
var cut = Render<MyComponent>();
3838
IHtmlAnchorElement link = (IHtmlAnchorElement)cut.Find("a");
3939
```
4040

41-
**Correct**:
41+
**Correct**:
4242
```csharp
4343
using AngleSharp.Dom;
4444

45-
var cut = RenderComponent<MyComponent>();
45+
var cut = Render<MyComponent>();
4646
var link = cut.Find<IHtmlAnchorElement>("a");
4747
```
4848

4949
#### When to Use
5050

51-
Use `Find<T>()` whenever you need a specific element type:
51+
`Find<T>()` should be used whenever a specific element type is needed:
5252
- When working with AngleSharp element interfaces (`IHtmlAnchorElement`, `IHtmlButtonElement`, etc.)
53-
- When you need to access type-specific properties or methods
54-
- When you want clearer, more maintainable test code
53+
- When type-specific properties or methods need to be accessed
54+
- When clearer, more maintainable test code is desired
5555

5656
### BUNIT0001: Razor test files should inherit from BunitContext
5757

58-
**Status**: 🚧 Planned for future release
58+
**Status**: Planned for future release
5959

60-
This analyzer will detect when Razor test files (`.razor` files) use variables or event callbacks from the test code without inheriting from `BunitContext`. Without the proper inheritance, you may encounter the error "The render handle is not yet assigned."
60+
This analyzer will detect when Razor test files (`.razor` files) use variables or event callbacks from the test code without inheriting from `BunitContext`. Without the proper inheritance, the error "The render handle is not yet assigned" may be encountered.
6161

6262
#### Planned Examples
6363

64-
**Incorrect** - will trigger BUNIT0001 in the future:
64+
**Incorrect** - will trigger BUNIT0001 in the future:
6565
```razor
6666
@code
6767
{
@@ -78,7 +78,7 @@ This analyzer will detect when Razor test files (`.razor` files) use variables o
7878
}
7979
```
8080

81-
**Correct**:
81+
**Correct**:
8282
```razor
8383
@inherits BunitContext
8484
@code
@@ -101,7 +101,7 @@ This analyzer will detect when Razor test files (`.razor` files) use variables o
101101

102102
## Configuration
103103

104-
The analyzers can be configured in your project's `.editorconfig` file or using ruleset files. For example, to change the severity of BUNIT0002:
104+
The analyzers can be configured in a project's `.editorconfig` file or using ruleset files. For example, to change the severity of BUNIT0002:
105105

106106
```ini
107107
# .editorconfig

tests/bunit.analyzers.tests/PreferGenericFindAnalyzerTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class TestHelper
5757
}
5858

5959
[Fact]
60-
public async Task NoDiagnostic_WhenFindIsNotFromRenderedFragment()
60+
public async Task NoDiagnostic_WhenFindIsNotFromRenderedComponent()
6161
{
6262
const string code = @"
6363
namespace TestNamespace
@@ -81,7 +81,7 @@ public class UnrelatedHelper
8181
}
8282

8383
[Fact]
84-
public async Task Diagnostic_WhenCastingFindResultFromIRenderedFragment()
84+
public async Task Diagnostic_WhenCastingFindResultFromIRenderedComponent()
8585
{
8686
const string code = @"
8787
namespace TestNamespace
@@ -92,17 +92,17 @@ public class TestClass
9292
{
9393
public void TestMethod()
9494
{
95-
var cut = new MockRenderedFragment();
95+
var cut = new MockRenderedComponent();
9696
IMyElement elem = {|#0:(IMyElement)cut.Find(""a"")|};
9797
}
9898
}
9999
100-
public interface IRenderedFragment
100+
public interface IRenderedComponent
101101
{
102102
object Find(string selector);
103103
}
104104
105-
public class MockRenderedFragment : IRenderedFragment
105+
public class MockRenderedComponent : IRenderedComponent
106106
{
107107
public object Find(string selector) => null;
108108
}
@@ -151,7 +151,7 @@ public class MockRenderedComponent : IRenderedComponent
151151
}
152152

153153
[Fact]
154-
public async Task Diagnostic_WhenCastingFindResultFromRenderedFragmentType()
154+
public async Task Diagnostic_WhenCastingFindResultFromRenderedComponentType()
155155
{
156156
const string code = @"
157157
namespace TestNamespace
@@ -162,12 +162,12 @@ public class TestClass
162162
{
163163
public void TestMethod()
164164
{
165-
var cut = new RenderedFragment();
165+
var cut = new RenderedComponent();
166166
var button = {|#0:(IMyElement)cut.Find(""button"")|};
167167
}
168168
}
169169
170-
public class RenderedFragment
170+
public class RenderedComponent
171171
{
172172
public object Find(string selector) => null;
173173
}
@@ -192,17 +192,17 @@ public class TestClass
192192
{
193193
public void TestMethod()
194194
{
195-
var cut = new MockRenderedFragment();
195+
var cut = new MockRenderedComponent();
196196
var link = {|#0:(IMyElement)cut.Find(""a.nav-link[href='/home']"")|};
197197
}
198198
}
199199
200-
public interface IRenderedFragment
200+
public interface IRenderedComponent
201201
{
202202
object Find(string selector);
203203
}
204204
205-
public class MockRenderedFragment : IRenderedFragment
205+
public class MockRenderedComponent : IRenderedComponent
206206
{
207207
public object Find(string selector) => null;
208208
}

0 commit comments

Comments
 (0)