Run()
).
+
RunEx(0, 0, "MyUserName")
).
+
+
+
+
" +
+ "" +
+ " " +
+ " " +
+ " S-1-5-18 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " 2017-09-04T14:04:03 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " cmd " +
+ " " +
+ " " +
+ " ";
+ // Register the task in the root folder of the local machine using the SYSTEM account defined in XML
+ TaskService.Instance.RootFolder.RegisterTaskDefinition("Test", xml);
+ ]]>
+
+
+
+
+
+
+
+
+ <Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week>
+
+
+ * * * * *
+ | | | | |
+ | | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
+ | | | +------ Month of the Year (range: 1-12)
+ | | +-------- Day of the Month (range: 1-31)
+ | +---------- Hour (range: 0-23)
+ +------------ Minute (range: 0-59)
+
+
+
+
+
+
+
+
+ ";
+ eTrigger.ValueQueries.Add("Name", "Value");
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+
Run()
).
+
RunEx(0, 0, "MyUserName")
).
+
+
+
+
" +
+ "" +
+ " " +
+ " " +
+ " S-1-5-18 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " 2017-09-04T14:04:03 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " cmd " +
+ " " +
+ " " +
+ " ";
+ // Register the task in the root folder of the local machine using the SYSTEM account defined in XML
+ TaskService.Instance.RootFolder.RegisterTaskDefinition("Test", xml);
+ ]]>
+
+
+
+
+
+
+
+
+ <Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week>
+
+
+ * * * * *
+ | | | | |
+ | | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
+ | | | +------ Month of the Year (range: 1-12)
+ | | +-------- Day of the Month (range: 1-31)
+ | +---------- Hour (range: 0-23)
+ +------------ Minute (range: 0-59)
+
+
+
+
+
+
+
+
+ ";
+ eTrigger.ValueQueries.Add("Name", "Value");
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+
Run()
).
+
RunEx(0, 0, "MyUserName")
).
+
+
+
+
" +
+ "" +
+ " " +
+ " " +
+ " S-1-5-18 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " 2017-09-04T14:04:03 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " cmd " +
+ " " +
+ " " +
+ " ";
+ // Register the task in the root folder of the local machine using the SYSTEM account defined in XML
+ TaskService.Instance.RootFolder.RegisterTaskDefinition("Test", xml);
+ ]]>
+
+
+
+
+
+
+
+
+ <Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week>
+
+
+ * * * * *
+ | | | | |
+ | | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
+ | | | +------ Month of the Year (range: 1-12)
+ | | +-------- Day of the Month (range: 1-31)
+ | +---------- Hour (range: 0-23)
+ +------------ Minute (range: 0-59)
+
+
+
+
+
+
+
+
+ ";
+ eTrigger.ValueQueries.Add("Name", "Value");
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+
Run()
).
+
RunEx(0, 0, "MyUserName")
).
+
+
+
+
" +
+ "" +
+ " " +
+ " " +
+ " S-1-5-18 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " 2017-09-04T14:04:03 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " cmd " +
+ " " +
+ " " +
+ " ";
+ // Register the task in the root folder of the local machine using the SYSTEM account defined in XML
+ TaskService.Instance.RootFolder.RegisterTaskDefinition("Test", xml);
+ ]]>
+
+
+
+
+
+
+
+
+ <Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week>
+
+
+ * * * * *
+ | | | | |
+ | | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
+ | | | +------ Month of the Year (range: 1-12)
+ | | +-------- Day of the Month (range: 1-31)
+ | +---------- Hour (range: 0-23)
+ +------------ Minute (range: 0-59)
+
+
+
+
+
+
+
+
+ ";
+ eTrigger.ValueQueries.Add("Name", "Value");
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+
Run()
).
+
RunEx(0, 0, "MyUserName")
).
+
+
+
+
" +
+ "" +
+ " " +
+ " " +
+ " S-1-5-18 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " 2017-09-04T14:04:03 " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " cmd " +
+ " " +
+ " " +
+ " ";
+ // Register the task in the root folder of the local machine using the SYSTEM account defined in XML
+ TaskService.Instance.RootFolder.RegisterTaskDefinition("Test", xml);
+ ]]>
+
+
+
+
+
+
+
+
+ <Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week>
+
+
+ * * * * *
+ | | | | |
+ | | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
+ | | | +------ Month of the Year (range: 1-12)
+ | | +-------- Day of the Month (range: 1-31)
+ | +---------- Hour (range: 0-23)
+ +------------ Minute (range: 0-59)
+
+
+
+
+
+
+
+
+ ";
+ eTrigger.ValueQueries.Add("Name", "Value");
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [CanBeNull] object Test() => null;
+
+ void UseTest() {
+ var p = Test();
+ var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
+ }
+
+ [NotNull] object Foo() {
+ return null; // Warning: Possible 'null' assignment
+ }
+
+ [StringFormatMethod("message")]
+ void ShowError(string message, params object[] args) { /* do something */ }
+
+ void Foo() {
+ ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
+ }
+
+ void Foo(string param) {
+ if (param == null)
+ throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
+ }
+
+ public class Foo : INotifyPropertyChanged {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void NotifyChanged(string propertyName) { ... }
+
+ string _name;
+
+ public string Name {
+ get { return _name; }
+ set { _name = value; NotifyChanged("LastName"); /* Warning */ }
+ }
+ }
+
+ Examples of generated notifications:
+ Function Definition Table syntax:
+
+ [ContractAnnotation("=> halt")]
+ public void TerminationMethod()
+
+ [ContractAnnotation("halt <= condition: false")]
+ public void Assert(bool condition, string text) // regular assertion method
+
+ [ContractAnnotation("s:null => true")]
+ public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
+
+ // A method that returns null if the parameter is null,
+ // and not null if the parameter is not null
+ [ContractAnnotation("null => null; notnull => notnull")]
+ public object Transform(object data)
+
+ [ContractAnnotation("=> true, result: notnull; => false, result: null")]
+ public bool TryParse(string s, out Person result)
+
+ [LocalizationRequiredAttribute(true)]
+ class Foo {
+ string str = "my string"; // Warning: Localizable string
+ }
+
+ [CannotApplyEqualityOperator]
+ class NoEquality { }
+
+ class UsesNoEquality {
+ void Test() {
+ var ca1 = new NoEquality();
+ var ca2 = new NoEquality();
+ if (ca1 != null) { // OK
+ bool condition = ca1 == ca2; // Warning
+ }
+ }
+ }
+
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ class ComponentAttribute : Attribute { }
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ class MyComponent : IComponent { }
+
+ [Pure] int Multiply(int x, int y) => x * y;
+
+ void M() {
+ Multiply(123, 42); // Waring: Return value of pure method is not used
+ }
+
+ class Foo {
+ [ProvidesContext] IBarService _barService = ...;
+
+ void ProcessNode(INode node) {
+ DoSomething(node, node.GetGlobalServices().Bar);
+ // ^ Warning: use value of '_barService' field
+ }
+ }
+
+ [SourceTemplate]
+ public static void forEach<T>(this IEnumerable<T> xs) {
+ foreach (var x in xs) {
+ //$ $END$
+ }
+ }
+
+
+ [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+ public static void forEach<T>(this IEnumerable<T> collection) {
+ foreach (var item in collection) {
+ //$ $END$
+ }
+ }
+
+ Applying the attribute on a template method parameter:
+
+ [SourceTemplate]
+ public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+ /*$ var $x$Id = "$newguid$" + x.ToString();
+ x.DoSomething($x$Id); */
+ }
+
+
+ [ActionName("Foo")]
+ public ActionResult Login(string returnUrl) {
+ ViewBag.ReturnUrl = Url.Action("Foo"); // OK
+ return RedirectToAction("Bar"); // Error: Cannot resolve action
+ }
+