icsharpcode/ILSpy · error · ReflectionNameParseException
Could not find '.' separating type name from member name
Error message
Could not find '.' separating type name from member name
What it means
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.
Source
Thrown at ICSharpCode.Decompiler/Documentation/IdStringProvider.cs:744
/// <param name="idString">ID string of the entity.</param>
/// <param name="context">Type resolve context</param>
/// <returns>Returns the entity, or null if it is not found.</returns>
/// <exception cref="ReflectionNameParseException">The syntax of the ID string is invalid</exception>
public static IEntity FindEntity(string idString, ITypeResolveContext context)
{
if (idString == null)
throw new ArgumentNullException(nameof(idString));
if (context == null)
throw new ArgumentNullException(nameof(context));
if (idString.Length < 2 || idString[1] != ':')
throw new ReflectionNameParseException(0, "Missing type tag");
if (idString[0] == 'T')
return FindTypeDefinition(idString.Substring(2), context);
int dotPos = FindMemberNameDot(idString);
if (dotPos <= 2)
throw new ReflectionNameParseException(0, "Could not find '.' separating type name from member name");
var declaringType = FindTypeDefinition(idString.Substring(2, dotPos - 2), context);
if (declaringType?.ParentModule is not MetadataModule metadataModule)
return null;
var typeDef = metadataModule.MetadataFile.Metadata.GetTypeDefinition(
(TypeDefinitionHandle)declaringType.MetadataToken);
var handle = FindMemberInType(metadataModule.MetadataFile, typeDef, idString[0], idString);
return handle.IsNil ? null : metadataModule.ResolveEntity(handle);
}
/// <summary>
/// Resolves a type name from an ID string (without the "T:" prefix) in the given
/// type resolve context, trying all namespace/type-name boundary splits.
/// </summary>
static ITypeDefinition FindTypeDefinition(string typeName, ITypeResolveContext context)
{
var parts = ParseTypeNameParts(typeName);
string[] dotParts = parts[0].Name.Split('.');
View on GitHub (pinned to 60c08fcb74)
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.
Example fix
// before
var e = IdStringProvider.FindEntity("M:System.Console", context);
// after
var e = IdStringProvider.FindEntity("M:System.Console.WriteLine", context); Defensive patterns
Strategy: validation
Validate before calling
if (idString[0] == 'T') return IdStringProvider.FindEntity(idString, context);
int dot = idString.LastIndexOf('.', Math.Max(0, (idString.IndexOf('(') is int p && p >= 0 ? p : idString.Length) - 1));
if (dot <= 2) return null; // no member name
return IdStringProvider.FindEntity(idString, context); Type guard
static bool IsMemberIdString(string s) => s != null && s.Length >= 2 && s[1] == ':' && "MFPE".IndexOf(s[0]) >= 0 && s.LastIndexOf('.') > 2; Try / catch
try { return IdStringProvider.FindEntity(idString, context); }
catch (ReflectionNameParseException ex) { logger.Warn($"Bad member ID string at {ex.Position}: {ex.Message}"); return null; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Truncating an ID string after the type name; passing a type ID into a member lookup; hand-built crefs that omit the member.
Related errors
- Missing type tag
- Expected type name
- Expected '}'
- The handle must not be nil.
- Unsupported handle kind: {handle.Kind}
AI-assisted analysis of icsharpcode/ILSpy@60c08fcb74 (2026-08-13).
Data as JSON: /api/errors/7c8cc17a4901d0d6.
Report an issue: GitHub.