0

I'm trying to build an incremental source generator that will output nested classes with strings for each content file in my project containing its file path like so:

public static class Content
{
    public static class SomeDirectory
    {
        public static readonly string MyFile = "Content/SomeDirectory/MyFile.png";
    }
}

A "content" file is a file marked via the Content build action: <Content Include="Content\foobar.png" />.

In my other source generators I have marked any files I needed with the AdditionalFiles build action and then accessed them through the AdditionalTextsProvider property on the source generator context. However for these files they need to be marked as Content and as such do not appear in the AdditionalTextsProvider list of files.

Is it possible to access the content files similarly to AdditionalFiles-files or will I need to resort to manual I/O operations (which I really want to avoid inside a source generator)?

2
  • Please edit your question to include your source code as a working minimal reproducible example, which can be compiled and tested by others to provide an answer faster. It is unclear what you are asking or what the problem is. Please edit your question to include a more detailed description of the problem you have. Commented Dec 22, 2024 at 10:41
  • @Progman Did you even read the question? This is not a "code snippet does not work" question, I'm asking if it is at all possible to access Content files through source generators... Commented Dec 22, 2024 at 10:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.