Winify – Blame information for rev 28

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