Browse Source

Fix #1509: Show error message that unresolved entities cannot be analyzed.

pull/1515/head
Siegfried Pammer 7 years ago
parent
commit
3b93d095ec
  1. 4
      ILSpy/Analyzers/AnalyzerSearchTreeNode.cs
  2. 5
      ILSpy/Analyzers/AnalyzerTreeView.cs
  3. 13
      ILSpy/Properties/Resources.Designer.cs
  4. 3
      ILSpy/Properties/Resources.resx

4
ILSpy/Analyzers/AnalyzerSearchTreeNode.cs

@ -52,9 +52,7 @@ namespace ICSharpCode.ILSpy.Analyzers
protected IEnumerable<AnalyzerTreeNode> FetchChildren(CancellationToken ct) protected IEnumerable<AnalyzerTreeNode> FetchChildren(CancellationToken ct)
{ {
if (symbol is IEntity entity) { if (symbol is IEntity) {
var module = entity.ParentModule.PEFile;
var ts = new DecompilerTypeSystem(module, module.GetAssemblyResolver());
var context = new AnalyzerContext() { var context = new AnalyzerContext() {
CancellationToken = ct, CancellationToken = ct,
Language = Language, Language = Language,

5
ILSpy/Analyzers/AnalyzerTreeView.cs

@ -109,6 +109,11 @@ namespace ICSharpCode.ILSpy.Analyzers
throw new ArgumentNullException(nameof(entity)); throw new ArgumentNullException(nameof(entity));
} }
if (entity.MetadataToken.IsNil) {
MessageBox.Show(Properties.Resources.CannotAnalyzeMissingRef, "ILSpy");
return;
}
switch (entity) { switch (entity) {
case ITypeDefinition td: case ITypeDefinition td:
ShowOrFocus(new AnalyzedTypeTreeNode(td)); ShowOrFocus(new AnalyzedTypeTreeNode(td));

13
ILSpy/Properties/Resources.Designer.cs generated

@ -330,6 +330,15 @@ namespace ICSharpCode.ILSpy.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Entity could not be resolved. Cannot analyze entities from missing assembly references. Add the missing reference and try again..
/// </summary>
public static string CannotAnalyzeMissingRef {
get {
return ResourceManager.GetString("CannotAnalyzeMissingRef", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Check again. /// Looks up a localized string similar to Check again.
/// </summary> /// </summary>
@ -1476,7 +1485,7 @@ namespace ICSharpCode.ILSpy.Properties {
} }
/// <summary> /// <summary>
/// 查找类似 Search MSDN... 的本地化字符串。 /// Looks up a localized string similar to Search MSDN....
/// </summary> /// </summary>
public static string SearchMSDN { public static string SearchMSDN {
get { get {
@ -1485,7 +1494,7 @@ namespace ICSharpCode.ILSpy.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Search. /// Looks up a localized string similar to Search.
/// </summary> /// </summary>
public static string SearchPane_Search { public static string SearchPane_Search {
get { get {

3
ILSpy/Properties/Resources.resx

@ -726,4 +726,7 @@
<data name="SearchMSDN" xml:space="preserve"> <data name="SearchMSDN" xml:space="preserve">
<value>Search MSDN...</value> <value>Search MSDN...</value>
</data> </data>
<data name="CannotAnalyzeMissingRef" xml:space="preserve">
<value>Entity could not be resolved. Cannot analyze entities from missing assembly references. Add the missing reference and try again.</value>
</data>
</root> </root>
Loading…
Cancel
Save