Code Generation Question - Generated Variable Names Changing #2500
-
We occasionally see new code get generated for existing projections and document types without any apparent reason - there are no changes being made to the related code. The generated type name is the same, but the variable names change like so: switch (@event)
{
case Marten.Events.IEvent<Foo.Bar> event_Bar63:
return _someProjection.Create(event_Bar63);
} Becomes: switch (@event)
{
case Marten.Events.IEvent<Foo.Bar> event_Bar64:
return _someProjection.Create(event_Bar64);
break;
} Can this be controlled in any way, or is this pointing to something we're doing incorrectly? If not, should these updates be ignored? We have code generation turned off in production, so presumably if the code was already generated and we ignored one of these updates it would be fine but just wanted to make sure we wouldn't have a ticking time bomb on our hands if that happened. Version: 5.11.0 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@mattburton It's not a ticking time bomb, and you're good if you've pre-generated the code and nothing has changed about that document type / projection / whatnot. What you're seeing is a global variable counter across the existing app. If you changed something else, or the code generation that still happens at runtime sometimes without actual compilation happens in a different order, you could get different variable suffixes. I'd be lying if I told you why I made that global, but there's no harm here even if it seems weird. I'm converting this to a discussion. |
Beta Was this translation helpful? Give feedback.
@mattburton It's not a ticking time bomb, and you're good if you've pre-generated the code and nothing has changed about that document type / projection / whatnot. What you're seeing is a global variable counter across the existing app. If you changed something else, or the code generation that still happens at runtime sometimes without actual compilation happens in a different order, you could get different variable suffixes.
I'd be lying if I told you why I made that global, but there's no harm here even if it seems weird.
I'm converting this to a discussion.