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

[Bug] Invalid cref value "!:ObservableObject" in WPF UserControl #10259

Open
RobGess opened this issue Oct 11, 2024 · 1 comment
Open

[Bug] Invalid cref value "!:ObservableObject" in WPF UserControl #10259

RobGess opened this issue Oct 11, 2024 · 1 comment
Labels
bug A bug to fix

Comments

@RobGess
Copy link

RobGess commented Oct 11, 2024

When using the ObservableObject attribute from the CommunityToolkit.Mvvm v8.3.2 package on the code behind partial class of a WPF UserControl like this:

Image

DocFx seems to have an issue with properly generating the code documentation for the SourceGenerators. The following warning occurs when generating the documention with DocFx v.2.77.0:

warning: InvalidCref: Invalid cref value "!:ObservableObject" found in XML documentation comment for SetProperty defined in CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.ObservableObjectGenerator\DocFxTest.TestControl.g.cs Line 243.

I am aware that the proper way to handle this kind of functionality should utilize a view model. Also, ObservableObject used in view models don't have this issue with DocFx.

Feel free to have a look at my test project DocFxTest to reproduce this issue.

If this is an user issue and can be solve with a proper docfx.json configuration, please let me know.

Spec Summary:

  • Windows 11
  • CommunityToolkit.Mvvm 8.3.2
  • DocFx 2.77.0

Expected behavior
No warning.

@RobGess RobGess added the bug A bug to fix label Oct 11, 2024
@filzrev
Copy link
Contributor

filzrev commented Oct 11, 2024

Reported issue seems to be caused by CommunityToolkit.Mvvm source generator side problems.

When Roslyn failed to resolve symbol.
It's resolved with !: prefixed name. And docfx reporting this name as InvalidCref warnings.
https://github.com/dotnet/roslyn/blob/d5a5b2101b5ddc32adca0d7b517899607c404332/src/Compilers/CSharp/Portable/DocumentationComments/DocumentationCommentIDVisitor.cs#L86-L92

Steps to confirm root cause of problem

  1. Open DocfxTest project with Visual Studio.
  2. Open generated DocFxTest.TestControl.g.cs file from Solution Explorer.

    TreePath:
    [Dependencies]-[Analyzers]-[CommunityToolkit.Mvvm.SourceGenerators]-[CommunityToolkit.Mvvm.SourceGenerators.ObservableObjectGenerator]

  3. Confirm <see cref = "ObservableObject"/> symbol reference is not resolved (It's not highlighted)

How to fix problems
I should be referenced by using fully qualified name.
(e,g, <see cref = "global::CommunityToolkit.Mvvm.ComponentModel.ObservableObject"/>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug to fix
Projects
None yet
Development

No branches or pull requests

2 participants