Skip to content

RemoveCurrentStatement Code Mapping Action

ldfallas edited this page Aug 31, 2015 · 3 revisions

Usage

 <map:RemoveCurrentStatement/>

Description

Removes the statement where the current expression is contained.

Properties

No properties

Example

In this example we remove the statement where the call to an artificial class is made.

<MapUnit xmlns="clr-namespace:Mobilize.Mappers.Extensibility.Core;assembly=Mobilize.ExtensibleMappers"
         xmlns:map="clr-namespace:Mobilize.Mappers.Extensibility.Code;assembly=Mobilize.ExtensibleMappers">
	<MapUnit.Elements>
		<map:CodeMapPackage Type="MyNamespace.MyClass">
			<map:CodeMapPackage.Maps>
				<map:CodeMap Kind="Call" MemberName="Foo">
          <map:RemoveCurrentStatement/>
        </map:CodeMap>
     </map:CodeMapPackage.Maps>
  </MapUnit.Elements>
</MapUnit>

Given the following code:

MyNamespace.MyClass myClass = new MyNamespace.MyClass();

System.Diagnostics.WriteLine("start");
myClass.Foo(1,2,3);
System.Diagnostics.WriteLine("end");

This mapping action will do the following change:

MyNamespace.MyClass myClass = new MyNamespace.MyClass();

System.Diagnostics.WriteLine("start");

System.Diagnostics.WriteLine("end");

Notes

  • Use this mapping action only when it's safe to remove the code
  • Prefer the [Comment Out Mapping Action](Comment Out Mapping Action)

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally