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

Warnings about invalid XML Comments in generated code #408

Closed
pocki opened this issue Sep 30, 2024 · 3 comments · Fixed by #409 or #411
Closed

Warnings about invalid XML Comments in generated code #408

pocki opened this issue Sep 30, 2024 · 3 comments · Fixed by #409 or #411
Labels
bug Something isn't working

Comments

@pocki
Copy link

pocki commented Sep 30, 2024

Describe the Bug

Since the update to v2.0 I am getting warnings about invalid XML comments in the generated code.
It seems that there is cref used for referencing to Url - href should be used in this case, and cref to reference code.

Steps to Reproduce

Update to v2.0

\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Constants.BuildDateTime.g.cs(42,26,42,31): warning CS1584: XML comment has syntactically incorrect cref attribute 'https :  / / github . com / devlooped # sponsorlink'
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Constants.BuildDateTime.g.cs(42,64,42,64): warning CS1658: Unexpected character '#'. See also error CS1056.
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Branch.g.cs(42,26,42,31): warning CS1584: XML comment has syntactically incorrect cref attribute 'https :  / / github . com / devlooped # sponsorlink'
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Branch.g.cs(42,64,42,64): warning CS1658: Unexpected character '#'. See also error CS1056.
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Commit.g.cs(42,26,42,31): warning CS1584: XML comment has syntactically incorrect cref attribute 'https :  / / github . com / devlooped # sponsorlink'
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Commit.g.cs(42,64,42,64): warning CS1658: Unexpected character '#'. See also error CS1056.
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Sha.g.cs(42,26,42,31): warning CS1584: XML comment has syntactically incorrect cref attribute 'https :  / / github . com / devlooped # sponsorlink'
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Sha.g.cs(42,64,42,64): warning CS1658: Unexpected character '#'. See also error CS1056.
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Root.g.cs(42,26,42,31): warning CS1584: XML comment has syntactically incorrect cref attribute 'https :  / / github . com / devlooped # sponsorlink'
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Root.g.cs(42,64,42,64): warning CS1658: Unexpected character '#'. See also error CS1056.
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Url.g.cs(42,26,42,31): warning CS1584: XML comment has syntactically incorrect cref attribute 'https :  / / github . com / devlooped # sponsorlink'
\Debug\net8.0\ThisAssembly.Constants\ThisAssembly.ConstantsGenerator\Git.Url.g.cs(42,64,42,64): warning CS1658: Unexpected character '#'. See also error CS1056.

Expected Behavior

XML comments should be generated correctly, no warning

Exception with Stack Trace

no exception

Version Info

    <PackageVersion Include="ThisAssembly.Constants" Version="2.0.0" />
    <PackageVersion Include="ThisAssembly.Git" Version="2.0.0" />

Additional Info

.NET 8 project
Visual Studio 2022

Back this issue
Back this issue

@pocki pocki added the bug Something isn't working label Sep 30, 2024
@kzu
Copy link
Member

kzu commented Sep 30, 2024

Fixed in #411, shipping in 2.0.2

@kzu kzu closed this as completed Sep 30, 2024
kzu added a commit that referenced this issue Sep 30, 2024
We were using cref, which is for API members, which is what was causing the formatting error in the first place.

Fixes #408
kzu added a commit that referenced this issue Sep 30, 2024
We were using cref, which is for API members, which is what was causing the formatting error in the first place.

Fixes #408
@OoLunar
Copy link

OoLunar commented Oct 7, 2024

Still happening in 2.0.3:

/home/lunar/Code/OoLunar/Tomoe/src/obj/Debug/net8.0/ThisAssembly.Constants/ThisAssembly.ConstantsGenerator/Project.ProjectFile.g.cs(26,15): warning CS1570: XML comment has badly formed XML -- 'End tag 'summary' does not match the start tag 'Project'.'
/home/lunar/Code/OoLunar/Tomoe/src/obj/Debug/net8.0/ThisAssembly.Constants/ThisAssembly.ConstantsGenerator/Project.ProjectFile.g.cs(27,1): warning CS1570: XML comment has badly formed XML -- 'Expected an end tag for element 'summary'.'

I would provide the files if I could but unfortunately I cannot access them since they only exist when compiling.

@kzu
Copy link
Member

kzu commented Oct 8, 2024

You can view them by setting:

    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>

In your project.
A small isolated repro (in particular, the contents of that ProjectFile property, which I suspect has newlines in it) would be super helpful. Alternatively, you can provide a comment for it that will override the default comment which just renders the value, like so:

<ItemGroup>
 <Constant Include="ProjectFile" Value="$(ProjectFile)" Comment="The contents of the project" Root="Project" />
</ItemGroup>

@devlooped devlooped locked and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
3 participants