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

GeneratedRegex Attribute Failed to generate code and shows CS8795 error #65850

Open
laolarou726 opened this issue Dec 7, 2022 · 7 comments
Open
Assignees
Milestone

Comments

@laolarou726
Copy link

Version Used:

  • Visual Studio 2022 17.4.2
  • .NET 7.0.100

Steps to Reproduce:

  1. Create a class with GeneratedRegex
private partial class Test{
    [GeneratedRegex("(\\d+\\.?\\d*|\\d*\\.?\\d+)")]
    private static partial Regex DecimalRegex();
}
  1. The error will shows

image

image

SourceGenerator does not generate anything.

Diagnostic Id:

CS8795

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 7, 2022
@svick svick added the New Feature - Source Generators Source Generators label Dec 8, 2022
@arkalyanms arkalyanms added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 6, 2023
@arkalyanms arkalyanms added this to the 17.5 P3 milestone Jan 6, 2023
@jasonmalinowski
Copy link
Member

This doesn't reproduce in 17.5.0 Preview 2.0; we'd be hearing pretty loudly if we broke this generally. @laolarou726 any idea if there's something special with your setup, or was that screenshot from a larger project where there might be some extra things impacting it?

@laolarou726
Copy link
Author

This doesn't reproduce in 17.5.0 Preview 2.0; we'd be hearing pretty loudly if we broke this generally. @laolarou726 any idea if there's something special with your setup, or was that screenshot from a larger project where there might be some extra things impacting it?

I think this bug is randomly happening to me. Sometime I need close Visual Studio and open again then the problem will resolve.

@jasonmalinowski
Copy link
Member

If you get to the point where you have the squiggle, if you click on the method name and invoke Go to Definition, what happens? The request may seem odd since it seems like it shouldn't work if there's a squiggle at all, but it's possible a few different systems are out of sync here.

@laolarou726
Copy link
Author

If you get to the point where you have the squiggle, if you click on the method name and invoke Go to Definition, what happens? The request may seem odd since it seems like it shouldn't work if there's a squiggle at all, but it's possible a few different systems are out of sync here.

Sometimes it will jump to the right definition. But VS still shows error there.

@cheenamalhotra
Copy link
Member

This is happening in VS 2022 as well in .NET 7.0 projects.

Microsoft Visual Studio Enterprise 2022
Version 17.6.0 Preview 2.0
VisualStudio.17.Preview/17.6.0-pre.2.0+33513.286
Microsoft .NET Framework
Version 4.8.09032

@onionhammer
Copy link

onionhammer commented Aug 14, 2023

Same thing happening in VS Code with C# dev kit (not omnisharp), using Riok.Mapperly (which also uses source generators)

image

@sharwell
Copy link
Member

@onionhammer This issue is also specific to Visual Studio (not VS Code). Can you file a new issue for the behavior you observed?

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

No branches or pull requests

7 participants