Skip to content

Commit

Permalink
Add further AOT Markup Update Packages (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman authored Jan 28, 2025
1 parent 1545429 commit db0a52b
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 180 deletions.
20 changes: 11 additions & 9 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<PackageVersion Include="Microsoft.AppCenter.Analytics" Version="5.0.6" />
<PackageVersion Include="Microsoft.AppCenter.Crashes" Version="5.0.6" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Mindscape.Raygun4Net.NetCore" Version="11.2.1" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
Expand All @@ -33,7 +33,7 @@
<PackageVersion Include="SimpleInjector" Version="5.5.0" />
<PackageVersion Include="stylecop.analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="System.AppContext" Version="4.3.0" />
<PackageVersion Include="System.Collections.Immutable" Version="9.0.0" />
<PackageVersion Include="System.Collections.Immutable" Version="9.0.1" />
<PackageVersion Include="System.Collections.NonGeneric" Version="4.3.0" />
<PackageVersion Include="System.Console" Version="4.3.1" />
<PackageVersion Include="System.Diagnostics.Debug" Version="4.3.0" />
Expand All @@ -53,8 +53,7 @@
<PackageVersion Include="System.Runtime.Extensions" Version="4.3.1" />
<PackageVersion Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageVersion Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageVersion Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
<PackageVersion Include="System.Text.Json" Version="9.0.1" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageVersion Include="System.Threading" Version="4.3.0" />
<PackageVersion Include="System.Threading.Thread" Version="4.3.0" />
Expand All @@ -66,20 +65,23 @@
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1" />
<PackageVersion Include="Verify.Xunit" Version="28.9.0" />
<PackageVersion Include="Xunit.StaFact" Version="1.2.69" />
<PackageVersion Include="FluentAssertions" Version="7.1.0" />
<PackageVersion Include="FluentAssertions" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.Reactive.Testing" Version="6.0.1" />
<PackageVersion Include="PublicApiGenerator" Version="11.3.0" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) or $(TargetFramework.StartsWith('netstandard'))">
<PackageVersion Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
<PackageVersion Include="System.Drawing.Primitives" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net8')) or $(TargetFramework.StartsWith('net9'))">
<PackageVersion Include="System.Runtime.Serialization.Formatters" Version="9.0.1" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net46'))">
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
<PackageVersion Include="System.Diagnostics.Contracts" Version="4.3.0" />
<PackageVersion Include="System.Drawing.Primitives" Version="4.3.0" />
<PackageVersion Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void AutoFacWhenAnyTest()
var builder = new ContainerBuilder();

var autofacResolver = builder.UseAutofacDependencyResolver();
Locator.CurrentMutable.RegisterConstant(new ActivatingViewFetcher(), typeof(IActivationForViewFetcher));
Locator.CurrentMutable.RegisterConstant<IActivationForViewFetcher>(new ActivatingViewFetcher());
autofacResolver.InitializeSplat();
autofacResolver.InitializeReactiveUI();
_ = builder.Build();
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI.DI.Tests/ReactiveUI.DI.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net8.0;net9.0</TargetFrameworks>
<NoWarn>$(NoWarn);1591;CA1707;SA1633;CA2000</NoWarn>
<NoWarn>$(NoWarn);1591;CA1707;SA1633;CA2000;CA1515</NoWarn>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
4 changes: 1 addition & 3 deletions src/Splat.Autofac.Tests/DependencyResolverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ public void AutofacDependencyResolver_Should_ReturnRegisteredLogger()

var autofacResolver = builder.UseAutofacDependencyResolver();

Locator.CurrentMutable.RegisterConstant(
new FuncLogManager(type => new WrappingFullLogger(new ConsoleLogger())),
typeof(ILogManager));
Locator.CurrentMutable.RegisterConstant<ILogManager>(new FuncLogManager(type => new WrappingFullLogger(new ConsoleLogger())));

autofacResolver.SetLifetimeScope(builder.Build());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000</NoWarn>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000;CA1515</NoWarn>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<DefineConstants>$(DefineConstants);DRYIOC1</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000</NoWarn>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000;CA1515</NoWarn>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<DefineConstants>$(DefineConstants);DRYIOC2</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000</NoWarn>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000;CA1515</NoWarn>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<DefineConstants>$(DefineConstants);MICROSOFT1</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000</NoWarn>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000;CA1515</NoWarn>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<DefineConstants>$(DefineConstants);MICROSOFT2</DefineConstants>
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
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000</NoWarn>
<NoWarn>$(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000;CA1515</NoWarn>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<DefineConstants>$(DefineConstants);MAIN</DefineConstants>
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
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net8.0-windows10.0.17763.0;net9.0-windows10.0.17763.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);1591;CA1707;SA1633;CA2000;CA1034</NoWarn>
<NoWarn>$(NoWarn);1591;CA1707;SA1633;CA2000;CA1034;CA1515</NoWarn>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
Expand Down
33 changes: 33 additions & 0 deletions src/Splat.Drawing/Platforms/ReflectionStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;
using System.Reflection;

