{"record":{"id":"7c13ef5fab2cab49","repo":"stride3d/stride","slug":"unexpected-arguments-0","errorCode":null,"errorMessage":"Unexpected arguments [{0}]","messagePattern":"Unexpected arguments \\[(.+?)\\]","errorType":"validation","errorClass":"OptionException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.AssetCompiler/PackageBuilderApp.cs","lineNumber":405,"sourceCode":"                    if (sessionResult.Session == null)\n                        return (int)BuildResultCode.BuildError;\n\n                    // Be lenient like Game Studio: load errors (e.g. a project that won't build against the new\n                    // version, so its script-referencing assets load as IUnloadable) don't abort the upgrade.\n                    // Reconcile and save whatever loaded — IUnloadable round-trips its original YAML, so nothing\n                    // is lost — and let the exit code below still report the errors.\n                    if (sessionResult.HasErrors)\n                        options.Logger.Warning(\"The session loaded with errors; upgrading and saving the assets that loaded. Fix the errors and re-run for a complete upgrade.\");\n\n                    ReconcileBases(sessionResult.Session, options.Logger);\n\n                    sessionResult.Session.Save(options.Logger);\n                    return (int)(options.Logger.HasErrors ? BuildResultCode.BuildError : BuildResultCode.Successful);\n                }\n\n                if (unexpectedArgs.Any())\n                {\n                    throw new OptionException(\"Unexpected arguments [{0}]\".ToFormat(string.Join(\", \", unexpectedArgs)), \"args\");\n                }\n                try\n                {\n                    options.ValidateOptions();\n                }\n                catch (ArgumentException ex)\n                {\n                    throw new OptionException(ex.Message, ex.ParamName);\n                }\n\n                if (mode == BuilderMode.Pack)\n                {\n                    PackageSessionPublicHelper.FindAndSetMSBuildVersion();\n\n                    var csprojFile = options.PackageFile;\n                    var intermediatePackagePath = options.BuildDirectory;\n                    var generatedItems = new List<(string SourcePath, string PackagePath)>();\n                    var logger = new LoggerResult();","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.AssetCompiler/PackageBuilderApp.cs#L387-L423","documentation":"The ObjectReference constructor validates that objectValue is an instance of objectType; passing a non-null value whose runtime type does not match (or derive from) the declared type throws ArgumentException for objectValue. This keeps every reference's stored object consistent with its declared Type.","triggerScenarios":"Constructing ObjectReference (internal, via reference-building code) with a value whose runtime type differs from objectType, e.g. passing a DerivedModel while declaring typeof(OtherModel), or a stale object after a type refactor.","commonSituations":"Serialization/deserialization mismatches where a node's content type changed but cached type metadata did not; refactors renaming/moving model classes leaving old values in place; generic helper code passing object-typed values with an unrelated declared type.","solutions":["Ensure objectType matches the runtime type of objectValue (or a base type/interface of it).","Refresh type metadata after model refactors so declared types track actual object types.","Guard creation with objectType.IsInstanceOfType(objectValue) before constructing the reference."],"exampleFix":"// before\nnew ObjectReference(value, typeof(OldModel), index); // value is NewModel\n// after\nnew ObjectReference(value, value.GetType(), index);","handlingStrategy":"type-guard","validationCode":"if (objectValue != null && !objectType.IsInstanceOfType(objectValue))\n    throw new ArgumentException($\"{objectValue.GetType()} is not {objectType}\", nameof(objectValue));","typeGuard":"bool MatchesDeclaredType(object? value, Type declared) => value == null || declared.IsInstanceOfType(value);","tryCatchPattern":"try { var rf = CreateReference(value, declaredType, index); }\ncatch (ArgumentException ex) when (ex.ParamName == \"objectValue\") { /* recreate with value.GetType() or refresh type metadata */ }","preventionTips":["Derive objectType from value.GetType() when the value exists","Refresh cached type metadata after model refactors","Unit-test reference creation across serialized model types"],"tags":["type-mismatch","object-reference","argument"],"backgroundTag":"type-mismatch","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"}