{"record":{"id":"648747e6a5b38dea","repo":"elsa-workflows/elsa-core","slug":"value-cannot-be-null-parameter-type","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'type')","messagePattern":"Value cannot be null\\. \\(Parameter 'type'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/clients/Elsa.Api.Client/Extensions/TypeExtensions.cs","lineNumber":18,"sourceCode":"using System.Collections.Concurrent;\n\nnamespace Elsa.Api.Client.Extensions;\n\n/// <summary>\n/// Adds extension methods to <see cref=\"Type\"/>.\n/// </summary>\npublic static class TypeExtensions\n{\n    private static readonly ConcurrentDictionary<Type, string> SimpleAssemblyQualifiedTypeNameCache = new();\n\n    /// <summary>\n    /// Gets the assembly-qualified name of the type, without any version info etc.\n    /// E.g. \"System.String, System.Private.CoreLib\"\n    /// </summary>\n    public static string GetSimpleAssemblyQualifiedName(this Type type)\n    {\n        if (type is null) throw new ArgumentNullException(nameof(type));\n        return SimpleAssemblyQualifiedTypeNameCache.GetOrAdd(type, BuildSimplifiedName);\n    }\n\n    /// <summary>\n    /// Returns the default value for the specified type.\n    /// </summary>\n    public static object? GetDefaultValue(this Type type) => type.IsClass ? null : Activator.CreateInstance(type);\n    \n    /// <summary>\n    /// Returns the element type of the specified type representing an array or generic enumerable.\n    /// </summary>\n    public static Type GetEnumerableElementType(this Type type)\n    {\n        if (type.IsArray)\n            return type.GetElementType()!;\n\n        var elementType = FindIEnumerable(type);\n        return elementType == null ? type : elementType.GetGenericArguments()[0];","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/clients/Elsa.Api.Client/Extensions/TypeExtensions.cs#L1-L36","documentation":"TypeExtensions.GetSimpleAssemblyQualifiedName is a null-forgiving extension that explicitly guards with ArgumentNullException. It computes a simplified assembly-qualified type name (no version info) and caches it; a null Type is never valid.","triggerScenarios":"Passing a null Type reference to the extension, typically from reflection code that looked up a type by name and got null.","commonSituations":"Type.GetType returning null for misspelled or unloaded type names, then flowing into GetSimpleAssemblyQualifiedName.","solutions":["Ensure the Type is non-null before calling (check the result of Type.GetType)","Throw or log early in the reflection helper that resolved the type","Coalesce to a fallback type if the lookup can legitimately fail"],"exampleFix":"// before\nvar name = type.GetSimpleAssemblyQualifiedName();\n// after\nvar name = type is null ? throw new InvalidOperationException(\"Type not resolved\") : type.GetSimpleAssemblyQualifiedName();","handlingStrategy":"type-guard","validationCode":"if (type is null) throw new InvalidOperationException(\"Type lookup failed before building AQN\");","typeGuard":"static bool HasType(Type? t) => t is not null;","tryCatchPattern":"try { name = type.GetSimpleAssemblyQualifiedName(); } catch (ArgumentNullException) { name = null; }","preventionTips":["Never pass results of Type.GetType directly without null check","Log failed type lookups with the original name","Use typeof(...) constants where the type is known at compile time"],"tags":["dotnet","null","reflection"],"backgroundTag":"null-argument","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}