Browse Source

Fix NotImplementedException when checking project with FxCop.

Implement class and member search to get position.
Nested classes are not currently found (works in SD 4.3).
SD 4.3 does not match constructors, generics and indexers.
newNRvisualizers
Matt Ward 13 years ago
parent
commit
b350936869
  1. 6
      src/AddIns/Analysis/CodeAnalysis/Src/FxCopLogger.cs
  2. 28
      src/AddIns/Analysis/CodeAnalysis/Src/SuppressMessageCommand.cs

6
src/AddIns/Analysis/CodeAnalysis/Src/FxCopLogger.cs

@ -95,16 +95,14 @@ namespace ICSharpCode.CodeAnalysis @@ -95,16 +95,14 @@ namespace ICSharpCode.CodeAnalysis
static DomRegion GetPosition(ICompilation compilation, string memberName)
{
throw new NotImplementedException();
/*
// memberName is a special syntax used by our FxCop task:
// className#memberName
int pos = memberName.IndexOf('#');
if (pos <= 0)
return FilePosition.Empty;
return DomRegion.Empty;
string className = memberName.Substring(0, pos);
memberName = memberName.Substring(pos + 1);
return SuppressMessageCommand.GetPosition(pc, className, memberName);*/
return SuppressMessageCommand.GetPosition(compilation, className, memberName);
}
}
}

28
src/AddIns/Analysis/CodeAnalysis/Src/SuppressMessageCommand.cs

@ -6,7 +6,9 @@ using System.Collections.Generic; @@ -6,7 +6,9 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
@ -59,20 +61,28 @@ namespace ICSharpCode.CodeAnalysis @@ -59,20 +61,28 @@ namespace ICSharpCode.CodeAnalysis
}
}
/*
internal static FilePosition GetPosition(IProjectContent pc, string className, string memberName)
internal static DomRegion GetPosition(ICompilation compilation, string className, string memberName)
{
IClass c = pc.GetClassByReflectionName(className, false);
if (string.IsNullOrEmpty(memberName))
return pc.GetPosition(c);
if (c != null) {
IMember m = DefaultProjectContent.GetMemberByReflectionName(c, memberName);
var typeName = new TopLevelTypeName(className);
ITypeDefinition type = compilation.MainAssembly.GetTypeDefinition(typeName);
if (type != null) {
if (string.IsNullOrEmpty(memberName))
return type.Region;
IMember m = GetMember(type, memberName);
if (m != null)
return pc.GetPosition(m);
return m.Region;
}
return FilePosition.Empty;
return DomRegion.Empty;
}
static IMember GetMember(ITypeDefinition type, string memberName)
{
string fullName = type.ReflectionName + "." + memberName;
return type.GetMembers(m => m.ReflectionName == fullName).FirstOrDefault();
}
/*
FilePosition GetAssemblyAttributeInsertionPosition(IProjectContent pc)
{
FilePosition best = FilePosition.Empty;

Loading…
Cancel
Save