Skip to content

Commit

Permalink
Housekeeping Retire Net 7, clean up (#1145)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman committed May 16, 2024
1 parent 8977918 commit 45068e9
Show file tree
Hide file tree
Showing 37 changed files with 178 additions and 275 deletions.
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ dotnet_diagnostic.SA1006.severity = error
dotnet_diagnostic.SA1007.severity = error
dotnet_diagnostic.SA1008.severity = error
dotnet_diagnostic.SA1009.severity = error
dotnet_diagnostic.SA1010.severity = suggestion
dotnet_diagnostic.SA1010.severity = none
dotnet_diagnostic.SA1011.severity = error
dotnet_diagnostic.SA1012.severity = error
dotnet_diagnostic.SA1013.severity = error
Expand Down Expand Up @@ -418,6 +418,8 @@ dotnet_diagnostic.SX1101.severity = error
dotnet_diagnostic.SX1309.severity = error
dotnet_diagnostic.SX1623.severity = none

dotnet_diagnostic.VSSpell001.severity = none

# C++ Files
[*.{cpp,h,in}]
curly_bracket_next_line = true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Splat currently supports:

[Always Be NuGetting](https://nuget.org/packages/Splat/). Package contains binaries for:

* .NET Framework 4.6.2, .NET Framework 4.7.2, .NET Standard 2.0, .NET 6.0, .NET 7.0, and .NET 8.0
* .NET Framework 4.6.2, .NET Framework 4.7.2, .NET Standard 2.0, .NET 6.0, and .NET 8.0
- Works with:
* WPF
* Windows Forms
Expand Down
11 changes: 3 additions & 8 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageIconUrl>https://github.com/reactiveui/styleguide/blob/master/logo_splat/logo.png?raw=true</PackageIconUrl>
<PackageDescription>A library to make things cross-platform that should be.</PackageDescription>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<Owners>xanaisbettsx;ghuntley</Owners>
<Owners>anaisbetts;ghuntley</Owners>
<PackageTags>drawing;colours;geometry;logging;unit test detection;service location;image handling;portable;xamarin;xamarin ios;xamarin mac;android;monodroid;uwp;net45</PackageTags>
<PackageReleaseNotes>https://github.com/reactiveui/splat/releases</PackageReleaseNotes>
<RepositoryUrl>https://github.com/reactiveui/splat</RepositoryUrl>
Expand All @@ -27,7 +27,6 @@
<ImplicitUsings>true</ImplicitUsings>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);VSSpell001;SA1010</NoWarn>
<!-- disable sourcelink on mono, to workaround https://github.com/dotnet/sourcelink/issues/155 -->
<EnableSourceLink Condition=" '$(OS)' != 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' ">false</EnableSourceLink>
<EnableSourceControlManagerQueries>$(EnableSourceLink)</EnableSourceControlManagerQueries>
Expand All @@ -37,16 +36,12 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Include PDB in the built .nupkg -->
<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>
<SplatTargetFrameworks>netstandard2.0;net6.0;net8.0</SplatTargetFrameworks>
<SplatWindowsTargetFrameworks>net6.0-windows10.0.17763.0;net8.0-windows10.0.17763.0</SplatWindowsTargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="$(IsTestProject) != 'true'">
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<!-- MonoAndroid doesn't seem to want to allow debugging for maintainers -->
<PropertyGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<DebugType>Full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand Down
17 changes: 1 addition & 16 deletions src/Directory.build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
<DefineConstants>$(DefineConstants);NET_45;XAML</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('MonoAndroid'))">
<DefineConstants>$(DefineConstants);MONO;ANDROID</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA;IOS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac'))">
<DefineConstants>$(DefineConstants);MONO;COCOA</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.TVOS'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA;TVOS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.WatchOS'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('tizen'))">
<DefineConstants>$(DefineConstants);TIZEN</DefineConstants>
</PropertyGroup>
Expand All @@ -40,7 +25,7 @@
<PropertyGroup Condition="$(TargetFramework.EndsWith('0-android'))">
<DefineConstants>$(DefineConstants);MONO;ANDROID</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.Equals('net6.0')) or $(TargetFramework.Equals('net7.0')) or $(TargetFramework.Equals('net8.0')) or $(TargetFramework.Equals('netstandard2.1')) or $(TargetFramework.Equals('netstandard2.0'))">
<PropertyGroup Condition="$(TargetFramework.Equals('net6.0')) or $(TargetFramework.Equals('net8.0')) or $(TargetFramework.Equals('netstandard2.1')) or $(TargetFramework.Equals('netstandard2.0'))">
<DefineConstants>$(DefineConstants);IS_SHARED_NET</DefineConstants>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions src/ReactiveUI.DI.Tests/ReactiveUI.DI.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net6.0;</TargetFrameworks>
<TargetFrameworks>net472;net8.0;</TargetFrameworks>
<NoWarn>$(NoWarn);1591;CA1707;SA1633;CA2000</NoWarn>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
Expand All @@ -14,7 +14,7 @@
<ProjectReference Include="..\Splat.Autofac\Splat.Autofac.csproj" />
</ItemGroup>
</When>
<When Condition="$(TargetFramework.StartsWith('net6.0'))">
<When Condition="$(TargetFramework.StartsWith('net8.0'))">
<ItemGroup>
<Compile Remove="AutoFacReactiveUIDependencyTests.cs" />
<Compile Remove="NinjectReactiveUIDependencyTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,5 @@ public void OnViewNavigation(PageViewTelemetry telemetry)
_telemetryClient.TrackPageView(telemetry);
}

