Skip to content

Commit

Permalink
Fix for Verify.Xunit, Update Avalonia version (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman authored Jan 23, 2024
1 parent 9fca815 commit ce2685f
Show file tree
Hide file tree
Showing 30 changed files with 148 additions and 544 deletions.
11 changes: 6 additions & 5 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<SplatTargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</SplatTargetFrameworks>
<SplatWindowsTargetFrameworks>net6.0-windows10.0.17763.0;net7.0-windows10.0.17763.0;net8.0-windows10.0.17763.0</SplatWindowsTargetFrameworks>
<AvaloniaReactiveUIVersion>11.0.7</AvaloniaReactiveUIVersion>
</PropertyGroup>
<PropertyGroup Condition="$(IsTestProject) != 'true'">
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
Expand All @@ -56,17 +57,17 @@

<ItemGroup Condition="$(IsTestProject) or $(MSBuildProjectName.Contains('TestRunner'))">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="6.0.0" />
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
<PackageReference Include="Verify.Xunit" Version="22.5.0" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
<PackageReference Include="Verify.Xunit" Version="23.0.0" />
</ItemGroup>

<ItemGroup Condition="$(IsTestProject)">
<PackageReference Include="xunit.runner.console" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" />
<PackageReference Include="xunit.runner.console" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageReference Include="coverlet.msbuild" Version="6.0.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/Splat.Avalonia.Autofac/Splat.Avalonia.Autofac.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>$(SplatTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Autofac" Version="7.*" />
<ProjectReference Include="..\Splat\Splat.csproj" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Splat.Avalonia.DryIoc/Splat.Avalonia.DryIoc.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>$(SplatTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="DryIoc.Dll" Version="5.4.3" />
<ProjectReference Include="..\Splat\Splat.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="11.0.5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaReactiveUIVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
<!--
<ProjectReference Include="..\ReactiveUI.Avalonia.Ninject\ReactiveUI.Avalonia.Ninject.csproj" />
-->
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="11.0.5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaReactiveUIVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>$(SplatTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<ProjectReference Include="..\Splat\Splat.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
<!--
<ProjectReference Include="..\Splat.Avalonia.Ninject\ReactiveUI.Avalonia.Ninject.csproj" />
-->
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="11.0.5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaReactiveUIVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="11.0.5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaReactiveUIVersion)" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Splat.Avalonia.Ninject/Splat.Avalonia.Ninject.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>$(SplatTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Ninject" Version="3.3.6" />
<ProjectReference Include="..\Splat\Splat.csproj" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Splat.Avalonia.Tests/Splat.Avalonia.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<!--
<ProjectReference Include="..\ReactiveUI.Avalonia.Ninject\ReactiveUI.Avalonia.Ninject.csproj" />
-->
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="11.0.5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Headless.XUnit" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaReactiveUIVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaReactiveUIVersion)" />
</ItemGroup>

</Project>
1 change: 0 additions & 1 deletion src/Splat.Drawing.Tests/API/ApiApprovalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace Splat.Tests;
/// Tests to make sure that the API matches the approved ones.
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public class ApiApprovalTests
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ public class PlatformBitmapLoader : IBitmapLoader, IEnableLogger
/// <inheritdoc />
public async Task<IBitmap?> Load(Stream sourceStream, float? desiredWidth, float? desiredHeight)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(sourceStream);
#else
if (sourceStream == null)
{
throw new ArgumentNullException(nameof(sourceStream));
}
#endif
sourceStream.ThrowArgumentNullExceptionIfNull(nameof(sourceStream));

