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

Fix IDIC casts throwing exceptions for is operator checks #1676

Merged
merged 1 commit into from
Jul 22, 2024
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
11 changes: 10 additions & 1 deletion src/Tests/FunctionalTests/Collections/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,17 @@
return 101;
}

var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
var names = profile.GetNetworkNames();

List<string> networkNames = new();
if (names?.Count > 0)
{
networkNames.AddRange(names);
}

return 100;

static bool SequencesEqual<T>(IEnumerable<T> x, params IEnumerable<T>[] list) => list.All((y) => x.SequenceEqual(y));

static bool AllEqual<T>(T[] x, params T[][] list) => list.All((y) => x.SequenceEqual(y));
static bool AllEqual<T>(T[] x, params T[][] list) => list.All((y) => x.SequenceEqual(y));
9 changes: 5 additions & 4 deletions src/WinRT.Runtime/IWinRTObject.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ internal sealed bool IsInterfaceImplementedFallback(RuntimeTypeHandle interfaceT
{
if (!FeatureSwitches.EnableIDynamicInterfaceCastableSupport)
{
throw new NotSupportedException($"Support for 'IDynamicInterfaceCastable' is disabled (make sure that the 'CsWinRTEnableIDynamicInterfaceCastableSupport' property is not set to 'false').");
return throwIfNotImplemented ?
throw new NotSupportedException($"Support for 'IDynamicInterfaceCastable' is disabled (make sure that the 'CsWinRTEnableIDynamicInterfaceCastableSupport' property is not set to 'false').") : false;
}

if (QueryInterfaceCache.ContainsKey(interfaceType))
Expand Down Expand Up @@ -67,7 +68,7 @@ internal sealed bool IsInterfaceImplementedFallback(RuntimeTypeHandle interfaceT
#if NET
if (!RuntimeFeature.IsDynamicCodeCompiled)
{
throw new NotSupportedException($"IDynamicInterfaceCastable is not supported for generic type '{type}'.");
return throwIfNotImplemented ? throw new NotSupportedException($"IDynamicInterfaceCastable is not supported for generic type '{type}'.") : false;
}
#endif

Expand Down Expand Up @@ -103,7 +104,7 @@ internal sealed bool IsInterfaceImplementedFallback(RuntimeTypeHandle interfaceT
#if NET
if (!RuntimeFeature.IsDynamicCodeCompiled)
{
throw new NotSupportedException($"IDynamicInterfaceCastable is not supported for generic type '{type}'.");
return throwIfNotImplemented ? throw new NotSupportedException($"IDynamicInterfaceCastable is not supported for generic type '{type}'.") : false;
}
#endif

Expand Down Expand Up @@ -204,7 +205,7 @@ internal sealed bool IsInterfaceImplementedFallback(RuntimeTypeHandle interfaceT
#if NET
if (!RuntimeFeature.IsDynamicCodeCompiled)
{
throw new NotSupportedException($"Cannot construct an object reference for vtable type '{vftblType}'.");
return throwIfNotImplemented ? throw new NotSupportedException($"Cannot construct an object reference for vtable type '{vftblType}'.") : false;
}
#endif

Expand Down