How to structure your .net files? What is the best...
# dotnet
b
How to structure your .net files? What is the best practice for structuring the .cs files in a large stack within a project. In Terraform, you would typically group all of the resource related to the same "thing" into a .tf file For example for an Azure Function, the app service plan, storage and app service itself might all go into one .tf file. What is the equivalent for Pulumi to avoid having one giant .cs file for the stack (or is the answer that I should have a stack for each "thing" in my system and use Stack References to create inter-stack dependencies?). I have thought about using
partial class
but wanted to reach out to see if there are any conventions?
b
I encapsulate related resources into component resources and separate them into separate files that way. My stack class then declares large numbers of resources with only a few high-level abstract component resource declarations.
👍 1
For example a simple application's stack class might end up just declaring: • cluster resources / anything shared • backend component resource • frontend component resource • dns
Of course if you don't want to do the component resource route, you could just as easily place static classes in separate files with a static entrypoint function in each to organize your code. Then your stack constructor could just call those static functions.
b
Thanks @bored-oyster-3147 I'll take a look at that approach Do you know of a sample anywhere I could look at?
b