question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Source Generator support for WPF project blocked?

See original GitHub issue

Version Used: dotnet 5 preview 8, visual studio 16.8 preview 2

Steps to Reproduce: Create fresh WPF project from VS modify project like this:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net5.0-windows</TargetFramework>
        <UseWPF>true</UseWPF>
        <LangVersion>preview</LangVersion>
    </PropertyGroup>

    <ItemGroup>
	    <ProjectReference Include="..\SourceGenerators\SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
    </ItemGroup>
</Project>

Expected Behavior: The source generator referenced works for me in a console dotnet core app. I would expect this to work in a WPF project too.

Actual Behavior: In a freshly created WPF (dotnet core) project from the VS-template, however the generator does not seem to run.

Is this intended behavior?

As the generator is not used at all, I have not included it here. It is a slight variation of the HelloWorld sample.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:12
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

6reactions
jaredparcommented, Aug 31, 2020

Just documenting that it doesn’t work isn’t enough, this needs to be implemented.

Intent is to fix the behavior, not document it.

3reactions
ryalanmscommented, Jan 12, 2021

Thanks for pointing this out, @Zalutskii. Existing source generator and PackageReference issues have not been linked to the source generator change: #3846. Apologies.

This was made ‘opt-in’ to reduce the possibility of breaking compilation of existing WPF applications, but will eventually be turned on by default in .NET 6.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source Generator not functioning with XAML files in .NET 6
This seems to be a regression bug with the current release of .NET SDK 6.0.302, and the fix is either a slight change...
Read more >
Source Generators an Exercise in futility - Dan Siegel
Forms projects stable, I was immediately blocked. While the generators did run for netstandard2.0 and Xamarin.iOS and MonoAndroid targets, no ...
Read more >
Improved Source Generators and Code Fixers Arrive in . ...
Note: there is a known issue with source generators in older versions of Roslyn that might cause IntelliSense to sometimes not work correctly ......
Read more >
Why is no-one using Roslyn token-based code generation ...
I'm planning to rewrite all of our company's old T4-based codegen tools into Source Generators. I've been looking at how other Source ......
Read more >
Even More MVVM Source Generator Awesomeness for .NET ...
Regardless if you are developing a .NET MAUI, WPF, WinUI, Uno, or Avalonia app, if you are using MVVM then you need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found