dotnet / dotnet/roslyn

Creating a Source Generator results in an empty RS1042

Open
#77,988 3 comments 9 reactions 1 assignee Claimed by @jasonmalinowski View on GitHub
Area-Analyzers
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Creating-a-Source-Generator-results-in-a/10881619)._

---
[severity:I'm unable to use this version] [regression] [worked-in:17.14.0 preview 2]
With a project file

```

netstandard2.0
preview
enable
enable
true


all
runtime; build; native; contentfiles; analyzers; buildtransitive


```

and content of

```
[Generator]
internal class SourceGenerator : ISourceGenerator
```

It results in an empty error message:

`C:\Dev\RPWSourceGenerator\SourceGenerator.cs(13,20,13,35): error RS1042:`

---
### Original Comments

#### Peter Smulovics on 29/3/2025, 09:51 PM:

Yes - I am aware what the error supposed to say; my report is that visual studio do not fill out the error, it actually says just:


C:\Dev\RPWSourceGenerator\SourceGenerator.cs(13,20,13,35): error RS1042:


Eg no actual error message.

#### Feedback Bot on 31/3/2025, 01:30 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

---
### Original Solutions

#### Patrick Lacasse solved on 29/3/2025, 06:53 PM, undefined votes:

Hi Peter,

RS1042 means ISourceGenerator is now obsolete.

There is this new feature instead https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.md

I’m now reading this article https://www.thinktecture.com/en/net-core/roslyn-source-generators-high-level-api-forattributewithmetadataname/

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.