Skip to content

Commit

Permalink
fix: Only throw bUnit created exceptions to the user (#1519)
Browse files Browse the repository at this point in the history
* fix: Only throw bUnit created exceptions to the user

* fix: .NET 9 p7 issues

* chore: Bump packages

* fix: S3993
  • Loading branch information
linkdotnet authored Aug 14, 2024
1 parent e470106 commit e1bc92c
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
9.0.x
- name: 🛠️ Update changelog
uses: thomaseizinger/keep-a-changelog-new-release@3.0.0
uses: thomaseizinger/keep-a-changelog-new-release@3.1.0
with:
version: ${{ env.NBGV_SemVer2 }}

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` should only throw an exception when the file size exceeds the maximum allowed size. Reported by [@candritzky](https://github.com/candritzky). Fixed by [@linkdotnet](https://github.com/linkdotnet).

## [1.30.3] - 2024-07-21

### 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.29.0.95321" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="Implicit usings"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/bunit.benchmarks/bunit.benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ See the full changelog at https://github.com/bUnit-dev/bUnit/releases

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.141" PrivateAssets="All" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/bunit.web/Extensions/InputFile/InputFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public static void UploadFiles(
uploadTask.GetAwaiter().GetResult();
}

if (uploadTask.Exception is { InnerException: not null } e)
if (uploadTask.Exception?.InnerException is IOException e)
{
ExceptionDispatchInfo.Capture(e.InnerException).Throw();
ExceptionDispatchInfo.Capture(e).Throw();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@ protected internal override Task<object> HandleAsync(JSRuntimeInvocation invocat
if (!invocation.Identifier.Equals(JsFunctionsPrefix + "dispose", StringComparison.Ordinal))
{
// Assert expectations about the internals of the <Virtualize> component
#if !NET9_0_OR_GREATER
Debug.Assert(invocation.Identifier.Equals(JsFunctionsPrefix + "init", StringComparison.Ordinal), "Received an unexpected invocation identifier from the <Virtualize> component.");
Debug.Assert(invocation.Arguments.Count == 3, "Received an unexpected amount of arguments from the <Virtualize> component.");
Debug.Assert(invocation.Arguments[0] is not null, "Received an unexpected null argument, expected an DotNetObjectReference<VirtualizeJsInterop> instance.");
#else
Debug.Assert(invocation.Identifier.Equals(JsFunctionsPrefix + "init", StringComparison.Ordinal));
Debug.Assert(invocation.Arguments.Count == 3);
Debug.Assert(invocation.Arguments[0] is not null);
#endif

InvokeOnSpacerBeforeVisible(invocation.Arguments[0]!);

Expand Down
4 changes: 4 additions & 0 deletions src/bunit.web/Rendering/BunitHtmlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ private static (IElement? Context, string? MatchedElement) GetParseContextFromTa
int startIndex,
IDocument document)
{
#if !NET9_0_OR_GREATER
Debug.Assert(document.Body is not null, "Body of the document should never be null at this point.");
#else
Debug.Assert(document.Body is not null);
#endif

IElement? result = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
/// <summary>
/// Will throw exception to prompt the user.
/// </summary>
#pragma warning disable S2325 // "WithCulture" is public API and can't be changed
public IStringLocalizer WithCulture(CultureInfo culture)
#pragma warning restore S2325
=> throw new MissingMockStringLocalizationException(nameof(WithCulture), culture);

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions tests/bunit.generators.tests/bunit.generators.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<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" />
<PackageReference Include="Verify.SourceGenerators" Version="2.3.0" />
<PackageReference Include="Verify.Xunit" Version="26.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.10.0" />
Expand Down
1 change: 1 addition & 0 deletions tests/bunit.testassets/XunitExtensions/RepeatAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Xunit;

[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public sealed class RepeatAttribute : DataAttribute
{
public int Count { get; }
Expand Down
4 changes: 2 additions & 2 deletions tests/bunit.testassets/bunit.testassets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog.Expressions" Version="5.0.0" />
<PackageReference Include="xunit.extensibility.execution" Version="2.9.0" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.assert" Version="2.9.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
builder.CloseComponent();
}

private void InterceptNavigation(LocationChangingContext context)
private static void InterceptNavigation(LocationChangingContext context)
{
throw new NotSupportedException("Don't intercept");
}
Expand Down

0 comments on commit e1bc92c

Please sign in to comment.