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

[release/5.0] Support Source Generators in WPF projects #3846

Merged
merged 11 commits into from
Dec 11, 2020

Conversation

ryalanms
Copy link
Member

@ryalanms ryalanms commented Nov 23, 2020

[release/5.0] Support Source Generators in WPF projects

This feature requires applications to opt-in by explicitly setting a property in their project file. Otherwise, the existing GenerateTemporaryTargetAssembly code is executed.

This PR brings the changes from master to release/5.0:

https://github.com/dotnet/roslyn/blob/master/docs/features/source-generators.md

Original PR:

#3585

  • Include generated NuGet props and targets from outer WPF parent project in generated temp project
  • Add condition and cleanup generated NuGet props and targets after compilation of temp project
  • Move BuildEngine global properties to project properties

The source generator samples now work in WPF applications:

https://github.com/dotnet/roslyn-sdk/tree/master/samples/CSharp/SourceGenerators

A single property turns on the new PackageReference support (IncludePackageReferencesDuringMarkupCompilation = true) and enables the new behavior. By default, the unmodified GenerateTemporaryTargetAssembly code is called, the old path.

There was an incomplete change previously committed and reverted. The new change includes:

  • Relative path fixes from previous commit: .NET Core WPF Build error on custom BaseIntermediateOutputPath #1718 #3120
  • Addition of ResolveProjectReferences target when IncludePackageReferencesDuringMarkupCompilation is not false
  • Replacement of BuildEngine global properties with project properties that caused build failures in referenced projects and various other scenarios (e.g. AssemblyName)

* Include generated NuGet props and targets from outer WPF parent project in generated temp project

* Add condition and cleanup generated NuGet props and targets after compilation of temp project

* Move BuildEngine global properties to project properties
@ryalanms ryalanms requested a review from a team as a code owner November 23, 2020 23:24
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Nov 23, 2020
@ghost ghost requested review from fabiant3 and SamBent November 23, 2020 23:24
@lindexi
Copy link
Member

lindexi commented Nov 24, 2020

Can this fix #811 ?

Looks like it can fix the source code nuget packages that package by SourceYard: https://github.com/dotnet-campus/SourceYard

Thank you

Copy link
Member

@vatsan-madhavan vatsan-madhavan left a comment

Choose a reason for hiding this comment

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

I seem to recall that this PR was merged, then reverted, and is now being brought back. If this recollection is correct, then perhaps an explanation about what went wrong, and how the problem has been remedied in this version (besides providing an opt-out) would be a helpful to incorporate in the description.

@ryalanms
Copy link
Member Author

The description has been updated to include the differences between this and the previous PR. Thanks.

Copy link
Member

@vatsan-madhavan vatsan-madhavan left a comment

Choose a reason for hiding this comment

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

The question about the glob-pattern looks interesting and should be resolved before merging - maybe it's nothing; and a few maintainability nits best taken care of now. otherwise looks good.

ryalanms and others added 3 commits December 6, 2020 11:45
…WinFX.targets

Co-authored-by: Rainer Sigwald <raines@microsoft.com>
Co-authored-by: Rainer Sigwald <raines@microsoft.com>
…kupCompilation. Rename GenerateTemporaryTargetAssembly task. Add comment on porting source for GetRelativePath implementation.
@ryalanms
Copy link
Member Author

@rainersigwald: Thank you for reviewing. I believe all the design suggestions were accommodated here. Everything has been consolidated in to a single task and target.

…around, and make implicit SDK imports explicit.
…udePackageReferencesDuringMarkupCompilation.
@ryalanms
Copy link
Member Author

This was approved by .NET Tactics today for 5.0.2. Thanks.

@ryalanms ryalanms merged commit 06e0d92 into release/5.0 Dec 11, 2020
ryalanms added a commit that referenced this pull request Dec 11, 2020
[release/5.0] Support source generators in WPF projects (#3846) [5.0.2 servicing]
@mmitche mmitche deleted the SourceGenerators branch December 30, 2020 17:03
ryalanms added a commit that referenced this pull request Jan 6, 2021
[release/5.0] Support source generators in WPF projects (#3846) [5.0.2 servicing]
ryalanms added a commit that referenced this pull request Jan 6, 2021
[release/5.0] Support source generators in WPF projects (#3846) [5.0.2 servicing]
@ghost ghost locked as resolved and limited conversation to collaborators Apr 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants