Skip to content

Commit fd5b766

Browse files
authored
Fix PlatformNotSupportedException thrown on Android in ConsoleTitler (#2390)
* Remove Immutable packages reference from Forms sample * Catch PlatformNotSupportedException when checking if console output is redirected in ConsoleTitler
1 parent 914ee71 commit fd5b766

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

samples/BenchmarkDotNet.Samples.Forms/BenchmarkDotNet.Samples.Forms.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
</ItemGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
1413
<PackageReference Include="Xamarin.Forms" Version="4.5.0.530" />
1514
<PackageReference Include="Xamarin.Essentials" Version="1.5.2" />
1615
</ItemGroup>

src/BenchmarkDotNet/Running/ConsoleTitler.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@ internal class ConsoleTitler : IDisposable
2020

2121
public ConsoleTitler(string initialTitle)
2222
{
23-
// Return without enabling if Console output is redirected.
24-
if (Console.IsOutputRedirected)
23+
try
24+
{
25+
// Return without enabling if Console output is redirected.
26+
if (Console.IsOutputRedirected)
27+
{
28+
return;
29+
}
30+
}
31+
catch (PlatformNotSupportedException)
2532
{
26-
return;
33+
// Ignore the exception. Some platforms do not support Console.IsOutputRedirected.
2734
}
2835

2936
try

0 commit comments

Comments
 (0)