Skip to content

Commit 505ff6c

Browse files
authored
refactor(NET11): suppress false positive analyzer warnings (#8543)
1 parent 1816327 commit 505ff6c

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎src/BootstrapBlazor.Server/Components/Pages/Chats.razor.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -99,7 +99,10 @@ private async Task GetCompletionsAsync()
9999
if (!string.IsNullOrEmpty(chatMessage.Content))
100100
{
101101
msg.Content += chatMessage.Content;
102+
// TODO: NET 11 误报警告
103+
#pragma warning disable BL0012 // Unnecessary StateHasChanged call
102104
StateHasChanged();
105+
#pragma warning restore BL0012 // Unnecessary StateHasChanged call
103106
}
104107
}
105108

‎src/BootstrapBlazor.Server/Components/Samples/Blocks.razor.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -52,7 +52,10 @@ private async Task ToggleAuthor()
5252
if (!IsAuth)
5353
{
5454
mock.Login();
55+
// TODO: NET 11 误报警告
56+
#pragma warning disable BL0013 // AuthenticationStateProvider.GetAuthenticationStateAsync used without subscribing to AuthenticationStateChanged
5557
var state = await mock.GetAuthenticationStateAsync();
58+
#pragma warning restore BL0013 // AuthenticationStateProvider.GetAuthenticationStateAsync used without subscribing to AuthenticationStateChanged
5659
UserName = state.User.Identity?.Name;
5760
IsAuth = state.User.Identity?.IsAuthenticated ?? false;
5861
}

‎test/UnitTest/Utils/JSModuleTest.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ protected virtual ValueTask DisposeAsyncCore(bool disposing)
132132

133133
public async ValueTask DisposeAsync()
134134
{
135+
// TODO: NET 11 误报警告
136+
#pragma warning disable BL0016 // Unguarded JS interop call
135137
await DisposeAsyncCore(true);
138+
#pragma warning restore BL0016 // Unguarded JS interop call
136139
GC.SuppressFinalize(this);
137140
}
138141

0 commit comments

Comments
 (0)