diff --git a/Rx.NET/Source/Directory.build.targets b/Rx.NET/Source/Directory.build.targets
index 268dcf92ec..ea47a0a5bb 100644
--- a/Rx.NET/Source/Directory.build.targets
+++ b/Rx.NET/Source/Directory.build.targets
@@ -16,6 +16,9 @@
$(DefineConstants);HAS_WINRT;NO_NULLABLE_ATTRIBUTES
+
+ $(DefineConstants);HAS_TRIMMABILITY_ATTRIBUTES
+ $(DefineConstants);HAS_WINRT;HAS_WINFORMS;HAS_WPF;HAS_DISPATCHER;DESKTOPCLR;WINDOWS;CSWINRT
diff --git a/Rx.NET/Source/src/System.Reactive/Internal/Constants.cs b/Rx.NET/Source/src/System.Reactive/Internal/Constants.cs
index 8b7296a33c..4dc84033b8 100644
--- a/Rx.NET/Source/src/System.Reactive/Internal/Constants.cs
+++ b/Rx.NET/Source/src/System.Reactive/Internal/Constants.cs
@@ -4,7 +4,7 @@
namespace System.Reactive
{
- // We can't make those based on the Strings_Core.resx file, because the ObsoleteAttribute needs a compile-time constant.
+ // We can't make those based on the Strings_Core.resx file, because attributes need a compile-time constant.
internal static class Constants_Core
{
@@ -15,6 +15,9 @@ internal static class Constants_Core
public const string ObsoleteSchedulerThreadpool = ObsoleteRefactoring + " Consider using Scheduler.Default to obtain the platform's most appropriate pool-based scheduler. In order to access a specific pool-based scheduler, please add a reference to the System.Reactive.PlatformServices assembly for your target platform and use the appropriate scheduler in the System.Reactive.Concurrency namespace.";
public const string ObsoleteSchedulerequired = "This instance property is no longer supported. Use CurrentThreadScheduler.IsScheduleRequired instead.";
+
+ internal const string AsQueryableTrimIncompatibilityMessage = "This type uses Queryable.AsQueryable, which is not compatible with trimming because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods, and those IEnumerable methods might be trimmed.";
+ internal const string EventReflectionTrimIncompatibilityMessage = "This member uses reflection to discover event members and associated delegate types.";
}
// We can't make those based on the Strings_*.resx file, because the ObsoleteAttribute needs a compile-time constant.
diff --git a/Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs b/Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs
index d913ead511..38a200d30e 100644
--- a/Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs
+++ b/Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
@@ -19,6 +20,9 @@ public static Delegate CreateDelegate(Type delegateType, object o, MethodInfo me
return method.CreateDelegate(delegateType, o);
}
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static void GetEventMethods(Type targetType, object? target, string eventName, out MethodInfo addMethod, out MethodInfo removeMethod, out Type delegateType, out bool isWinRT)
{
EventInfo? e;
diff --git a/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs b/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs
index 8bb42762b3..34dae85bb1 100644
--- a/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs
+++ b/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs
@@ -433,17 +433,53 @@ internal partial interface IQueryLanguage
IObservable> FromEventPattern(Action> addHandler, Action> removeHandler, IScheduler scheduler);
IObservable> FromEventPattern(Action addHandler, Action removeHandler);
IObservable> FromEventPattern(Action addHandler, Action removeHandler, IScheduler scheduler);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(object target, string eventName);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(object target, string eventName);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(object target, string eventName);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(Type type, string eventName);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(Type type, string eventName, IScheduler scheduler);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(Type type, string eventName);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(Type type, string eventName, IScheduler scheduler);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(Type type, string eventName);
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
IObservable> FromEventPattern(Type type, string eventName, IScheduler scheduler);
IObservable FromEvent(Func, TDelegate> conversion, Action addHandler, Action removeHandler);
diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Events.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Events.cs
index 1f04fe9989..502966f7d7 100644
--- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Events.cs
+++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Events.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics.CodeAnalysis;
using System.Reactive.Concurrency;
using System.Threading;
@@ -538,6 +539,9 @@ public static IObservable> FromEventPattern
///
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(object target, string eventName)
{
if (target == null)
@@ -581,6 +585,9 @@ public static IObservable> FromEventPattern(object target,
///
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler)
{
if (target == null)
@@ -633,6 +640,9 @@ public static IObservable> FromEventPattern(object target,
///
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(object target, string eventName)
{
if (target == null)
@@ -677,6 +687,9 @@ public static IObservable> FromEventPattern
///
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler)
{
if (target == null)
@@ -730,6 +743,9 @@ public static IObservable> FromEventPattern
///
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(object target, string eventName)
{
if (target == null)
@@ -775,6 +791,9 @@ public static IObservable> FromEventPattern
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler)
{
if (target == null)
@@ -830,6 +849,9 @@ public static IObservable> FromEventPattern
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(Type type, string eventName)
{
if (type == null)
@@ -873,6 +895,9 @@ public static IObservable> FromEventPattern(Type type, stri
///
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(Type type, string eventName, IScheduler scheduler)
{
if (type == null)
@@ -925,6 +950,9 @@ public static IObservable> FromEventPattern(Type type, stri
///
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(Type type, string eventName)
{
if (type == null)
@@ -969,6 +997,9 @@ public static IObservable> FromEventPattern
///
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(Type type, string eventName, IScheduler scheduler)
{
if (type == null)
@@ -1022,6 +1053,9 @@ public static IObservable> FromEventPattern
///
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(Type type, string eventName)
{
if (type == null)
@@ -1067,6 +1101,9 @@ public static IObservable> FromEventPattern
///
///
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public static IObservable> FromEventPattern(Type type, string eventName, IScheduler scheduler)
{
if (type == null)
diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs
index 2e9cd721d4..8834b6ff2e 100644
--- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs
+++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs
@@ -4,8 +4,13 @@
#pragma warning disable 1591
+using System.Diagnostics.CodeAnalysis;
+
namespace System.Reactive.Linq
{
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.AsQueryableTrimIncompatibilityMessage)]
+#endif
public static partial class Qbservable
{
#pragma warning disable IDE1006 // Naming Styles: 3rd party code is known to reflect for this specific field name
diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs b/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs
index b3043b902f..f8af610ecb 100644
--- a/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs
+++ b/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs
@@ -45,7 +45,9 @@ public static QueryablePattern And(this IQbservabl
#if CRIPPLED_REFLECTION
InfoOf(() => And(default, default)),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodBase.GetCurrentMethod()!).MakeGenericMethod(typeof(TLeft), typeof(TRight)),
+#pragma warning restore IL2060
#endif
left.Expression,
GetSourceExpression(right)
@@ -80,7 +82,9 @@ public static QueryablePlan Then(this IQbservable Then(default, default)),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodBase.GetCurrentMethod()!).MakeGenericMethod(typeof(TSource), typeof(TResult)),
+#pragma warning restore IL2060
#endif
source.Expression,
selector
@@ -114,7 +118,9 @@ public static IQbservable When(this IQbservableProvider provid
#if CRIPPLED_REFLECTION
InfoOf(() => When(default, default)),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodBase.GetCurrentMethod()!).MakeGenericMethod(typeof(TResult)),
+#pragma warning restore IL2060
#endif
Expression.Constant(provider, typeof(IQbservableProvider)),
Expression.NewArrayInit(
@@ -151,7 +157,9 @@ public static IQbservable When(this IQbservableProvider provid
#if CRIPPLED_REFLECTION
InfoOf(() => When(default, default(IEnumerable>))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodBase.GetCurrentMethod()!).MakeGenericMethod(typeof(TResult)),
+#pragma warning restore IL2060
#endif
Expression.Constant(provider, typeof(IQbservableProvider)),
Expression.Constant(plans, typeof(IEnumerable>))
diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.cs b/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.cs
index e3c086d7d4..78c29b81c2 100644
--- a/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.cs
+++ b/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.cs
@@ -56,7 +56,9 @@ public static IQbservable ToQbservable(this IQueryable ToQbservable(default)),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodBase.GetCurrentMethod()!).MakeGenericMethod(typeof(TSource)),
+#pragma warning restore IL2060
#endif
source.Expression
)
@@ -90,7 +92,9 @@ public static IQbservable ToQbservable(this IQueryable ToQbservable(default)),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodBase.GetCurrentMethod()!).MakeGenericMethod(typeof(TSource)),
+#pragma warning restore IL2060
#endif
source.Expression,
Expression.Constant(scheduler)
diff --git a/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.NAry.cs b/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.NAry.cs
index ee8155b6b4..8e5c5bc346 100644
--- a/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.NAry.cs
+++ b/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.NAry.cs
@@ -35,12 +35,14 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond)),
#endif
first.Expression,
GetSourceExpression(second)
)
);
+#pragma warning restore IL2060 // Call to 'System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method.
}
///
@@ -69,7 +71,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -108,7 +112,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -152,7 +158,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -201,7 +209,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -255,7 +265,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -314,7 +326,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -378,7 +392,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -447,7 +463,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -521,7 +539,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -600,7 +620,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -684,7 +706,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth), typeof(TThirteenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -773,7 +797,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth), typeof(TThirteenth), typeof(TFourteenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -867,7 +893,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth), typeof(TThirteenth), typeof(TFourteenth), typeof(TFifteenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -966,7 +994,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.CombineLatest(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth), typeof(TThirteenth), typeof(TFourteenth), typeof(TFifteenth), typeof(TSixteenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1010,7 +1040,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second)
@@ -1044,7 +1076,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1083,7 +1117,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1127,7 +1163,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1176,7 +1214,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1230,7 +1270,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1289,7 +1331,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1353,7 +1397,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1422,7 +1468,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1496,7 +1544,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1575,7 +1625,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1659,7 +1711,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth), typeof(TThirteenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1748,7 +1802,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth), typeof(TThirteenth), typeof(TFourteenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1842,7 +1898,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth), typeof(TThirteenth), typeof(TFourteenth), typeof(TFifteenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
@@ -1941,7 +1999,9 @@ public static partial class QbservableEx
#if CRIPPLED_REFLECTION
InfoOf(() => Qbservable.Zip(default(IQbservable), default(IObservable))),
#else
+#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed
((MethodInfo)MethodInfo.GetCurrentMethod()!).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh), typeof(TEighth), typeof(TNinth), typeof(TTenth), typeof(TEleventh), typeof(TTwelfth), typeof(TThirteenth), typeof(TFourteenth), typeof(TFifteenth), typeof(TSixteenth)),
+#pragma warning restore IL2060
#endif
first.Expression,
GetSourceExpression(second),
diff --git a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Events.cs b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Events.cs
index e4d04a1d3f..c9354c9cc9 100644
--- a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Events.cs
+++ b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Events.cs
@@ -7,6 +7,8 @@
namespace System.Reactive.Linq
{
+ using System.Diagnostics.CodeAnalysis;
+
using ObservableImpl;
//
@@ -133,11 +135,17 @@ private static IObservable> FromEventPattern_> FromEventPattern(object target, string eventName)
{
return FromEventPattern_(target, eventName, GetSchedulerForCurrentContext());
}
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
public virtual IObservable> FromEventPattern(object target, string eventName, IScheduler scheduler)
{
return FromEventPattern_(target, eventName, scheduler);
@@ -145,6 +153,9 @@ public virtual IObservable> FromEventPattern(object target,
#region Implementation
+#if HAS_TRIMMABILITY_ATTRIBUTES
+ [RequiresUnreferencedCode(Constants_Core.EventReflectionTrimIncompatibilityMessage)]
+#endif
private static IObservable> FromEventPattern_(object target, string eventName, IScheduler scheduler)
{
return FromEventPattern_