internal static PageViewTelemetry GetPageViewTelemetry()
{
var result = new PageViewTelemetry();
return result;
}
internal static PageViewTelemetry GetPageViewTelemetry() => new();
}
2 changes: 1 addition & 1 deletion src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-windows10.0.17763.0</TargetFrameworks>
<TargetFrameworks>net8.0-windows10.0.17763.0</TargetFrameworks>

<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);1591;CA1707;SA1633;CA2000;CA1851</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Autofac/AutofacDependencyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public virtual IEnumerable<object> GetServices(Type? serviceType, string? contra
// no op
}

return Array.Empty<object>();
return [];
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Avalonia.Tests/Splat.Avalonia.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Common.Test/Splat.Common.Test.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</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<NoWarn>$(NoWarn);CA2000</NoWarn>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.TestRunner.Uwp")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Splat.Tests")]
[assembly: System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.17763.0")]
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName=".NET 6.0")]
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")]
[assembly: System.Runtime.Versioning.TargetPlatform("Windows10.0.17763.0")]
namespace Splat
{
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Drawing.Tests/Splat.Drawing.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-windows10.0.17763.0</TargetFrameworks>
<TargetFrameworks>net8.0-windows10.0.17763.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);1591;CA1707;SA1633;CA2000;CA1034</NoWarn>
<Nullable>enable</Nullable>
Expand Down
4 changes: 2 additions & 2 deletions src/Splat.Drawing/DefaultPlatformModeDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DefaultPlatformModeDetector : IPlatformModeDetector

