Skip to content

Commit

Permalink
Added some AOT compilation warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed May 24, 2024
1 parent 6f358cd commit 91a41c7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 46 deletions.
59 changes: 13 additions & 46 deletions src/Epoxy.Core/EventBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System;
using System.Diagnostics;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Input;

#if WINDOWS_UWP || UNO
Expand Down Expand Up @@ -268,6 +269,9 @@ public sealed class Event :
/// <summary>
/// Binds target CLR event name bindable property declaration.
/// </summary>
#if NET5_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicEvents)]
#endif
public static readonly BindableProperty EventNameProperty =
BindableProperty.Create(
"EventName",
Expand All @@ -278,20 +282,6 @@ public sealed class Event :
null,
(d, ov, nv) => ((Event)d).OnEventNamePropertyChanged(ov, nv));

/// <summary>
/// Binds target CLR event name bindable property declaration.
/// </summary>
[Obsolete("Use EventName instead.")]
public static readonly BindableProperty NameProperty =
BindableProperty.Create(
"Name",
typeof(string),
typeof(Event),
null,
BindingMode.Default,
null,
(d, ov, nv) => ((Event)d).OnEventNamePropertyChanged(ov, nv));

/// <summary>
/// Binds ICommand expression bindable property declaration.
/// </summary>
Expand All @@ -308,16 +298,12 @@ public sealed class Event :
/// <summary>
/// Binds target CLR event name bindable property declaration.
/// </summary>
#if NET5_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicEvents)]
#endif
public static readonly AvaloniaProperty<string> EventNameProperty =
AvaloniaProperty.Register<Event, string>("EventName");

/// <summary>
/// Binds target CLR event name bindable property declaration.
/// </summary>
[Obsolete("Use EventName instead.")]
public static readonly AvaloniaProperty<string> NameProperty =
AvaloniaProperty.Register<Event, string>("Name");

/// <summary>
/// Binds ICommand expression bindable property declaration.
/// </summary>
Expand All @@ -343,26 +329,16 @@ static Event()
/// <summary>
/// Binds target CLR event name bindable property declaration.
/// </summary>
#if NET5_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicEvents)]
#endif
public static readonly DependencyProperty EventNameProperty =
DependencyProperty.Register(
"EventName",
typeof(string),
typeof(Event),
new PropertyMetadata(null, (d, e) => ((Event)d).OnEventNamePropertyChanged(e.OldValue, e.NewValue)));

#if !OPENSILVER
/// <summary>
/// Binds target CLR event name bindable property declaration.
/// </summary>
[Obsolete("Use EventName instead.")]
public static readonly DependencyProperty NameProperty =
DependencyProperty.Register(
"Name",
typeof(string),
typeof(Event),
new PropertyMetadata(null, (d, e) => ((Event)d).OnEventNamePropertyChanged(e.OldValue, e.NewValue)));
#endif

/// <summary>
/// Binds ICommand expression bindable property declaration.
/// </summary>
Expand All @@ -384,24 +360,15 @@ public Event()
/// <summary>
/// Binds target CLR event name.
/// </summary>
#if NET5_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicEvents)]
#endif
public string? EventName
{
get => (string?)this.GetValue(EventNameProperty);
set => this.SetValue(EventNameProperty, value);
}

#if !OPENSILVER
/// <summary>
/// Binds target CLR event name.
/// </summary>
[Obsolete("Use EventName instead.")]
public string? Name
{
get => (string?)this.GetValue(EventNameProperty);
set => this.SetValue(EventNameProperty, value);
}
#endif

/// <summary>
/// Binds ICommand expression.
/// </summary>
Expand Down
19 changes: 19 additions & 0 deletions src/Epoxy/Advanced/GlobalServiceAccessorExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#nullable enable

using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;

using Epoxy.Internal;
Expand Down Expand Up @@ -94,6 +95,9 @@ public static class GlobalServiceAccessorExtension
/// GlobalService.Register(facade);
/// </code>
/// </example>
#if NET7_0_OR_GREATER
[RequiresDynamicCode("Epoxy requires CLR for GlobalService feature, have to disable NativeAOT.")]
#endif
public static void Register(
this GlobalServiceAccessor accessor,
object instance, RegisteringValidations validation = RegisteringValidations.Strict) =>
Expand Down Expand Up @@ -131,6 +135,9 @@ public static void Register(
/// GlobalService.RegisterExplicit<IBlueTooth>(facade);
/// </code>
/// </example>
#if NET7_0_OR_GREATER
[RequiresDynamicCode("Epoxy requires CLR for GlobalService feature, have to disable NativeAOT.")]
#endif
public static void RegisterExplicit<TService>(
this GlobalServiceAccessor accessor,
TService instance, RegisteringValidations validation = RegisteringValidations.Strict)
Expand All @@ -142,6 +149,9 @@ public static void RegisterExplicit<TService>(
/// </summary>
/// <param name="accessor">Accessor instance (will use only fixup by compiler)</param>
/// <param name="instance">Target instance</param>
#if NET7_0_OR_GREATER
[RequiresDynamicCode("Epoxy requires CLR for GlobalService feature, have to disable NativeAOT.")]
#endif
public static void Unregister(
this GlobalServiceAccessor accessor,
object instance) =>
Expand All @@ -152,6 +162,9 @@ public static void Unregister(
/// </summary>
/// <typeparam name="TService">Explicit interface type</typeparam>
/// <param name="accessor">Accessor instance (will use only fixup by compiler)</param>
#if NET7_0_OR_GREATER
[RequiresDynamicCode("Epoxy requires CLR for GlobalService feature, have to disable NativeAOT.")]
#endif
public static void UnregisterExplicit<TService>(
this GlobalServiceAccessor accessor)
where TService : class =>
Expand All @@ -175,6 +188,9 @@ public static void UnregisterExplicit<TService>(
/// });
/// </code>
/// </example>
#if NET7_0_OR_GREATER
[RequiresDynamicCode("Epoxy requires CLR for GlobalService feature, have to disable NativeAOT.")]
#endif
public static ValueTask ExecuteAsync<TService>(
this GlobalServiceAccessor accessor,
Func<TService, ValueTask> action,
Expand All @@ -200,6 +216,9 @@ public static ValueTask ExecuteAsync<TService>(
/// });
/// </code>
/// </example>
#if NET7_0_OR_GREATER
[RequiresDynamicCode("Epoxy requires CLR for GlobalService feature, have to disable NativeAOT.")]
#endif
public static ValueTask<TResult> ExecuteAsync<TService, TResult>(
this GlobalServiceAccessor accessor,
Func<TService, ValueTask<TResult>> action) =>
Expand Down

0 comments on commit 91a41c7

Please sign in to comment.