Winify – Blame information for rev 15

Subversion Repositories:
Rev:
Rev Author Line No. Line
15 office 1 /* MIT License
2  
3 Copyright (c) 2016 JetBrains http://www.jetbrains.com
4  
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11  
12 The above copyright notice and this permission notice shall be included in all
13 copies or substantial portions of the Software.
14  
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 SOFTWARE. */
22  
23 using System;
24  
25 // ReSharper disable InheritdocConsiderUsage
26  
27 #pragma warning disable 1591
28 // ReSharper disable UnusedMember.Global
29 // ReSharper disable MemberCanBePrivate.Global
30 // ReSharper disable UnusedAutoPropertyAccessor.Global
31 // ReSharper disable IntroduceOptionalParameters.Global
32 // ReSharper disable MemberCanBeProtected.Global
33 // ReSharper disable InconsistentNaming
34  
35 namespace Announcements.Annotations
36 {
37 /// <summary>
38 /// Indicates that the value of the marked element could be <c>null</c> sometimes,
39 /// so checking for <c>null</c> is required before its usage.
40 /// </summary>
41 /// <example>
42 /// <code>
43 /// [CanBeNull] object Test() => null;
44 ///
45 /// void UseTest() {
46 /// var p = Test();
47 /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
48 /// }
49 /// </code>
50 /// </example>
51 [AttributeUsage(
52 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
53 AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
54 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
55 public sealed class CanBeNullAttribute : Attribute
56 {
57 }
58  
59 /// <summary>
60 /// Indicates that the value of the marked element can never be <c>null</c>.
61 /// </summary>
62 /// <example>
63 /// <code>
64 /// [NotNull] object Foo() {
65 /// return null; // Warning: Possible 'null' assignment
66 /// }
67 /// </code>
68 /// </example>
69 [AttributeUsage(
70 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
71 AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
72 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
73 public sealed class NotNullAttribute : Attribute
74 {
75 }
76  
77 /// <summary>
78 /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
79 /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
80 /// or of the Lazy.Value property can never be null.
81 /// </summary>
82 /// <example>
83 /// <code>
84 /// public void Foo([ItemNotNull]List&lt;string&gt; books)
85 /// {
86 /// foreach (var book in books) {
87 /// if (book != null) // Warning: Expression is always true
88 /// Console.WriteLine(book.ToUpper());
89 /// }
90 /// }
91 /// </code>
92 /// </example>
93 [AttributeUsage(
94 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
95 AttributeTargets.Delegate | AttributeTargets.Field)]
96 public sealed class ItemNotNullAttribute : Attribute
97 {
98 }
99  
100 /// <summary>
101 /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
102 /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
103 /// or of the Lazy.Value property can be null.
104 /// </summary>
105 /// <example>
106 /// <code>
107 /// public void Foo([ItemCanBeNull]List&lt;string&gt; books)
108 /// {
109 /// foreach (var book in books)
110 /// {
111 /// // Warning: Possible 'System.NullReferenceException'
112 /// Console.WriteLine(book.ToUpper());
113 /// }
114 /// }
115 /// </code>
116 /// </example>
117 [AttributeUsage(
118 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
119 AttributeTargets.Delegate | AttributeTargets.Field)]
120 public sealed class ItemCanBeNullAttribute : Attribute
121 {
122 }
123  
124 /// <summary>
125 /// Indicates that the marked method builds string by the format pattern and (optional) arguments.
126 /// The parameter, which contains the format string, should be given in constructor. The format string
127 /// should be in <see cref="string.Format(IFormatProvider,string,object[])" />-like form.
128 /// </summary>
129 /// <example>
130 /// <code>
131 /// [StringFormatMethod("message")]
132 /// void ShowError(string message, params object[] args) { /* do something */ }
133 ///
134 /// void Foo() {
135 /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
136 /// }
137 /// </code>
138 /// </example>
139 [AttributeUsage(
140 AttributeTargets.Constructor | AttributeTargets.Method |
141 AttributeTargets.Property | AttributeTargets.Delegate)]
142 public sealed class StringFormatMethodAttribute : Attribute
143 {
144 #region Public Enums, Properties and Fields
145  
146 [NotNull]
147 public string FormatParameterName { get; }
148  
149 #endregion
150  
151 #region Constructors, Destructors and Finalizers
152  
153 /// <param name="formatParameterName">
154 /// Specifies which parameter of an annotated method should be treated as the format string
155 /// </param>
156 public StringFormatMethodAttribute([NotNull] string formatParameterName)
157 {
158 FormatParameterName = formatParameterName;
159 }
160  
161 #endregion
162 }
163  
164 /// <summary>
165 /// Use this annotation to specify a type that contains static or const fields
166 /// with values for the annotated property/field/parameter.
167 /// The specified type will be used to improve completion suggestions.
168 /// </summary>
169 /// <example>
170 /// <code>
171 /// namespace TestNamespace
172 /// {
173 /// public class Constants
174 /// {
175 /// public static int INT_CONST = 1;
176 /// public const string STRING_CONST = "1";
177 /// }
178 ///
179 /// public class Class1
180 /// {
181 /// [ValueProvider("TestNamespace.Constants")] public int myField;
182 /// public void Foo([ValueProvider("TestNamespace.Constants")] string str) { }
183 ///
184 /// public void Test()
185 /// {
186 /// Foo(/*try completion here*/);//
187 /// myField = /*try completion here*/
188 /// }
189 /// }
190 /// }
191 /// </code>
192 /// </example>
193 [AttributeUsage(
194 AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field,
195 AllowMultiple = true)]
196 public sealed class ValueProviderAttribute : Attribute
197 {
198 #region Public Enums, Properties and Fields
199  
200 [NotNull]
201 public string Name { get; }
202  
203 #endregion
204  
205 #region Constructors, Destructors and Finalizers
206  
207 public ValueProviderAttribute([NotNull] string name)
208 {
209 Name = name;
210 }
211  
212 #endregion
213 }
214  
215 /// <summary>
216 /// Indicates that the integral value falls into the specified interval.
217 /// It's allowed to specify multiple non-intersecting intervals.
218 /// Values of interval boundaries are inclusive.
219 /// </summary>
220 /// <example>
221 /// <code>
222 /// void Foo([ValueRange(0, 100)] int value) {
223 /// if (value == -1) { // Warning: Expression is always 'false'
224 /// ...
225 /// }
226 /// }
227 /// </code>
228 /// </example>
229 [AttributeUsage(
230 AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |
231 AttributeTargets.Method | AttributeTargets.Delegate,
232 AllowMultiple = true)]
233 public sealed class ValueRangeAttribute : Attribute
234 {
235 #region Public Enums, Properties and Fields
236  
237 public object From { get; }
238  
239 public object To { get; }
240  
241 #endregion
242  
243 #region Constructors, Destructors and Finalizers
244  
245 public ValueRangeAttribute(long from, long to)
246 {
247 From = from;
248 To = to;
249 }
250  
251 public ValueRangeAttribute(ulong from, ulong to)
252 {
253 From = from;
254 To = to;
255 }
256  
257 public ValueRangeAttribute(long value)
258 {
259 From = To = value;
260 }
261  
262 public ValueRangeAttribute(ulong value)
263 {
264 From = To = value;
265 }
266  
267 #endregion
268 }
269  
270 /// <summary>
271 /// Indicates that the integral value never falls below zero.
272 /// </summary>
273 /// <example>
274 /// <code>
275 /// void Foo([NonNegativeValue] int value) {
276 /// if (value == -1) { // Warning: Expression is always 'false'
277 /// ...
278 /// }
279 /// }
280 /// </code>
281 /// </example>
282 [AttributeUsage(
283 AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |
284 AttributeTargets.Method | AttributeTargets.Delegate)]
285 public sealed class NonNegativeValueAttribute : Attribute
286 {
287 }
288  
289 /// <summary>
290 /// Indicates that the function argument should be a string literal and match one
291 /// of the parameters of the caller function. For example, ReSharper annotates
292 /// the parameter of <see cref="System.ArgumentNullException" />.
293 /// </summary>
294 /// <example>
295 /// <code>
296 /// void Foo(string param) {
297 /// if (param == null)
298 /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
299 /// }
300 /// </code>
301 /// </example>
302 [AttributeUsage(AttributeTargets.Parameter)]
303 public sealed class InvokerParameterNameAttribute : Attribute
304 {
305 }
306  
307 /// <summary>
308 /// Indicates that the method is contained in a type that implements
309 /// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method
310 /// is used to notify that some property value changed.
311 /// </summary>
312 /// <remarks>
313 /// The method should be non-static and conform to one of the supported signatures:
314 /// <list>
315 /// <item>
316 /// <c>NotifyChanged(string)</c>
317 /// </item>
318 /// <item>
319 /// <c>NotifyChanged(params string[])</c>
320 /// </item>
321 /// <item>
322 /// <c>NotifyChanged{T}(Expression{Func{T}})</c>
323 /// </item>
324 /// <item>
325 /// <c>NotifyChanged{T,U}(Expression{Func{T,U}})</c>
326 /// </item>
327 /// <item>
328 /// <c>SetProperty{T}(ref T, T, string)</c>
329 /// </item>
330 /// </list>
331 /// </remarks>
332 /// <example>
333 /// <code>
334 /// public class Foo : INotifyPropertyChanged {
335 /// public event PropertyChangedEventHandler PropertyChanged;
336 ///
337 /// [NotifyPropertyChangedInvocator]
338 /// protected virtual void NotifyChanged(string propertyName) { ... }
339 ///
340 /// string _name;
341 ///
342 /// public string Name {
343 /// get { return _name; }
344 /// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
345 /// }
346 /// }
347 /// </code>
348 /// Examples of generated notifications:
349 /// <list>
350 /// <item>
351 /// <c>NotifyChanged("Property")</c>
352 /// </item>
353 /// <item>
354 /// <c>NotifyChanged(() =&gt; Property)</c>
355 /// </item>
356 /// <item>
357 /// <c>NotifyChanged((VM x) =&gt; x.Property)</c>
358 /// </item>
359 /// <item>
360 /// <c>SetProperty(ref myField, value, "Property")</c>
361 /// </item>
362 /// </list>
363 /// </example>
364 [AttributeUsage(AttributeTargets.Method)]
365 public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
366 {
367 #region Public Enums, Properties and Fields
368  
369 [CanBeNull]
370 public string ParameterName { get; }
371  
372 #endregion
373  
374 #region Constructors, Destructors and Finalizers
375  
376 public NotifyPropertyChangedInvocatorAttribute()
377 {
378 }
379  
380 public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
381 {
382 ParameterName = parameterName;
383 }
384  
385 #endregion
386 }
387  
388 /// <summary>
389 /// Describes dependency between method input and output.
390 /// </summary>
391 /// <syntax>
392 /// <p>Function Definition Table syntax:</p>
393 /// <list>
394 /// <item>FDT ::= FDTRow [;FDTRow]*</item>
395 /// <item>FDTRow ::= Input =&gt; Output | Output &lt;= Input</item>
396 /// <item>Input ::= ParameterName: Value [, Input]*</item>
397 /// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>
398 /// <item>Value ::= true | false | null | notnull | canbenull</item>
399 /// </list>
400 /// If the method has a single input parameter, its name could be omitted.<br />
401 /// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for the method output
402 /// means that the method doesn't return normally (throws or terminates the process).<br />
403 /// Value <c>canbenull</c> is only applicable for output parameters.<br />
404 /// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute
405 /// with rows separated by semicolon. There is no notion of order rows, all rows are checked
406 /// for applicability and applied per each program state tracked by the analysis engine.<br />
407 /// </syntax>
408 /// <examples>
409 /// <list>
410 /// <item>
411 /// <code>
412 /// [ContractAnnotation("=&gt; halt")]
413 /// public void TerminationMethod()
414 /// </code>
415 /// </item>
416 /// <item>
417 /// <code>
418 /// [ContractAnnotation("null &lt;= param:null")] // reverse condition syntax
419 /// public string GetName(string surname)
420 /// </code>
421 /// </item>
422 /// <item>
423 /// <code>
424 /// [ContractAnnotation("s:null =&gt; true")]
425 /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
426 /// </code>
427 /// </item>
428 /// <item>
429 /// <code>
430 /// // A method that returns null if the parameter is null,
431 /// // and not null if the parameter is not null
432 /// [ContractAnnotation("null =&gt; null; notnull =&gt; notnull")]
433 /// public object Transform(object data)
434 /// </code>
435 /// </item>
436 /// <item>
437 /// <code>
438 /// [ContractAnnotation("=&gt; true, result: notnull; =&gt; false, result: null")]
439 /// public bool TryParse(string s, out Person result)
440 /// </code>
441 /// </item>
442 /// </list>
443 /// </examples>
444 [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
445 public sealed class ContractAnnotationAttribute : Attribute
446 {
447 #region Public Enums, Properties and Fields
448  
449 [NotNull]
450 public string Contract { get; }
451  
452 public bool ForceFullStates { get; }
453  
454 #endregion
455  
456 #region Constructors, Destructors and Finalizers
457  
458 public ContractAnnotationAttribute([NotNull] string contract)
459 : this(contract, false)
460 {
461 }
462  
463 public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
464 {
465 Contract = contract;
466 ForceFullStates = forceFullStates;
467 }
468  
469 #endregion
470 }
471  
472 /// <summary>
473 /// Indicates whether the marked element should be localized.
474 /// </summary>
475 /// <example>
476 /// <code>
477 /// [LocalizationRequiredAttribute(true)]
478 /// class Foo {
479 /// string str = "my string"; // Warning: Localizable string
480 /// }
481 /// </code>
482 /// </example>
483 [AttributeUsage(AttributeTargets.All)]
484 public sealed class LocalizationRequiredAttribute : Attribute
485 {
486 #region Public Enums, Properties and Fields
487  
488 public bool Required { get; }
489  
490 #endregion
491  
492 #region Constructors, Destructors and Finalizers
493  
494 public LocalizationRequiredAttribute() : this(true)
495 {
496 }
497  
498 public LocalizationRequiredAttribute(bool required)
499 {
500 Required = required;
501 }
502  
503 #endregion
504 }
505  
506 /// <summary>
507 /// Indicates that the value of the marked type (or its derivatives)
508 /// cannot be compared using '==' or '!=' operators and <c>Equals()</c>
509 /// should be used instead. However, using '==' or '!=' for comparison
510 /// with <c>null</c> is always permitted.
511 /// </summary>
512 /// <example>
513 /// <code>
514 /// [CannotApplyEqualityOperator]
515 /// class NoEquality { }
516 ///
517 /// class UsesNoEquality {
518 /// void Test() {
519 /// var ca1 = new NoEquality();
520 /// var ca2 = new NoEquality();
521 /// if (ca1 != null) { // OK
522 /// bool condition = ca1 == ca2; // Warning
523 /// }
524 /// }
525 /// }
526 /// </code>
527 /// </example>
528 [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]
529 public sealed class CannotApplyEqualityOperatorAttribute : Attribute
530 {
531 }
532  
533 /// <summary>
534 /// When applied to a target attribute, specifies a requirement for any type marked
535 /// with the target attribute to implement or inherit specific type or types.
536 /// </summary>
537 /// <example>
538 /// <code>
539 /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
540 /// class ComponentAttribute : Attribute { }
541 ///
542 /// [Component] // ComponentAttribute requires implementing IComponent interface
543 /// class MyComponent : IComponent { }
544 /// </code>
545 /// </example>
546 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
547 [BaseTypeRequired(typeof(Attribute))]
548 public sealed class BaseTypeRequiredAttribute : Attribute
549 {
550 #region Public Enums, Properties and Fields
551  
552 [NotNull]
553 public Type BaseType { get; }
554  
555 #endregion
556  
557 #region Constructors, Destructors and Finalizers
558  
559 public BaseTypeRequiredAttribute([NotNull] Type baseType)
560 {
561 BaseType = baseType;
562 }
563  
564 #endregion
565 }
566  
567 /// <summary>
568 /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library),
569 /// so this symbol will not be reported as unused (as well as by other usage inspections).
570 /// </summary>
571 [AttributeUsage(AttributeTargets.All)]
572 public sealed class UsedImplicitlyAttribute : Attribute
573 {
574 #region Public Enums, Properties and Fields
575  
576 public ImplicitUseKindFlags UseKindFlags { get; }
577  
578 public ImplicitUseTargetFlags TargetFlags { get; }
579  
580 #endregion
581  
582 #region Constructors, Destructors and Finalizers
583  
584 public UsedImplicitlyAttribute()
585 : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
586 {
587 }
588  
589 public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
590 : this(useKindFlags, ImplicitUseTargetFlags.Default)
591 {
592 }
593  
594 public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
595 : this(ImplicitUseKindFlags.Default, targetFlags)
596 {
597 }
598  
599 public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
600 {
601 UseKindFlags = useKindFlags;
602 TargetFlags = targetFlags;
603 }
604  
605 #endregion
606 }
607  
608 /// <summary>
609 /// Can be applied to attributes, type parameters, and parameters of a type assignable from <see cref="System.Type" />
610 /// .
611 /// When applied to an attribute, the decorated attribute behaves the same as <see cref="UsedImplicitlyAttribute" />.
612 /// When applied to a type parameter or to a parameter of type <see cref="System.Type" />, indicates that the
613 /// corresponding type
614 /// is used implicitly.
615 /// </summary>
616 [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter | AttributeTargets.Parameter)]
617 public sealed class MeansImplicitUseAttribute : Attribute
618 {
619 #region Public Enums, Properties and Fields
620  
621 [UsedImplicitly]
622 public ImplicitUseKindFlags UseKindFlags { get; }
623  
624 [UsedImplicitly]
625 public ImplicitUseTargetFlags TargetFlags { get; }
626  
627 #endregion
628  
629 #region Constructors, Destructors and Finalizers
630  
631 public MeansImplicitUseAttribute()
632 : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
633 {
634 }
635  
636 public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
637 : this(useKindFlags, ImplicitUseTargetFlags.Default)
638 {
639 }
640  
641 public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
642 : this(ImplicitUseKindFlags.Default, targetFlags)
643 {
644 }
645  
646 public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
647 {
648 UseKindFlags = useKindFlags;
649 TargetFlags = targetFlags;
650 }
651  
652 #endregion
653 }
654  
655 /// <summary>
656 /// Specify the details of implicitly used symbol when it is marked
657 /// with <see cref="MeansImplicitUseAttribute" /> or <see cref="UsedImplicitlyAttribute" />.
658 /// </summary>
659 [Flags]
660 public enum ImplicitUseKindFlags
661 {
662 Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
663  
664 /// <summary>Only entity marked with attribute considered used.</summary>
665 Access = 1,
666  
667 /// <summary>Indicates implicit assignment to a member.</summary>
668 Assign = 2,
669  
670 /// <summary>
671 /// Indicates implicit instantiation of a type with fixed constructor signature.
672 /// That means any unused constructor parameters won't be reported as such.
673 /// </summary>
674 InstantiatedWithFixedConstructorSignature = 4,
675  
676 /// <summary>Indicates implicit instantiation of a type.</summary>
677 InstantiatedNoFixedConstructorSignature = 8
678 }
679  
680 /// <summary>
681 /// Specify what is considered to be used implicitly when marked
682 /// with <see cref="MeansImplicitUseAttribute" /> or <see cref="UsedImplicitlyAttribute" />.
683 /// </summary>
684 [Flags]
685 public enum ImplicitUseTargetFlags
686 {
687 Default = Itself,
688  
689 Itself = 1,
690  
691 /// <summary>Members of entity marked with attribute are considered used.</summary>
692 Members = 2,
693  
694 /// <summary> Inherited entities are considered used. </summary>
695 WithInheritors = 4,
696  
697 /// <summary>Entity marked with attribute and all its members considered used.</summary>
698 WithMembers = Itself | Members
699 }
700  
701 /// <summary>
702 /// This attribute is intended to mark publicly available API
703 /// which should not be removed and so is treated as used.
704 /// </summary>
705 [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)]
706 [AttributeUsage(AttributeTargets.All, Inherited = false)]
707 public sealed class PublicAPIAttribute : Attribute
708 {
709 #region Public Enums, Properties and Fields
710  
711 [CanBeNull]
712 public string Comment { get; }
713  
714 #endregion
715  
716 #region Constructors, Destructors and Finalizers
717  
718 public PublicAPIAttribute()
719 {
720 }
721  
722 public PublicAPIAttribute([NotNull] string comment)
723 {
724 Comment = comment;
725 }
726  
727 #endregion
728 }
729  
730 /// <summary>
731 /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack.
732 /// If the parameter is a delegate, indicates that delegate is executed while the method is executed.
733 /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed.
734 /// </summary>
735 [AttributeUsage(AttributeTargets.Parameter)]
736 public sealed class InstantHandleAttribute : Attribute
737 {
738 }
739  
740 /// <summary>
741 /// Indicates that a method does not make any observable state changes.
742 /// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>.
743 /// </summary>
744 /// <example>
745 /// <code>
746 /// [Pure] int Multiply(int x, int y) => x * y;
747 ///
748 /// void M() {
749 /// Multiply(123, 42); // Warning: Return value of pure method is not used
750 /// }
751 /// </code>
752 /// </example>
753 [AttributeUsage(AttributeTargets.Method)]
754 public sealed class PureAttribute : Attribute
755 {
756 }
757  
758 /// <summary>
759 /// Indicates that the return value of the method invocation must be used.
760 /// </summary>
761 /// <remarks>
762 /// Methods decorated with this attribute (in contrast to pure methods) might change state,
763 /// but make no sense without using their return value. <br />
764 /// Similarly to <see cref="PureAttribute" />, this attribute
765 /// will help detecting usages of the method when the return value in not used.
766 /// Additionally, you can optionally specify a custom message, which will be used when showing warnings, e.g.
767 /// <code>[MustUseReturnValue("Use the return value to...")]</code>.
768 /// </remarks>
769 [AttributeUsage(AttributeTargets.Method)]
770 public sealed class MustUseReturnValueAttribute : Attribute
771 {
772 #region Public Enums, Properties and Fields
773  
774 [CanBeNull]
775 public string Justification { get; }
776  
777 #endregion
778  
779 #region Constructors, Destructors and Finalizers
780  
781 public MustUseReturnValueAttribute()
782 {
783 }
784  
785 public MustUseReturnValueAttribute([NotNull] string justification)
786 {
787 Justification = justification;
788 }
789  
790 #endregion
791 }
792  
793 /// <summary>
794 /// Indicates the type member or parameter of some type, that should be used instead of all other ways
795 /// to get the value of that type. This annotation is useful when you have some "context" value evaluated
796 /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one.
797 /// </summary>
798 /// <example>
799 /// <code>
800 /// class Foo {
801 /// [ProvidesContext] IBarService _barService = ...;
802 ///
803 /// void ProcessNode(INode node) {
804 /// DoSomething(node, node.GetGlobalServices().Bar);
805 /// // ^ Warning: use value of '_barService' field
806 /// }
807 /// }
808 /// </code>
809 /// </example>
810 [AttributeUsage(
811 AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method |
812 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct |
813 AttributeTargets.GenericParameter)]
814 public sealed class ProvidesContextAttribute : Attribute
815 {
816 }
817  
818 /// <summary>
819 /// Indicates that a parameter is a path to a file or a folder within a web project.
820 /// Path can be relative or absolute, starting from web root (~).
821 /// </summary>
822 [AttributeUsage(AttributeTargets.Parameter)]
823 public sealed class PathReferenceAttribute : Attribute
824 {
825 #region Public Enums, Properties and Fields
826  
827 [CanBeNull]
828 public string BasePath { get; }
829  
830 #endregion
831  
832 #region Constructors, Destructors and Finalizers
833  
834 public PathReferenceAttribute()
835 {
836 }
837  
838 public PathReferenceAttribute([NotNull] [PathReference] string basePath)
839 {
840 BasePath = basePath;
841 }
842  
843 #endregion
844 }
845  
846 /// <summary>
847 /// An extension method marked with this attribute is processed by code completion
848 /// as a 'Source Template'. When the extension method is completed over some expression, its source code
849 /// is automatically expanded like a template at call site.
850 /// </summary>
851 /// <remarks>
852 /// Template method body can contain valid source code and/or special comments starting with '$'.
853 /// Text inside these comments is added as source code when the template is applied. Template parameters
854 /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs.
855 /// Use the <see cref="MacroAttribute" /> attribute to specify macros for parameters.
856 /// </remarks>
857 /// <example>
858 /// In this example, the 'forEach' method is a source template available over all values
859 /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:
860 /// <code>
861 /// [SourceTemplate]
862 /// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; xs) {
863 /// foreach (var x in xs) {
864 /// //$ $END$
865 /// }
866 /// }
867 /// </code>
868 /// </example>
869 [AttributeUsage(AttributeTargets.Method)]
870 public sealed class SourceTemplateAttribute : Attribute
871 {
872 }
873  
874 /// <summary>
875 /// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>.
876 /// </summary>
877 /// <remarks>
878 /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression
879 /// is defined in the <see cref="MacroAttribute.Expression" /> property. When applied on a method, the target
880 /// template parameter is defined in the <see cref="MacroAttribute.Target" /> property. To apply the macro silently
881 /// for the parameter, set the <see cref="MacroAttribute.Editable" /> property value = -1.
882 /// </remarks>
883 /// <example>
884 /// Applying the attribute on a source template method:
885 /// <code>
886 /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
887 /// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; collection) {
888 /// foreach (var item in collection) {
889 /// //$ $END$
890 /// }
891 /// }
892 /// </code>
893 /// Applying the attribute on a template method parameter:
894 /// <code>
895 /// [SourceTemplate]
896 /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
897 /// /*$ var $x$Id = "$newguid$" + x.ToString();
898 /// x.DoSomething($x$Id); */
899 /// }
900 /// </code>
901 /// </example>
902 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)]
903 public sealed class MacroAttribute : Attribute
904 {
905 #region Public Enums, Properties and Fields
906  
907 /// <summary>
908 /// Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see>
909 /// parameter when the template is expanded.
910 /// </summary>
911 [CanBeNull]
912 public string Expression { get; set; }
913  
914 /// <summary>
915 /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
916 /// </summary>
917 /// <remarks>
918 /// If the target parameter is used several times in the template, only one occurrence becomes editable;
919 /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence,
920 /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1.
921 /// </remarks>
922 public int Editable { get; set; }
923  
924 /// <summary>
925 /// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the
926 /// <see cref="MacroAttribute" /> is applied on a template method.
927 /// </summary>
928 [CanBeNull]
929 public string Target { get; set; }
930  
931 #endregion
932 }
933  
934 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
935 AllowMultiple = true)]
936 public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
937 {
938 #region Public Enums, Properties and Fields
939  
940 [NotNull]
941 public string Format { get; }
942  
943 #endregion
944  
945 #region Constructors, Destructors and Finalizers
946  
947 public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format)
948 {
949 Format = format;
950 }
951  
952 #endregion
953 }
954  
955 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
956 AllowMultiple = true)]
957 public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
958 {
959 #region Public Enums, Properties and Fields
960  
961 [NotNull]
962 public string Format { get; }
963  
964 #endregion
965  
966 #region Constructors, Destructors and Finalizers
967  
968 public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format)
969 {
970 Format = format;
971 }
972  
973 #endregion
974 }
975  
976 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
977 AllowMultiple = true)]
978 public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
979 {
980 #region Public Enums, Properties and Fields
981  
982 [NotNull]
983 public string Format { get; }
984  
985 #endregion
986  
987 #region Constructors, Destructors and Finalizers
988  
989 public AspMvcAreaViewLocationFormatAttribute([NotNull] string format)
990 {
991 Format = format;
992 }
993  
994 #endregion
995 }
996  
997 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
998 AllowMultiple = true)]
999 public sealed class AspMvcMasterLocationFormatAttribute : Attribute
1000 {
1001 #region Public Enums, Properties and Fields
1002  
1003 [NotNull]
1004 public string Format { get; }
1005  
1006 #endregion
1007  
1008 #region Constructors, Destructors and Finalizers
1009  
1010 public AspMvcMasterLocationFormatAttribute([NotNull] string format)
1011 {
1012 Format = format;
1013 }
1014  
1015 #endregion
1016 }
1017  
1018 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1019 AllowMultiple = true)]
1020 public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
1021 {
1022 #region Public Enums, Properties and Fields
1023  
1024 [NotNull]
1025 public string Format { get; }
1026  
1027 #endregion
1028  
1029 #region Constructors, Destructors and Finalizers
1030  
1031 public AspMvcPartialViewLocationFormatAttribute([NotNull] string format)
1032 {
1033 Format = format;
1034 }
1035  
1036 #endregion
1037 }
1038  
1039 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1040 AllowMultiple = true)]
1041 public sealed class AspMvcViewLocationFormatAttribute : Attribute
1042 {
1043 #region Public Enums, Properties and Fields
1044  
1045 [NotNull]
1046 public string Format { get; }
1047  
1048 #endregion
1049  
1050 #region Constructors, Destructors and Finalizers
1051  
1052 public AspMvcViewLocationFormatAttribute([NotNull] string format)
1053 {
1054 Format = format;
1055 }
1056  
1057 #endregion
1058 }
1059  
1060 /// <summary>
1061 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1062 /// is an MVC action. If applied to a method, the MVC action name is calculated
1063 /// implicitly from the context. Use this attribute for custom wrappers similar to
1064 /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
1065 /// </summary>
1066 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1067 AttributeTargets.Property)]
1068 public sealed class AspMvcActionAttribute : Attribute
1069 {
1070 #region Public Enums, Properties and Fields
1071  
1072 [CanBeNull]
1073 public string AnonymousProperty { get; }
1074  
1075 #endregion
1076  
1077 #region Constructors, Destructors and Finalizers
1078  
1079 public AspMvcActionAttribute()
1080 {
1081 }
1082  
1083 public AspMvcActionAttribute([NotNull] string anonymousProperty)
1084 {
1085 AnonymousProperty = anonymousProperty;
1086 }
1087  
1088 #endregion
1089 }
1090  
1091 /// <summary>
1092 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC area.
1093 /// Use this attribute for custom wrappers similar to
1094 /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
1095 /// </summary>
1096 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1097 public sealed class AspMvcAreaAttribute : Attribute
1098 {
1099 #region Public Enums, Properties and Fields
1100  
1101 [CanBeNull]
1102 public string AnonymousProperty { get; }
1103  
1104 #endregion
1105  
1106 #region Constructors, Destructors and Finalizers
1107  
1108 public AspMvcAreaAttribute()
1109 {
1110 }
1111  
1112 public AspMvcAreaAttribute([NotNull] string anonymousProperty)
1113 {
1114 AnonymousProperty = anonymousProperty;
1115 }
1116  
1117 #endregion
1118 }
1119  
1120 /// <summary>
1121 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is
1122 /// an MVC controller. If applied to a method, the MVC controller name is calculated
1123 /// implicitly from the context. Use this attribute for custom wrappers similar to
1124 /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>.
1125 /// </summary>
1126 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1127 AttributeTargets.Property)]
1128 public sealed class AspMvcControllerAttribute : Attribute
1129 {
1130 #region Public Enums, Properties and Fields
1131  
1132 [CanBeNull]
1133 public string AnonymousProperty { get; }
1134  
1135 #endregion
1136  
1137 #region Constructors, Destructors and Finalizers
1138  
1139 public AspMvcControllerAttribute()
1140 {
1141 }
1142  
1143 public AspMvcControllerAttribute([NotNull] string anonymousProperty)
1144 {
1145 AnonymousProperty = anonymousProperty;
1146 }
1147  
1148 #endregion
1149 }
1150  
1151 /// <summary>
1152 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC Master. Use this attribute
1153 /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.
1154 /// </summary>
1155 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1156 public sealed class AspMvcMasterAttribute : Attribute
1157 {
1158 }
1159  
1160 /// <summary>
1161 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC model type. Use this attribute
1162 /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>.
1163 /// </summary>
1164 [AttributeUsage(AttributeTargets.Parameter)]
1165 public sealed class AspMvcModelTypeAttribute : Attribute
1166 {
1167 }
1168  
1169 /// <summary>
1170 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC
1171 /// partial view. If applied to a method, the MVC partial view name is calculated implicitly
1172 /// from the context. Use this attribute for custom wrappers similar to
1173 /// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.
1174 /// </summary>
1175 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1176 AttributeTargets.Property)]
1177 public sealed class AspMvcPartialViewAttribute : Attribute
1178 {
1179 }
1180  
1181 /// <summary>
1182 /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.
1183 /// </summary>
1184 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
1185 public sealed class AspMvcSuppressViewErrorAttribute : Attribute
1186 {
1187 }
1188  
1189 /// <summary>
1190 /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
1191 /// Use this attribute for custom wrappers similar to
1192 /// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.
1193 /// </summary>
1194 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1195 public sealed class AspMvcDisplayTemplateAttribute : Attribute
1196 {
1197 }
1198  
1199 /// <summary>
1200 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC editor template.
1201 /// Use this attribute for custom wrappers similar to
1202 /// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>.
1203 /// </summary>
1204 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1205 public sealed class AspMvcEditorTemplateAttribute : Attribute
1206 {
1207 }
1208  
1209 /// <summary>
1210 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC template.
1211 /// Use this attribute for custom wrappers similar to
1212 /// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.
1213 /// </summary>
1214 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1215 public sealed class AspMvcTemplateAttribute : Attribute
1216 {
1217 }
1218  
1219 /// <summary>
1220 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1221 /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly
1222 /// from the context. Use this attribute for custom wrappers similar to
1223 /// <c>System.Web.Mvc.Controller.View(Object)</c>.
1224 /// </summary>
1225 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1226 AttributeTargets.Property)]
1227 public sealed class AspMvcViewAttribute : Attribute
1228 {
1229 }
1230  
1231 /// <summary>
1232 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1233 /// is an MVC view component name.
1234 /// </summary>
1235 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1236 public sealed class AspMvcViewComponentAttribute : Attribute
1237 {
1238 }
1239  
1240 /// <summary>
1241 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1242 /// is an MVC view component view. If applied to a method, the MVC view component view name is default.
1243 /// </summary>
1244 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1245 AttributeTargets.Property)]
1246 public sealed class AspMvcViewComponentViewAttribute : Attribute
1247 {
1248 }
1249  
1250 /// <summary>
1251 /// ASP.NET MVC attribute. When applied to a parameter of an attribute,
1252 /// indicates that this parameter is an MVC action name.
1253 /// </summary>
1254 /// <example>
1255 /// <code>
1256 /// [ActionName("Foo")]
1257 /// public ActionResult Login(string returnUrl) {
1258 /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
1259 /// return RedirectToAction("Bar"); // Error: Cannot resolve action
1260 /// }
1261 /// </code>
1262 /// </example>
1263 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
1264 public sealed class AspMvcActionSelectorAttribute : Attribute
1265 {
1266 }
1267  
1268 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]
1269 public sealed class HtmlElementAttributesAttribute : Attribute
1270 {
1271 #region Public Enums, Properties and Fields
1272  
1273 [CanBeNull]
1274 public string Name { get; }
1275  
1276 #endregion
1277  
1278 #region Constructors, Destructors and Finalizers
1279  
1280 public HtmlElementAttributesAttribute()
1281 {
1282 }
1283  
1284 public HtmlElementAttributesAttribute([NotNull] string name)
1285 {
1286 Name = name;
1287 }
1288  
1289 #endregion
1290 }
1291  
1292 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1293 public sealed class HtmlAttributeValueAttribute : Attribute
1294 {
1295 #region Public Enums, Properties and Fields
1296  
1297 [NotNull]
1298 public string Name { get; }
1299  
1300 #endregion
1301  
1302 #region Constructors, Destructors and Finalizers
1303  
1304 public HtmlAttributeValueAttribute([NotNull] string name)
1305 {
1306 Name = name;
1307 }
1308  
1309 #endregion
1310 }
1311  
1312 /// <summary>
1313 /// Razor attribute. Indicates that the marked parameter or method is a Razor section.
1314 /// Use this attribute for custom wrappers similar to
1315 /// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>.
1316 /// </summary>
1317 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
1318 public sealed class RazorSectionAttribute : Attribute
1319 {
1320 }
1321  
1322 /// <summary>
1323 /// Indicates how method, constructor invocation, or property access
1324 /// over collection type affects the contents of the collection.
1325 /// Use <see cref="CollectionAccessType" /> to specify the access type.
1326 /// </summary>
1327 /// <remarks>
1328 /// Using this attribute only makes sense if all collection methods are marked with this attribute.
1329 /// </remarks>
1330 /// <example>
1331 /// <code>
1332 /// public class MyStringCollection : List&lt;string&gt;
1333 /// {
1334 /// [CollectionAccess(CollectionAccessType.Read)]
1335 /// public string GetFirstString()
1336 /// {
1337 /// return this.ElementAt(0);
1338 /// }
1339 /// }
1340 /// class Test
1341 /// {
1342 /// public void Foo()
1343 /// {
1344 /// // Warning: Contents of the collection is never updated
1345 /// var col = new MyStringCollection();
1346 /// string x = col.GetFirstString();
1347 /// }
1348 /// }
1349 /// </code>
1350 /// </example>
1351 [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)]
1352 public sealed class CollectionAccessAttribute : Attribute
1353 {
1354 #region Public Enums, Properties and Fields
1355  
1356 public CollectionAccessType CollectionAccessType { get; }
1357  
1358 #endregion
1359  
1360 #region Constructors, Destructors and Finalizers
1361  
1362 public CollectionAccessAttribute(CollectionAccessType collectionAccessType)
1363 {
1364 CollectionAccessType = collectionAccessType;
1365 }
1366  
1367 #endregion
1368 }
1369  
1370 /// <summary>
1371 /// Provides a value for the <see cref="CollectionAccessAttribute" /> to define
1372 /// how the collection method invocation affects the contents of the collection.
1373 /// </summary>
1374 [Flags]
1375 public enum CollectionAccessType
1376 {
1377 /// <summary>Method does not use or modify content of the collection.</summary>
1378 None = 0,
1379  
1380 /// <summary>Method only reads content of the collection but does not modify it.</summary>
1381 Read = 1,
1382  
1383 /// <summary>Method can change content of the collection but does not add new elements.</summary>
1384 ModifyExistingContent = 2,
1385  
1386 /// <summary>Method can add new elements to the collection.</summary>
1387 UpdatedContent = ModifyExistingContent | 4
1388 }
1389  
1390 /// <summary>
1391 /// Indicates that the marked method is assertion method, i.e. it halts the control flow if
1392 /// one of the conditions is satisfied. To set the condition, mark one of the parameters with
1393 /// <see cref="AssertionConditionAttribute" /> attribute.
1394 /// </summary>
1395 [AttributeUsage(AttributeTargets.Method)]
1396 public sealed class AssertionMethodAttribute : Attribute
1397 {
1398 }
1399  
1400 /// <summary>
1401 /// Indicates the condition parameter of the assertion method. The method itself should be
1402 /// marked by <see cref="AssertionMethodAttribute" /> attribute. The mandatory argument of
1403 /// the attribute is the assertion type.
1404 /// </summary>
1405 [AttributeUsage(AttributeTargets.Parameter)]
1406 public sealed class AssertionConditionAttribute : Attribute
1407 {
1408 #region Public Enums, Properties and Fields
1409  
1410 public AssertionConditionType ConditionType { get; }
1411  
1412 #endregion
1413  
1414 #region Constructors, Destructors and Finalizers
1415  
1416 public AssertionConditionAttribute(AssertionConditionType conditionType)
1417 {
1418 ConditionType = conditionType;
1419 }
1420  
1421 #endregion
1422 }
1423  
1424 /// <summary>
1425 /// Specifies assertion type. If the assertion method argument satisfies the condition,
1426 /// then the execution continues. Otherwise, execution is assumed to be halted.
1427 /// </summary>
1428 public enum AssertionConditionType
1429 {
1430 /// <summary>Marked parameter should be evaluated to true.</summary>
1431 IS_TRUE = 0,
1432  
1433 /// <summary>Marked parameter should be evaluated to false.</summary>
1434 IS_FALSE = 1,
1435  
1436 /// <summary>Marked parameter should be evaluated to null value.</summary>
1437 IS_NULL = 2,
1438  
1439 /// <summary>Marked parameter should be evaluated to not null value.</summary>
1440 IS_NOT_NULL = 3
1441 }
1442  
1443 /// <summary>
1444 /// Indicates that the marked method unconditionally terminates control flow execution.
1445 /// For example, it could unconditionally throw exception.
1446 /// </summary>
1447 [Obsolete("Use [ContractAnnotation('=> halt')] instead")]
1448 [AttributeUsage(AttributeTargets.Method)]
1449 public sealed class TerminatesProgramAttribute : Attribute
1450 {
1451 }
1452  
1453 /// <summary>
1454 /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select,
1455 /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters
1456 /// of delegate type by analyzing LINQ method chains.
1457 /// </summary>
1458 [AttributeUsage(AttributeTargets.Method)]
1459 public sealed class LinqTunnelAttribute : Attribute
1460 {
1461 }
1462  
1463 /// <summary>
1464 /// Indicates that IEnumerable passed as a parameter is not enumerated.
1465 /// Use this annotation to suppress the 'Possible multiple enumeration of IEnumerable' inspection.
1466 /// </summary>
1467 /// <example>
1468 /// <code>
1469 /// static void ThrowIfNull&lt;T&gt;([NoEnumeration] T v, string n) where T : class
1470 /// {
1471 /// // custom check for null but no enumeration
1472 /// }
1473 ///
1474 /// void Foo(IEnumerable&lt;string&gt; values)
1475 /// {
1476 /// ThrowIfNull(values, nameof(values));
1477 /// var x = values.ToList(); // No warnings about multiple enumeration
1478 /// }
1479 /// </code>
1480 /// </example>
1481 [AttributeUsage(AttributeTargets.Parameter)]
1482 public sealed class NoEnumerationAttribute : Attribute
1483 {
1484 }
1485  
1486 /// <summary>
1487 /// Indicates that the marked parameter is a regular expression pattern.
1488 /// </summary>
1489 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1490 public sealed class RegexPatternAttribute : Attribute
1491 {
1492 }
1493  
1494 /// <summary>
1495 /// Prevents the Member Reordering feature from tossing members of the marked class.
1496 /// </summary>
1497 /// <remarks>
1498 /// The attribute must be mentioned in your member reordering patterns.
1499 /// </remarks>
1500 [AttributeUsage(
1501 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)]
1502 public sealed class NoReorderAttribute : Attribute
1503 {
1504 }
1505  
1506 /// <summary>
1507 /// XAML attribute. Indicates the type that has <c>ItemsSource</c> property and should be treated
1508 /// as <c>ItemsControl</c>-derived type, to enable inner items <c>DataContext</c> type resolve.
1509 /// </summary>
1510 [AttributeUsage(AttributeTargets.Class)]
1511 public sealed class XamlItemsControlAttribute : Attribute
1512 {
1513 }
1514  
1515 /// <summary>
1516 /// XAML attribute. Indicates the property of some <c>BindingBase</c>-derived type, that
1517 /// is used to bind some item of <c>ItemsControl</c>-derived type. This annotation will
1518 /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
1519 /// </summary>
1520 /// <remarks>
1521 /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
1522 /// marked with the <see cref="XamlItemsControlAttribute" /> attribute.
1523 /// </remarks>
1524 [AttributeUsage(AttributeTargets.Property)]
1525 public sealed class XamlItemBindingOfItemsControlAttribute : Attribute
1526 {
1527 }
1528  
1529 /// <summary>
1530 /// XAML attribute. Indicates the property of some <c>Style</c>-derived type, that
1531 /// is used to style items of <c>ItemsControl</c>-derived type. This annotation will
1532 /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
1533 /// </summary>
1534 /// <remarks>
1535 /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
1536 /// marked with the <see cref="XamlItemsControlAttribute" /> attribute.
1537 /// </remarks>
1538 [AttributeUsage(AttributeTargets.Property)]
1539 public sealed class XamlItemStyleOfItemsControlAttribute : Attribute
1540 {
1541 }
1542  
1543 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
1544 public sealed class AspChildControlTypeAttribute : Attribute
1545 {
1546 #region Public Enums, Properties and Fields
1547  
1548 [NotNull]
1549 public string TagName { get; }
1550  
1551 [NotNull]
1552 public Type ControlType { get; }
1553  
1554 #endregion
1555  
1556 #region Constructors, Destructors and Finalizers
1557  
1558 public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType)
1559 {
1560 TagName = tagName;
1561 ControlType = controlType;
1562 }
1563  
1564 #endregion
1565 }
1566  
1567 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
1568 public sealed class AspDataFieldAttribute : Attribute
1569 {
1570 }
1571  
1572 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
1573 public sealed class AspDataFieldsAttribute : Attribute
1574 {
1575 }
1576  
1577 [AttributeUsage(AttributeTargets.Property)]
1578 public sealed class AspMethodPropertyAttribute : Attribute
1579 {
1580 }
1581  
1582 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
1583 public sealed class AspRequiredAttributeAttribute : Attribute
1584 {
1585 #region Public Enums, Properties and Fields
1586  
1587 [NotNull]
1588 public string Attribute { get; }
1589  
1590 #endregion
1591  
1592 #region Constructors, Destructors and Finalizers
1593  
1594 public AspRequiredAttributeAttribute([NotNull] string attribute)
1595 {
1596 Attribute = attribute;
1597 }
1598  
1599 #endregion
1600 }
1601  
1602 [AttributeUsage(AttributeTargets.Property)]
1603 public sealed class AspTypePropertyAttribute : Attribute
1604 {
1605 #region Public Enums, Properties and Fields
1606  
1607 public bool CreateConstructorReferences { get; }
1608  
1609 #endregion
1610  
1611 #region Constructors, Destructors and Finalizers
1612  
1613 public AspTypePropertyAttribute(bool createConstructorReferences)
1614 {
1615 CreateConstructorReferences = createConstructorReferences;
1616 }
1617  
1618 #endregion
1619 }
1620  
1621 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1622 public sealed class RazorImportNamespaceAttribute : Attribute
1623 {
1624 #region Public Enums, Properties and Fields
1625  
1626 [NotNull]
1627 public string Name { get; }
1628  
1629 #endregion
1630  
1631 #region Constructors, Destructors and Finalizers
1632  
1633 public RazorImportNamespaceAttribute([NotNull] string name)
1634 {
1635 Name = name;
1636 }
1637  
1638 #endregion
1639 }
1640  
1641 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1642 public sealed class RazorInjectionAttribute : Attribute
1643 {
1644 #region Public Enums, Properties and Fields
1645  
1646 [NotNull]
1647 public string Type { get; }
1648  
1649 [NotNull]
1650 public string FieldName { get; }
1651  
1652 #endregion
1653  
1654 #region Constructors, Destructors and Finalizers
1655  
1656 public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName)
1657 {
1658 Type = type;
1659 FieldName = fieldName;
1660 }
1661  
1662 #endregion
1663 }
1664  
1665 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1666 public sealed class RazorDirectiveAttribute : Attribute
1667 {
1668 #region Public Enums, Properties and Fields
1669  
1670 [NotNull]
1671 public string Directive { get; }
1672  
1673 #endregion
1674  
1675 #region Constructors, Destructors and Finalizers
1676  
1677 public RazorDirectiveAttribute([NotNull] string directive)
1678 {
1679 Directive = directive;
1680 }
1681  
1682 #endregion
1683 }
1684  
1685 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1686 public sealed class RazorPageBaseTypeAttribute : Attribute
1687 {
1688 #region Public Enums, Properties and Fields
1689  
1690 [NotNull]
1691 public string BaseType { get; }
1692  
1693 [CanBeNull]
1694 public string PageName { get; }
1695  
1696 #endregion
1697  
1698 #region Constructors, Destructors and Finalizers
1699  
1700 public RazorPageBaseTypeAttribute([NotNull] string baseType)
1701 {
1702 BaseType = baseType;
1703 }
1704  
1705 public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName)
1706 {
1707 BaseType = baseType;
1708 PageName = pageName;
1709 }
1710  
1711 #endregion
1712 }
1713  
1714 [AttributeUsage(AttributeTargets.Method)]
1715 public sealed class RazorHelperCommonAttribute : Attribute
1716 {
1717 }
1718  
1719 [AttributeUsage(AttributeTargets.Property)]
1720 public sealed class RazorLayoutAttribute : Attribute
1721 {
1722 }
1723  
1724 [AttributeUsage(AttributeTargets.Method)]
1725 public sealed class RazorWriteLiteralMethodAttribute : Attribute
1726 {
1727 }
1728  
1729 [AttributeUsage(AttributeTargets.Method)]
1730 public sealed class RazorWriteMethodAttribute : Attribute
1731 {
1732 }
1733  
1734 [AttributeUsage(AttributeTargets.Parameter)]
1735 public sealed class RazorWriteMethodParameterAttribute : Attribute
1736 {
1737 }
1738 }