reactiveui / ReactiveUI.SourceGenerators

Use source generators to generate objects.
MIT License
27 stars 2 forks source link

[Bug]: All generators cannot handle generic class #115

Open ethpch opened 2 hours ago

ethpch commented 2 hours ago

Describe the bug 🐞

I have tried the latest version 2.0.9, and find some unexpected error.

As the title says, all generators cannot generate code for generic types like Foo<T>. Error messages are 生成器[GeneratorName]未能生成源。它不会影响输出,因此可能会造成编译错误。异常的类型为“ArgumentException”,显示消息“hintName“TestClass2<T>.IViewFor.g.cs”在位置 10 处包含无效字符“<”。 All generators behave like this, [Reactive], [ObservableAsProperty], [ReactiveCommand], [IViewFor], [RoutedControlHost], ViewModelControlHost. Finally no code is generated.

Minimal reproduction repository is below.

Non-generic class and version 1.1.31 work well.

Step to reproduce

  1. Clone the minimal reproduction repository
  2. Build
  3. See error

Reproduction repository

https://github.com/ethpch/ReactiveUI.SourceGenerators.GenericClassBug

Expected behavior

Code is generated as expected

Screenshots 🖼️

image

IDE

No response

Operating system

No response

Version

No response

Device

No response

ReactiveUI Version

No response

Additional information ℹ️

I find some of your documentation is wrong, like [IViewFor(...)]. #61 says now IViewFor uses generic type, and do not accept string as parameter anymore. Can you correct the documentation? Maybe next time, but finally a correct documentation is better.

glennawatson commented 1 hour ago

The old functionality is correct so this is a legitimate bug. Thanks for bringing it to our attention.

We should probably add some unit tests around this scenario to fix I guess @ChrisPulman