if (mInfo is not null && dependencyObject is not null)
{
_cachedInDesignModeResult = (bool)(mInfo.Invoke(null, new[] { Activator.CreateInstance(dependencyObject) }) ?? false);
_cachedInDesignModeResult = (bool)(mInfo.Invoke(null, [Activator.CreateInstance(dependencyObject)]) ?? false);
}
}
else if ((type = Type.GetType(WpfDesignerPropertiesType, false)) is not null)
Expand All @@ -53,7 +53,7 @@ public class DefaultPlatformModeDetector : IPlatformModeDetector
var dependencyObject = Type.GetType(WpfDependencyPropertyType, false);
if (mInfo is not null && dependencyObject is not null)
{
_cachedInDesignModeResult = (bool)(mInfo.Invoke(null, new[] { Activator.CreateInstance(dependencyObject) }) ?? false);
_cachedInDesignModeResult = (bool)(mInfo.Invoke(null, [Activator.CreateInstance(dependencyObject)]) ?? false);
}
}
else if ((type = Type.GetType(WinFormsDesignerPropertiesType, false)) is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class PlatformBitmapLoader : IBitmapLoader, IEnableLogger
var config = Bitmap.Config.Argb8888 ?? throw new InvalidOperationException("The ARGB8888 bitmap format is unavailable");

#pragma warning disable CA2000 // Dispose objects before losing scope
return Bitmap.CreateBitmap((int)width, (int)height, config)?.FromNative();
return Bitmap.CreateBitmap((int)width, (int)height, config).FromNative();
#pragma warning restore CA2000 // Dispose objects before losing scope
}

Expand Down Expand Up @@ -232,7 +232,7 @@ private void AttemptStreamByteCorrection(Stream sourceStream)
{
this.Log().Warn("Carrying out source stream byte correction.");
sourceStream.Position = sourceStream.Length;
sourceStream.Write(new byte[] { 0xFF, 0xD9 });
sourceStream.Write([0xFF, 0xD9]);
}
}
}
45 changes: 15 additions & 30 deletions src/Splat.Drawing/Platforms/ReflectionStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,36 @@ internal static class ReflectionStubs
{
var ti = value.GetTypeInfo();
var ret = ti.GetDeclaredField(name);
if (ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null)
{
return ret;
}

return ti.BaseType.GetField(name, flags);
return ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null
? ret
: ti.BaseType.GetField(name, flags);
}

public static MethodInfo? GetMethod(this Type value, string name, BindingFlags flags = default)
{
var ti = value.GetTypeInfo();
var ret = ti.GetDeclaredMethod(name);
if (ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null)
{
return ret;
}

return ti.BaseType.GetMethod(name, flags);
return ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null
? ret
: ti.BaseType.GetMethod(name, flags);
}

public static PropertyInfo? GetProperty(this Type value, string name, BindingFlags flags = default)
{
var ti = value.GetTypeInfo();
var ret = ti.GetDeclaredProperty(name);
if (ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null)
{
return ret;
}

return ti.BaseType.GetProperty(name, flags);
return ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null
? ret
: ti.BaseType.GetProperty(name, flags);
}

public static EventInfo? GetEvent(this Type value, string name, BindingFlags flags = default)
{
var ti = value.GetTypeInfo();
var ret = ti.GetDeclaredEvent(name);
if (ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null)
{
return ret;
}

return ti.BaseType.GetEvent(name, flags);
return ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null
? ret
: ti.BaseType.GetEvent(name, flags);
}

public static IEnumerable<PropertyInfo> GetProperties(this Type value) => value.GetTypeInfo().DeclaredProperties;
Expand All @@ -67,12 +55,9 @@ internal static class ReflectionStubs
var ret = ti.GetDeclaredMethods(methodName)
.FirstOrDefault(x => paramTypes.Zip(x.GetParameters().Select(y => y.ParameterType), (l, r) => l == r).All(y => y));

if (ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null)
{
return ret;
}

return ti.BaseType.GetMethod(methodName, paramTypes, flags);
return ret is not null || !flags.HasFlag(BindingFlags.FlattenHierarchy) || ti.BaseType is null
? ret
: ti.BaseType.GetMethod(methodName, paramTypes, flags);
}

