Use file from MAUI project to create a source file compile time in referenced project/package c# #15251
Unanswered
prabhav-mehra
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am stuck at this issue for sometime and looking for implementation ideas and/or code snippets.
So I have 2 projects:
A dotnet maui project which has a xml file.
A class library which does something.
Now The MAUI app references the class library through a package or a project reference.
I want to create a c# class in the Class library with property names in sync with key value pairs from the xml file present in the MAUI app, at compile time.
So if the xml file has tags with key “key1” of type string. Then it will create a get set property with key1 as Property Name.
I tried different approaches but didn’t seem to work.
SourceGenerators was one. But if you reference a source generator to the MAUI app to create a c# class, it will create it in the MAUI app and not the class library.
I have the code to create the c# class from the xml file but the approaches i had were incorrect. Either I had to put a .xml in the class library to create a c# class using a source generator, or some other things which weren’t desired.
Does anyone have any idea how to go about this?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions