Browse Source

Fixed exception double clicking code-coverage class node when that class didn't contain any methods.

Console pad: support calling methods like "this.M()" using the syntax "M()".

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3552 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
f28c5af616
  1. 5
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.csproj
  2. 12
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageClassTreeNode.cs
  3. 24
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Expressions/EvaluateAstVisitor.cs

5
src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.csproj

@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup> <PropertyGroup>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.CodeCoverage</RootNamespace> <RootNamespace>ICSharpCode.CodeCoverage</RootNamespace>
@ -15,6 +15,7 @@
<FileAlignment>4096</FileAlignment> <FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\CodeCoverage\</OutputPath> <OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\CodeCoverage\</OutputPath>
@ -118,4 +119,4 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project> </Project>

12
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageClassTreeNode.cs

@ -20,10 +20,18 @@ namespace ICSharpCode.CodeCoverage
public override void ActivateItem() public override void ActivateItem()
{ {
if (Nodes.Count > 0) { if (Nodes.Count > 0) {
CodeCoverageMethodTreeNode methodNode = (CodeCoverageMethodTreeNode)Nodes[0]; CodeCoverageMethodTreeNode methodNode = Nodes[0] as CodeCoverageMethodTreeNode;
if (methodNode.Method.SequencePoints.Count > 0) { if (methodNode != null && methodNode.Method.SequencePoints.Count > 0) {
FileService.OpenFile(methodNode.Method.SequencePoints[0].Document); FileService.OpenFile(methodNode.Method.SequencePoints[0].Document);
} }
// when the first node is a property:
CodeCoverageMethodsTreeNode methodsNode = Nodes[0] as CodeCoverageMethodsTreeNode;
if (methodsNode != null && methodsNode.Methods.Count > 0) {
var sequencePoints = methodsNode.Methods[0].SequencePoints;
if (sequencePoints != null) {
FileService.OpenFile(sequencePoints[0].Document);
}
}
} }
} }

24
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Expressions/EvaluateAstVisitor.cs

@ -93,18 +93,28 @@ namespace Debugger.AddIn
public override object VisitInvocationExpression(InvocationExpression invocationExpression, object data) public override object VisitInvocationExpression(InvocationExpression invocationExpression, object data)
{ {
Value target;
string methodName;
MemberReferenceExpression memberRef = invocationExpression.TargetObject as MemberReferenceExpression; MemberReferenceExpression memberRef = invocationExpression.TargetObject as MemberReferenceExpression;
if (memberRef == null) { if (memberRef != null) {
throw new GetValueException("Member reference expected duting method invocation"); target = ((Value)memberRef.TargetObject.AcceptVisitor(this, null)).GetPermanentReference();
methodName = memberRef.MemberName;
} else {
IdentifierExpression ident = invocationExpression.TargetObject as IdentifierExpression;
if (ident != null) {
target = context.GetThisValue();
methodName = ident.Identifier;
} else {
throw new GetValueException("Member reference expected for method invocation");
}
} }
Value target = ((Value)memberRef.TargetObject.AcceptVisitor(this, null)).GetPermanentReference();
List<Value> args = new List<Value>(); List<Value> args = new List<Value>();
foreach(Expression expr in invocationExpression.Arguments) { foreach(Expression expr in invocationExpression.Arguments) {
args.Add(((Value)expr.AcceptVisitor(this, null)).GetPermanentReference()); args.Add(((Value)expr.AcceptVisitor(this, null)).GetPermanentReference());
} }
MethodInfo method = target.Type.GetMember(memberRef.MemberName, BindingFlags.Method | BindingFlags.IncludeSuperType) as MethodInfo; MethodInfo method = target.Type.GetMember(methodName, BindingFlags.Method | BindingFlags.IncludeSuperType) as MethodInfo;
if (method == null) { if (method == null) {
throw new GetValueException("Method " + memberRef.MemberName + " not found"); throw new GetValueException("Method " + methodName + " not found");
} }
return target.InvokeMethod(method, args.ToArray()); return target.InvokeMethod(method, args.ToArray());
} }
@ -175,8 +185,8 @@ namespace Debugger.AddIn
// case BinaryOperatorType.GreaterThanOrEqual : // case BinaryOperatorType.GreaterThanOrEqual :
// val.PrimitiveValue = (right.PrimitiveValue >= left.PrimitiveValue); // val.PrimitiveValue = (right.PrimitiveValue >= left.PrimitiveValue);
// break; // break;
default : default:
throw new NotImplementedException("BinaryOperator: " + binaryOperatorExpression.Op + "!"); throw new NotImplementedException("BinaryOperator: " + binaryOperatorExpression.Op);
} }
} catch (System.Exception e) { } catch (System.Exception e) {
throw new GetValueException(e.Message); throw new GetValueException(e.Message);

Loading…
Cancel
Save