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 | ///
93 | /// [StringFormatMethod("message")]
94 | /// void ShowError(string message, params object[] args) { /* do something */ }
95 | ///
96 | /// void Foo() {
97 | /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
98 | /// }
99 | ///
139 | /// void Foo(string param) {
140 | /// if (param == null)
141 | /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
142 | /// }
143 | ///
163 | /// public class Foo : INotifyPropertyChanged {
164 | /// public event PropertyChangedEventHandler PropertyChanged;
165 | ///
166 | /// [NotifyPropertyChangedInvocator]
167 | /// protected virtual void NotifyChanged(string propertyName) { ... }
168 | ///
169 | /// string _name;
170 | ///
171 | /// public string Name {
172 | /// get { return _name; }
173 | /// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
174 | /// }
175 | /// }
176 | ///
177 | /// Examples of generated notifications:
178 | /// Function Definition Table syntax:
202 | ///
219 | /// [ContractAnnotation("=> halt")]
220 | /// public void TerminationMethod()
221 | ///
223 | /// [ContractAnnotation("halt <= condition: false")]
224 | /// public void Assert(bool condition, string text) // regular assertion method
225 | ///
227 | /// [ContractAnnotation("s:null => true")]
228 | /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
229 | ///
231 | /// // A method that returns null if the parameter is null,
232 | /// // and not null if the parameter is not null
233 | /// [ContractAnnotation("null => null; notnull => notnull")]
234 | /// public object Transform(object data)
235 | ///
237 | /// [ContractAnnotation("=> true, result: notnull; => false, result: null")]
238 | /// public bool TryParse(string s, out Person result)
239 | ///
262 | /// [LocalizationRequiredAttribute(true)]
263 | /// class Foo {
264 | /// string str = "my string"; // Warning: Localizable string
265 | /// }
266 | ///
287 | /// [CannotApplyEqualityOperator]
288 | /// class NoEquality { }
289 | ///
290 | /// class UsesNoEquality {
291 | /// void Test() {
292 | /// var ca1 = new NoEquality();
293 | /// var ca2 = new NoEquality();
294 | /// if (ca1 != null) { // OK
295 | /// bool condition = ca1 == ca2; // Warning
296 | /// }
297 | /// }
298 | /// }
299 | ///
308 | /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
309 | /// class ComponentAttribute : Attribute { }
310 | ///
311 | /// [Component] // ComponentAttribute requires implementing IComponent interface
312 | /// class MyComponent : IComponent { }
313 | ///
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 | ///
473 | /// class Foo {
474 | /// [ProvidesContext] IBarService _barService = ...;
475 | ///
476 | /// void ProcessNode(INode node) {
477 | /// DoSomething(node, node.GetGlobalServices().Bar);
478 | /// // ^ Warning: use value of '_barService' field
479 | /// }
480 | /// }
481 | ///
519 | /// [SourceTemplate]
520 | /// public static void forEach<T>(this IEnumerable<T> xs) {
521 | /// foreach (var x in xs) {
522 | /// //$ $END$
523 | /// }
524 | /// }
525 | ///
526 | ///
542 | /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
543 | /// public static void forEach<T>(this IEnumerable<T> collection) {
544 | /// foreach (var item in collection) {
545 | /// //$ $END$
546 | /// }
547 | /// }
548 | ///
549 | /// Applying the attribute on a template method parameter:
550 | ///
551 | /// [SourceTemplate]
552 | /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
553 | /// /*$ var $x$Id = "$newguid$" + x.ToString();
554 | /// x.DoSomething($x$Id); */
555 | /// }
556 | ///
557 | ///
787 | /// [ActionName("Foo")]
788 | /// public ActionResult Login(string returnUrl) {
789 | /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
790 | /// return RedirectToAction("Bar"); // Error: Cannot resolve action
791 | /// }
792 | ///