18 | /// [CanBeNull] object Test() => null;
19 | ///
20 | /// void UseTest() {
21 | /// var p = Test();
22 | /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
23 | /// }
24 | ///
34 | /// [NotNull] object Foo() {
35 | /// return null; // Warning: Possible 'null' assignment
36 | /// }
37 | ///
69 | /// [StringFormatMethod("message")]
70 | /// void ShowError(string message, params object[] args) { /* do something */ }
71 | ///
72 | /// void Foo() {
73 | /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
74 | /// }
75 | ///
113 | /// void Foo(string param) {
114 | /// if (param == null)
115 | /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
116 | /// }
117 | ///
137 | /// public class Foo : INotifyPropertyChanged {
138 | /// public event PropertyChangedEventHandler PropertyChanged;
139 | ///
140 | /// [NotifyPropertyChangedInvocator]
141 | /// protected virtual void NotifyChanged(string propertyName) { ... }
142 | ///
143 | /// string _name;
144 | ///
145 | /// public string Name {
146 | /// get { return _name; }
147 | /// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
148 | /// }
149 | /// }
150 | ///
151 | /// Examples of generated notifications:
152 | /// Function Definition Table syntax:
176 | ///
192 | /// [ContractAnnotation("=> halt")]
193 | /// public void TerminationMethod()
194 | ///
196 | /// [ContractAnnotation("halt <= condition: false")]
197 | /// public void Assert(bool condition, string text) // regular assertion method
198 | ///
200 | /// [ContractAnnotation("s:null => true")]
201 | /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
202 | ///
204 | /// // A method that returns null if the parameter is null,
205 | /// // and not null if the parameter is not null
206 | /// [ContractAnnotation("null => null; notnull => notnull")]
207 | /// public object Transform(object data)
208 | ///
210 | /// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")]
211 | /// public bool TryParse(string s, out Person result)
212 | ///
234 | /// [LocalizationRequiredAttribute(true)]
235 | /// class Foo {
236 | /// string str = "my string"; // Warning: Localizable string
237 | /// }
238 | ///
258 | /// [CannotApplyEqualityOperator]
259 | /// class NoEquality { }
260 | ///
261 | /// class UsesNoEquality {
262 | /// void Test() {
263 | /// var ca1 = new NoEquality();
264 | /// var ca2 = new NoEquality();
265 | /// if (ca1 != null) { // OK
266 | /// bool condition = ca1 == ca2; // Warning
267 | /// }
268 | /// }
269 | /// }
270 | ///
279 | /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
280 | /// class ComponentAttribute : Attribute { }
281 | ///
282 | /// [Component] // ComponentAttribute requires implementing IComponent interface
283 | /// class MyComponent : IComponent { }
284 | ///
410 | /// [Pure] int Multiply(int x, int y) => x * y;
411 | ///
412 | /// void M() {
413 | /// Multiply(123, 42); // Waring: Return value of pure method is not used
414 | /// }
415 | ///
440 | /// class Foo {
441 | /// [ProvidesContext] IBarService _barService = ...;
442 | ///
443 | /// void ProcessNode(INode node) {
444 | /// DoSomething(node, node.GetGlobalServices().Bar);
445 | /// // ^ Warning: use value of '_barService' field
446 | /// }
447 | /// }
448 | ///
485 | /// [SourceTemplate]
486 | /// public static void forEach<T>(this IEnumerable<T> xs) {
487 | /// foreach (var x in xs) {
488 | /// //$ $END$
489 | /// }
490 | /// }
491 | ///
492 | ///
508 | /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
509 | /// public static void forEach<T>(this IEnumerable<T> collection) {
510 | /// foreach (var item in collection) {
511 | /// //$ $END$
512 | /// }
513 | /// }
514 | ///
515 | /// Applying the attribute on a template method parameter:
516 | ///
517 | /// [SourceTemplate]
518 | /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
519 | /// /*$ var $x$Id = "$newguid$" + x.ToString();
520 | /// x.DoSomething($x$Id); */
521 | /// }
522 | ///
523 | ///
750 | /// [ActionName("Foo")]
751 | /// public ActionResult Login(string returnUrl) {
752 | /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
753 | /// return RedirectToAction("Bar"); // Error: Cannot resolve action
754 | /// }
755 | ///