// this is a rough check to do with the termination check for #479
if (sourceStream.Length < 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ public static class ServiceLocationDrawingInitialization
/// <param name="resolver">The resolver to register against.</param>
public static void RegisterPlatformBitmapLoader(this IMutableDependencyResolver resolver)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(resolver);
#else
if (resolver == null)
{
throw new ArgumentNullException(nameof(resolver));
}
#endif
resolver.ThrowArgumentNullExceptionIfNull(nameof(resolver));

#if !IS_SHARED_NET
// not supported in netstandard or NET6 library
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Drawing.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Drawing")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Drawing.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.TestRunner.Android")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.TestRunner.Uwp")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Tests")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Drawing.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Drawing")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Drawing.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.TestRunner.Android")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.TestRunner.Uwp")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Tests")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Drawing.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Drawing")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Drawing.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.TestRunner.Android")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.TestRunner.Uwp")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Tests")]
Expand Down
1 change: 0 additions & 1 deletion src/Splat.Tests/API/ApiApprovalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace Splat.Tests;
/// Tests to make sure that the API matches the approved ones.
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public class ApiApprovalTests
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,7 @@ public static void WithFeatureUsageTrackingSession(
string featureName,
Action<IFeatureUsageTrackingSession> action)
{
#if NETSTANDARD
if (action is null)
{
throw new ArgumentNullException(nameof(action));
}
#else
ArgumentNullException.ThrowIfNull(action);
#endif
action.ThrowArgumentNullExceptionIfNull(nameof(action));

using var session = instance.FeatureUsageTrackingSession(featureName);
try
Expand All @@ -74,20 +67,8 @@ public static void WithSubFeatureUsageTrackingSession(
string featureName,
Action<IFeatureUsageTrackingSession> action)
{
#if NETSTANDARD
if (instance is null)
{
throw new ArgumentNullException(nameof(instance));
}

if (action is null)
{
throw new ArgumentNullException(nameof(action));
}
#else
ArgumentNullException.ThrowIfNull(instance);
ArgumentNullException.ThrowIfNull(action);
#endif
instance.ThrowArgumentNullExceptionIfNull(nameof(instance));
action.ThrowArgumentNullExceptionIfNull(nameof(action));

using var session = instance.SubFeature(featureName);
try
Expand Down
18 changes: 2 additions & 16 deletions src/Splat/Disposables/CompositeDisposable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ internal sealed class CompositeDisposable : IDisposable
/// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than zero.</exception>
public CompositeDisposable(int capacity)
{
#if NET8_0_OR_GREATER
ArgumentOutOfRangeException.ThrowIfNegative(capacity);
#else
if (capacity < 0)
{
throw new ArgumentOutOfRangeException(nameof(capacity));
}
#endif
capacity.ThrowArgumentNullExceptionIfNull(nameof(capacity));

_disposables = new(capacity);
}
Expand All @@ -51,14 +44,7 @@ public CompositeDisposable(int capacity)
/// <exception cref="ArgumentException">Any of the disposables in the <paramref name="disposables"/> collection is <c>null</c>.</exception>
public CompositeDisposable(params IDisposable[] disposables)
{
#if NETSTANDARD
if (disposables is null)
{
throw new ArgumentNullException(nameof(disposables));
}
#else
ArgumentNullException.ThrowIfNull(disposables);
#endif
disposables.ThrowArgumentNullExceptionIfNull(nameof(disposables));

_disposables = new(disposables.Length);
Init(disposables);
Expand Down
38 changes: 38 additions & 0 deletions src/Splat/ExceptionMixins.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

namespace Splat;

internal static class ExceptionMixins
{
/// <summary>
/// Throws the argument null exception if null.
/// </summary>
/// <typeparam name="T">Source Type.</typeparam>
/// <param name="value">The value.</param>
/// <param name="name">The name.</param>
public static void ThrowArgumentNullExceptionIfNull<T>(this T? value, string name)
{
if (value is null)
{
throw new ArgumentNullException(name);
}
}

/// <summary>
/// Throws the argument null exception if null.
/// </summary>
/// <typeparam name="T">Source Type.</typeparam>
/// <param name="value">The value.</param>
/// <param name="name">The name.</param>
/// <param name="message">The message.</param>
public static void ThrowArgumentNullExceptionIfNull<T>(this T? value, string name, string message)
{
if (value is null)
{
throw new ArgumentNullException(name, message);
}
}
}
Loading

0 comments on commit ce2685f

Please sign in to comment.