public static IEnumerable<MethodInfo> GetMethods(this Type value) => value.GetTypeInfo().DeclaredMethods;
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Drawing/Splat.Drawing.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(SplatTargetFrameworks);net7.0-android;net7.0-ios;net7.0-tvos;net7.0-macos;net7.0-maccatalyst;net8.0-android;net8.0-ios;net8.0-tvos;net8.0-macos;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>$(SplatTargetFrameworks);net8.0-android;net8.0-ios;net8.0-tvos;net8.0-macos;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462;net472;$(SplatWindowsTargetFrameworks)</TargetFrameworks>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<NoWarn>$(NoWarn);1591;CA1707;SA1633;CA2000</NoWarn>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public virtual IEnumerable<object> GetServices(Type? serviceType, string? contra
var isNull = serviceType is null;
serviceType ??= typeof(NullServiceType);

IEnumerable<object> services = Enumerable.Empty<object>();
IEnumerable<object> services = [];

if (contract is null || string.IsNullOrWhiteSpace(contract))
{
Expand Down Expand Up @@ -207,17 +207,12 @@ public virtual void UnregisterAll(Type? serviceType, string? contract = null)
return;
}

IEnumerable<ServiceDescriptor> sds = Enumerable.Empty<ServiceDescriptor>();
IEnumerable<ServiceDescriptor> sds = [];

if (contract is null || string.IsNullOrWhiteSpace(contract))
{
sds = _serviceCollection.Where(s => !s.IsKeyedService && s.ServiceType == serviceType);
}
else
{
sds = _serviceCollection
sds = contract is null || string.IsNullOrWhiteSpace(contract)
? _serviceCollection.Where(s => !s.IsKeyedService && s.ServiceType == serviceType)
: _serviceCollection
.Where(sd => MatchesKeyedContract(serviceType, contract, sd));
}

foreach (var sd in sds.ToList())
{
Expand All @@ -239,12 +234,9 @@ public virtual bool HasRegistration(Type? serviceType, string? contract = null)

if (!_isImmutable)
{
if (contract is null || string.IsNullOrWhiteSpace(contract))
{
return _serviceCollection?.Any(sd => !sd.IsKeyedService && sd.ServiceType == serviceType) == true;
}

return _serviceCollection?.Any(sd => MatchesKeyedContract(serviceType, contract, sd)) == true;
return contract is null || string.IsNullOrWhiteSpace(contract)
? _serviceCollection?.Any(sd => !sd.IsKeyedService && sd.ServiceType == serviceType) == true
: _serviceCollection?.Any(sd => MatchesKeyedContract(serviceType, contract, sd)) == true;
}

if (contract is null)
Expand All @@ -253,12 +245,8 @@ public virtual bool HasRegistration(Type? serviceType, string? contract = null)
return service is not null;
}

if (_serviceProvider is IKeyedServiceProvider keyedServiceProvider)
{
return keyedServiceProvider.GetKeyedService(serviceType, contract) is not null;
}

return false;
return _serviceProvider is IKeyedServiceProvider keyedServiceProvider
&& keyedServiceProvider.GetKeyedService(serviceType, contract) is not null;
}

/// <inheritdoc />
Expand Down
4 changes: 2 additions & 2 deletions src/Splat.Microsoft.Extensions.Logging/MsLoggingHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace Splat.Microsoft.Extensions.Logging;
internal static class MsLoggingHelpers
{
public static KeyValuePair<LogLevel, global::Microsoft.Extensions.Logging.LogLevel>[] Mappings { get; } =
{
[
new(LogLevel.Debug, global::Microsoft.Extensions.Logging.LogLevel.Debug),
new(LogLevel.Info, global::Microsoft.Extensions.Logging.LogLevel.Information),
new(LogLevel.Warn, global::Microsoft.Extensions.Logging.LogLevel.Warning),
new(LogLevel.Error, global::Microsoft.Extensions.Logging.LogLevel.Error),
new(LogLevel.Fatal, global::Microsoft.Extensions.Logging.LogLevel.Critical),
};
];

public static ImmutableDictionary<LogLevel, global::Microsoft.Extensions.Logging.LogLevel> Splat2MsLogDictionary { get; } = Mappings.ToImmutableDictionary();

Expand Down
Loading

0 comments on commit 45068e9

Please sign in to comment.