maxweisel
maxweisel14mo ago

we use roslyn source generators to

we use roslyn source generators to generate the model code at compile* time
5 Replies
René
René14mo ago
Does this take access modifiers on the model class into account? One small problem we're having with the current code generator is that it ignores whether the model is public or not. We just fix that by hand after regenerating. Would be awesome if that is taken care of automatically.
maxweisel
maxweisel14mo ago
the model shouldn’t ever be public fwiw. you should have accessors so if / when the model instance is swapped out, an external class isn’t holding a reference to the old one
René
René14mo ago
What I mean is the current code generator will ALWAYS emit a public class and thus make the model class public. Even if you declare the model class internal, the code generator ignores that. Thus the hand editing.
maxweisel
maxweisel14mo ago
are you putting the class in it’s own asmdef? it seems odd to me that you’d want (or even be able to) mark it as internal I guess your RealtimeComponent can be public and be the bridge for it but unless you’re using an asmdef, internal doesn’t give you less visibility than public anyway right?
René
René14mo ago
Yup, in its own .asmdef. And we have a CI check that nothing that isn't part of the public interface of the module is publicly exposed. It's a minor thing, though. Updating the model is not a daily thing and hand editing the generated file is a trivial change.