namespace Splat;

internal static class ReflectionStubs
{
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Type.GetField() may be trimmed.")]
[RequiresDynamicCode("Type.GetField() may be trimmed.")]
#endif
public static FieldInfo? GetField(this Type value, string name, BindingFlags flags = default)
{
var ti = value.GetTypeInfo();
Expand All @@ -18,6 +23,10 @@ internal static class ReflectionStubs
: ti.BaseType.GetField(name, flags);
}

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Type.GetMethod() may be trimmed.")]
[RequiresDynamicCode("Type.GetMethod() may be trimmed.")]
#endif
public static MethodInfo? GetMethod(this Type value, string name, BindingFlags flags = default)
{
var ti = value.GetTypeInfo();
Expand All @@ -27,6 +36,10 @@ internal static class ReflectionStubs
: ti.BaseType.GetMethod(name, flags);
}

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Type.GetProperty() may be trimmed.")]
[RequiresDynamicCode("Type.GetProperty() may be trimmed.")]
#endif
public static PropertyInfo? GetProperty(this Type value, string name, BindingFlags flags = default)
{
var ti = value.GetTypeInfo();
Expand All @@ -36,6 +49,10 @@ internal static class ReflectionStubs
: ti.BaseType.GetProperty(name, flags);
}

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Type.GetEvent() may be trimmed.")]
[RequiresDynamicCode("Type.GetEvent() may be trimmed.")]
#endif
public static EventInfo? GetEvent(this Type value, string name, BindingFlags flags = default)
{
var ti = value.GetTypeInfo();
Expand All @@ -45,10 +62,22 @@ internal static class ReflectionStubs
: ti.BaseType.GetEvent(name, flags);
}

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Type.GetProperties() may be trimmed.")]
[RequiresDynamicCode("Type.GetProperties() may be trimmed.")]
#endif
public static IEnumerable<PropertyInfo> GetProperties(this Type value) => value.GetTypeInfo().DeclaredProperties;

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Type.GetFields() may be trimmed.")]
[RequiresDynamicCode("Type.GetFields() may be trimmed.")]
#endif
public static IEnumerable<FieldInfo> GetFields(this Type value) => value.GetTypeInfo().DeclaredFields;

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Type.GetMethod() may be trimmed.")]
[RequiresDynamicCode("Type.GetMethod() may be trimmed.")]
#endif
public static MethodInfo? GetMethod(this Type value, string methodName, Type[] paramTypes, BindingFlags flags = default)
{
var ti = value.GetTypeInfo();
Expand All @@ -60,6 +89,10 @@ internal static class ReflectionStubs
: ti.BaseType.GetMethod(methodName, paramTypes, flags);
}

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Type.GetMethods() may be trimmed.")]
[RequiresDynamicCode("Type.GetMethods() may be trimmed.")]
#endif
public static IEnumerable<MethodInfo> GetMethods(this Type value) => value.GetTypeInfo().DeclaredMethods;

public static IEnumerable<object> GetCustomAttributes(this Type value, Type attributeType, bool inherit) => value.GetTypeInfo().GetCustomAttributes(attributeType, inherit);
Expand Down
6 changes: 2 additions & 4 deletions src/Splat.DryIoc.Tests/DependencyResolverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,7 @@ public void DryIocDependencyResolver_Should_ReturnRegisteredLogger()
var c = new Container();
c.UseDryIocDependencyResolver();
c.Register<ILogger, ConsoleLogger>(ifAlreadyRegistered: IfAlreadyRegistered.Replace);
Locator.CurrentMutable.RegisterConstant(
new FuncLogManager(type => new WrappingFullLogger(new ConsoleLogger())),
typeof(ILogManager));
Locator.CurrentMutable.RegisterConstant<ILogManager>(new FuncLogManager(type => new WrappingFullLogger(new ConsoleLogger())));

var d = Splat.Locator.Current.GetService<ILogManager>();
Assert.IsType<FuncLogManager>(d);
Expand All @@ -272,7 +270,7 @@ public void DryIocDependencyResolver_Should_ReturnRegisteredLogger()
public void DryIocDependencyResolver_PreInit_Should_ReturnRegisteredLogger()
{
var c = new Container();
c.RegisterInstance(typeof(ILogManager), new FuncLogManager(type => new WrappingFullLogger(new ConsoleLogger())));
c.RegisterInstance<ILogManager>(new FuncLogManager(type => new WrappingFullLogger(new ConsoleLogger())));
c.UseDryIocDependencyResolver();

var d = Splat.Locator.Current.GetService<ILogManager>();
Expand Down
4 changes: 1 addition & 3 deletions src/Splat.Prism.Tests/DependencyResolverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ public void PrismDependencyResolver_Should_ReturnRegisteredLogger()
{
using var c = new SplatContainerExtension();
c.Register(typeof(ILogger), typeof(ConsoleLogger));
Locator.CurrentMutable.RegisterConstant(
new FuncLogManager(type => new WrappingFullLogger(new ConsoleLogger())),
typeof(ILogManager));
Locator.CurrentMutable.RegisterConstant<ILogManager>(new FuncLogManager(type => new WrappingFullLogger(new ConsoleLogger())));

var d = Splat.Locator.Current.GetService<ILogManager>();
Assert.IsType<FuncLogManager>(d);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public static class EnableFeatureUsageTrackingExtensionsTests
/// <summary>
/// Dummy object for testing IEnableFeatureUsageTracking.
/// </summary>
public sealed class TestObjectThatSupportsFeatureUsageTracking : IEnableFeatureUsageTracking
{
}
public sealed class TestObjectThatSupportsFeatureUsageTracking : IEnableFeatureUsageTracking;

/// <summary>
/// Unit tests for the FeatureUsageTrackingExtensionMethod.
Expand Down
8 changes: 4 additions & 4 deletions src/Splat.Tests/LocatorSerialRegisterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,13 @@ public void FuncDependencyResolver_UnregisterAll()
});

currentMutable.UnregisterAll<IDummyInterface>();
type.Should().Be(typeof(IDummyInterface));
type.Should().Be<IDummyInterface>();
contract.Should().BeNull();
unregisterAllCalled.Should().BeTrue();

unregisterAllCalled = false;
currentMutable.UnregisterAll<IEnableLogger>("test");
type.Should().Be(typeof(IEnableLogger));
type.Should().Be<IEnableLogger>();
contract.Should().Be("test");
unregisterAllCalled.Should().BeTrue();
}
Expand All @@ -353,13 +353,13 @@ public void FuncDependencyResolver_UnregisterCurrent()
});

