public static IEnumerable <string> GetPossibleSourceNames([NotNull] IDeclaredElement element) { var name = element.ShortName; var names = new HashSet <string> { name, DecompileOpName.Invoke(name) }; if (element is IFSharpDeclaredElement fsDeclaredElement) { names.Add(fsDeclaredElement.SourceName); } if (element is IConstructor ctor && ctor.GetContainingType() is ITypeElement typeElement) { GetPossibleSourceNames(typeElement, names); } if (element is ITypeElement type) { GetPossibleSourceNames(type, names); } if (element is IAttributesOwner attrOwner) { if (GetAttributeValue(attrOwner, SourceNameAttributeClrTypeName) is string sourceName) { names.Add(sourceName); } } return(names.SelectMany(n => new[] { n, $"``{n}``" })); }
public static IEnumerable <string> GetPossibleSourceNames([NotNull] IDeclaredElement element) { var name = element.ShortName; var names = new HashSet <string> { name, DecompileOpName.Invoke(name) }; if (element is IFSharpDeclaredElement fsDeclaredElement) { names.Add(fsDeclaredElement.SourceName); } if (element is IConstructor ctor && ctor.GetContainingType() is ITypeElement typeElement) { GetPossibleSourceNames(typeElement, names); } if (element is ITypeElement type) { GetPossibleSourceNames(type, names); } if (element is IAttributesOwner attrOwner) { if (GetAttributeValue(attrOwner, SourceNameAttrTypeName) is string sourceName) { names.Add(sourceName); } if (GetAttributeValue(attrOwner, CompilationMappingAttrTypeName) is var flagValue && flagValue != null) { if ((SourceConstructFlags)flagValue == SourceConstructFlags.UnionCase && element is IMethod && name.StartsWith("New", StringComparison.Ordinal)) { names.Add(name.Substring(3)); } } } return(names.SelectMany(n => new[] { n, $"``{n}``" })); }