Skip to content

Disallow asigning to init-only properties in bindings#1909

Merged
tomasherceg merged 2 commits intomainfrom
not-assign-init-only
Mar 16, 2025
Merged

Disallow asigning to init-only properties in bindings#1909
tomasherceg merged 2 commits intomainfrom
not-assign-init-only

Conversation

@exyi
Copy link
Copy Markdown
Member

@exyi exyi commented Feb 16, 2025

See https://forum.dotvvm.com/t/intended-behaviour-coherence-of-init-only-properties-between-c-code-and-dotvvm-front-end/295 for some context. In short, it is OK to allow this in JS code (IMHO we want to simplify staticCommands with records, given that we don't support with / new yet it's necessary).

However, it can be quite dangerous on server, where this might allow you to accidentally mutate a shared singleton object (imagine defining public static readonly MyRecord Default = new() { ... } and then using it to initialize a view model property)

@exyi exyi added this to the Version 5.0 milestone Feb 16, 2025
@exyi exyi force-pushed the not-assign-init-only branch from f306223 to d9387b2 Compare March 16, 2025 11:14
@tomasherceg tomasherceg merged commit 0e0c11a into main Mar 16, 2025
14 of 17 checks passed
@tomasherceg tomasherceg deleted the not-assign-init-only branch March 16, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants