sourcegenerators Questions
5
Solved
I recently tested the WPF UI library (https://wpfui.lepo.co/). I created a sample project, and that project targeted .NET 6.0. The sample project contained some basic Models and ViewModels, and in ...
Matz asked 27/9, 2022 at 9:15
2
Solved
I am experimenting with C# source generators. I have spent about a day on it, and I find it a very frustrating and painful experience. IntelliSense is extremely unreliable. It occasionally works, b...
Havener asked 24/5, 2022 at 13:8
3
Solved
I writed a SourceGenerator, but how do I test it?
Main issue is how to imitate GeneratorExecutionContext (or just Compilation inside it) which generator gets into Execute method. I think there is a...
Consequence asked 12/4, 2021 at 6:56
4
Solved
I am working on source generator and I have problems with dependencies:
It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'FileNotFoundExcepti...
Kandace asked 13/4, 2021 at 8:33
3
Solved
I am trying to get some values from the appsettings.json. But whatever I try with the AdditionalTextsProvider doesn't work. Here is my code
IncrementalValuesProvider<AdditionalText> textFiles...
Sakmar asked 3/5, 2022 at 5:40
1
I'm creating a simple Roslyn Source Generator. The generator seems to work well in debug, correctly generating the desired class. However, when referencing it from another project in the solution, ...
Haver asked 16/1, 2023 at 11:18
1
I'm working on a project utilizing C# 9's Source Generator, but when the code is generated, I'm wanting different files of generated code to be emitted to specific file paths/locations within the e...
Cabrilla asked 7/7, 2021 at 13:11
1
I've followed the documentation to create a basic incremental source generator that outputs a copy of classes marked with an attribute:
// Code found in my project
[Copy]
public class MyClass
{
...
Incoercible asked 26/12, 2021 at 0:10
1
Solved
I have 3 projects
Project A (Client)
Project B (Server)
Project C (Shared)
Within Project B I have the DB connection using the entity framework as well as all the entity classes, Project A (Client...
Estelaestele asked 17/10, 2022 at 7:59
1
I created a Source Generator to extend (partial) classes which fulfill certain criteria. To check and view the generated code I enabled the emission of these files by adding the following to my pro...
Hexose asked 15/9, 2021 at 13:28
1
Context
I was able to debug my source generator in VS 2019 by setting the project properties/debug Launch to Roslyn Component, then the target project combo to one of my consuming project:
Now th...
Gennygeno asked 19/1, 2022 at 16:23
0
Given a working source generator and a working test project for the generator.
Generator
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandar...
Pelagia asked 11/2, 2022 at 11:2
2
Edit3: At some point this just started working. No clue why. Maybe it was a VS bug that got fixed?
Edit2: Looking into the Analyzers node in solution explorer, I've discovered the source generator ...
Hernardo asked 29/10, 2021 at 5:49
1
Solved
How are custom JsonConverter<> classes used together with System.Text.Json source generator?
I would like to call JsonSerializer.Deserialize<MyType[]>() that doesn't fallback to a refle...
Hushaby asked 17/12, 2021 at 11:56
1
I am attempting to write a C# source generator that throws a warning/error under certain conditions using GeneratorExecutionContext.ReportDiagnostic. My source generator is able to run and output e...
Dearth asked 24/1, 2021 at 18:52
1
Solved
I have tried to implement Source Generation-based JSON serilization, based on MS Docs: How to use source generation in System.Text.Json. My code is as follows:
using System;
using System.Text.Json;...
Fifty asked 16/11, 2021 at 15:40
2
Solved
I am writing a source generator but am struggling to get the value of an argument passed to the constructor of my attribute.
I inject the following into the compilation:
namespace Richiban.Cmdr
{
...
Whitsunday asked 5/11, 2021 at 12:28
1
I have a library that relies on a source generator to work correctly. In the MyLibrary.csproj, I reference the generator like so.
<ItemGroup>
<ProjectReference
Include="..\MyLibrar...
Boondocks asked 23/2, 2021 at 7:17
1
I have a Class Library project First.csproj with one file ICar.cs:
namespace First
{
public interface ICar
{
string Name { get; set; }
}
}
I have an empty Class Library project Second.csproj a...
Stellular asked 10/8, 2021 at 18:40
1
Solved
I want to generate a static class that should have a method depending on other classes in specific reference assembly.
a simplified example:
// Generator.csproj
[Generator]
public class MyGenerato...
Judicature asked 20/6, 2021 at 11:9
1
Solved
I'm attempting to develop a source generator to auto-implement an interface on partial classes with that interface.
I believe this has to be a common use case for Microsoft's new Source Generators,...
Blanketing asked 17/6, 2021 at 13:6
0
I've created a C# source generator, and would like to publish it to Nuget.
But I run into warnings/errors such as:
Some target frameworks declared in the dependencies group of the nuspec and the l...
Molehill asked 20/3, 2021 at 23:49
0
I have a C# 9.0 source code generator that references a class library that contains an attribute that is used to identify the classes to process. I am now writing unit tests as described here:
Com...
Shower asked 7/3, 2021 at 15:51
1
Solved
Is there any way to disable a specific C# 9 source generator? Or alternatively disable them all?
the package in question is https://github.com/Husqvik/GraphQlClientGenerator#c-9-source-generator wh...
Acetaldehyde asked 10/2, 2021 at 2:51
1
© 2022 - 2024 — McMap. All rights reserved.