Browse Source

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

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

4
ILSpy/Analyzers/AnalyzerSearchTreeNode.cs

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

5
ILSpy/Analyzers/AnalyzerTreeView.cs

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

11
ILSpy/Properties/Resources.Designer.cs generated

@ -330,6 +330,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -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>
/// Looks up a localized string similar to Check again.
/// </summary>
@ -1476,7 +1485,7 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1476,7 +1485,7 @@ namespace ICSharpCode.ILSpy.Properties {
}
/// <summary>
/// 查找类似 Search MSDN... 的本地化字符串。
/// Looks up a localized string similar to Search MSDN....
/// </summary>
public static string SearchMSDN {
get {

3
ILSpy/Properties/Resources.resx

@ -726,4 +726,7 @@ @@ -726,4 +726,7 @@
<data name="SearchMSDN" xml:space="preserve">
<value>Search MSDN...</value>
</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>
Loading…
Cancel
Save