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

Update Microsoft.CodeAnalysis.Workspaces.UnitTests to target netcoreapp3.1 #45813

Merged
merged 8 commits into from
Sep 23, 2020

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Jul 8, 2020

No description provided.

@genlu
Copy link
Member

genlu commented Jul 9, 2020

Is there any CI configuration needs to be done to include those tests in CoreClr legs?

@sharwell
Copy link
Member Author

sharwell commented Jul 9, 2020

It seems to already be running them there.

@sharwell sharwell marked this pull request as ready for review July 9, 2020 19:59
@sharwell sharwell requested review from a team as code owners July 9, 2020 19:59
{
Debug.Assert(false, output);
}
#endif
Copy link
Member Author

Choose a reason for hiding this comment

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

@tmat This is causing a problem because we expect the ThrowingTraceListener to be active, but it's not taking effect in .NET Core scenarios so we failfast instead.

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem like the right solution. We have Debug.Assert in many places.

Copy link
Member Author

Choose a reason for hiding this comment

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

Any suggestions for how to proceed here?

Copy link
Member

Choose a reason for hiding this comment

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

Do we know why it doesn't work on Core? For now, perhaps we can skip fail-fast on Core.

Copy link
Member Author

@sharwell sharwell Jul 10, 2020

Choose a reason for hiding this comment

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

Do we know why it doesn't work on Core?

Debug.Assert doesn't use trace listeners on .NET Core.

For now, perhaps we can skip fail-fast on Core.

I have not found a way to change this behavior without private reflection, and even if we go that route I'm not sure how to do it from a single location in the xunit startup process. Perhaps a custom MemberData property so it runs during discovery?

Copy link
Member Author

Choose a reason for hiding this comment

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

I discussed this with @stephentoub , and it looks like we can still use ThrowingTraceListener, but we have to add it explicitly:

Trace.Listeners.Clear();
Trace.Listeners.Add(new ThrowingTraceListener());

Copy link
Member

Choose a reason for hiding this comment

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

K. That pattern + module initailizers on .NET Core would seem to essentially cover this issue for us then.

Copy link
Member Author

Choose a reason for hiding this comment

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

What release is the first to support module initializers? Are we already able to add one for the test helper assembly?

Copy link
Member

Choose a reason for hiding this comment

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

The feature has been available in the runtime since 1.0 I believe. The language support will come in C# 9.0. The feature branch should get merged into the main branch sometime next week.

Copy link
Member Author

Choose a reason for hiding this comment

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

This has been updated to use a module initializer to install the trace listener. There are two resulting impacts:

  1. Visual Basic test projects targeting .NET Core cannot use Debug.Assert in any location where assertion might fail. Doing so will cause a FailFast. Workaround: if/when this occurs, make the test class extend TestBase to force module initialization via inheritance.
  2. This PR is now blocked on using the preview language version (Enable usage of preview language features #44485).

@sharwell sharwell marked this pull request as draft July 9, 2020 23:38
@genlu
Copy link
Member

genlu commented Jul 25, 2020

@sharwell Any update on this? I think the change @jaredpar mentioned above is already merged?

@sharwell
Copy link
Member Author

@genlu This PR is blocked on #44485

@genlu
Copy link
Member

genlu commented Aug 10, 2020

@sharwell Any update?

@genlu
Copy link
Member

genlu commented Aug 31, 2020

Ping @sharwell

@genlu
Copy link
Member

genlu commented Sep 22, 2020

@sharwell Looks like the tests are running and pass on .Net Core legs, is this good to go now?

@sharwell sharwell marked this pull request as ready for review September 23, 2020 16:20
@sharwell sharwell removed the Blocked label Sep 23, 2020
@sharwell sharwell merged commit ad73fb9 into dotnet:master Sep 23, 2020
@ghost ghost added this to the Next milestone Sep 23, 2020
@sharwell sharwell deleted the netcoreapp-workspaces-tests branch September 23, 2020 23:07
@Cosifne Cosifne modified the milestones: Next, 16.9.P1 Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants