diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml
index 5d610a2d5..d85e829b0 100644
--- a/.github/workflows/docs-deploy.yml
+++ b/.github/workflows/docs-deploy.yml
@@ -68,6 +68,7 @@ jobs:
5.0.x
6.0.x
7.0.x
+ 8.0.x
- name: ๐จ Setup color
run: |
diff --git a/.github/workflows/release-preview.yml b/.github/workflows/release-preview.yml
index 53aa12abb..134b5b3d6 100644
--- a/.github/workflows/release-preview.yml
+++ b/.github/workflows/release-preview.yml
@@ -36,6 +36,7 @@ jobs:
5.0.x
6.0.x
7.0.x
+ 8.0.x
- name: ๐จ Setup color
run: |
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a21f37e05..ba276bfec 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -67,6 +67,7 @@ jobs:
5.0.x
6.0.x
7.0.x
+ 8.0.x
- name: ๐ ๏ธ Update changelog
uses: thomaseizinger/keep-a-changelog-new-release@1.3.0
diff --git a/.github/workflows/verification.yml b/.github/workflows/verification.yml
index 387adad62..5b6120f2a 100644
--- a/.github/workflows/verification.yml
+++ b/.github/workflows/verification.yml
@@ -48,6 +48,7 @@ jobs:
5.0.x
6.0.x
7.0.x
+ 8.0.x
- name: ๐จ Setup color
if: matrix.os != 'windows-latest'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index babc33a94..1c6aa6834 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,11 @@ All notable changes to **bUnit** will be documented in this file. The project ad
## [Unreleased]
+
+### Added
+
+- `net8.0` support
+
## [1.22.19] - 2023-07-28
### Added
diff --git a/Directory.Build.props b/Directory.Build.props
index 9e0490b0e..73e317ed9 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,6 +6,7 @@
5.0.0
6.0.0
7.0.0
+ 8.0.0-*
@@ -21,7 +22,7 @@
11.0
false
enable
- CA1014,NU5104,NETSDK1138
+ CA1014,NU5104,NETSDK1138,SYSLIB0051
false
@@ -38,7 +39,7 @@
AllEnabledByDefault
true
- latest
+ 7
true
diff --git a/global.json b/global.json
index 18562b58c..83105ca8e 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
"rollForward": "latestMajor",
- "allowPrerelease": false
+ "allowPrerelease": true
}
}
diff --git a/src/bunit.core/Rendering/TestRenderer.cs b/src/bunit.core/Rendering/TestRenderer.cs
index 04b9e4987..11c1b106f 100644
--- a/src/bunit.core/Rendering/TestRenderer.cs
+++ b/src/bunit.core/Rendering/TestRenderer.cs
@@ -12,7 +12,9 @@ public class TestRenderer : Renderer, ITestRenderer
{
private static readonly Type RendererType = typeof(Renderer);
private static readonly FieldInfo IsBatchInProgressField = RendererType.GetField("_isBatchInProgress", BindingFlags.Instance | BindingFlags.NonPublic)!;
+#if !NET8_0_OR_GREATER
private static readonly MethodInfo GetRequiredComponentStateMethod = RendererType.GetMethod("GetRequiredComponentState", BindingFlags.Instance | BindingFlags.NonPublic)!;
+#endif
private readonly object renderTreeUpdateLock = new();
private readonly Dictionary renderedComponents = new();
@@ -96,7 +98,11 @@ public IRenderedComponentBase RenderComponent(ComponentP
EventArgs eventArgs) => DispatchEventAsync(eventHandlerId, fieldInfo, eventArgs, ignoreUnknownEventHandlers: false);
///
+#if !NET8_0_OR_GREATER
public Task DispatchEventAsync(
+#else
+ public new Task DispatchEventAsync(
+#endif
ulong eventHandlerId,
EventFieldInfo fieldInfo,
EventArgs eventArgs,
@@ -188,6 +194,17 @@ public void DisposeComponents()
AssertNoUnhandledExceptions();
}
}
+
+#if NET8_0_OR_GREATER
+ ///
+ protected override IComponent ResolveComponentForRenderMode(Type componentType, int? parentComponentId,
+ IComponentActivator componentActivator, IComponentRenderMode renderMode)
+
+ {
+ ArgumentNullException.ThrowIfNull(componentActivator);
+ return componentActivator.CreateInstance(componentType);
+ }
+#endif
///
internal void SetDirectParameters(IRenderedFragmentBase renderedComponent, ParameterView parameters)
@@ -207,9 +224,14 @@ internal void SetDirectParameters(IRenderedFragmentBase renderedComponent, Param
try
{
IsBatchInProgress = true;
-
+
+#if NET8_0_OR_GREATER
+ var setDirectParametersMethod = typeof(ComponentState).GetMethod("SetDirectParameters", BindingFlags.NonPublic | BindingFlags.Instance)!;
+ var componentState = GetComponentState(renderedComponent.ComponentId);
+#else
var componentState = GetRequiredComponentStateMethod.Invoke(this, new object[] { renderedComponent.ComponentId })!;
var setDirectParametersMethod = componentState.GetType().GetMethod("SetDirectParameters", BindingFlags.Public | BindingFlags.Instance)!;
+#endif
setDirectParametersMethod.Invoke(componentState, new object[] { parameters });
}
catch (TargetInvocationException ex) when (ex.InnerException is not null)
diff --git a/src/bunit.core/bunit.core.csproj b/src/bunit.core/bunit.core.csproj
index 49d699ac3..a65412011 100644
--- a/src/bunit.core/bunit.core.csproj
+++ b/src/bunit.core/bunit.core.csproj
@@ -1,7 +1,7 @@
- netstandard2.1;net5.0;net6.0;net7.0
+ netstandard2.1;net5.0;net6.0;net7.0;net8.0
Bunit
Bunit.Core
@@ -38,4 +38,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/bunit.web.testcomponents/bunit.web.testcomponents.csproj b/src/bunit.web.testcomponents/bunit.web.testcomponents.csproj
index d6ee50665..cc63f294e 100644
--- a/src/bunit.web.testcomponents/bunit.web.testcomponents.csproj
+++ b/src/bunit.web.testcomponents/bunit.web.testcomponents.csproj
@@ -33,10 +33,6 @@
-
-
-
-
diff --git a/src/bunit.web/Asserting/JSInvokeCountExpectedException.cs b/src/bunit.web/Asserting/JSInvokeCountExpectedException.cs
index c8efe2e71..856cef937 100644
--- a/src/bunit.web/Asserting/JSInvokeCountExpectedException.cs
+++ b/src/bunit.web/Asserting/JSInvokeCountExpectedException.cs
@@ -43,6 +43,9 @@ private JSInvokeCountExpectedException(SerializationInfo serializationInfo, Stre
}
///
+#if NET8_0_OR_GREATER
+ [Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
+#endif
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info is null)
diff --git a/src/bunit.web/Extensions/ElementNotFoundException.cs b/src/bunit.web/Extensions/ElementNotFoundException.cs
index 824428399..8d6d46af3 100644
--- a/src/bunit.web/Extensions/ElementNotFoundException.cs
+++ b/src/bunit.web/Extensions/ElementNotFoundException.cs
@@ -40,6 +40,9 @@ protected ElementNotFoundException(SerializationInfo serializationInfo, Streamin
}
///
+#if NET8_0_OR_GREATER
+ [Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
+#endif
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info is null)
diff --git a/src/bunit.web/Extensions/TestServiceProviderExtensions.cs b/src/bunit.web/Extensions/TestServiceProviderExtensions.cs
index f9788565c..3eb44f69a 100644
--- a/src/bunit.web/Extensions/TestServiceProviderExtensions.cs
+++ b/src/bunit.web/Extensions/TestServiceProviderExtensions.cs
@@ -45,6 +45,11 @@ public static IServiceCollection AddDefaultTestContextServices(this IServiceColl
services.AddSingleton();
services.AddSingleton(s => s.GetRequiredService());
+#if NET8_0_OR_GREATER
+ // bUnits fake ScrollToLocationHash
+ services.AddSingleton();
+#endif
+
// bUnit specific services
services.AddSingleton(testContext);
services.AddSingleton();
diff --git a/src/bunit.web/JSInterop/JSRuntimeInvocationDictionary.cs b/src/bunit.web/JSInterop/JSRuntimeInvocationDictionary.cs
index 5ef031652..57f26dc70 100644
--- a/src/bunit.web/JSInterop/JSRuntimeInvocationDictionary.cs
+++ b/src/bunit.web/JSInterop/JSRuntimeInvocationDictionary.cs
@@ -53,11 +53,12 @@ internal void RegisterInvocation(JSRuntimeInvocation invocation)
{
Count++;
- if (!invocations.ContainsKey(invocation.Identifier))
+ if (!invocations.TryGetValue(invocation.Identifier, out var value))
{
- invocations.Add(invocation.Identifier, new List());
+ value = new List();
+ invocations.Add(invocation.Identifier, value);
}
- invocations[invocation.Identifier].Add(invocation);
+ value.Add(invocation);
}
}
diff --git a/src/bunit.web/Rendering/RenderedComponent.cs b/src/bunit.web/Rendering/RenderedComponent.cs
index cee374acb..009b7b13a 100644
--- a/src/bunit.web/Rendering/RenderedComponent.cs
+++ b/src/bunit.web/Rendering/RenderedComponent.cs
@@ -50,7 +50,7 @@ private void SetComponentAndID(RenderEvent renderEvent)
}
}
- private bool TryFindComponent(RenderTreeFrameDictionary framesCollection, int parentComponentId, out int componentId, out TComponent component)
+ private static bool TryFindComponent(RenderTreeFrameDictionary framesCollection, int parentComponentId, out int componentId, out TComponent component)
{
componentId = -1;
component = default!;
diff --git a/src/bunit.web/TestDoubles/Components/CapturedParameterView{TComponent}.cs b/src/bunit.web/TestDoubles/Components/CapturedParameterView{TComponent}.cs
index 11f9b72c0..d10be16cc 100644
--- a/src/bunit.web/TestDoubles/Components/CapturedParameterView{TComponent}.cs
+++ b/src/bunit.web/TestDoubles/Components/CapturedParameterView{TComponent}.cs
@@ -106,6 +106,6 @@ IEnumerator IEnumerable.GetEnumerator()
/// An instance of .
[SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "Following factory pattern used in .net")]
public static CapturedParameterView From(ParameterView parameters)
- => new(parameters.ToDictionary());
+ => new(parameters.ToDictionary()!);
}
#endif
diff --git a/src/bunit.web/TestDoubles/Localization/MissingMockStringLocalizationException.cs b/src/bunit.web/TestDoubles/Localization/MissingMockStringLocalizationException.cs
index 99e366d8c..4ce43d8b1 100644
--- a/src/bunit.web/TestDoubles/Localization/MissingMockStringLocalizationException.cs
+++ b/src/bunit.web/TestDoubles/Localization/MissingMockStringLocalizationException.cs
@@ -32,7 +32,10 @@ private MissingMockStringLocalizationException(SerializationInfo serializationIn
Arguments = serializationInfo.GetValue(nameof(Arguments), Array.Empty