{"record":{"id":"2c50eb6c856c5c4c","repo":"dotnet/machinelearning","slug":"nameof-tkey","errorCode":null,"errorMessage":"nameof(TKey)","messagePattern":"nameof\\(TKey\\)","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs","lineNumber":438,"sourceCode":"                        if (containsKey)\n                        {\n                            values.Add(i);\n                        }\n                        else\n                        {\n                            multimap.Add(str, new List<long>() { i });\n                        }\n                    }\n                    else\n                    {\n                        nullIndices.Add(i);\n                    }\n                }\n                return multimap as Dictionary<TKey, ICollection<long>>;\n            }\n            else\n            {\n                throw new NotImplementedException(nameof(TKey));\n            }\n        }\n\n        /// <summary>\n        /// Returns a new column with <see langword=\"null\" /> elements replaced by <paramref name=\"value\"/>.\n        /// </summary>\n        /// <remarks>Tries to convert value to the column's DataType</remarks>\n        /// <param name=\"value\"></param>\n        /// <param name=\"inPlace\">Indicates if the operation should be performed in place</param>\n        public StringDataFrameColumn FillNulls(string value, bool inPlace = false)\n        {\n            if (value == null)\n                throw new ArgumentNullException(nameof(value));\n            StringDataFrameColumn column = inPlace ? this : Clone();\n\n            for (long i = 0; i < column.Length; i++)\n            {\n                if (column[i] == null)","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs#L420-L456","documentation":"Marks the not-implemented branch in StringDataFrameColumn's grouped-indices method (the typed GetGroupedIndices<TKey> path). Grouping is only implemented for TKey = string, because values are bucketed via a string multimap; any other key type falls into the NotImplementedException that names nameof(TKey) as the offending parameter.","triggerScenarios":"Calling GetGroupedIndices<TKey> (or similar grouping API) with an unsupported key type such as a custom class, Guid, or short.","commonSituations":"Grouping by an unexpected key type inferred from generics; migrating code that assumed arbitrary key types are supported.","solutions":["Use one of the supported TKey types (e.g. long, int, string, bool, DateTime per the API docs)","Pre-convert the key column to a supported primitive type before grouping","Implement custom grouping with LINQ GroupBy if the key type is unsupported","Check the source for the supported TKey set and match it"],"exampleFix":"// before\nvar grouped = column.GetGroupedIndices<MyKey>(...);\n// after\nvar grouped = column.GetGroupedIndices<long>(key => key.GetHashCode());","handlingStrategy":"validation","validationCode":"if (!(typeof(TKey) == typeof(long) || typeof(TKey) == typeof(int) || typeof(TKey) == typeof(string) || typeof(TKey) == typeof(bool)))\n    throw new NotSupportedException($\"TKey {typeof(TKey)} not supported for grouping\");","typeGuard":"bool IsSupportedKeyType<TKey>() => typeof(TKey) == typeof(long) || typeof(TKey) == typeof(int) || typeof(TKey) == typeof(bool);","tryCatchPattern":"try { column.GetGroupedIndices<TKey>(...); } catch (NotImplementedException) { /* fall back to LINQ GroupBy */ }","preventionTips":["Stick to primitive TKey types documented for grouping APIs","Check the library source/docs for the supported key set","Use LINQ GroupBy for custom key types"],"tags":["notimplemented","generic-type","grouping"],"backgroundTag":"method-not-implemented","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}