Skip to content
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
24 changes: 12 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net11.0'">
<PackageVersion Include="Microsoft.Extensions.Logging" Version="11.0.0-preview.6.26359.118"/>
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="11.0.0-preview.6.26359.118"/>
<PackageVersion Include="Microsoft.AspNetCore.Components" Version="11.0.0-preview.6.26359.118"/>

<PackageVersion Include="Microsoft.AspNetCore.Components.Authorization" Version="11.0.0-preview.6.26359.118"/>
<PackageVersion Include="Microsoft.Extensions.Localization.Abstractions" Version="11.0.0-preview.6.26359.118"/>
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="11.0.0-preview.6.26359.118"/>
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="11.0.0-preview.6.26359.118"/>
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="11.0.0-preview.6.26359.118"/>
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="11.0.0-preview.6.26359.118"/>

<PackageVersion Include="System.Text.Json" Version="11.0.0-preview.6.26359.118"/>
<PackageVersion Include="Microsoft.Extensions.Logging" Version="11.0.0-rc.1.26425.128"/>
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="11.0.0-rc.1.26425.128"/>
<PackageVersion Include="Microsoft.AspNetCore.Components" Version="11.0.0-rc.1.26425.128"/>

<PackageVersion Include="Microsoft.AspNetCore.Components.Authorization" Version="11.0.0-rc.1.26425.128"/>
<PackageVersion Include="Microsoft.Extensions.Localization.Abstractions" Version="11.0.0-rc.1.26425.128"/>
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="11.0.0-rc.1.26425.128"/>
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="11.0.0-rc.1.26425.128"/>
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="11.0.0-rc.1.26425.128"/>
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="11.0.0-rc.1.26425.128"/>

<PackageVersion Include="System.Text.Json" Version="11.0.0-rc.1.26425.128"/>
</ItemGroup>

<ItemGroup Label="Test Dependencies">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components.Web.Virtualization;
using System.Diagnostics;
using System.Reflection;
using Microsoft.AspNetCore.Components.Web.Virtualization;

namespace Bunit.JSInterop.InvocationHandlers.Implementation;

Expand Down Expand Up @@ -35,10 +35,15 @@ internal VirtualizeJSRuntimeInvocationHandler()
/// <inheritdoc/>
protected internal override Task<Microsoft.JSInterop.Infrastructure.IJSVoidResult> HandleAsync(JSRuntimeInvocation invocation)
{
if (!invocation.Identifier.Equals(JsFunctionsPrefix + "dispose", StringComparison.Ordinal))
if (!invocation.Identifier.Equals(JsFunctionsPrefix + "dispose", StringComparison.Ordinal) &&
!invocation.Identifier.Equals(JsFunctionsPrefix + "refreshObservers", StringComparison.Ordinal))
{
Debug.Assert(invocation.Identifier.Equals(JsFunctionsPrefix + "init", StringComparison.Ordinal));
#if NET11_0_OR_GREATER
Debug.Assert(invocation.Arguments.Count == 4);
#else
Debug.Assert(invocation.Arguments.Count == 3);
#endif
Debug.Assert(invocation.Arguments[0] is not null);

InvokeOnSpacerBeforeVisible(invocation.Arguments[0]!);
Expand All @@ -58,7 +63,12 @@ private static void InvokeOnSpacerBeforeVisible(object dotNetObjectReference)
0f, /* spacerSize */
0f, /* spacerSeparation */
1_000_000_000f, /* containerSize - very large number to ensure all items are loaded at once */
#if NET11_0_OR_GREATER
0, /* UserScroll <see cref="SpacerVisibilityReason" /> */
#endif
Comment thread
vnbaaij marked this conversation as resolved.

};

onSpacerBeforeVisibleMethodInfo.Invoke(virtualizeJsInterop, parameters);
}
}
4 changes: 2 additions & 2 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<OutputType>Exe</OutputType>
</PropertyGroup>

<PropertyGroup>
<!--
<!--
Because of a CVE in System.Text.Json we get NU1903.
As this is a test project, we can ignore this warning for the time being.
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
@inject AuthenticationStateProvider AuthenticationStateProvider

<AuthorizeView>
<div>Authorized!</div>
<div>Name: @userName</div>
@if (hasUserEmail)
{
<div>Email: @userEmail</div>
}
@if (hasUserId)
{
<div>Id: @userId</div>
}
<div>Authorized!</div>
<div>Name: @userName</div>
@if (hasUserEmail)
{
<div>Email: @userEmail</div>
}
@if (hasUserId)
{
<div>Id: @userId</div>
}
</AuthorizeView>

