{"record":{"id":"7c8cc17a4901d0d6","repo":"icsharpcode/ILSpy","slug":"could-not-find-separating-type-name-from-membe","errorCode":null,"errorMessage":"Could not find '.' separating type name from member name","messagePattern":"Could not find '\\.' separating type name from member name","errorType":"exception","errorClass":"ReflectionNameParseException","httpStatus":null,"severity":"error","filePath":"ICSharpCode.Decompiler/Documentation/IdStringProvider.cs","lineNumber":744,"sourceCode":"\t\t/// <param name=\"idString\">ID string of the entity.</param>\r\n\t\t/// <param name=\"context\">Type resolve context</param>\r\n\t\t/// <returns>Returns the entity, or null if it is not found.</returns>\r\n\t\t/// <exception cref=\"ReflectionNameParseException\">The syntax of the ID string is invalid</exception>\r\n\t\tpublic static IEntity FindEntity(string idString, ITypeResolveContext context)\r\n\t\t{\r\n\t\t\tif (idString == null)\r\n\t\t\t\tthrow new ArgumentNullException(nameof(idString));\r\n\t\t\tif (context == null)\r\n\t\t\t\tthrow new ArgumentNullException(nameof(context));\r\n\t\t\tif (idString.Length < 2 || idString[1] != ':')\r\n\t\t\t\tthrow new ReflectionNameParseException(0, \"Missing type tag\");\r\n\r\n\t\t\tif (idString[0] == 'T')\r\n\t\t\t\treturn FindTypeDefinition(idString.Substring(2), context);\r\n\r\n\t\t\tint dotPos = FindMemberNameDot(idString);\r\n\t\t\tif (dotPos <= 2)\r\n\t\t\t\tthrow new ReflectionNameParseException(0, \"Could not find '.' separating type name from member name\");\r\n\t\t\tvar declaringType = FindTypeDefinition(idString.Substring(2, dotPos - 2), context);\r\n\t\t\tif (declaringType?.ParentModule is not MetadataModule metadataModule)\r\n\t\t\t\treturn null;\r\n\t\t\tvar typeDef = metadataModule.MetadataFile.Metadata.GetTypeDefinition(\r\n\t\t\t\t(TypeDefinitionHandle)declaringType.MetadataToken);\r\n\t\t\tvar handle = FindMemberInType(metadataModule.MetadataFile, typeDef, idString[0], idString);\r\n\t\t\treturn handle.IsNil ? null : metadataModule.ResolveEntity(handle);\r\n\t\t}\r\n\r\n\t\t/// <summary>\r\n\t\t/// Resolves a type name from an ID string (without the \"T:\" prefix) in the given\r\n\t\t/// type resolve context, trying all namespace/type-name boundary splits.\r\n\t\t/// </summary>\r\n\t\tstatic ITypeDefinition FindTypeDefinition(string typeName, ITypeResolveContext context)\r\n\t\t{\r\n\t\t\tvar parts = ParseTypeNameParts(typeName);\r\n\t\t\tstring[] dotParts = parts[0].Name.Split('.');\r\n\r","sourceCodeStart":726,"sourceCodeEnd":762,"githubUrl":"https://github.com/icsharpcode/ILSpy/blob/60c08fcb74fcc183130f73c861ed35cf944d0bf1/ICSharpCode.Decompiler/Documentation/IdStringProvider.cs#L726-L762","documentation":"ReflectionNameParseException at position 0 thrown by FindEntity(string, ITypeResolveContext) on the member path when FindMemberNameDot returns a value <= 2. A member ID string must contain a '.' that separates the declaring type name from the member name (e.g. 'M:System.Console.WriteLine'); with no dot after the 'X:' prefix there is no member name to resolve.","triggerScenarios":"Calling FindEntity with a member-tagged string that has no member name, e.g. \"M:Console\", \"F:System.Console\", or any 'M:'/'F:'/'P:'/'E:' string whose only dot (if any) sits at index <= 2.","commonSituations":"Truncating an ID string after the type name; passing a type ID into a member lookup; hand-built crefs that omit the member.","solutions":["Provide the full member ID including the declaring type and member name separated by '.', e.g. \"M:System.Console.WriteLine\".","For type lookups use the 'T:' tag so the member path is not taken.","Validate that the substring after 'X:' contains a '.' before calling."],"exampleFix":"// before\nvar e = IdStringProvider.FindEntity(\"M:System.Console\", context);\n\n// after\nvar e = IdStringProvider.FindEntity(\"M:System.Console.WriteLine\", context);","handlingStrategy":"validation","validationCode":"if (idString[0] == 'T') return IdStringProvider.FindEntity(idString, context);\nint dot = idString.LastIndexOf('.', Math.Max(0, (idString.IndexOf('(') is int p && p >= 0 ? p : idString.Length) - 1));\nif (dot <= 2) return null; // no member name\nreturn IdStringProvider.FindEntity(idString, context);","typeGuard":"static bool IsMemberIdString(string s) => s != null && s.Length >= 2 && s[1] == ':' && \"MFPE\".IndexOf(s[0]) >= 0 && s.LastIndexOf('.') > 2;","tryCatchPattern":"try { return IdStringProvider.FindEntity(idString, context); }\ncatch (ReflectionNameParseException ex) { logger.Warn($\"Bad member ID string at {ex.Position}: {ex.Message}\"); return null; }","preventionTips":["For member lookups, ensure the declaring type and member are both present and dot-separated.","Use the 'T:' tag for type-only lookups to avoid the member path entirely.","Catch ReflectionNameParseException wherever untrusted ID strings are resolved."],"tags":["id-string","parse","reflection-name","find-entity"],"backgroundTag":null,"analyzedSha":"60c08fcb74fcc183130f73c861ed35cf944d0bf1","analyzedAt":"2026-08-13T11:34:51.223Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}