Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
236 views

I'm currently using the following code to set up a System.Text.Json JsonSerializerOptions object that alphabetizes properties upon serialization: public static readonly JsonSerializerOptions ...
Chaosed0's user avatar
  • 981
1 vote
0 answers
83 views

I have a bunch of source generators and they are all doing stuff in the background but as the codebase they operate on grows I want to make sure that they are still scaling sensibly. According to this ...
user3797758's user avatar
  • 1,113
0 votes
0 answers
114 views

I'm writing a source generator which will generate factories to create instances of object(s). Since the source generator generates code that's related to tests, I'm going to install the source ...
Complexity's user avatar
  • 5,842
1 vote
0 answers
12 views

I'm having a problem with the comparer as it is generating a new object everytime I make a meaningless change (e.g. add a space) to the file that is being inspected. More specifically, it is ...
Webbert's user avatar
  • 83
0 votes
1 answer
275 views

I need to write a source generator that scans the project for one or another set of classes (marked with different attributes), then generates the same code from them (the second set of attributes is ...
MaxEd's user avatar
  • 372
0 votes
0 answers
158 views

I'm trying to learn and use source generator in C#, but I'm having few issues. I want to make use of some C# new features, like generic attribute, and use it to generate custom code. I have for ...
Adnan's user avatar
  • 1,044
1 vote
0 answers
125 views

I'm trying to get a source generator working, but for some reason its failing to include the namespace it needs. The generated code looks like this: using OwlTree; // namespace proxy factory is from ...
CaptainToTo's user avatar
1 vote
1 answer
73 views

I can get MemberDeclarationSyntax.Modifiers at syntaxic level, but once I'm at semantic level, dealing with ISymbol, I don't know how to get back the modifiers of such given ISymbol ? In my use case, ...
TRex's user avatar
  • 350
0 votes
0 answers
87 views

I'm building an ASP.NET Core Web API for AOT publishing and need to configure source-generated JSON serialization for it, as reflection-based serialization will not work for AOT. According to ...
Daniil Palii's user avatar
  • 1,295
0 votes
0 answers
233 views

Is there a way to make the process of registering types to serialise dynamic, i.e. not having to tediously write [JsonSerializable(typeof(<type goes here>))] for each type. So far, I've tried to ...
devcayed's user avatar
1 vote
0 answers
58 views

I am trying to take a class like below with an [AutoSave] attribute: [AutoSave] public partial class GeneratedConfig : NotifiyingJsonSettings, IVersionable { [EnforcedVersion("1.0.0.0")] ...
Alexa's user avatar
  • 11
1 vote
1 answer
505 views

I have three c# projects, designed to use a custom attribute to generate code referencing a common class using a custom IIncremental Generator. I used and extended this guide from dotnet https://www....
Lachlan's user avatar
  • 11
3 votes
2 answers
2k views

Beginner to Roslyn Source Generators here. I'm following the documentation on Source Generators by Microsoft. I have created a .NET Standard 2.0 Class Library, and set the following as the contents of ...
winscripter's user avatar
1 vote
1 answer
93 views

I am writing an application on Avalonia UI in Visual Studio Community 2022. However, as of recently I have encountered a problem. For example, I am writing code in a ViewModel file. [...
Ali-Muhammad Zakaryaev's user avatar
1 vote
1 answer
169 views

I am authoring an incremental source generator which uses a marker attribute to control the source generation, which is configured via an enum parameter passed to the attribute's constructor, such as: ...
monkey0506's user avatar
  • 2,627
2 votes
1 answer
513 views

I have created a source generator that works perfectly on my local machine; however, when it's being built by our CI-CD pipeline (Azure devops - DotNetCoreCLI@2), it does not seem to work. Here is the ...
Saf-G's user avatar
  • 135
1 vote
1 answer
119 views

I'm currently trying to learn about source generators, and have implemented a very simple one. [Generator] public class KeysSourceGenerator : ISourceGenerator { public void Execute(...
jessejbweld's user avatar
1 vote
0 answers
160 views

I referred to this official tutorial: https://learn.microsoft.com/zh-cn/dotnet/csharp/roslyn-sdk/source-generators-overview , but it didn't work as expected. The Source Generator project I created ...
Hacbit's user avatar
  • 11
0 votes
1 answer
145 views

I created a simple source generator that works fine using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; ...
Luiz Bicalho's user avatar
0 votes
2 answers
711 views

My source generator needs to find other classes that derive from the inspected class to know whether special code needs to be added. So far, I have only inspected the class to augment itself and ...
ygoe's user avatar
  • 20.7k
1 vote
1 answer
280 views

I'm writing a source generator that processes my model classes and adds some custom serialisation code for them. The model classes can have all sorts of property types. I'm currently interested in the ...
ygoe's user avatar
  • 20.7k
1 vote
1 answer
568 views

I'm getting build errors despite the SourceGenerator apparently working correctly. Example code: namespace VisGit.ViewModels { public partial class MainViewModel: ObservableObject { ...
stigzler's user avatar
  • 1,035
6 votes
1 answer
1k views

How can I tell Visual Studio to regenerate files that are generated using Roslyn's incremental generator? Context: I have a solution with a project containing custom generators and another project ...
TN.'s user avatar
  • 20.1k
0 votes
1 answer
425 views

I'm working on a large code base with multiple linked projects, so I've decided to write some source generators to auto-generate some boilerplate code. My project structure looks something like this: ...
mpagliaro98's user avatar
0 votes
0 answers
68 views

My generator needs to find all types in referenced projects which meet a specific criteria and generate a class for each of them using their method return types. Example input (in a referenced project,...
Vlad's user avatar
  • 3,201

1
2 3 4 5