@code {
string userName = "";
string? userEmail = "";
string? userId = "";
bool hasUserEmail => userEmail != null;
bool hasUserId => userId != null;
string userName = "";
string? userEmail = "";
string? userId = "";
bool hasUserEmail => userEmail != null;
bool hasUserId => userId != null;

protected override async Task OnParametersSetAsync()
{
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
userName = state?.User?.Identity?.Name ?? string.Empty;
userEmail = state?.User?.FindFirst(ClaimTypes.Email)?.Value;
userId = state?.User?.FindFirst(ClaimTypes.Sid)?.Value;
}
protected override async Task OnParametersSetAsync()
{
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();

Check failure on line 27 in tests/bunit.testassets/SampleComponents/SimpleAuthViewWithClaims.razor

View workflow job for this annotation

GitHub Actions / run-test (macos-latest)

'SimpleAuthViewWithClaims' calls GetAuthenticationStateAsync on AuthenticationStateProvider without subscribing to the AuthenticationStateChanged event. This may result in using stale authentication state.

Check failure on line 27 in tests/bunit.testassets/SampleComponents/SimpleAuthViewWithClaims.razor

View workflow job for this annotation

GitHub Actions / run-test (windows-latest)

'SimpleAuthViewWithClaims' calls GetAuthenticationStateAsync on AuthenticationStateProvider without subscribing to the AuthenticationStateChanged event. This may result in using stale authentication state.

Check failure on line 27 in tests/bunit.testassets/SampleComponents/SimpleAuthViewWithClaims.razor

View workflow job for this annotation

GitHub Actions / validate-docs

'SimpleAuthViewWithClaims' calls GetAuthenticationStateAsync on AuthenticationStateProvider without subscribing to the AuthenticationStateChanged event. This may result in using stale authentication state.

Check failure on line 27 in tests/bunit.testassets/SampleComponents/SimpleAuthViewWithClaims.razor

View workflow job for this annotation

GitHub Actions / run-test (ubuntu-latest)

'SimpleAuthViewWithClaims' calls GetAuthenticationStateAsync on AuthenticationStateProvider without subscribing to the AuthenticationStateChanged event. This may result in using stale authentication state.
userName = state?.User?.Identity?.Name ?? string.Empty;
userEmail = state?.User?.FindFirst(ClaimTypes.Email)?.Value;
userId = state?.User?.FindFirst(ClaimTypes.Sid)?.Value;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inject HttpClient HttpClient
@inject HttpClient HttpClient


<h3>SimpleWithHttpClient</h3>
Expand All @@ -7,6 +7,5 @@
protected override async Task OnInitializedAsync()
{
await HttpClient.GetAsync("/api/weather");
StateHasChanged();
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@inject IJSRuntime jsRuntime
@inject IJSRuntime jsRuntime
<p>@name</p>
@code{
@code {
string name = string.Empty;

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
name = await jsRuntime.InvokeAsync<string>("getdata");

Check failure on line 10 in tests/bunit.testassets/SampleComponents/SimpleWithJSRuntimeDep.razor

View workflow job for this annotation

GitHub Actions / run-test (macos-latest)

JS interop call 'InvokeAsync' is not guarded with a try/catch block.

Check failure on line 10 in tests/bunit.testassets/SampleComponents/SimpleWithJSRuntimeDep.razor

View workflow job for this annotation

GitHub Actions / run-test (windows-latest)

JS interop call 'InvokeAsync' is not guarded with a try/catch block.

Check failure on line 10 in tests/bunit.testassets/SampleComponents/SimpleWithJSRuntimeDep.razor

View workflow job for this annotation

GitHub Actions / validate-docs

JS interop call 'InvokeAsync' is not guarded with a try/catch block.

Check failure on line 10 in tests/bunit.testassets/SampleComponents/SimpleWithJSRuntimeDep.razor

View workflow job for this annotation

GitHub Actions / run-test (ubuntu-latest)

JS interop call 'InvokeAsync' is not guarded with a try/catch block.
StateHasChanged();
}
}
}
}
2 changes: 1 addition & 1 deletion tests/bunit.testassets/bunit.testassets.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0;net11.0</TargetFrameworks>
Expand Down
4 changes: 2 additions & 2 deletions tests/bunit.tests/bunit.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\bunit\bunit.csproj" />
<ProjectReference Include="..\..\src\bunit\bunit.csproj" />
<ProjectReference Include="..\bunit.testassets\bunit.testassets.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="../xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Loading