{"record":{"id":"6734f37b7fa06a7d","repo":"stride3d/stride","slug":"this-method-must-be-invoked-with-at-least-one-property-name-6734f3","errorCode":null,"errorMessage":"This method must be invoked with at least one property name.","messagePattern":"This method must be invoked with at least one property name\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation/ViewModels/ViewModelBase.cs","lineNumber":124,"sourceCode":"    {\n        return SetValue(ref field, value, updateAction, [propertyName]);\n    }\n\n    /// <summary>\n    /// Sets the value of a field to the given value. Both values are compared with the default <see cref=\"EqualityComparer{T}\"/>, and if they are equals,\n    /// this method does nothing. If they are different, the <see cref=\"PropertyChanging\"/> event will be raised first, then the field value will be modified.\n    /// The given update action will be executed and finally the <see cref=\"PropertyChanged\"/> event will be raised.\n    /// </summary>\n    /// <typeparam name=\"T\">The type of the field.</typeparam>\n    /// <param name=\"field\">A reference to the field to set.</param>\n    /// <param name=\"value\">The new value to set.</param>\n    /// <param name=\"updateAction\">The update action to execute after setting the value. Can be <c>null</c>.</param>\n    /// <param name=\"propertyNames\">The names of the properties that must be notified as changing/changed. At least one property name must be provided.</param>\n    /// <returns><c>True</c> if the field was modified and events were raised, <c>False</c> if the new value was equal to the old one and nothing was done.</returns>\n    protected virtual bool SetValue<T>([NotNullIfNotNull(nameof(value))] ref T field, T value, Action? updateAction, params string[] propertyNames)\n    {\n        if (propertyNames.Length == 0)\n            throw new ArgumentOutOfRangeException(nameof(propertyNames), \"This method must be invoked with at least one property name.\");\n\n        if (!EqualityComparer<T>.Default.Equals(field, value))\n        {\n            OnPropertyChanging(propertyNames);\n            field = value;\n            updateAction?.Invoke();\n            OnPropertyChanged(propertyNames);\n            return true;\n        }\n\n        return false;\n    }\n\n    /// <summary>\n    /// Manages a property modification and its notifications. This method will invoke the provided update action. The <see cref=\"PropertyChanging\"/>\n    /// event will be raised prior to the update action, and the <see cref=\"PropertyChanged\"/> event will be raised after.\n    /// </summary>\n    /// <param name=\"updateAction\">The update action that will actually manage the update of the property.</param>","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation/ViewModels/ViewModelBase.cs#L106-L142","documentation":"The protected SetValue<T>(ref T, T, Action, params string[]) overload notifies change events for the given property names; calling it with zero names leaves nothing to notify, so it throws ArgumentOutOfRangeException.","triggerScenarios":"Calling SetValue(ref field, value, updateAction) with an empty params string[] propertyNames — e.g. forwarding an empty property-name array or forgetting the name entirely.","commonSituations":"Refactoring a property setter and dropping the nameof(Property) argument; dynamically built property-name arrays that end up empty.","solutions":["Pass at least one property name, typically nameof(YourProperty)","Validate dynamically built name arrays are non-empty before calling","Split empty-array handling into a separate no-notify update path if no notification is desired"],"exampleFix":"// before\nSetValue(ref _name, value);\n// after\nSetValue(ref _name, value, nameof(Name));","handlingStrategy":"validation","validationCode":"if (propertyNames == null || propertyNames.Length == 0)\n    throw new ArgumentException(\"At least one property name is required\", nameof(propertyNames));\nSetValue(ref _field, value, propertyNames);","typeGuard":null,"tryCatchPattern":"try { SetValue(ref _field, value, names); }\ncatch (ArgumentOutOfRangeException ex) { log.Error(ex, \"SetValue called without property names\"); }","preventionTips":["Always use nameof(...) for property-name arguments","Wrap SetValue in a helper that enforces non-empty names at compile/debug time","Never forward params string[] blindly — validate count first"],"tags":["dotnet","mvvm","arguments","viewmodel"],"backgroundTag":"argument-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}