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 PlatformNotSupportedException thrown on Android in ConsoleTitler #2390

Merged
merged 2 commits into from Aug 2, 2023

Conversation

Adam--
Copy link
Contributor

@Adam-- Adam-- commented Aug 2, 2023

Previously on the Android platform, and possibly other platforms, the ConsoleTitler threw a PlatformNotSupportedException when checking if console output is redirected and prevented benchmarks from running. This is fixed by catching and ignoring the PlatformNotSupportedException. The try-catch around Console.Title is still used to determine if the platform supports console retitling. This seemed more appropriate in the event that the platform doesn't support checking if output is redirected but supports retitling, even though it is unlikely.

Additionally removes the Forms sample project's Immutable package reference. BenchmarkDotNet has a dependency on Immutable 5.0.0 and this reference was causing package downgrade warnings that were treated as errors:

error NU1605: Warning As Error: Detected package downgrade: System.Collections.Immutable from 5.0.0 to 1.7.0. Reference the package directly from the project to select a different version.
error NU1605:  BenchmarkDotNet.Samples.Forms -> BenchmarkDotNet -> Microsoft.Diagnostics.Runtime 2.2.332302 -> System.Collections.Immutable (>= 5.0.0)
error NU1605:  BenchmarkDotNet.Samples.Forms -> System.Collections.Immutable (>= 1.7.0)
error NU1605: Warning As Error: Detected package downgrade: System.Collections.Immutable from 5.0.0 to 1.7.0. Reference the package directly from the project to select a different version.
error NU1605:  BenchmarkDotNet.Samples.Forms -> BenchmarkDotNet -> Microsoft.CodeAnalysis.CSharp 4.1.0 -> Microsoft.CodeAnalysis.Common 4.1.0 -> System.Collections.Immutable (>= 5.0.0)
error NU1605:  BenchmarkDotNet.Samples.Forms -> System.Collections.Immutable (>= 1.7.0)

Fixes #2389

BenchmarkDotNet has a dependency on Immutable 5.0.0 and this reference was causing package downgrade warnings:

```
error NU1605: Warning As Error: Detected package downgrade: System.Collections.Immutable from 5.0.0 to 1.7.0. Reference the package directly from the project to select a different version.
error NU1605:  BenchmarkDotNet.Samples.Forms -> BenchmarkDotNet -> Microsoft.Diagnostics.Runtime 2.2.332302 -> System.Collections.Immutable (>= 5.0.0)
error NU1605:  BenchmarkDotNet.Samples.Forms -> System.Collections.Immutable (>= 1.7.0)
error NU1605: Warning As Error: Detected package downgrade: System.Collections.Immutable from 5.0.0 to 1.7.0. Reference the package directly from the project to select a different version.
error NU1605:  BenchmarkDotNet.Samples.Forms -> BenchmarkDotNet -> Microsoft.CodeAnalysis.CSharp 4.1.0 -> Microsoft.CodeAnalysis.Common 4.1.0 -> System.Collections.Immutable (>= 5.0.0)
error NU1605:  BenchmarkDotNet.Samples.Forms -> System.Collections.Immutable (>= 1.7.0)
```
@timcassell
Copy link
Collaborator

Thanks @Adam--!

@timcassell timcassell merged commit fd5b766 into dotnet:master Aug 2, 2023
7 checks passed
@timcassell timcassell added this to the v0.13.7 milestone Aug 2, 2023
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Adam-- thank you for providing the fix! Also, it's really strange that Console.IsOutputRedirected throws on Android..

@Adam--
Copy link
Contributor Author

Adam-- commented Aug 3, 2023

@timcassell, @adamsitnik,

No problem, glad I could help! I see it was added to milestone 0.13.7, but wasn't sure what the release schedule is like. Do you know when it will be released or are there prereleases?

@Adam-- Adam-- deleted the xamarin-fix branch August 3, 2023 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PlatformNotSupportedException thrown on Android in ConsoleTitler
3 participants