Skip to content

Commit

Permalink
Release of new minor version v1.30 (#1506)
Browse files Browse the repository at this point in the history
* Set version to '1.30-preview'

* fix: Replace Tokens in docfx.json for release information (#1496)

* fix: Add net7.0 for devcontainers

* fix: Bunit browser file exc (#1504)

* chore: Align package versions

* fix: BunitBrowserFile throws when filesize too big

* chore: Fix CVE in System.Text.Json for production code

* docs: Added changelog entry

* Set version to '1.30'

---------

Co-authored-by: Egil Hansen <[email protected]>
Co-authored-by: Steven Giesel <[email protected]>
  • Loading branch information
egil and linkdotnet authored Jul 21, 2024
2 parents be59e05 + 7ce3d34 commit 9f80241
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "latest",
"additionalVersions": "6.0,5.0,3.1"
"additionalVersions": "7.0,6.0,5.0,3.1"
}
},

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ jobs:
- name: 🍥 Replace tokens in files
uses: cschleiden/replace-tokens@v1
with:
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj", "src/Directory.Build.props"]'
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj", "src/Directory.Build.props", "docs/site/docfx.json"]'
env:
RELEASE_VERSION: ${{ env.NBGV_SimpleVersion }}${{ env.NBGV_PrereleaseVersion }}
RELEASE_NOTES: ${{ steps.changelog_reader.outputs.changes }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to **bUnit** will be documented in this file. The project ad

## [Unreleased]

### Fixed

- `UploadFile` doesn't throw an exception when the file size exceeds the maximum allowed size. Reported by [@MorneZaayman](https://github.com/MorneZaayman) in [#1503](https://github.com/bUnit-dev/bUnit/issues/1503). Fixed by [@linkdotnet](https://github.com/linkdotnet).

## [1.29.5] - 2024-07-05

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<!-- Shared code analyzers used for all projects in the solution -->
<ItemGroup Label="Code Analyzers">
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.26.0.92422" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.29.0.95321" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="Implicit usings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.32" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion docs/samples/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net8.0'">
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/tests/razor/bunit.docs.razor.samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<!-- DO NOT UPGRADE TO versions > 2.4.5 as they do not support .net5 or older -->
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/tests/xunit/bunit.docs.xunit.samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<!-- DO NOT UPGRADE TO versions > 2.4.5 as they do not support .net5 or older -->
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/bunit.template/template/Company.BlazorTests1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemGroup>

<ItemGroup Condition="'$(testFramework_xunit)' == 'true'">
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
7 changes: 6 additions & 1 deletion src/bunit.web/Extensions/InputFile/BUnitBrowserFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ public BUnitBrowserFile(

public Stream OpenReadStream(long maxAllowedSize = 512000, CancellationToken cancellationToken = default)
{
if (Size > maxAllowedSize)
{
throw new IOException($"Supplied file with size {Size} bytes exceeds the maximum of {maxAllowedSize} bytes.");
}

return new MemoryStream(Content);
}
}
#endif
#endif
8 changes: 7 additions & 1 deletion src/bunit.web/Extensions/InputFile/InputFileExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if NET5_0_OR_GREATER
using System.Runtime.ExceptionServices;
using Microsoft.AspNetCore.Components.Forms;

namespace Bunit;
Expand Down Expand Up @@ -36,6 +37,11 @@ public static void UploadFiles(
{
uploadTask.GetAwaiter().GetResult();
}

if (uploadTask.Exception is { InnerException: not null } e)
{
ExceptionDispatchInfo.Capture(e.InnerException).Throw();
}
}
}
#endif
#endif
15 changes: 15 additions & 0 deletions src/bunit.web/bunit.web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet3Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.1" />

<!-- Due to a CVE in System.Text.Json we explicitly reference the latest version of System.Text.Json -->
<PackageReference Include="System.Text.Json" Version="6.0.9" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
Expand All @@ -41,6 +44,9 @@
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet5Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet5Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet5Version)" />

