Skip to content

Commit

Permalink
Fix IDIC casts throwing exceptions for is operator checks (#1676)
Browse files Browse the repository at this point in the history
  • Loading branch information
manodasanW authored Jul 22, 2024
1 parent d71f2d3 commit fa224c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
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

0 comments on commit fa224c3

Please sign in to comment.