{"record":{"id":"6088482a5f2e2b27","repo":"AvaloniaUI/Avalonia","slug":"cannot-get-system-name-for-kind-format-identifi","errorCode":null,"errorMessage":"Cannot get system name for {Kind} format {Identifier}","messagePattern":"Cannot get system name for (.+?) format (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Input/DataFormat.cs","lineNumber":65,"sourceCode":"\n    /// <summary>\n    /// Creates a name for this format, usable by the underlying platform.\n    /// </summary>\n    /// <param name=\"applicationPrefix\">The system prefix used to recognize the name as an application format.</param>\n    /// <returns>A system name for the format.</returns>\n    /// <remarks>\n    /// This method can only be called if <see cref=\"Kind\"/> is\n    /// <see cref=\"DataFormatKind.Application\"/> or <see cref=\"DataFormatKind.Platform\"/>.\n    /// </remarks>\n    public string ToSystemName(string applicationPrefix)\n    {\n        ThrowHelper.ThrowIfNull(applicationPrefix);\n\n        return Kind switch\n        {\n            DataFormatKind.Application => applicationPrefix + Identifier,\n            DataFormatKind.Platform => Identifier,\n            _ => throw new InvalidOperationException($\"Cannot get system name for {Kind} format {Identifier}\")\n        };\n    }\n\n    /// <inheritdoc />\n    public bool Equals(DataFormat? other)\n    {\n        if (other is null)\n            return false;\n        if (ReferenceEquals(this, other))\n            return true;\n        return Kind == other.Kind && Identifier == other.Identifier;\n    }\n\n    /// <inheritdoc />\n    public override bool Equals(object? obj)\n        => Equals(obj as DataFormat);\n\n    /// <inheritdoc />","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Input/DataFormat.cs#L47-L83","documentation":"ToSystemName produces the platform-facing string for a DataFormat. Only Application (prefix + identifier) and Platform (raw identifier) kinds have a meaningful system name; Universal and InProcess formats do not map to a platform string, so the method throws InvalidOperationException for them.","triggerScenarios":"Calling `format.ToSystemName(prefix)` on a DataFormat whose Kind is Universal (e.g. DataFormat.Text/Bitmap/File) or InProcess (created via CreateInProcessFormat<T>).","commonSituations":"Passing the built-in DataFormat.Text/DataFormat.File to a clipboard/drag-drop routine that calls ToSystemName. Trying to get a system name for an in-process-only format.","solutions":["Only call ToSystemName on Application or Platform formats.","For Universal formats, use the platform's built-in text/file/bitmap handling rather than a custom system name.","Guard on Kind before calling: `if (format.Kind is Application or Platform) ...`."],"exampleFix":"// before:\nvar name = DataFormat.Text.ToSystemName(\"myapp:\"); // Universal -> throws\n\n// after:\nstring name = format.Kind switch\n{\n    DataFormatKind.Application => format.ToSystemName(\"myapp:\"),\n    DataFormatKind.Platform   => format.ToSystemName(\"myapp:\"),\n    _ => throw new InvalidOperationException($\"No system name for {format.Kind}\")\n};","handlingStrategy":"validation","validationCode":"if (format.Kind is not (DataFormatKind.Application or DataFormatKind.Platform))\n    throw new InvalidOperationException($\"No system name for {format.Kind}.\");\nvar name = format.ToSystemName(prefix);","typeGuard":"static bool HasSystemName(DataFormat f) => f.Kind is DataFormatKind.Application or DataFormatKind.Platform;","tryCatchPattern":null,"preventionTips":["Only call ToSystemName on Application/Platform formats.","Handle Universal formats (Text/Bitmap/File) via platform built-ins.","Branch on Kind before producing system names."],"tags":["dataformat","clipboard","drag-drop","invalidoperation"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}