dotnet / dotnet/wpf

Cannot use source generator code in xaml file

Open
#8,128 2 comments 0 reactions 1 assignee Claimed by @Kuldeep-MS View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

Cannot use generated code from analyzers in xaml file, it reported missing assembly or reference.

### Reproduction Steps

**Steps**
1. Create a WPF project with .net6.0-windows
2. Add `true` in csproj
3. Reference Aigamo.ResXGenerator to generate designer file of resx manually.
4. Add Resources.resx file, remove `Custom Tool` of it, add `HelloWorld` key into resx.
5. Add textblock to use this string in xaml, ``
6. Build the project

**Error**
```
Target CoreCompile:
1> xxx\WpfApp2\WpfApp2\obj\Debug\net6.0-windows\MainWindow.g.cs(34,15,34,25): error CS0234: The type or namespace name 'Properties' does not exist in the namespace 'WpfApp2' (are you missing an assembly reference?)
```

**Sample**
[SamleApplication.zip](https://github.com/dotnet/wpf/files/12417426/SamleApplication.zip)

### Expected behavior

`IncludePackageReferencesDuringMarkupCompilation` should works for xaml file.
Please include sources from analyzers in CoreCompile target.

### Actual behavior

`IncludePackageReferencesDuringMarkupCompilation` not works in xaml file.

### Regression?

_No response_

### Known Workarounds

https://github.com/dotnet/wpf/issues/3404

### Impact

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.