Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove BinaryFormatter, Start Adding AOT Markup #3943

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,25 @@ namespace ReactiveUI
public class CreatesCommandBindingViaCommandParameter : ReactiveUI.ICreatesCommandBinding
{
public CreatesCommandBindingViaCommandParameter() { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls GetRuntimeProperty(string name)")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls GetRuntimeProperty(string name)")]
public System.IDisposable? BindCommandToObject(System.Windows.Input.ICommand? command, object? target, System.IObservable<object?> commandParameter) { }
public System.IDisposable? BindCommandToObject<TEventArgs>(System.Windows.Input.ICommand? command, object? target, System.IObservable<object?> commandParameter, string eventName) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls GetRuntimeProperty(string name)")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls GetRuntimeProperty(string name)")]
public int GetAffinityForObject(System.Type type, bool hasEventTarget) { }
}
public class CreatesCommandBindingViaEvent : ReactiveUI.ICreatesCommandBinding
{
public CreatesCommandBindingViaEvent() { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
public System.IDisposable? BindCommandToObject(System.Windows.Input.ICommand? command, object? target, System.IObservable<object?> commandParameter) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
public System.IDisposable? BindCommandToObject<TEventArgs>(System.Windows.Input.ICommand? command, object? target, System.IObservable<object?> commandParameter, string eventName) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
public int GetAffinityForObject(System.Type type, bool hasEventTarget) { }
}
public class DecimalToStringTypeConverter : ReactiveUI.IBindingTypeConverter, Splat.IEnableLogger
Expand All @@ -137,6 +147,8 @@ namespace ReactiveUI
public sealed class DefaultViewLocator : ReactiveUI.IViewLocator, Splat.IEnableLogger
{
public System.Func<string, string> ViewModelToViewFunc { get; set; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The method is used to resolve views for view models.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
public ReactiveUI.IViewFor? ResolveView<T>(T? viewModel, string? contract = null) { }
}
public static class DependencyResolverMixins
Expand Down Expand Up @@ -369,7 +381,7 @@ namespace ReactiveUI
public interface ISuspensionDriver
{
System.IObservable<System.Reactive.Unit> InvalidateState();
System.IObservable<object> LoadState();
System.IObservable<object?> LoadState();
System.IObservable<System.Reactive.Unit> SaveState(object state);
}
public interface ISuspensionHost : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging
Expand Down Expand Up @@ -813,6 +825,8 @@ namespace ReactiveUI
public static class Reflection
{
public static string ExpressionToPropertyNames(System.Linq.Expressions.Expression? expression) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls GetRuntimeMethods()")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls GetRuntimeMethods()")]
public static System.Type GetEventArgsTypeForEvent(System.Type type, string? eventName) { }
public static System.Func<object?, object?[]?, object?>? GetValueFetcherForProperty(System.Reflection.MemberInfo? member) { }
public static System.Func<object?, object?[]?, object?> GetValueFetcherOrThrow(System.Reflection.MemberInfo? member) { }
Expand All @@ -821,6 +835,8 @@ namespace ReactiveUI
public static bool IsStatic(this System.Reflection.PropertyInfo item) { }
public static System.Type? ReallyFindType(string? type, bool throwOnFailure) { }
public static System.Linq.Expressions.Expression Rewrite(System.Linq.Expressions.Expression? expression) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls GetTypeInfo()")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls GetTypeInfo()")]
public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object targetObject, params string[] methodsToCheck) { }
public static bool TryGetAllValuesForPropertyChain(out ReactiveUI.IObservedChange<object, object?>[] changeValues, object? current, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> expressionChain) { }
public static bool TryGetValueForPropertyChain<TValue>(out TValue changeValue, object? current, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> expressionChain) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,25 @@ namespace ReactiveUI
public class CreatesCommandBindingViaCommandParameter : ReactiveUI.ICreatesCommandBinding
{
public CreatesCommandBindingViaCommandParameter() { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls GetRuntimeProperty(string name)")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls GetRuntimeProperty(string name)")]
public System.IDisposable? BindCommandToObject(System.Windows.Input.ICommand? command, object? target, System.IObservable<object?> commandParameter) { }
public System.IDisposable? BindCommandToObject<TEventArgs>(System.Windows.Input.ICommand? command, object? target, System.IObservable<object?> commandParameter, string eventName) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls GetRuntimeProperty(string name)")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls GetRuntimeProperty(string name)")]
public int GetAffinityForObject(System.Type type, bool hasEventTarget) { }
}
public class CreatesCommandBindingViaEvent : ReactiveUI.ICreatesCommandBinding
{
public CreatesCommandBindingViaEvent() { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
public System.IDisposable? BindCommandToObject(System.Windows.Input.ICommand? command, object? target, System.IObservable<object?> commandParameter) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
public System.IDisposable? BindCommandToObject<TEventArgs>(System.Windows.Input.ICommand? command, object? target, System.IObservable<object?> commandParameter, string eventName) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
public int GetAffinityForObject(System.Type type, bool hasEventTarget) { }
}
public class DecimalToStringTypeConverter : ReactiveUI.IBindingTypeConverter, Splat.IEnableLogger
Expand All @@ -137,6 +147,8 @@ namespace ReactiveUI
public sealed class DefaultViewLocator : ReactiveUI.IViewLocator, Splat.IEnableLogger
{
public System.Func<string, string> ViewModelToViewFunc { get; set; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The method is used to resolve views for view models.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
public ReactiveUI.IViewFor? ResolveView<T>(T? viewModel, string? contract = null) { }
}
public static class DependencyResolverMixins
Expand Down Expand Up @@ -369,7 +381,7 @@ namespace ReactiveUI
public interface ISuspensionDriver
{
System.IObservable<System.Reactive.Unit> InvalidateState();
System.IObservable<object> LoadState();
System.IObservable<object?> LoadState();
System.IObservable<System.Reactive.Unit> SaveState(object state);
}
public interface ISuspensionHost : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging
Expand Down Expand Up @@ -813,6 +825,8 @@ namespace ReactiveUI
public static class Reflection
{
public static string ExpressionToPropertyNames(System.Linq.Expressions.Expression? expression) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls GetRuntimeMethods()")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls GetRuntimeMethods()")]
public static System.Type GetEventArgsTypeForEvent(System.Type type, string? eventName) { }
public static System.Func<object?, object?[]?, object?>? GetValueFetcherForProperty(System.Reflection.MemberInfo? member) { }
public static System.Func<object?, object?[]?, object?> GetValueFetcherOrThrow(System.Reflection.MemberInfo? member) { }
Expand All @@ -821,6 +835,8 @@ namespace ReactiveUI
public static bool IsStatic(this System.Reflection.PropertyInfo item) { }
public static System.Type? ReallyFindType(string? type, bool throwOnFailure) { }
public static System.Linq.Expressions.Expression Rewrite(System.Linq.Expressions.Expression? expression) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Calls GetTypeInfo()")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Calls GetTypeInfo()")]
public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object targetObject, params string[] methodsToCheck) { }
public static bool TryGetAllValuesForPropertyChain(out ReactiveUI.IObservedChange<object, object?>[] changeValues, object? current, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> expressionChain) { }
public static bool TryGetValueForPropertyChain<TValue>(out TValue changeValue, object? current, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> expressionChain) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ namespace ReactiveUI
public interface ISuspensionDriver
{
System.IObservable<System.Reactive.Unit> InvalidateState();
System.IObservable<object> LoadState();
System.IObservable<object?> LoadState();
System.IObservable<System.Reactive.Unit> SaveState(object state);
}
public interface ISuspensionHost : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging
Expand Down
4 changes: 4 additions & 0 deletions src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public static IDisposable BindCommandToObject(ICommand? command, object? target,
return ret;
}

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
#endif
public static IDisposable BindCommandToObject(ICommand? command, object? target, IObservable<object?> commandParameter, string? eventName)
{
var type = target!.GetType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
public class CreatesCommandBindingViaCommandParameter : ICreatesCommandBinding
{
/// <inheritdoc/>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls GetRuntimeProperty(string name)")]
[RequiresDynamicCode("Calls GetRuntimeProperty(string name)")]
#endif
public int GetAffinityForObject(Type type, bool hasEventTarget)

Check warning on line 21 in src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaCommandParameter.cs

View workflow job for this annotation

GitHub Actions / build / build

Member 'ReactiveUI.CreatesCommandBindingViaCommandParameter.GetAffinityForObject(Type, Boolean)' with 'RequiresDynamicCodeAttribute' implements interface member 'ReactiveUI.ICreatesCommandBinding.GetAffinityForObject(Type, Boolean)' without 'RequiresDynamicCodeAttribute'. 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.
{
if (hasEventTarget)
{
Expand All @@ -35,7 +39,11 @@
}

/// <inheritdoc/>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls GetRuntimeProperty(string name)")]
[RequiresDynamicCode("Calls GetRuntimeProperty(string name)")]
#endif
public IDisposable? BindCommandToObject(ICommand? command, object? target, IObservable<object?> commandParameter)

Check warning on line 46 in src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaCommandParameter.cs

View workflow job for this annotation

GitHub Actions / build / build

Member 'ReactiveUI.CreatesCommandBindingViaCommandParameter.BindCommandToObject(ICommand, Object, IObservable<Object>)' with 'RequiresDynamicCodeAttribute' implements interface member 'ReactiveUI.ICreatesCommandBinding.BindCommandToObject(ICommand, Object, IObservable<Object>)' without 'RequiresDynamicCodeAttribute'. 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.
{
target.ArgumentNullExceptionThrowIfNull(nameof(target));

Expand Down
12 changes: 12 additions & 0 deletions src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
];

/// <inheritdoc/>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
#endif
public int GetAffinityForObject(Type type, bool hasEventTarget)

Check warning on line 37 in src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs

View workflow job for this annotation

GitHub Actions / build / build

Member 'ReactiveUI.CreatesCommandBindingViaEvent.GetAffinityForObject(Type, Boolean)' with 'RequiresDynamicCodeAttribute' implements interface member 'ReactiveUI.ICreatesCommandBinding.GetAffinityForObject(Type, Boolean)' without 'RequiresDynamicCodeAttribute'. 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.
{
if (hasEventTarget)
{
Expand All @@ -45,7 +49,11 @@
}

/// <inheritdoc/>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
#endif
public IDisposable? BindCommandToObject(ICommand? command, object? target, IObservable<object?> commandParameter)

Check warning on line 56 in src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs

View workflow job for this annotation

GitHub Actions / build / build

Member 'ReactiveUI.CreatesCommandBindingViaEvent.BindCommandToObject(ICommand, Object, IObservable<Object>)' with 'RequiresDynamicCodeAttribute' implements interface member 'ReactiveUI.ICreatesCommandBinding.BindCommandToObject(ICommand, Object, IObservable<Object>)' without 'RequiresDynamicCodeAttribute'. 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.
{
target.ArgumentNullExceptionThrowIfNull(nameof(target));

Expand All @@ -61,7 +69,11 @@
}

/// <inheritdoc/>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
[RequiresDynamicCode("Calls System.Reflection.MethodInfo.MakeGenericMethod(params Type[])")]
#endif
public IDisposable? BindCommandToObject<TEventArgs>(ICommand? command, object? target, IObservable<object?> commandParameter, string eventName)

Check warning on line 76 in src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs

View workflow job for this annotation

GitHub Actions / build / build

Member 'ReactiveUI.CreatesCommandBindingViaEvent.BindCommandToObject<TEventArgs>(ICommand, Object, IObservable<Object>, String)' with 'RequiresDynamicCodeAttribute' implements interface member 'ReactiveUI.ICreatesCommandBinding.BindCommandToObject<TEventArgs>(ICommand, Object, IObservable<Object>, String)' without 'RequiresDynamicCodeAttribute'. 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.
#if MONO
where TEventArgs : EventArgs
#endif
Expand Down
8 changes: 8 additions & 0 deletions src/ReactiveUI/Expression/Reflection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ public static bool TrySetValueToPropertyChain<TValue>(object? target, IEnumerabl
/// <param name="eventName">The name of the event.</param>
/// <returns>The Type of the EventArgs to use.</returns>
/// <exception cref="Exception">If there is no event matching the name on the target type.</exception>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls GetRuntimeMethods()")]
[RequiresDynamicCode("Calls GetRuntimeMethods()")]
#endif
public static Type GetEventArgsTypeForEvent(Type type, string? eventName) // TODO: Create Test
{
type.ArgumentNullExceptionThrowIfNull(nameof(type));
Expand All @@ -354,6 +358,10 @@ public static Type GetEventArgsTypeForEvent(Type type, string? eventName) // TOD
/// <param name="targetObject">The object to check.</param>
/// <param name="methodsToCheck">The name of the methods to check.</param>
/// <exception cref="Exception">Thrown if the methods aren't overriden on the target object.</exception>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls GetTypeInfo()")]
[RequiresDynamicCode("Calls GetTypeInfo()")]
#endif
public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object targetObject, params string[] methodsToCheck) // TODO: Create Test
{
var (methodName, methodImplementation) = methodsToCheck
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI/Interfaces/ISuspensionDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface ISuspensionDriver
/// Loads the application state from persistent storage.
/// </summary>
/// <returns>An object observable.</returns>
IObservable<object> LoadState();
IObservable<object?> LoadState();

/// <summary>
/// Saves the application state to disk.
Expand All @@ -30,4 +30,4 @@ public interface ISuspensionDriver
/// </summary>
/// <returns>A completed observable.</returns>
IObservable<Unit> InvalidateState();
}
}
2 changes: 1 addition & 1 deletion src/ReactiveUI/Mixins/AutoPersistHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ReactiveUI;
public static class AutoPersistHelper
{
private static readonly MemoizingMRUCache<Type, Dictionary<string, bool>> _persistablePropertiesCache = new(
(type, _) => type.GetTypeInfo().DeclaredProperties
static (type, _) => type.GetTypeInfo().DeclaredProperties
.Where(x => x.CustomAttributes.Any(y => typeof(DataMemberAttribute).GetTypeInfo().IsAssignableFrom(y.AttributeType.GetTypeInfo())))
.ToDictionary(k => k.Name, _ => true),
RxApp.SmallCacheLimit);
Expand Down
6 changes: 5 additions & 1 deletion src/ReactiveUI/PlatformRegistrationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ namespace ReactiveUI;
public static class PlatformRegistrationManager
{
internal static RegistrationNamespace[] DefaultRegistrationNamespaces { get; } =
#if NET6_0_OR_GREATER
Enum.GetValues<RegistrationNamespace>();
#else
(RegistrationNamespace[])Enum.GetValues(typeof(RegistrationNamespace));
#endif

internal static RegistrationNamespace[] NamespacesToRegister { get; set; } = DefaultRegistrationNamespaces;

Expand All @@ -21,4 +25,4 @@ public static class PlatformRegistrationManager
/// </summary>
/// <param name="namespaces">The namespaces to register.</param>
public static void SetRegistrationNamespaces(params RegistrationNamespace[] namespaces) => NamespacesToRegister = namespaces;
}
}
18 changes: 12 additions & 6 deletions src/ReactiveUI/Platforms/android/BundleSuspensionDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// See the LICENSE file in the project root for full license information.

using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.Json;

namespace ReactiveUI;

Expand All @@ -14,7 +14,11 @@ namespace ReactiveUI;
public class BundleSuspensionDriver : ISuspensionDriver
{
/// <inheritdoc/>
public IObservable<object> LoadState() // TODO: Create Test
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls Deserialize<object>()")]
[RequiresDynamicCode("Calls Deserialize<object>()")]
#endif
public IObservable<object?> LoadState() // TODO: Create Test
{
try
{
Expand All @@ -24,7 +28,6 @@ public IObservable<object> LoadState() // TODO: Create Test
return Observable.Throw<object>(new Exception("New bundle, start from scratch"));
}

var serializer = new BinaryFormatter();
var buffer = AutoSuspendHelper.LatestBundle.GetByteArray("__state");

if (buffer is null)
Expand All @@ -34,7 +37,7 @@ public IObservable<object> LoadState() // TODO: Create Test

var st = new MemoryStream(buffer);

return Observable.Return(serializer.Deserialize(st));
return Observable.Return(JsonSerializer.Deserialize<object>(st));
}
catch (Exception ex)
{
Expand All @@ -43,13 +46,16 @@ public IObservable<object> LoadState() // TODO: Create Test
}

/// <inheritdoc/>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Calls Serialize<object>()")]
[RequiresDynamicCode("Calls Serialize<object>()")]
#endif
public IObservable<Unit> SaveState(object state) // TODO: Create Test
{
try
{
var serializer = new BinaryFormatter();
var st = new MemoryStream();

JsonSerializer.Serialize(st, state);
AutoSuspendHelper.LatestBundle?.PutByteArray("__state", st.ToArray());
return Observables.Unit;
}
Expand Down
Loading
Loading