NeVeSpl / NTypewriter

File/code generator using Scriban text templates populated with C# code metadata from Roslyn API.
https://nevespl.github.io/NTypewriter/
MIT License
126 stars 24 forks source link

Filter out types not used in properties #36

Closed SimmeNilsson closed 3 years ago

SimmeNilsson commented 3 years ago

Just found out about NTypewriter when looking for how to make Typewriter accept types from assemblies. Looks promising and fast! :) Looking into migrating a project now.

Question: What would the best way to filter out referenced types in a class so that only types that are used in the properties (and/or implements/extends) remain? (So I can skip importing a type only used in a function.)

NeVeSpl commented 3 years ago

I am not sure what are you asking about. Do you use Type.AllReferencedTypes? https://github.com/NeVeSpl/NTypewriter/blob/3a2ad42593efd36611ca835579693c3a7a642f14/NTypewriter.CodeModel.Functions/TypeFunctions.AllReferencedTypes.cs#L26 if that is the case, the last parameter allows specifying from which place referenced types will be returned ...

SimmeNilsson commented 3 years ago

Excellent, that was what I was looking for. Thank you!