Skip to content

Fix exception under blazor 5 #3647

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

Merged
merged 1 commit into from
Nov 26, 2020
Merged

Fix exception under blazor 5 #3647

merged 1 commit into from
Nov 26, 2020

Conversation

Temtaime
Copy link
Contributor

@Temtaime Temtaime commented Oct 14, 2020

testAssembly.Properties.Set(PropertyNames.ProcessId, System.Diagnostics.Process.GetCurrentProcess().Id);
try
{
testAssembly.Properties.Set(PropertyNames.ProcessId, System.Diagnostics.Process.GetCurrentProcess().Id);
Copy link
Contributor

@jnm2 jnm2 Nov 21, 2020

Choose a reason for hiding this comment

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

Also starting in .NET 5, we should use the much less wasteful Environment.ProcessId. Do you know if Blazor still implements Environment.ProcessId to throw the same exception? If it doesn't throw an exception, we maybe want to add #if NET5_0 and use it in this PR to address Blazor 5.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we could also call https://docs.microsoft.com/en-us/dotnet/api/system.operatingsystem.isbrowser?view=net-5.0 inside the #if NET5_0 section even if Environment.ProcessId does throw, rather than catching an exception.

Copy link
Member

Choose a reason for hiding this comment

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

I think I would prefer that solution, as I think we should avoid catching exceptions with empty error handlers if it is possible.

@jnm2 jnm2 requested a review from a team November 21, 2020 21:12
@rprouse rprouse added this to the 3.13 milestone Nov 26, 2020
@rprouse rprouse merged commit 23426f3 into nunit:master Nov 26, 2020
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.

4 participants