Skip to content

Commit

Permalink
Fix PlatformNotSupportedException thrown on Android in ConsoleTitler (#…
Browse files Browse the repository at this point in the history
…2390)

* Remove Immutable packages reference from Forms sample

* Catch PlatformNotSupportedException when checking if console output is redirected in ConsoleTitler
  • Loading branch information
Adam-- committed Aug 2, 2023
1 parent 914ee71 commit fd5b766
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
<PackageReference Include="Xamarin.Forms" Version="4.5.0.530" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.2" />
</ItemGroup>
Expand Down
13 changes: 10 additions & 3 deletions src/BenchmarkDotNet/Running/ConsoleTitler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ internal class ConsoleTitler : IDisposable

public ConsoleTitler(string initialTitle)
{
// Return without enabling if Console output is redirected.
if (Console.IsOutputRedirected)
try
{
// Return without enabling if Console output is redirected.
if (Console.IsOutputRedirected)
{
return;
}
}
catch (PlatformNotSupportedException)
{
return;
// Ignore the exception. Some platforms do not support Console.IsOutputRedirected.
}

try
Expand Down

0 comments on commit fd5b766

Please sign in to comment.