Skip to content

Commit a689c16

Browse files
committed
chore: Upgrade SA
1 parent 3f1ca07 commit a689c16

17 files changed

+26
-27
lines changed

Directory.Packages.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<!-- Shared code analyzers used for all projects in the solution -->
77
<ItemGroup Condition="!$(MSBuildProjectName.EndsWith('samples'))">
88
<GlobalPackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" IncludeAssets="Runtime;Build;Native;contentFiles;Analyzers"/>
9-
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" PrivateAssets="All" IncludeAssets="Runtime;Build;Native;contentFiles;Analyzers"/>
9+
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="10.5.0.109200" PrivateAssets="All" IncludeAssets="Runtime;Build;Native;contentFiles;Analyzers"/>
1010
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
1111
<PackageVersion Include="Meziantou.Polyfill" Version="1.0.42" />
1212
</ItemGroup>
@@ -28,7 +28,7 @@
2828

2929
<ItemGroup Label="System.Text.Json Vulnerability">
3030
<!-- Due to a CVE in System.Text.Json we explicitly reference the latest version of System.Text.Json -->
31-
<PackageVersion Include="System.Text.Json" Version="9.0.0"/>
31+
<PackageVersion Include="System.Text.Json" Version="9.0.1"/>
3232
</ItemGroup>
3333

3434
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">

tests/bunit.core.tests/Rendering/RenderModeTests.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
</ComponentWithChildContent>
169169
</ComponentWithChildContent>);
170170

