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

fix: Only throw bUnit created exceptions to the user #1519

Merged
merged 4 commits into from
Aug 14, 2024
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
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
Loading