Spring – Blame information for rev 1

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