171-
act.ShouldThrow<RenderModeMisMatchException>(); // todo: figure out good exception to use
171+
act.ShouldThrow<RenderModeMisMatchException>();
172172
}
173173
}
174174
@code{

tests/bunit.core.tests/TestDoubles/PersistentComponentState/FakePersistentComponentStateTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void Test013(string key)
6767
{
6868
var fakeState = this.AddFakePersistentComponentState();
6969

70-
fakeState.TryTake<string>(key, out var actual).ShouldBeFalse();
70+
fakeState.TryTake<string>(key, out _).ShouldBeFalse();
7171
}
7272

7373
[Fact(DisplayName = "TriggerOnPersisting triggers OnPersisting callbacks added to store")]

tests/bunit.testassets/BlazorE2E/AddRemoveChildComponents.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Child components follow.
1010

1111
@code {
1212
int numAdded = 0;
13-
List<string> currentChildrenMessages = new List<string>();
13+
private readonly List<string> currentChildrenMessages = new List<string>();
1414

1515
void AddChild()
1616
{
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div id="cool_beans" data-tab="@TabId">@TabId</div>
22

33
@code {
4-
string TabId = "17";
4+
private readonly string TabId = "17";
55
}

tests/bunit.testassets/BlazorE2E/DuplicateAttributesComponent.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</div>
1414

1515
@functions {
16-
Dictionary<string, object> elementValues = new Dictionary<string, object>
16+
private readonly Dictionary<string, object> elementValues = new Dictionary<string, object>
1717
{
1818
{ "bool", true },
1919
{ "string", "middle-value" },

tests/bunit.testassets/BlazorE2E/KeyPressEventComponent.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Type here: <input @onkeypress=OnKeyPressed />
99
</ul>
1010

1111
@code {
12-
List<string> keysPressed = new List<string>();
12+
private readonly List<string> keysPressed = new List<string>();
1313

1414
void OnKeyPressed(KeyboardEventArgs eventArgs)
1515
{

tests/bunit.testassets/BlazorE2E/MarkupBlockComponent.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#nullable disable
2929
bool changeOutput;
3030

31-
string myMarkup = "<p class='markup-string-value'>This is a <em>markup string</em>.</p>";
31+
private readonly string myMarkup = "<p class='markup-string-value'>This is a <em>markup string</em>.</p>";
3232

3333
void EmitMarkupBlock(RenderTreeBuilder builder)
3434
{

tests/bunit.testassets/BlazorE2E/MovingCheckboxesComponent.razor

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141

4242
@code {
4343
#nullable disable
44-
List<TodoItem> items = new List<TodoItem>
44+
private readonly List<TodoItem> items = new List<TodoItem>
4545
{
4646
new TodoItem { Text = "Alpha" },
4747
new TodoItem { Text = "Beta" },
4848
new TodoItem { Text = "Gamma", IsDone = true },
4949
new TodoItem { Text = "Delta", IsDone = true },
5050
};
5151

52-
class TodoItem
52+
private sealed class TodoItem
5353
{
5454
public bool IsDone { get; set; }
5555
public string Text { get; set; }

tests/bunit.testassets/BlazorE2E/OrderedList.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77
@foreach (var item in Items)
88
{
9-
@Template(new Context { Index = index++, Item = item, });
9+
@Template(new Context { Index = index++, Item = item, })
1010
}
1111
</ol>
1212

tests/bunit.testassets/SampleComponents/AsyncRenderChangesProperty.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<button id="tick" @onclick="Tick">Tick</button>
22
<button id="tock" @onclick="Tock">Tock</button>
33
@code {
4-
private TaskCompletionSource<object?> _tcs = new TaskCompletionSource<object?>();
4+
private readonly TaskCompletionSource<object?> _tcs = new TaskCompletionSource<object?>();
55
public int Counter;
66

77
private Task Tick()

tests/bunit.testassets/SampleComponents/InvokeAsyncInsideContinueWith.razor

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
{
2323
registeredTask = task;
2424
delegatedTask = task == null ? null : DelegateTo(task);
25-
RenderWhenDone();
25+
_ = RenderWhenDone();
2626
}
2727

2828
base.OnParametersSet();
2929
}
3030

31-
private async void RenderWhenDone()
31+
private async Task RenderWhenDone()
3232
{
3333
var task = delegatedTask;
3434
if (task != null)
@@ -44,7 +44,7 @@
4444

4545
private static async Task<object?> DelegateTo(Task task)
4646
{
47-
await task;//.ConfigureAwait(false);
47+
await task;
4848
return null;
4949
}
5050
}

tests/bunit.testassets/SampleComponents/RenderOnClick.razor

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
@code {
44
public int RenderCount { get; private set; }
5-
6-
void IncreaseCount() { }
5+
6+
void IncreaseCount()
7+
{
8+
// Left empty on purpose
9+
}
710

811
protected override void OnAfterRender(bool firstRender) => RenderCount++;
912
}

tests/bunit.testassets/SampleComponents/SimpleUsingLocalizer.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@code {
77
protected override void OnInitialized()
88
{
9-
var localizedString = StringLocalizer["StringName"];
9+
_ = StringLocalizer["StringName"];
1010
}
1111

1212
}

tests/bunit.testassets/SampleComponents/SimpleWithTemplate.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@typeparam T
22
@foreach (var d in Data)
33
{
4-
@Template?.Invoke(d);
4+
@Template?.Invoke(d)
55
}
66
@code
77
{

tests/bunit.testassets/SampleComponents/ToggleableDetails.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
<p>Read the details carefully!</p>
55
}
6-
<details id="details-toggle" @ontoggle="OnToggle">
6+
<details id="details-toggle" @ontoggle="@OnToggle">
77
<summary>Summary</summary>
88
<p>Detailed content</p>
99
</details>

tests/bunit.web.tests/Asserting/MarkupMatchesTests.razor

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
@using Bunit.TestAssets
21
@using Bunit.TestAssets.SampleComponents
32
@inherits TestContext
43
@code {
5-
private readonly ITestOutputHelper outputHelper;
6-
7-
public MarkupMatchesTests(ITestOutputHelper outputHelper)
4+
public MarkupMatchesTests()
85
{
9-
this.outputHelper = outputHelper;
10-
TestContext.DefaultWaitTimeout = TimeSpan.FromSeconds(30);
6+
DefaultWaitTimeout = TimeSpan.FromSeconds(30);
117
}
128

139
[Fact]

0 commit comments

Comments
 (0)