CommunityToolkit / CommunityToolkit/dotnet

Incorrect code generation when declaring an observable property with a source-generated type

Open
#733 1 comment 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

Declaring an observable property with a source-generated type fails at compile-time.

Source generators should have access to other source-generated code.

### Steps to reproduce

```text
1. Create a project
2. Add CsWin32
3. Add CommunityToolkit.MVVM
4. Register `WindowFromPoint` in the `NativeMethods.txt` file
5. Add an observable property of type `HWND`
6. `The type or namespace name 'HWND' could not be found ...\SpySharp.Views.WPF.MainWindow.g.cs`
```

### Expected behavior

The project should compile as it does with non-source-generated types.

### Screenshots

![image](https://github.com/CommunityToolkit/dotnet/assets/48759429/c04f5580-eea8-4d97-b899-8cb2b9dc3e63)

### IDE and version

VS 2022 Preview

### IDE version

VisualStudio.17.Preview/17.7.0-pre.2.0+33808.371

### Nuget packages

- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [X] CommunityToolkit.Mvvm (aka MVVM Toolkit)

### Nuget package version(s)

8.2.1

### Additional context

_No response_

### Help us help you

Yes, but only if others can assist

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.