<!-- Due to a CVE in System.Text.Json we explicitly reference the latest version of System.Text.Json -->
<PackageReference Include="System.Text.Json" Version="6.0.9" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand All @@ -52,6 +58,9 @@
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet6Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet6Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet6Version)" />

<!-- Due to a CVE in System.Text.Json we explicitly reference the latest version of System.Text.Json -->
<PackageReference Include="System.Text.Json" Version="6.0.9" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
Expand All @@ -63,6 +72,9 @@
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet7Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet7Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet7Version)" />

<!-- Due to a CVE in System.Text.Json we explicitly reference the latest version of System.Text.Json -->
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand All @@ -74,6 +86,9 @@
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet8Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet8Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet8Version)" />

<!-- Due to a CVE in System.Text.Json we explicitly reference the latest version of System.Text.Json -->
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
Expand Down
8 changes: 8 additions & 0 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
<IsTestProject>true</IsTestProject>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</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.
-->
<NoWarn>NU1903</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.1" />
Expand Down
2 changes: 1 addition & 1 deletion tests/bunit.core.tests/bunit.core.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<!-- DO NOT UPGRADE TO versions > 2.4.5 as they do not support .net5 or older -->
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
5 changes: 2 additions & 3 deletions tests/bunit.generators.tests/bunit.generators.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="Verify.SourceGenerators" Version="2.2.0" />
<PackageReference Include="Verify.Xunit" Version="25.3.0" />
Expand All @@ -25,8 +24,8 @@
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.9.2" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="1.1.1" />

<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private WeatherForecast[] CreateForecasts()
{
return new WeatherForecast[]
{
new WeatherForecast{ Temperature = 42 },
new WeatherForecast{ Temperature = 42 },
};
}
#endif
Expand Down
1 change: 0 additions & 1 deletion tests/bunit.testassets/_Imports.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
Expand Down
6 changes: 3 additions & 3 deletions tests/bunit.testassets/bunit.testassets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
<ItemGroup>
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
<PackageReference Include="xunit.extensibility.execution" Version="2.8.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.9.0" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.assert" Version="2.8.1" />
<PackageReference Include="xunit.assert" Version="2.9.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(DotNet3Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.1" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
Expand Down
2 changes: 1 addition & 1 deletion tests/bunit.web.query.tests/bunit.web.query.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<!-- DO NOT UPGRADE TO versions > 2.4.5 as they do not support .net5 or older -->
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
16 changes: 15 additions & 1 deletion tests/bunit.web.tests/Extensions/InputFile/InputFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,23 @@ public void Test008()

act.ShouldNotThrow();
}

[Fact(DisplayName = "Uploading file exceeding the maximum file size will throw an exception")]
public void Test009()
{
var cut = RenderComponent<InputFileComponent>(ps => ps.Add(p => p.MaxFileSize, 512));
var file = InputFileContent.CreateFromText(new string('a', 513));

Action act = () => cut.FindComponent<InputFile>().UploadFiles(file);

act.ShouldThrow<IOException>();
}

private sealed class InputFileComponent : ComponentBase
{
[Parameter]
public long MaxFileSize { get; set; } = 512000;

public string? Filename { get; private set; }
public string? Content { get; private set; }
public DateTimeOffset? LastChanged { get; private set; }
Expand All @@ -127,7 +141,7 @@ private void OnChange(InputFileChangeEventArgs args)
Filename = file.Name;
LastChanged = file.LastModified;
Size = file.Size;
using var stream = new StreamReader(file.OpenReadStream());
using var stream = new StreamReader(file.OpenReadStream(MaxFileSize));
Content = stream.ReadToEnd();
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/bunit.web.tests/bunit.web.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<!-- DO NOT UPGRADE TO versions > 2.4.5 as they do not support .net5 or older -->
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.29",
"version": "1.30",
"assemblyVersion": {
"precision": "revision"
},
Expand Down

0 comments on commit 9f80241

Please sign in to comment.