40 | /// [CanBeNull] object Test() => null;
41 | ///
42 | /// void UseTest() {
43 | /// var p = Test();
44 | /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
45 | /// }
46 | ///
57 | /// [NotNull] object Foo() {
58 | /// return null; // Warning: Possible 'null' assignment
59 | /// }
60 | ///
101 | /// [StringFormatMethod("message")]
102 | /// void ShowError(string message, params object[] args) { /* do something */ }
103 | ///
104 | /// void Foo() {
105 | /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
106 | /// }
107 | ///
145 | /// void Foo(string param) {
146 | /// if (param == null)
147 | /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
148 | /// }
149 | ///
169 | /// public class Foo : INotifyPropertyChanged {
170 | /// public event PropertyChangedEventHandler PropertyChanged;
171 | ///
172 | /// [NotifyPropertyChangedInvocator]
173 | /// protected virtual void NotifyChanged(string propertyName) { ... }
174 | ///
175 | /// string _name;
176 | ///
177 | /// public string Name {
178 | /// get { return _name; }
179 | /// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
180 | /// }
181 | /// }
182 | ///
183 | /// Examples of generated notifications:
184 | /// Function Definition Table syntax:
208 | ///
224 | /// [ContractAnnotation("=> halt")]
225 | /// public void TerminationMethod()
226 | ///
228 | /// [ContractAnnotation("halt <= condition: false")]
229 | /// public void Assert(bool condition, string text) // regular assertion method
230 | ///
232 | /// [ContractAnnotation("s:null => true")]
233 | /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
234 | ///
236 | /// // A method that returns null if the parameter is null,
237 | /// // and not null if the parameter is not null
238 | /// [ContractAnnotation("null => null; notnull => notnull")]
239 | /// public object Transform(object data)
240 | ///
242 | /// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")]
243 | /// public bool TryParse(string s, out Person result)
244 | ///
266 | /// [LocalizationRequiredAttribute(true)]
267 | /// class Foo {
268 | /// string str = "my string"; // Warning: Localizable string
269 | /// }
270 | ///
290 | /// [CannotApplyEqualityOperator]
291 | /// class NoEquality { }
292 | ///
293 | /// class UsesNoEquality {
294 | /// void Test() {
295 | /// var ca1 = new NoEquality();
296 | /// var ca2 = new NoEquality();
297 | /// if (ca1 != null) { // OK
298 | /// bool condition = ca1 == ca2; // Warning
299 | /// }
300 | /// }
301 | /// }
302 | ///
311 | /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
312 | /// class ComponentAttribute : Attribute { }
313 | ///
314 | /// [Component] // ComponentAttribute requires implementing IComponent interface
315 | /// class MyComponent : IComponent { }
316 | ///
442 | /// [Pure] int Multiply(int x, int y) => x * y;
443 | ///
444 | /// void M() {
445 | /// Multiply(123, 42); // Waring: Return value of pure method is not used
446 | /// }
447 | ///
472 | /// class Foo {
473 | /// [ProvidesContext] IBarService _barService = ...;
474 | ///
475 | /// void ProcessNode(INode node) {
476 | /// DoSomething(node, node.GetGlobalServices().Bar);
477 | /// // ^ Warning: use value of '_barService' field
478 | /// }
479 | /// }
480 | ///
517 | /// [SourceTemplate]
518 | /// public static void forEach<T>(this IEnumerable<T> xs) {
519 | /// foreach (var x in xs) {
520 | /// //$ $END$
521 | /// }
522 | /// }
523 | ///
524 | ///
540 | /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
541 | /// public static void forEach<T>(this IEnumerable<T> collection) {
542 | /// foreach (var item in collection) {
543 | /// //$ $END$
544 | /// }
545 | /// }
546 | ///
547 | /// Applying the attribute on a template method parameter:
548 | ///
549 | /// [SourceTemplate]
550 | /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
551 | /// /*$ var $x$Id = "$newguid$" + x.ToString();
552 | /// x.DoSomething($x$Id); */
553 | /// }
554 | ///
555 | ///
782 | /// [ActionName("Foo")]
783 | /// public ActionResult Login(string returnUrl) {
784 | /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
785 | /// return RedirectToAction("Bar"); // Error: Cannot resolve action
786 | /// }
787 | ///