Skip to content

Fix command line build error#24614

Merged
chborl merged 1 commit intodotnet:dev15.6.xfrom
chborl:failedbuildcommandline
Feb 5, 2018
Merged

Fix command line build error#24614
chborl merged 1 commit intodotnet:dev15.6.xfrom
chborl:failedbuildcommandline

Conversation

@chborl
Copy link
Contributor

@chborl chborl commented Feb 2, 2018

Customer scenario

Create a solution and from command line run:
devenv <solutionname>.sln /build

Bugs this fixes

https://devdiv.visualstudio.com/DevDiv/_workitems/edit/559223
fixes #18204

Workarounds, if any

build from IDE

Risk

None, just added a null check on a method call

Performance impact

None

Is this a regression from a previous update?

Root cause analysis

We are re-enabling this test: #18204 to catch this error.

How was the bug found?

Internal - VS team

Test documentation updated?

n/a

Fix and re-enable test that would catch this error
@chborl chborl requested a review from a team as a code owner February 2, 2018 21:17
@chborl
Copy link
Contributor Author

chborl commented Feb 2, 2018

@jinujoseph @jasonmalinowski @heejaechang for review

@chborl chborl changed the title Fixes 559223 Fix command line build error Feb 2, 2018
var kind = ForegroundThreadDataInfo.CreateDefault(defaultKind);

return new ForegroundThreadData(Thread.CurrentThread, new SynchronizationContextTaskScheduler(SynchronizationContext.Current), kind);
return new ForegroundThreadData(Thread.CurrentThread, SynchronizationContext.Current == null ? TaskScheduler.Default : new SynchronizationContextTaskScheduler(SynchronizationContext.Current), kind);
Copy link
Member

Choose a reason for hiding this comment

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

Actually, should this be TaskScheduler.Current? I don't presume we're using this much in the /build case, but Default does mean we're always picking the thread pool. Current would mean it might be right (and might still be wrong, but whatever.)

Copy link
Contributor

Choose a reason for hiding this comment

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

https://msdn.microsoft.com/en-us/library/system.threading.tasks.taskscheduler.current(v=vs.110).aspx

Remarks
When not called from within a task, Current will return the Default scheduler.

..

so in this case, it will be Default anyway?

Copy link
Member

Choose a reason for hiding this comment

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

If we run this inside of an xunit unit test, then it might pick up the xunit scheduler or something which might be what we want there.

Copy link
Member

Choose a reason for hiding this comment

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

Although I guess in that case SynchronizationContext.Current won't be null anyways. 🤷‍♂️

@jinujoseph
Copy link
Contributor

Approved via Link

@chborl chborl merged commit 201260c into dotnet:dev15.6.x Feb 5, 2018
@chborl chborl deleted the failedbuildcommandline branch October 26, 2018 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.

5 participants