Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Upgrade SA #1656

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!-- Shared code analyzers used for all projects in the solution -->
<ItemGroup Condition="!$(MSBuildProjectName.EndsWith('samples'))">
<GlobalPackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" IncludeAssets="Runtime;Build;Native;contentFiles;Analyzers"/>
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" PrivateAssets="All" IncludeAssets="Runtime;Build;Native;contentFiles;Analyzers"/>
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="10.5.0.109200" PrivateAssets="All" IncludeAssets="Runtime;Build;Native;contentFiles;Analyzers"/>
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
<PackageVersion Include="Meziantou.Polyfill" Version="1.0.42" />
</ItemGroup>
Expand All @@ -28,7 +28,7 @@

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

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
Expand Down
2 changes: 1 addition & 1 deletion tests/bunit.core.tests/Rendering/RenderModeTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
</ComponentWithChildContent>
</ComponentWithChildContent>);

act.ShouldThrow<RenderModeMisMatchException>(); // todo: figure out good exception to use
act.ShouldThrow<RenderModeMisMatchException>();
}
}
@code{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void Test013(string key)
{
var fakeState = this.AddFakePersistentComponentState();

fakeState.TryTake<string>(key, out var actual).ShouldBeFalse();
fakeState.TryTake<string>(key, out _).ShouldBeFalse();
}

[Fact(DisplayName = "TriggerOnPersisting triggers OnPersisting callbacks added to store")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Child components follow.

@code {
int numAdded = 0;
List<string> currentChildrenMessages = new List<string>();
private readonly List<string> currentChildrenMessages = new List<string>();

void AddChild()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/bunit.testassets/BlazorE2E/DataDashComponent.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="cool_beans" data-tab="@TabId">@TabId</div>

@code {
string TabId = "17";
private readonly string TabId = "17";
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>

@functions {
Dictionary<string, object> elementValues = new Dictionary<string, object>
private readonly Dictionary<string, object> elementValues = new Dictionary<string, object>
{
{ "bool", true },
{ "string", "middle-value" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Type here: <input @onkeypress=OnKeyPressed />
</ul>

@code {
List<string> keysPressed = new List<string>();
private readonly List<string> keysPressed = new List<string>();

void OnKeyPressed(KeyboardEventArgs eventArgs)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#nullable disable
bool changeOutput;

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

void EmitMarkupBlock(RenderTreeBuilder builder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@

@code {
#nullable disable
List<TodoItem> items = new List<TodoItem>
private readonly List<TodoItem> items = new List<TodoItem>
{
new TodoItem { Text = "Alpha" },
new TodoItem { Text = "Beta" },
new TodoItem { Text = "Gamma", IsDone = true },
new TodoItem { Text = "Delta", IsDone = true },
};

class TodoItem
private sealed class TodoItem
{
public bool IsDone { get; set; }
public string Text { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion tests/bunit.testassets/BlazorE2E/OrderedList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
@foreach (var item in Items)
{
@Template(new Context { Index = index++, Item = item, });
@Template(new Context { Index = index++, Item = item, })
}
</ol>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<button id="tick" @onclick="Tick">Tick</button>
<button id="tock" @onclick="Tock">Tock</button>
@code {
private TaskCompletionSource<object?> _tcs = new TaskCompletionSource<object?>();
private readonly TaskCompletionSource<object?> _tcs = new TaskCompletionSource<object?>();
public int Counter;

private Task Tick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
{
registeredTask = task;
delegatedTask = task == null ? null : DelegateTo(task);
RenderWhenDone();
_ = RenderWhenDone();
}

base.OnParametersSet();
}

private async void RenderWhenDone()
private async Task RenderWhenDone()
{
var task = delegatedTask;
if (task != null)
Expand All @@ -44,7 +44,7 @@

private static async Task<object?> DelegateTo(Task task)
{
await task;//.ConfigureAwait(false);
await task;
return null;
}
}
7 changes: 5 additions & 2 deletions tests/bunit.testassets/SampleComponents/RenderOnClick.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

@code {
public int RenderCount { get; private set; }

void IncreaseCount() { }

void IncreaseCount()
{
// Left empty on purpose
}

protected override void OnAfterRender(bool firstRender) => RenderCount++;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@code {
protected override void OnInitialized()
{
var localizedString = StringLocalizer["StringName"];
_ = StringLocalizer["StringName"];
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@typeparam T
@foreach (var d in Data)
{
@Template?.Invoke(d);
@Template?.Invoke(d)
}
@code
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
<p>Read the details carefully!</p>
}
<details id="details-toggle" @ontoggle="OnToggle">
<details id="details-toggle" @ontoggle="@OnToggle">
<summary>Summary</summary>
<p>Detailed content</p>
</details>
Expand Down
8 changes: 2 additions & 6 deletions tests/bunit.web.tests/Asserting/MarkupMatchesTests.razor
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
@using Bunit.TestAssets
@using Bunit.TestAssets.SampleComponents
@inherits TestContext
@code {
private readonly ITestOutputHelper outputHelper;

public MarkupMatchesTests(ITestOutputHelper outputHelper)
public MarkupMatchesTests()
{
this.outputHelper = outputHelper;
TestContext.DefaultWaitTimeout = TimeSpan.FromSeconds(30);
DefaultWaitTimeout = TimeSpan.FromSeconds(30);
}

[Fact]
Expand Down
Loading