{"record":{"id":"095993ebdc39dc54","repo":"unoplatform/uno","slug":"instance-095993","errorCode":null,"errorMessage":"instance","messagePattern":"instance","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlObjectEventArgs.cs","lineNumber":36,"sourceCode":"// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing System.Windows.Markup;\n\nnamespace Uno.Xaml\n{\n\tpublic class XamlObjectEventArgs : EventArgs\n\t{\n\t\tpublic XamlObjectEventArgs (object instance)\n\t\t{\n\t\t\tif (instance == null)\n\t\t\t\tthrow new ArgumentNullException (\"instance\");\n\t\t\tInstance = instance;\n\t\t}\n\n\t\tpublic object Instance { get; private set; }\n\t}\n}\n","sourceCodeStart":18,"sourceCodeEnd":43,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlObjectEventArgs.cs#L18-L43","documentation":"Thrown by the XamlObjectEventArgs constructor when the instance argument is null. XamlObjectEventArgs carries a reference to an object being processed during XAML object reading/writing; a null instance has no type identity to report, so the constructor rejects it.","triggerScenarios":"Constructing new XamlObjectEventArgs(null). This fires from event-handler invocation code or custom XAML object reader hooks that pass a potentially-null object.","commonSituations":"Subscribing to XamlObjectReader or XamlXmlReader events (e.g. value-set callbacks) and constructing XamlObjectEventArgs from data that may be null. Custom XAML reader implementations that fire object events with unguarded null values.","solutions":["Guard for null before constructing XamlObjectEventArgs: if (instance != null) args = new XamlObjectEventArgs(instance);","Fix upstream code so the object passed to the event is never null (ensure object construction succeeded).","Skip the event raise entirely when the instance is null."],"exampleFix":"// before\nvar args = new XamlObjectEventArgs(currentObject);\n// currentObject is null → throws\n\n// after\nif (currentObject != null)\n{\n    var args = new XamlObjectEventArgs(currentObject);\n    handler?.Invoke(this, args);\n}","handlingStrategy":"validation","validationCode":"if (instance == null) return;\nvar args = new XamlObjectEventArgs(instance);","typeGuard":null,"tryCatchPattern":"try { var args = new XamlObjectEventArgs(instance); handler?.Invoke(this, args); }\ncatch (ArgumentNullException) { /* skip event for null instance */ }","preventionTips":["Guard for null before constructing XamlObjectEventArgs.","Ensure object references passed to XAML events are never null."],"tags":["xaml","argument-null","event-args","uno-xaml"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}