-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Explain need for Locator API call #4935
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
Conversation
Clarify rationale for separating call to Locator API from method using types
@@ -79,7 +79,7 @@ Do not specify `ExcludeAssets=runtime` for the Microsoft.Build.Locator package. | |||
|
|||
### Register instance before calling MSBuild | |||
|
|||
Add a call to the Locator API before calling any method that uses MSBuild. | |||
Add a call to the Locator API before calling any method that uses MSBuild. This is important because the just-in-time (JIT) compiler needs to understand the types of the objects it compiles, and when trying to build a project using a specific version of MSBuild, it has to inspect that version before it compiles the code in case those types have changed. Since the JIT compiler works at a method-level granularity, if the call to the Locator API is in the same method as the first use of an MSBuild type (even if it precedes it, and the code involving the type has not yet been executed), the JIT compiler will not be able to JIT the whole method, causing an error. Some types that require the call to the MSBuildLocator API to have already been called include ProjectRootElement, ProjectInstance, and BuildManager. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is overly detailed and would be better off with a good and bad example. Writing one up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it's just because I think this sort of thing is really cool, but I would appreciate that level of detail if for no other reason than that I'd wonder why Microsoft would put in arbitrary requirements, and this would clarify that. That being said, an example would help, and you could certainly look at it faster.
@Forgind : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghogen thoughts?
Co-Authored-By: Rainer Sigwald <[email protected]>
@Forgind : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
Clarify rationale for separating call to Locator API from method using types