currentMutable.UnregisterCurrent<IDummyInterface>();
type.Should().Be(typeof(IDummyInterface));
type.Should().Be<IDummyInterface>();
contract.Should().BeNull();
unregisterAllCalled.Should().BeTrue();

unregisterAllCalled = false;
currentMutable.UnregisterCurrent<IEnableLogger>("test");
type.Should().Be(typeof(IEnableLogger));
type.Should().Be<IEnableLogger>();
contract.Should().Be("test");
unregisterAllCalled.Should().BeTrue();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Splat.Tests/LocatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,13 @@ public void FuncDependencyResolver_UnregisterAll()
});

currentMutable.UnregisterAll<IDummyInterface>();
type.Should().Be(typeof(IDummyInterface));
type.Should().Be<IDummyInterface>();
contract.Should().BeNull();
unregisterAllCalled.Should().BeTrue();

unregisterAllCalled = false;
currentMutable.UnregisterAll<IEnableLogger>("test");
type.Should().Be(typeof(IEnableLogger));
type.Should().Be<IEnableLogger>();
contract.Should().Be("test");
unregisterAllCalled.Should().BeTrue();
}
Expand All @@ -435,13 +435,13 @@ public void FuncDependencyResolver_UnregisterCurrent()
});

currentMutable.UnregisterCurrent<IDummyInterface>();
type.Should().Be(typeof(IDummyInterface));
type.Should().Be<IDummyInterface>();
contract.Should().BeNull();
unregisterAllCalled.Should().BeTrue();

unregisterAllCalled = false;
currentMutable.UnregisterCurrent<IEnableLogger>("test");
type.Should().Be(typeof(IEnableLogger));
type.Should().Be<IEnableLogger>();
contract.Should().Be("test");
unregisterAllCalled.Should().BeTrue();
}
Expand Down
Loading

0 comments on commit db0a52b

Please sign in to comment.