diff --git a/.editorconfig b/.editorconfig index 688cf0772..e37b7bd21 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 @@ -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 diff --git a/README.md b/README.md index b23eb42b9..019306af1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/Directory.build.props b/src/Directory.build.props index cd22fd563..6b36a0aab 100644 --- a/src/Directory.build.props +++ b/src/Directory.build.props @@ -12,7 +12,7 @@ https://github.com/reactiveui/styleguide/blob/master/logo_splat/logo.png?raw=true A library to make things cross-platform that should be. true - xanaisbettsx;ghuntley + anaisbetts;ghuntley drawing;colours;geometry;logging;unit test detection;service location;image handling;portable;xamarin;xamarin ios;xamarin mac;android;monodroid;uwp;net45 https://github.com/reactiveui/splat/releases https://github.com/reactiveui/splat @@ -27,7 +27,6 @@ true preview enable - $(NoWarn);VSSpell001;SA1010 false $(EnableSourceLink) @@ -37,16 +36,12 @@ true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - netstandard2.0;net6.0;net7.0;net8.0 - net6.0-windows10.0.17763.0;net7.0-windows10.0.17763.0;net8.0-windows10.0.17763.0 + netstandard2.0;net6.0;net8.0 + net6.0-windows10.0.17763.0;net8.0-windows10.0.17763.0 false - - - Full - true diff --git a/src/Directory.build.targets b/src/Directory.build.targets index 512f03853..8c0765f72 100644 --- a/src/Directory.build.targets +++ b/src/Directory.build.targets @@ -7,21 +7,6 @@ $(DefineConstants);NET_45;XAML - - $(DefineConstants);MONO;ANDROID - - - $(DefineConstants);MONO;UIKIT;COCOA;IOS - - - $(DefineConstants);MONO;COCOA - - - $(DefineConstants);MONO;UIKIT;COCOA;TVOS - - - $(DefineConstants);MONO;UIKIT;COCOA - $(DefineConstants);TIZEN @@ -40,7 +25,7 @@ $(DefineConstants);MONO;ANDROID - + $(DefineConstants);IS_SHARED_NET diff --git a/src/ReactiveUI.DI.Tests/ReactiveUI.DI.Tests.csproj b/src/ReactiveUI.DI.Tests/ReactiveUI.DI.Tests.csproj index 64bcefe8d..ce3c829e5 100644 --- a/src/ReactiveUI.DI.Tests/ReactiveUI.DI.Tests.csproj +++ b/src/ReactiveUI.DI.Tests/ReactiveUI.DI.Tests.csproj @@ -1,6 +1,6 @@ - net472;net6.0; + net472;net8.0; $(NoWarn);1591;CA1707;SA1633;CA2000 false enable @@ -14,7 +14,7 @@ - + diff --git a/src/Splat.ApplicationInsights/ApplicationInsightsViewTracking.cs b/src/Splat.ApplicationInsights/ApplicationInsightsViewTracking.cs index 2f3d6bd82..99b81f049 100644 --- a/src/Splat.ApplicationInsights/ApplicationInsightsViewTracking.cs +++ b/src/Splat.ApplicationInsights/ApplicationInsightsViewTracking.cs @@ -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(); } diff --git a/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj b/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj index 0ad8abee5..19944b356 100644 --- a/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj +++ b/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj @@ -1,7 +1,7 @@  - net6.0-windows10.0.17763.0 + net8.0-windows10.0.17763.0 false $(NoWarn);1591;CA1707;SA1633;CA2000;CA1851 diff --git a/src/Splat.Autofac/AutofacDependencyResolver.cs b/src/Splat.Autofac/AutofacDependencyResolver.cs index c04bbdbe5..bc4c7c9ff 100644 --- a/src/Splat.Autofac/AutofacDependencyResolver.cs +++ b/src/Splat.Autofac/AutofacDependencyResolver.cs @@ -109,7 +109,7 @@ public virtual IEnumerable GetServices(Type? serviceType, string? contra // no op } - return Array.Empty(); + return []; } } diff --git a/src/Splat.Avalonia.DryIoc2.Tests/Splat.Avalonia.DryIoc2.Tests.csproj b/src/Splat.Avalonia.DryIoc2.Tests/Splat.Avalonia.DryIoc2.Tests.csproj index ce607b530..2ac5bc52f 100644 --- a/src/Splat.Avalonia.DryIoc2.Tests/Splat.Avalonia.DryIoc2.Tests.csproj +++ b/src/Splat.Avalonia.DryIoc2.Tests/Splat.Avalonia.DryIoc2.Tests.csproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 enable enable $(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000 diff --git a/src/Splat.Avalonia.Microsoft2.Tests/Splat.Avalonia.Microsoft2.Tests.csproj b/src/Splat.Avalonia.Microsoft2.Tests/Splat.Avalonia.Microsoft2.Tests.csproj index 1821d7868..53de45431 100644 --- a/src/Splat.Avalonia.Microsoft2.Tests/Splat.Avalonia.Microsoft2.Tests.csproj +++ b/src/Splat.Avalonia.Microsoft2.Tests/Splat.Avalonia.Microsoft2.Tests.csproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 enable enable $(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000 diff --git a/src/Splat.Avalonia.Tests/Splat.Avalonia.Tests.csproj b/src/Splat.Avalonia.Tests/Splat.Avalonia.Tests.csproj index afe024e4e..5ab40cc8c 100644 --- a/src/Splat.Avalonia.Tests/Splat.Avalonia.Tests.csproj +++ b/src/Splat.Avalonia.Tests/Splat.Avalonia.Tests.csproj @@ -1,6 +1,6 @@ - net6.0;net7.0 + net6.0;net8.0 enable enable $(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000 diff --git a/src/Splat.Common.Test/Splat.Common.Test.csproj b/src/Splat.Common.Test/Splat.Common.Test.csproj index 699fd4b95..c207ccd34 100644 --- a/src/Splat.Common.Test/Splat.Common.Test.csproj +++ b/src/Splat.Common.Test/Splat.Common.Test.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net6.0 + netstandard2.0;net8.0 $(NoWarn);CA2000 enable diff --git a/src/Splat.Drawing.Tests/API/ApiApprovalTests.SplatUIProject.DotNet6_0.verified.txt b/src/Splat.Drawing.Tests/API/ApiApprovalTests.SplatUIProject.DotNet8_0.verified.txt similarity index 99% rename from src/Splat.Drawing.Tests/API/ApiApprovalTests.SplatUIProject.DotNet6_0.verified.txt rename to src/Splat.Drawing.Tests/API/ApiApprovalTests.SplatUIProject.DotNet8_0.verified.txt index 1306202c7..8d93e0c7f 100644 --- a/src/Splat.Drawing.Tests/API/ApiApprovalTests.SplatUIProject.DotNet6_0.verified.txt +++ b/src/Splat.Drawing.Tests/API/ApiApprovalTests.SplatUIProject.DotNet8_0.verified.txt @@ -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 { diff --git a/src/Splat.Drawing.Tests/Splat.Drawing.Tests.csproj b/src/Splat.Drawing.Tests/Splat.Drawing.Tests.csproj index d7c1559ce..a2dd7cd9f 100644 --- a/src/Splat.Drawing.Tests/Splat.Drawing.Tests.csproj +++ b/src/Splat.Drawing.Tests/Splat.Drawing.Tests.csproj @@ -1,7 +1,7 @@  - net6.0-windows10.0.17763.0 + net8.0-windows10.0.17763.0 false $(NoWarn);1591;CA1707;SA1633;CA2000;CA1034 enable diff --git a/src/Splat.Drawing/DefaultPlatformModeDetector.cs b/src/Splat.Drawing/DefaultPlatformModeDetector.cs index fe6d4f7d8..d0388aedf 100644 --- a/src/Splat.Drawing/DefaultPlatformModeDetector.cs +++ b/src/Splat.Drawing/DefaultPlatformModeDetector.cs @@ -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) @@ -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) diff --git a/src/Splat.Drawing/Platforms/Android/Bitmaps/PlatformBitmapLoader.cs b/src/Splat.Drawing/Platforms/Android/Bitmaps/PlatformBitmapLoader.cs index 6eb40acfb..a59fe8d5a 100644 --- a/src/Splat.Drawing/Platforms/Android/Bitmaps/PlatformBitmapLoader.cs +++ b/src/Splat.Drawing/Platforms/Android/Bitmaps/PlatformBitmapLoader.cs @@ -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 } @@ -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]); } } } diff --git a/src/Splat.Drawing/Platforms/ReflectionStubs.cs b/src/Splat.Drawing/Platforms/ReflectionStubs.cs index 9a793d9db..2d5e614f0 100644 --- a/src/Splat.Drawing/Platforms/ReflectionStubs.cs +++ b/src/Splat.Drawing/Platforms/ReflectionStubs.cs @@ -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 GetProperties(this Type value) => value.GetTypeInfo().DeclaredProperties; @@ -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 GetMethods(this Type value) => value.GetTypeInfo().DeclaredMethods; diff --git a/src/Splat.Drawing/Splat.Drawing.csproj b/src/Splat.Drawing/Splat.Drawing.csproj index 67034634d..5235d04eb 100644 --- a/src/Splat.Drawing/Splat.Drawing.csproj +++ b/src/Splat.Drawing/Splat.Drawing.csproj @@ -1,6 +1,6 @@ - $(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 + $(SplatTargetFrameworks);net8.0-android;net8.0-ios;net8.0-tvos;net8.0-macos;net8.0-maccatalyst $(TargetFrameworks);net462;net472;$(SplatWindowsTargetFrameworks) Splat .NET Foundation and Contributors diff --git a/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj b/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj index 0095b9d06..24ad346d9 100644 --- a/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj +++ b/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 $(NoWarn);1591;CA1707;SA1633;CA2000 enable diff --git a/src/Splat.Microsoft.Extensions.DependencyInjection/MicrosoftDependencyResolver.cs b/src/Splat.Microsoft.Extensions.DependencyInjection/MicrosoftDependencyResolver.cs index 67e0e8d60..bb5ad06c9 100644 --- a/src/Splat.Microsoft.Extensions.DependencyInjection/MicrosoftDependencyResolver.cs +++ b/src/Splat.Microsoft.Extensions.DependencyInjection/MicrosoftDependencyResolver.cs @@ -88,7 +88,7 @@ public virtual IEnumerable GetServices(Type? serviceType, string? contra var isNull = serviceType is null; serviceType ??= typeof(NullServiceType); - IEnumerable services = Enumerable.Empty(); + IEnumerable services = []; if (contract is null || string.IsNullOrWhiteSpace(contract)) { @@ -207,17 +207,12 @@ public virtual void UnregisterAll(Type? serviceType, string? contract = null) return; } - IEnumerable sds = Enumerable.Empty(); + IEnumerable 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()) { @@ -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) @@ -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; } /// diff --git a/src/Splat.Microsoft.Extensions.Logging/MsLoggingHelpers.cs b/src/Splat.Microsoft.Extensions.Logging/MsLoggingHelpers.cs index 09bd0fa2e..0ef082fd9 100644 --- a/src/Splat.Microsoft.Extensions.Logging/MsLoggingHelpers.cs +++ b/src/Splat.Microsoft.Extensions.Logging/MsLoggingHelpers.cs @@ -10,13 +10,13 @@ namespace Splat.Microsoft.Extensions.Logging; internal static class MsLoggingHelpers { public static KeyValuePair[] 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 Splat2MsLogDictionary { get; } = Mappings.ToImmutableDictionary(); diff --git a/src/Splat.NLog/LogResolver.cs b/src/Splat.NLog/LogResolver.cs index cd929db69..03ff34193 100644 --- a/src/Splat.NLog/LogResolver.cs +++ b/src/Splat.NLog/LogResolver.cs @@ -11,9 +11,9 @@ namespace Splat.NLog; internal static class LogResolver { private const int MaxCacheSize = 16; - private static readonly MemoizingMRUCache _loggerCache = new( + private static readonly MemoizingMRUCache _loggerCache = new( (type, _) => global::NLog.LogManager.GetLogger(type.ToString()), MaxCacheSize); - public static global::NLog.ILogger Resolve(Type type) => _loggerCache.Get(type, null); + public static global::NLog.Logger Resolve(Type type) => _loggerCache.Get(type, null); } diff --git a/src/Splat.NLog/NLogLogger.cs b/src/Splat.NLog/NLogLogger.cs index 1e0623209..68d9a4045 100644 --- a/src/Splat.NLog/NLogLogger.cs +++ b/src/Splat.NLog/NLogLogger.cs @@ -16,24 +16,24 @@ namespace Splat.NLog; public sealed class NLogLogger : IFullLogger, IDisposable { private static readonly KeyValuePair[] _mappings = - { + [ new(LogLevel.Debug, global::NLog.LogLevel.Debug), new(LogLevel.Info, global::NLog.LogLevel.Info), new(LogLevel.Warn, global::NLog.LogLevel.Warn), new(LogLevel.Error, global::NLog.LogLevel.Error), new(LogLevel.Fatal, global::NLog.LogLevel.Fatal), - }; + ]; private static readonly ImmutableDictionary _mappingsDictionary = _mappings.ToImmutableDictionary(); - private readonly global::NLog.ILogger _inner; + private readonly global::NLog.Logger _inner; /// /// Initializes a new instance of the class. /// /// The actual nlog logger. /// NLog logger not passed. - public NLogLogger(global::NLog.ILogger inner) + public NLogLogger(global::NLog.Logger inner) { _inner = inner ?? throw new ArgumentNullException(nameof(inner)); SetLogLevel(); diff --git a/src/Splat.Ninject.Tests/Splat.Ninject.Tests.csproj b/src/Splat.Ninject.Tests/Splat.Ninject.Tests.csproj index acd47a5bf..6c331e0f4 100644 --- a/src/Splat.Ninject.Tests/Splat.Ninject.Tests.csproj +++ b/src/Splat.Ninject.Tests/Splat.Ninject.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 $(NoWarn);1591;CA1707;SA1633;CA2000 false enable diff --git a/src/Splat.Prism.Tests/Splat.Prism.Tests.csproj b/src/Splat.Prism.Tests/Splat.Prism.Tests.csproj index 30e0f6f35..42f11cf01 100644 --- a/src/Splat.Prism.Tests/Splat.Prism.Tests.csproj +++ b/src/Splat.Prism.Tests/Splat.Prism.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 $(NoWarn);CA1707;CS1574 enable diff --git a/src/Splat.SimpleInjector.Tests/Splat.SimpleInjector.Tests.csproj b/src/Splat.SimpleInjector.Tests/Splat.SimpleInjector.Tests.csproj index d8f63319b..283927310 100644 --- a/src/Splat.SimpleInjector.Tests/Splat.SimpleInjector.Tests.csproj +++ b/src/Splat.SimpleInjector.Tests/Splat.SimpleInjector.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 $(NoWarn);1591;CA1707;SA1633;CA2000 enable diff --git a/src/Splat.Tests/ApplicationPerformanceMonitoring/RaygunFeatureUsageTrackingSessionTests.cs b/src/Splat.Tests/ApplicationPerformanceMonitoring/RaygunFeatureUsageTrackingSessionTests.cs index 086658244..a5a17c693 100644 --- a/src/Splat.Tests/ApplicationPerformanceMonitoring/RaygunFeatureUsageTrackingSessionTests.cs +++ b/src/Splat.Tests/ApplicationPerformanceMonitoring/RaygunFeatureUsageTrackingSessionTests.cs @@ -20,11 +20,7 @@ private static RaygunFeatureUsageTrackingSession GetRaygunFeatureUsageTrackingSe ApiKey = apiKey, }; -#if NETSTANDARD2_0 var raygunClient = new RaygunClient(raygunSettings); -#else - var raygunClient = new RaygunClient(apiKey); -#endif return new(featureName, raygunClient, raygunSettings); } diff --git a/src/Splat.Tests/Splat.Tests.csproj b/src/Splat.Tests/Splat.Tests.csproj index 3fcf9a1bd..39ee5825a 100644 --- a/src/Splat.Tests/Splat.Tests.csproj +++ b/src/Splat.Tests/Splat.Tests.csproj @@ -1,6 +1,6 @@ - net6.0-windows10.0.17763.0;net7.0-windows10.0.17763.0;net8.0-windows10.0.17763.0 + net6.0-windows10.0.17763.0;net8.0-windows10.0.17763.0 $(NoWarn);1591;CA1707;SA1633;CA2000;CA1034 enable diff --git a/src/Splat/ApplicationPerformanceMonitoring/IEnableFeatureUsageTracking.cs b/src/Splat/ApplicationPerformanceMonitoring/IEnableFeatureUsageTracking.cs index bf51985ce..baad64807 100644 --- a/src/Splat/ApplicationPerformanceMonitoring/IEnableFeatureUsageTracking.cs +++ b/src/Splat/ApplicationPerformanceMonitoring/IEnableFeatureUsageTracking.cs @@ -12,6 +12,4 @@ namespace Splat.ApplicationPerformanceMonitoring; /// [ComVisible(false)] [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1040:Avoid empty interfaces", Justification = "Intended through design")] -public interface IEnableFeatureUsageTracking -{ -} +public interface IEnableFeatureUsageTracking; diff --git a/src/Splat/Logging/AllocationFreeLoggerBase.cs b/src/Splat/Logging/AllocationFreeLoggerBase.cs index f7402d67b..ad347baf7 100644 --- a/src/Splat/Logging/AllocationFreeLoggerBase.cs +++ b/src/Splat/Logging/AllocationFreeLoggerBase.cs @@ -13,19 +13,15 @@ namespace Splat; /// Base class for a logger the provides allocation free logging. /// /// +/// +/// Initializes a new instance of the class. +/// +/// The to wrap in this class. [SuppressMessage("Naming", "CA1716: Do not use built in identifiers", Justification = "Deliberate usage")] -public abstract class AllocationFreeLoggerBase : IAllocationFreeLogger +public abstract class AllocationFreeLoggerBase(ILogger inner) : IAllocationFreeLogger { - private readonly ILogger _inner; - - /// - /// Initializes a new instance of the class. - /// - /// The to wrap in this class. - protected AllocationFreeLoggerBase(ILogger inner) => _inner = inner; - /// - public LogLevel Level => _inner.Level; + public LogLevel Level => inner.Level; /// public bool IsDebugEnabled => Level <= LogLevel.Debug; @@ -47,7 +43,7 @@ public virtual void Debug([Localizable(false)] string messageFormat, { if (IsDebugEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Debug); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Debug); } } @@ -56,7 +52,7 @@ public virtual void Debug(Exception exception, string messageFormat, { if (IsDebugEnabled) { - _inner.Write(exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Debug); + inner.Write(exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Debug); } } @@ -65,7 +61,7 @@ public virtual void Debug([Localizable(false)] string me { if (IsDebugEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Debug); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Debug); } } @@ -78,7 +74,7 @@ public void Debug( { if (IsDebugEnabled) { - _inner.Write(exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Debug); + inner.Write(exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Debug); } } @@ -91,7 +87,7 @@ public virtual void Debug( { if (IsDebugEnabled) { - _inner.Write( + inner.Write( string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3), LogLevel.Debug); } @@ -107,7 +103,7 @@ public void Debug( { if (IsDebugEnabled) { - _inner.Write( + inner.Write( exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3), LogLevel.Debug); @@ -124,7 +120,7 @@ public virtual void Debug( { if (IsDebugEnabled) { - _inner.Write( + inner.Write( string.Format( CultureInfo.InvariantCulture, messageFormat, @@ -147,7 +143,7 @@ public void Debug( { if (IsDebugEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -171,7 +167,7 @@ public virtual void Debug( { if (IsDebugEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -222,7 +218,7 @@ public virtual void Debug([Localizable(false)] string messageFormat, T { if (IsInfoEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Info); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Info); } } @@ -534,7 +530,7 @@ public void Info(Exception exception, string messageFormat, TArgument { if (IsInfoEnabled) { - _inner.Write( + inner.Write( exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Info); @@ -546,7 +542,7 @@ public virtual void Info([Localizable(false)] string mes { if (IsInfoEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Info); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Info); } } @@ -559,7 +555,7 @@ public void Info( { if (IsInfoEnabled) { - _inner.Write( + inner.Write( exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Info); @@ -575,7 +571,7 @@ public virtual void Info( { if (IsInfoEnabled) { - _inner.Write( + inner.Write( string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3), LogLevel.Info); } @@ -591,7 +587,7 @@ public void Info( { if (IsInfoEnabled) { - _inner.Write( + inner.Write( exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3), LogLevel.Info); @@ -608,7 +604,7 @@ public virtual void Info( { if (IsInfoEnabled) { - _inner.Write( + inner.Write( string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3, argument4), LogLevel.Info); } @@ -625,7 +621,7 @@ public void Info( { if (IsInfoEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -649,7 +645,7 @@ public virtual void Info( { if (IsInfoEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -700,7 +696,7 @@ public virtual void Info([Localizable(false)] string messageFormat, T { if (IsWarnEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Warn); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Warn); } } @@ -1014,7 +1010,7 @@ public void Warn(Exception exception, string messageFormat, TArgument { if (IsWarnEnabled) { - _inner.Write(exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Warn); + inner.Write(exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Warn); } } @@ -1023,7 +1019,7 @@ public virtual void Warn([Localizable(false)] string mes { if (IsWarnEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Warn); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Warn); } } @@ -1036,7 +1032,7 @@ public void Warn( { if (IsWarnEnabled) { - _inner.Write(exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Warn); + inner.Write(exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Warn); } } @@ -1049,7 +1045,7 @@ public virtual void Warn( { if (IsWarnEnabled) { - _inner.Write( + inner.Write( string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3), LogLevel.Warn); } @@ -1065,7 +1061,7 @@ public void Warn( { if (IsWarnEnabled) { - _inner.Write( + inner.Write( exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3), LogLevel.Warn); @@ -1082,7 +1078,7 @@ public virtual void Warn( { if (IsWarnEnabled) { - _inner.Write( + inner.Write( string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3, argument4), LogLevel.Warn); } @@ -1099,7 +1095,7 @@ public void Warn( { if (IsWarnEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -1123,7 +1119,7 @@ public virtual void Warn( { if (IsWarnEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -1174,7 +1170,7 @@ public virtual void Warn([Localizable(false)] string messageFormat, { if (IsErrorEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Error); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Error); } } @@ -1488,7 +1484,7 @@ public void Error(Exception exception, string messageFormat, TArgumen { if (IsErrorEnabled) { - _inner.Write( + inner.Write( exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Error); @@ -1500,7 +1496,7 @@ public virtual void Error([Localizable(false)] string me { if (IsErrorEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Error); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Error); } } @@ -1513,7 +1509,7 @@ public void Error( { if (IsErrorEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -1533,7 +1529,7 @@ public virtual void Error( { if (IsErrorEnabled) { - _inner.Write( + inner.Write( string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3), LogLevel.Error); } @@ -1549,7 +1545,7 @@ public void Error( { if (IsErrorEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -1571,7 +1567,7 @@ public virtual void Error( { if (IsErrorEnabled) { - _inner.Write( + inner.Write( string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3, argument4), LogLevel.Error); } @@ -1588,7 +1584,7 @@ public void Error( { if (IsErrorEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -1612,7 +1608,7 @@ public virtual void Error( { if (IsErrorEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -1663,7 +1659,7 @@ public virtual void Error([Localizable(false)] string messageFormat, { if (IsFatalEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Fatal); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Fatal); } } @@ -1975,7 +1971,7 @@ public void Fatal(Exception exception, string messageFormat, TArgumen { if (IsFatalEnabled) { - _inner.Write( + inner.Write( exception, string.Format(CultureInfo.InvariantCulture, messageFormat, argument), LogLevel.Fatal); @@ -1987,7 +1983,7 @@ public virtual void Fatal([Localizable(false)] string me { if (IsFatalEnabled) { - _inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Fatal); + inner.Write(string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2), LogLevel.Fatal); } } @@ -2000,7 +1996,7 @@ public void Fatal( { if (IsFatalEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -2020,7 +2016,7 @@ public virtual void Fatal( { if (IsFatalEnabled) { - _inner.Write( + inner.Write( string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3), LogLevel.Fatal); } @@ -2036,7 +2032,7 @@ public void Fatal( { if (IsFatalEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -2058,7 +2054,7 @@ public virtual void Fatal( { if (IsFatalEnabled) { - _inner.Write( + inner.Write( string.Format(CultureInfo.InvariantCulture, messageFormat, argument1, argument2, argument3, argument4), LogLevel.Fatal); } @@ -2075,7 +2071,7 @@ public void Fatal( { if (IsFatalEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -2099,7 +2095,7 @@ public virtual void Fatal( { if (IsFatalEnabled) { - _inner.Write( + inner.Write( exception, string.Format( CultureInfo.InvariantCulture, @@ -2150,7 +2146,7 @@ public virtual void Fatal - public void Write([Localizable(false)] string message, LogLevel logLevel) => _inner.Write(message, logLevel); + public void Write([Localizable(false)] string message, LogLevel logLevel) => inner.Write(message, logLevel); /// - public void Write(Exception exception, [Localizable(false)] string message, LogLevel logLevel) => _inner.Write(exception, message, logLevel); + public void Write(Exception exception, [Localizable(false)] string message, LogLevel logLevel) => inner.Write(exception, message, logLevel); /// - public void Write([Localizable(false)] string message, [Localizable(false)] Type type, LogLevel logLevel) => _inner.Write(message, type, logLevel); + public void Write([Localizable(false)] string message, [Localizable(false)] Type type, LogLevel logLevel) => inner.Write(message, type, logLevel); /// - public void Write(Exception exception, [Localizable(false)] string message, [Localizable(false)] Type type, LogLevel logLevel) => _inner.Write(exception, message, type, logLevel); + public void Write(Exception exception, [Localizable(false)] string message, [Localizable(false)] Type type, LogLevel logLevel) => inner.Write(exception, message, type, logLevel); } diff --git a/src/Splat/Logging/IEnableLogger.cs b/src/Splat/Logging/IEnableLogger.cs index dffe72323..386eee1f4 100644 --- a/src/Splat/Logging/IEnableLogger.cs +++ b/src/Splat/Logging/IEnableLogger.cs @@ -14,6 +14,4 @@ namespace Splat; /// [ComVisible(false)] [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1040:Avoid empty interfaces", Justification = "By Design")] -public interface IEnableLogger -{ -} +public interface IEnableLogger; diff --git a/src/Splat/Logging/LocalizableAttribute.cs b/src/Splat/Logging/LocalizableAttribute.cs deleted file mode 100644 index 18d3aea20..000000000 --- a/src/Splat/Logging/LocalizableAttribute.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2024 .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; - -#if PORTABLE || WINDOWS_PHONE -/// -/// Specifies whether a property should be localized. -/// -[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] -public sealed class LocalizableAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// If the value is localizable or not. - public LocalizableAttribute(bool isLocalizable) - { - IsLocalizable = isLocalizable; - } - - /// - /// Gets a value indicating whether a property should be localized. - /// - public bool IsLocalizable { get; } -} -#endif diff --git a/src/Splat/Maths/PointMathExtensions.cs b/src/Splat/Maths/PointMathExtensions.cs index 291d721fb..82fdc1ea6 100644 --- a/src/Splat/Maths/PointMathExtensions.cs +++ b/src/Splat/Maths/PointMathExtensions.cs @@ -18,12 +18,7 @@ public static class PointMathExtensions /// The point value to use for the calculation. /// The point that has been floored. public static PointF Floor(this Point value) -#if UIKIT - // NB: I have no idea but Archimedes does this, soooooooo.... - => new PointF((float)Math.Floor((double)value.X), (float)Math.Floor((double)value.Y)); -#else => new((float)Math.Floor((double)value.X), (float)Math.Ceiling((double)value.Y)); -#endif /// /// Determines whether two points are within 'epsilon' of each other. diff --git a/src/Splat/ServiceLocation/FuncDependencyResolver.cs b/src/Splat/ServiceLocation/FuncDependencyResolver.cs index 920ecad31..f4c0b5a9d 100644 --- a/src/Splat/ServiceLocation/FuncDependencyResolver.cs +++ b/src/Splat/ServiceLocation/FuncDependencyResolver.cs @@ -44,7 +44,7 @@ public IEnumerable GetServices(Type? serviceType, string? contract = nul { serviceType ??= typeof(NullServiceType); - return _innerGetServices(serviceType, contract) ?? Array.Empty(); + return _innerGetServices(serviceType, contract) ?? []; } /// diff --git a/src/Splat/ServiceLocation/IDependencyResolver.cs b/src/Splat/ServiceLocation/IDependencyResolver.cs index a2d76a64f..ee1ee92bd 100644 --- a/src/Splat/ServiceLocation/IDependencyResolver.cs +++ b/src/Splat/ServiceLocation/IDependencyResolver.cs @@ -9,6 +9,4 @@ namespace Splat; /// Represents a dependency resolver, a service to look up global class /// instances or types. /// -public interface IDependencyResolver : IReadonlyDependencyResolver, IMutableDependencyResolver, IDisposable -{ -} +public interface IDependencyResolver : IReadonlyDependencyResolver, IMutableDependencyResolver, IDisposable; diff --git a/src/Splat/ServiceLocation/ModernDependencyResolver.cs b/src/Splat/ServiceLocation/ModernDependencyResolver.cs index 8eca6220f..58e290866 100644 --- a/src/Splat/ServiceLocation/ModernDependencyResolver.cs +++ b/src/Splat/ServiceLocation/ModernDependencyResolver.cs @@ -149,7 +149,7 @@ public IEnumerable GetServices(Type? serviceType, string? contract = nul { if (_registry is null) { - return Array.Empty(); + return []; } serviceType ??= typeof(NullServiceType); diff --git a/version.json b/version.json index 4b18fbd4b..433f8e798 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "15.0", + "version": "15.1", "publicReleaseRefSpec": [ "^refs/heads/main$", // we release out of master "^refs/heads/preview/.*", // we release previews