Winify – Blame information for rev 30

Subversion Repositories:
Rev:
Rev Author Line No. Line
30 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 #nullable disable
24  
25 using System;
26  
27 // ReSharper disable UnusedType.Global
28  
29 #pragma warning disable 1591
30 // ReSharper disable UnusedMember.Global
31 // ReSharper disable MemberCanBePrivate.Global
32 // ReSharper disable UnusedAutoPropertyAccessor.Global
33 // ReSharper disable IntroduceOptionalParameters.Global
34 // ReSharper disable MemberCanBeProtected.Global
35 // ReSharper disable InconsistentNaming
36  
37 namespace Configuration.Annotations
38 {
39 /// <summary>
40 /// Indicates that the value of the marked element could be <c>null</c> sometimes,
41 /// so checking for <c>null</c> is required before its usage.
42 /// </summary>
43 /// <example>
44 /// <code>
45 /// [CanBeNull] object Test() => null;
46 ///
47 /// void UseTest() {
48 /// var p = Test();
49 /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
50 /// }
51 /// </code>
52 /// </example>
53 [AttributeUsage(
54 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
55 AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
56 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
57 public sealed class CanBeNullAttribute : Attribute
58 {
59 }
60  
61 /// <summary>
62 /// Indicates that the value of the marked element can never be <c>null</c>.
63 /// </summary>
64 /// <example>
65 /// <code>
66 /// [NotNull] object Foo() {
67 /// return null; // Warning: Possible 'null' assignment
68 /// }
69 /// </code>
70 /// </example>
71 [AttributeUsage(
72 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
73 AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
74 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
75 public sealed class NotNullAttribute : Attribute
76 {
77 }
78  
79 /// <summary>
80 /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
81 /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
82 /// or of the Lazy.Value property can never be null.
83 /// </summary>
84 /// <example>
85 /// <code>
86 /// public void Foo([ItemNotNull]List&lt;string&gt; books)
87 /// {
88 /// foreach (var book in books) {
89 /// if (book != null) // Warning: Expression is always true
90 /// Console.WriteLine(book.ToUpper());
91 /// }
92 /// }
93 /// </code>
94 /// </example>
95 [AttributeUsage(
96 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
97 AttributeTargets.Delegate | AttributeTargets.Field)]
98 public sealed class ItemNotNullAttribute : Attribute
99 {
100 }
101  
102 /// <summary>
103 /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
104 /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
105 /// or of the Lazy.Value property can be null.
106 /// </summary>
107 /// <example>
108 /// <code>
109 /// public void Foo([ItemCanBeNull]List&lt;string&gt; books)
110 /// {
111 /// foreach (var book in books)
112 /// {
113 /// // Warning: Possible 'System.NullReferenceException'
114 /// Console.WriteLine(book.ToUpper());
115 /// }
116 /// }
117 /// </code>
118 /// </example>
119 [AttributeUsage(
120 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
121 AttributeTargets.Delegate | AttributeTargets.Field)]
122 public sealed class ItemCanBeNullAttribute : Attribute
123 {
124 }
125  
126 /// <summary>
127 /// Indicates that the marked method builds string by the format pattern and (optional) arguments.
128 /// The parameter, which contains the format string, should be given in the constructor. The format string
129 /// should be in <see cref="string.Format(IFormatProvider,string,object[])" />-like form.
130 /// </summary>
131 /// <example>
132 /// <code>
133 /// [StringFormatMethod("message")]
134 /// void ShowError(string message, params object[] args) { /* do something */ }
135 ///
136 /// void Foo() {
137 /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
138 /// }
139 /// </code>
140 /// </example>
141 [AttributeUsage(
142 AttributeTargets.Constructor | AttributeTargets.Method |
143 AttributeTargets.Property | AttributeTargets.Delegate)]
144 public sealed class StringFormatMethodAttribute : Attribute
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 [NotNull] public string FormatParameterName { get; }
155 }
156  
157 /// <summary>
158 /// Indicates that the marked parameter is a message template where placeholders are to be replaced by the following
159 /// arguments
160 /// in the order in which they appear
161 /// </summary>
162 /// <example>
163 /// <code>
164 /// void LogInfo([StructuredMessageTemplate]string message, params object[] args) { /* do something */ }
165 ///
166 /// void Foo() {
167 /// LogInfo("User created: {username}"); // Warning: Non-existing argument in format string
168 /// }
169 /// </code>
170 /// </example>
171 [AttributeUsage(AttributeTargets.Parameter)]
172 public sealed class StructuredMessageTemplateAttribute : Attribute
173 {
174 }
175  
176 /// <summary>
177 /// Use this annotation to specify a type that contains static or const fields
178 /// with values for the annotated property/field/parameter.
179 /// The specified type will be used to improve completion suggestions.
180 /// </summary>
181 /// <example>
182 /// <code>
183 /// namespace TestNamespace
184 /// {
185 /// public class Constants
186 /// {
187 /// public static int INT_CONST = 1;
188 /// public const string STRING_CONST = "1";
189 /// }
190 ///
191 /// public class Class1
192 /// {
193 /// [ValueProvider("TestNamespace.Constants")] public int myField;
194 /// public void Foo([ValueProvider("TestNamespace.Constants")] string str) { }
195 ///
196 /// public void Test()
197 /// {
198 /// Foo(/*try completion here*/);//
199 /// myField = /*try completion here*/
200 /// }
201 /// }
202 /// }
203 /// </code>
204 /// </example>
205 [AttributeUsage(
206 AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field,
207 AllowMultiple = true)]
208 public sealed class ValueProviderAttribute : Attribute
209 {
210 public ValueProviderAttribute([NotNull] string name)
211 {
212 Name = name;
213 }
214  
215 [NotNull] public string Name { get; }
216 }
217  
218 /// <summary>
219 /// Indicates that the integral value falls into the specified interval.
220 /// It's allowed to specify multiple non-intersecting intervals.
221 /// Values of interval boundaries are inclusive.
222 /// </summary>
223 /// <example>
224 /// <code>
225 /// void Foo([ValueRange(0, 100)] int value) {
226 /// if (value == -1) { // Warning: Expression is always 'false'
227 /// ...
228 /// }
229 /// }
230 /// </code>
231 /// </example>
232 [AttributeUsage(
233 AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |
234 AttributeTargets.Method | AttributeTargets.Delegate,
235 AllowMultiple = true)]
236 public sealed class ValueRangeAttribute : Attribute
237 {
238 public ValueRangeAttribute(long from, long to)
239 {
240 From = from;
241 To = to;
242 }
243  
244 public ValueRangeAttribute(ulong from, ulong to)
245 {
246 From = from;
247 To = to;
248 }
249  
250 public ValueRangeAttribute(long value)
251 {
252 From = To = value;
253 }
254  
255 public ValueRangeAttribute(ulong value)
256 {
257 From = To = value;
258 }
259  
260 public object From { get; }
261 public object To { get; }
262 }
263  
264 /// <summary>
265 /// Indicates that the integral value never falls below zero.
266 /// </summary>
267 /// <example>
268 /// <code>
269 /// void Foo([NonNegativeValue] int value) {
270 /// if (value == -1) { // Warning: Expression is always 'false'
271 /// ...
272 /// }
273 /// }
274 /// </code>
275 /// </example>
276 [AttributeUsage(
277 AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |
278 AttributeTargets.Method | AttributeTargets.Delegate)]
279 public sealed class NonNegativeValueAttribute : Attribute
280 {
281 }
282  
283 /// <summary>
284 /// Indicates that the function argument should be a string literal and match
285 /// one of the parameters of the caller function. This annotation is used for paramerers
286 /// like 'string paramName' parameter of the <see cref="System.ArgumentNullException" /> constuctor.
287 /// </summary>
288 /// <example>
289 /// <code>
290 /// void Foo(string param) {
291 /// if (param == null)
292 /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
293 /// }
294 /// </code>
295 /// </example>
296 [AttributeUsage(AttributeTargets.Parameter)]
297 public sealed class InvokerParameterNameAttribute : Attribute
298 {
299 }
300  
301 /// <summary>
302 /// Indicates that the method is contained in a type that implements
303 /// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method
304 /// is used to notify that some property value changed.
305 /// </summary>
306 /// <remarks>
307 /// The method should be non-static and conform to one of the supported signatures:
308 /// <list>
309 /// <item>
310 /// <c>NotifyChanged(string)</c>
311 /// </item>
312 /// <item>
313 /// <c>NotifyChanged(params string[])</c>
314 /// </item>
315 /// <item>
316 /// <c>NotifyChanged{T}(Expression{Func{T}})</c>
317 /// </item>
318 /// <item>
319 /// <c>NotifyChanged{T,U}(Expression{Func{T,U}})</c>
320 /// </item>
321 /// <item>
322 /// <c>SetProperty{T}(ref T, T, string)</c>
323 /// </item>
324 /// </list>
325 /// </remarks>
326 /// <example>
327 /// <code>
328 /// public class Foo : INotifyPropertyChanged {
329 /// public event PropertyChangedEventHandler PropertyChanged;
330 ///
331 /// [NotifyPropertyChangedInvocator]
332 /// protected virtual void NotifyChanged(string propertyName) { ... }
333 ///
334 /// string _name;
335 ///
336 /// public string Name {
337 /// get { return _name; }
338 /// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
339 /// }
340 /// }
341 /// </code>
342 /// Examples of generated notifications:
343 /// <list>
344 /// <item>
345 /// <c>NotifyChanged("Property")</c>
346 /// </item>
347 /// <item>
348 /// <c>NotifyChanged(() =&gt; Property)</c>
349 /// </item>
350 /// <item>
351 /// <c>NotifyChanged((VM x) =&gt; x.Property)</c>
352 /// </item>
353 /// <item>
354 /// <c>SetProperty(ref myField, value, "Property")</c>
355 /// </item>
356 /// </list>
357 /// </example>
358 [AttributeUsage(AttributeTargets.Method)]
359 public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
360 {
361 public NotifyPropertyChangedInvocatorAttribute()
362 {
363 }
364  
365 public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
366 {
367 ParameterName = parameterName;
368 }
369  
370 [CanBeNull] public string ParameterName { get; }
371 }
372  
373 /// <summary>
374 /// Describes dependency between method input and output.
375 /// </summary>
376 /// <syntax>
377 /// <p>Function Definition Table syntax:</p>
378 /// <list>
379 /// <item>FDT ::= FDTRow [;FDTRow]*</item>
380 /// <item>FDTRow ::= Input =&gt; Output | Output &lt;= Input</item>
381 /// <item>Input ::= ParameterName: Value [, Input]*</item>
382 /// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>
383 /// <item>Value ::= true | false | null | notnull | canbenull</item>
384 /// </list>
385 /// If the method has a single input parameter, its name could be omitted.<br />
386 /// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for the method output
387 /// means that the method doesn't return normally (throws or terminates the process).<br />
388 /// Value <c>canbenull</c> is only applicable for output parameters.<br />
389 /// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute
390 /// with rows separated by the semicolon. There is no notion of order rows, all rows are checked
391 /// for applicability and applied per each program state tracked by the analysis engine.<br />
392 /// </syntax>
393 /// <examples>
394 /// <list>
395 /// <item>
396 /// <code>
397 /// [ContractAnnotation("=&gt; halt")]
398 /// public void TerminationMethod()
399 /// </code>
400 /// </item>
401 /// <item>
402 /// <code>
403 /// [ContractAnnotation("null &lt;= param:null")] // reverse condition syntax
404 /// public string GetName(string surname)
405 /// </code>
406 /// </item>
407 /// <item>
408 /// <code>
409 /// [ContractAnnotation("s:null =&gt; true")]
410 /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
411 /// </code>
412 /// </item>
413 /// <item>
414 /// <code>
415 /// // A method that returns null if the parameter is null,
416 /// // and not null if the parameter is not null
417 /// [ContractAnnotation("null =&gt; null; notnull =&gt; notnull")]
418 /// public object Transform(object data)
419 /// </code>
420 /// </item>
421 /// <item>
422 /// <code>
423 /// [ContractAnnotation("=&gt; true, result: notnull; =&gt; false, result: null")]
424 /// public bool TryParse(string s, out Person result)
425 /// </code>
426 /// </item>
427 /// </list>
428 /// </examples>
429 [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
430 public sealed class ContractAnnotationAttribute : Attribute
431 {
432 public ContractAnnotationAttribute([NotNull] string contract)
433 : this(contract, false)
434 {
435 }
436  
437 public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
438 {
439 Contract = contract;
440 ForceFullStates = forceFullStates;
441 }
442  
443 [NotNull] public string Contract { get; }
444  
445 public bool ForceFullStates { get; }
446 }
447  
448 /// <summary>
449 /// Indicates whether the marked element should be localized.
450 /// </summary>
451 /// <example>
452 /// <code>
453 /// [LocalizationRequiredAttribute(true)]
454 /// class Foo {
455 /// string str = "my string"; // Warning: Localizable string
456 /// }
457 /// </code>
458 /// </example>
459 [AttributeUsage(AttributeTargets.All)]
460 public sealed class LocalizationRequiredAttribute : Attribute
461 {
462 public LocalizationRequiredAttribute() : this(true)
463 {
464 }
465  
466 public LocalizationRequiredAttribute(bool required)
467 {
468 Required = required;
469 }
470  
471 public bool Required { get; }
472 }
473  
474 /// <summary>
475 /// Indicates that the value of the marked type (or its derivatives)
476 /// cannot be compared using '==' or '!=' operators and <c>Equals()</c>
477 /// should be used instead. However, using '==' or '!=' for comparison
478 /// with <c>null</c> is always permitted.
479 /// </summary>
480 /// <example>
481 /// <code>
482 /// [CannotApplyEqualityOperator]
483 /// class NoEquality { }
484 ///
485 /// class UsesNoEquality {
486 /// void Test() {
487 /// var ca1 = new NoEquality();
488 /// var ca2 = new NoEquality();
489 /// if (ca1 != null) { // OK
490 /// bool condition = ca1 == ca2; // Warning
491 /// }
492 /// }
493 /// }
494 /// </code>
495 /// </example>
496 [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]
497 public sealed class CannotApplyEqualityOperatorAttribute : Attribute
498 {
499 }
500  
501 /// <summary>
502 /// When applied to a target attribute, specifies a requirement for any type marked
503 /// with the target attribute to implement or inherit specific type or types.
504 /// </summary>
505 /// <example>
506 /// <code>
507 /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
508 /// class ComponentAttribute : Attribute { }
509 ///
510 /// [Component] // ComponentAttribute requires implementing IComponent interface
511 /// class MyComponent : IComponent { }
512 /// </code>
513 /// </example>
514 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
515 [BaseTypeRequired(typeof(Attribute))]
516 public sealed class BaseTypeRequiredAttribute : Attribute
517 {
518 public BaseTypeRequiredAttribute([NotNull] Type baseType)
519 {
520 BaseType = baseType;
521 }
522  
523 [NotNull] public Type BaseType { get; }
524 }
525  
526 /// <summary>
527 /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library),
528 /// so this symbol will be ignored by usage-checking inspections. <br />
529 /// You can use <see cref="ImplicitUseKindFlags" /> and <see cref="ImplicitUseTargetFlags" />
530 /// to configure how this attribute is applied.
531 /// </summary>
532 /// <example>
533 /// <code>
534 /// [UsedImplicitly]
535 /// public class TypeConverter {}
536 ///
537 /// public class SummaryData
538 /// {
539 /// [UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
540 /// public SummaryData() {}
541 /// }
542 ///
543 /// [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors | ImplicitUseTargetFlags.Default)]
544 /// public interface IService {}
545 /// </code>
546 /// </example>
547 [AttributeUsage(AttributeTargets.All)]
548 public sealed class UsedImplicitlyAttribute : Attribute
549 {
550 public UsedImplicitlyAttribute()
551 : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
552 {
553 }
554  
555 public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
556 : this(useKindFlags, ImplicitUseTargetFlags.Default)
557 {
558 }
559  
560 public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
561 : this(ImplicitUseKindFlags.Default, targetFlags)
562 {
563 }
564  
565 public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
566 {
567 UseKindFlags = useKindFlags;
568 TargetFlags = targetFlags;
569 }
570  
571 public ImplicitUseKindFlags UseKindFlags { get; }
572  
573 public ImplicitUseTargetFlags TargetFlags { get; }
574 }
575  
576 /// <summary>
577 /// Can be applied to attributes, type parameters, and parameters of a type assignable from <see cref="System.Type" />
578 /// .
579 /// When applied to an attribute, the decorated attribute behaves the same as <see cref="UsedImplicitlyAttribute" />.
580 /// When applied to a type parameter or to a parameter of type <see cref="System.Type" />,
581 /// indicates that the corresponding type is used implicitly.
582 /// </summary>
583 [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter | AttributeTargets.Parameter)]
584 public sealed class MeansImplicitUseAttribute : Attribute
585 {
586 public MeansImplicitUseAttribute()
587 : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
588 {
589 }
590  
591 public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
592 : this(useKindFlags, ImplicitUseTargetFlags.Default)
593 {
594 }
595  
596 public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
597 : this(ImplicitUseKindFlags.Default, targetFlags)
598 {
599 }
600  
601 public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
602 {
603 UseKindFlags = useKindFlags;
604 TargetFlags = targetFlags;
605 }
606  
607 [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; }
608  
609 [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; }
610 }
611  
612 /// <summary>
613 /// Specifies the details of implicitly used symbol when it is marked
614 /// with <see cref="MeansImplicitUseAttribute" /> or <see cref="UsedImplicitlyAttribute" />.
615 /// </summary>
616 [Flags]
617 public enum ImplicitUseKindFlags
618 {
619 Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
620  
621 /// <summary>Only entity marked with attribute considered used.</summary>
622 Access = 1,
623  
624 /// <summary>Indicates implicit assignment to a member.</summary>
625 Assign = 2,
626  
627 /// <summary>
628 /// Indicates implicit instantiation of a type with fixed constructor signature.
629 /// That means any unused constructor parameters won't be reported as such.
630 /// </summary>
631 InstantiatedWithFixedConstructorSignature = 4,
632  
633 /// <summary>Indicates implicit instantiation of a type.</summary>
634 InstantiatedNoFixedConstructorSignature = 8
635 }
636  
637 /// <summary>
638 /// Specifies what is considered to be used implicitly when marked
639 /// with <see cref="MeansImplicitUseAttribute" /> or <see cref="UsedImplicitlyAttribute" />.
640 /// </summary>
641 [Flags]
642 public enum ImplicitUseTargetFlags
643 {
644 Default = Itself,
645 Itself = 1,
646  
647 /// <summary>Members of the type marked with the attribute are considered used.</summary>
648 Members = 2,
649  
650 /// <summary> Inherited entities are considered used. </summary>
651 WithInheritors = 4,
652  
653 /// <summary>Entity marked with the attribute and all its members considered used.</summary>
654 WithMembers = Itself | Members
655 }
656  
657 /// <summary>
658 /// This attribute is intended to mark publicly available API,
659 /// which should not be removed and so is treated as used.
660 /// </summary>
661 [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)]
662 [AttributeUsage(AttributeTargets.All, Inherited = false)]
663 public sealed class PublicAPIAttribute : Attribute
664 {
665 public PublicAPIAttribute()
666 {
667 }
668  
669 public PublicAPIAttribute([NotNull] string comment)
670 {
671 Comment = comment;
672 }
673  
674 [CanBeNull] public string Comment { get; }
675 }
676  
677 /// <summary>
678 /// Tells the code analysis engine if the parameter is completely handled when the invoked method is on stack.
679 /// If the parameter is a delegate, indicates that delegate can only be invoked during method execution
680 /// (the delegate can be invoked zero or multiple times, but not stored to some field and invoked later,
681 /// when the containing method is no longer on the execution stack).
682 /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed.
683 /// If <see cref="RequireAwait" /> is true, the attribute will only takes effect if the method invocation is located
684 /// under the 'await' expression.
685 /// </summary>
686 [AttributeUsage(AttributeTargets.Parameter)]
687 public sealed class InstantHandleAttribute : Attribute
688 {
689 /// <summary>
690 /// Require the method invocation to be used under the 'await' expression for this attribute to take effect on code
691 /// analysis engine.
692 /// Can be used for delegate/enumerable parameters of 'async' methods.
693 /// </summary>
694 public bool RequireAwait { get; set; }
695 }
696  
697 /// <summary>
698 /// Indicates that a method does not make any observable state changes.
699 /// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>.
700 /// </summary>
701 /// <example>
702 /// <code>
703 /// [Pure] int Multiply(int x, int y) => x * y;
704 ///
705 /// void M() {
706 /// Multiply(123, 42); // Warning: Return value of pure method is not used
707 /// }
708 /// </code>
709 /// </example>
710 [AttributeUsage(AttributeTargets.Method)]
711 public sealed class PureAttribute : Attribute
712 {
713 }
714  
715 /// <summary>
716 /// Indicates that the return value of the method invocation must be used.
717 /// </summary>
718 /// <remarks>
719 /// Methods decorated with this attribute (in contrast to pure methods) might change state,
720 /// but make no sense without using their return value. <br />
721 /// Similarly to <see cref="PureAttribute" />, this attribute
722 /// will help to detect usages of the method when the return value is not used.
723 /// Optionally, you can specify a message to use when showing warnings, e.g.
724 /// <code>[MustUseReturnValue("Use the return value to...")]</code>.
725 /// </remarks>
726 [AttributeUsage(AttributeTargets.Method)]
727 public sealed class MustUseReturnValueAttribute : Attribute
728 {
729 public MustUseReturnValueAttribute()
730 {
731 }
732  
733 public MustUseReturnValueAttribute([NotNull] string justification)
734 {
735 Justification = justification;
736 }
737  
738 [CanBeNull] public string Justification { get; }
739 }
740  
741 /// <summary>
742 /// This annotation allows to enforce allocation-less usage patterns of delegates for performance-critical APIs.
743 /// When this annotation is applied to the parameter of delegate type, IDE checks the input argument of this parameter:
744 /// * When lambda expression or anonymous method is passed as an argument, IDE verifies that the passed closure
745 /// has no captures of the containing local variables and the compiler is able to cache the delegate instance
746 /// to avoid heap allocations. Otherwise the warning is produced.
747 /// * IDE warns when method name or local function name is passed as an argument as this always results
748 /// in heap allocation of the delegate instance.
749 /// </summary>
750 /// <remarks>
751 /// In C# 9.0 code IDE would also suggest to annotate the anonymous function with 'static' modifier
752 /// to make use of the similar analysis provided by the language/compiler.
753 /// </remarks>
754 [AttributeUsage(AttributeTargets.Parameter)]
755 public sealed class RequireStaticDelegateAttribute : Attribute
756 {
757 public bool IsError { get; set; }
758 }
759  
760 /// <summary>
761 /// Indicates the type member or parameter of some type, that should be used instead of all other ways
762 /// to get the value of that type. This annotation is useful when you have some "context" value evaluated
763 /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one.
764 /// </summary>
765 /// <example>
766 /// <code>
767 /// class Foo {
768 /// [ProvidesContext] IBarService _barService = ...;
769 ///
770 /// void ProcessNode(INode node) {
771 /// DoSomething(node, node.GetGlobalServices().Bar);
772 /// // ^ Warning: use value of '_barService' field
773 /// }
774 /// }
775 /// </code>
776 /// </example>
777 [AttributeUsage(
778 AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method |
779 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct |
780 AttributeTargets.GenericParameter)]
781 public sealed class ProvidesContextAttribute : Attribute
782 {
783 }
784  
785 /// <summary>
786 /// Indicates that a parameter is a path to a file or a folder within a web project.
787 /// Path can be relative or absolute, starting from web root (~).
788 /// </summary>
789 [AttributeUsage(AttributeTargets.Parameter)]
790 public sealed class PathReferenceAttribute : Attribute
791 {
792 public PathReferenceAttribute()
793 {
794 }
795  
796 public PathReferenceAttribute([NotNull] [PathReference] string basePath)
797 {
798 BasePath = basePath;
799 }
800  
801 [CanBeNull] public string BasePath { get; }
802 }
803  
804 /// <summary>
805 /// An extension method marked with this attribute is processed by code completion
806 /// as a 'Source Template'. When the extension method is completed over some expression, its source code
807 /// is automatically expanded like a template at call site.
808 /// </summary>
809 /// <remarks>
810 /// Template method body can contain valid source code and/or special comments starting with '$'.
811 /// Text inside these comments is added as source code when the template is applied. Template parameters
812 /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs.
813 /// Use the <see cref="MacroAttribute" /> attribute to specify macros for parameters.
814 /// </remarks>
815 /// <example>
816 /// In this example, the 'forEach' method is a source template available over all values
817 /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:
818 /// <code>
819 /// [SourceTemplate]
820 /// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; xs) {
821 /// foreach (var x in xs) {
822 /// //$ $END$
823 /// }
824 /// }
825 /// </code>
826 /// </example>
827 [AttributeUsage(AttributeTargets.Method)]
828 public sealed class SourceTemplateAttribute : Attribute
829 {
830 }
831  
832 /// <summary>
833 /// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>.
834 /// </summary>
835 /// <remarks>
836 /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression
837 /// is defined in the <see cref="MacroAttribute.Expression" /> property. When applied on a method, the target
838 /// template parameter is defined in the <see cref="MacroAttribute.Target" /> property. To apply the macro silently
839 /// for the parameter, set the <see cref="MacroAttribute.Editable" /> property value = -1.
840 /// </remarks>
841 /// <example>
842 /// Applying the attribute on a source template method:
843 /// <code>
844 /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
845 /// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; collection) {
846 /// foreach (var item in collection) {
847 /// //$ $END$
848 /// }
849 /// }
850 /// </code>
851 /// Applying the attribute on a template method parameter:
852 /// <code>
853 /// [SourceTemplate]
854 /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
855 /// /*$ var $x$Id = "$newguid$" + x.ToString();
856 /// x.DoSomething($x$Id); */
857 /// }
858 /// </code>
859 /// </example>
860 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)]
861 public sealed class MacroAttribute : Attribute
862 {
863 /// <summary>
864 /// Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see>
865 /// parameter when the template is expanded.
866 /// </summary>
867 [CanBeNull]
868 public string Expression { get; set; }
869  
870 /// <summary>
871 /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
872 /// </summary>
873 /// <remarks>
874 /// If the target parameter is used several times in the template, only one occurrence becomes editable;
875 /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence,
876 /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1.
877 /// </remarks>
878 public int Editable { get; set; }
879  
880 /// <summary>
881 /// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the
882 /// <see cref="MacroAttribute" /> is applied on a template method.
883 /// </summary>
884 [CanBeNull]
885 public string Target { get; set; }
886 }
887  
888 /// <summary>
889 /// Indicates how method, constructor invocation, or property access
890 /// over collection type affects the contents of the collection.
891 /// When applied to a return value of a method indicates if the returned collection
892 /// is created exclusively for the caller (CollectionAccessType.UpdatedContent) or
893 /// can be read/updated from outside (CollectionAccessType.Read | CollectionAccessType.UpdatedContent)
894 /// Use <see cref="CollectionAccessType" /> to specify the access type.
895 /// </summary>
896 /// <remarks>
897 /// Using this attribute only makes sense if all collection methods are marked with this attribute.
898 /// </remarks>
899 /// <example>
900 /// <code>
901 /// public class MyStringCollection : List&lt;string&gt;
902 /// {
903 /// [CollectionAccess(CollectionAccessType.Read)]
904 /// public string GetFirstString()
905 /// {
906 /// return this.ElementAt(0);
907 /// }
908 /// }
909 /// class Test
910 /// {
911 /// public void Foo()
912 /// {
913 /// // Warning: Contents of the collection is never updated
914 /// var col = new MyStringCollection();
915 /// string x = col.GetFirstString();
916 /// }
917 /// }
918 /// </code>
919 /// </example>
920 [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property |
921 AttributeTargets.ReturnValue)]
922 public sealed class CollectionAccessAttribute : Attribute
923 {
924 public CollectionAccessAttribute(CollectionAccessType collectionAccessType)
925 {
926 CollectionAccessType = collectionAccessType;
927 }
928  
929 public CollectionAccessType CollectionAccessType { get; }
930 }
931  
932 /// <summary>
933 /// Provides a value for the <see cref="CollectionAccessAttribute" /> to define
934 /// how the collection method invocation affects the contents of the collection.
935 /// </summary>
936 [Flags]
937 public enum CollectionAccessType
938 {
939 /// <summary>Method does not use or modify content of the collection.</summary>
940 None = 0,
941  
942 /// <summary>Method only reads content of the collection but does not modify it.</summary>
943 Read = 1,
944  
945 /// <summary>Method can change content of the collection but does not add new elements.</summary>
946 ModifyExistingContent = 2,
947  
948 /// <summary>Method can add new elements to the collection.</summary>
949 UpdatedContent = ModifyExistingContent | 4
950 }
951  
952 /// <summary>
953 /// Indicates that the marked method is assertion method, i.e. it halts the control flow if
954 /// one of the conditions is satisfied. To set the condition, mark one of the parameters with
955 /// <see cref="AssertionConditionAttribute" /> attribute.
956 /// </summary>
957 [AttributeUsage(AttributeTargets.Method)]
958 public sealed class AssertionMethodAttribute : Attribute
959 {
960 }
961  
962 /// <summary>
963 /// Indicates the condition parameter of the assertion method. The method itself should be
964 /// marked by <see cref="AssertionMethodAttribute" /> attribute. The mandatory argument of
965 /// the attribute is the assertion type.
966 /// </summary>
967 [AttributeUsage(AttributeTargets.Parameter)]
968 public sealed class AssertionConditionAttribute : Attribute
969 {
970 public AssertionConditionAttribute(AssertionConditionType conditionType)
971 {
972 ConditionType = conditionType;
973 }
974  
975 public AssertionConditionType ConditionType { get; }
976 }
977  
978 /// <summary>
979 /// Specifies assertion type. If the assertion method argument satisfies the condition,
980 /// then the execution continues. Otherwise, execution is assumed to be halted.
981 /// </summary>
982 public enum AssertionConditionType
983 {
984 /// <summary>Marked parameter should be evaluated to true.</summary>
985 IS_TRUE = 0,
986  
987 /// <summary>Marked parameter should be evaluated to false.</summary>
988 IS_FALSE = 1,
989  
990 /// <summary>Marked parameter should be evaluated to null value.</summary>
991 IS_NULL = 2,
992  
993 /// <summary>Marked parameter should be evaluated to not null value.</summary>
994 IS_NOT_NULL = 3
995 }
996  
997 /// <summary>
998 /// Indicates that the marked method unconditionally terminates control flow execution.
999 /// For example, it could unconditionally throw exception.
1000 /// </summary>
1001 [Obsolete("Use [ContractAnnotation('=> halt')] instead")]
1002 [AttributeUsage(AttributeTargets.Method)]
1003 public sealed class TerminatesProgramAttribute : Attribute
1004 {
1005 }
1006  
1007 /// <summary>
1008 /// Indicates that the method is a pure LINQ method, with postponed enumeration (like Enumerable.Select,
1009 /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters
1010 /// of delegate type by analyzing LINQ method chains.
1011 /// </summary>
1012 [AttributeUsage(AttributeTargets.Method)]
1013 public sealed class LinqTunnelAttribute : Attribute
1014 {
1015 }
1016  
1017 /// <summary>
1018 /// Indicates that IEnumerable passed as a parameter is not enumerated.
1019 /// Use this annotation to suppress the 'Possible multiple enumeration of IEnumerable' inspection.
1020 /// </summary>
1021 /// <example>
1022 /// <code>
1023 /// static void ThrowIfNull&lt;T&gt;([NoEnumeration] T v, string n) where T : class
1024 /// {
1025 /// // custom check for null but no enumeration
1026 /// }
1027 ///
1028 /// void Foo(IEnumerable&lt;string&gt; values)
1029 /// {
1030 /// ThrowIfNull(values, nameof(values));
1031 /// var x = values.ToList(); // No warnings about multiple enumeration
1032 /// }
1033 /// </code>
1034 /// </example>
1035 [AttributeUsage(AttributeTargets.Parameter)]
1036 public sealed class NoEnumerationAttribute : Attribute
1037 {
1038 }
1039  
1040 /// <summary>
1041 /// Indicates that the marked parameter, field, or property is a regular expression pattern.
1042 /// </summary>
1043 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1044 public sealed class RegexPatternAttribute : Attribute
1045 {
1046 }
1047  
1048 /// <summary>
1049 /// Language of injected code fragment inside marked by <see cref="LanguageInjectionAttribute" /> string literal.
1050 /// </summary>
1051 public enum InjectedLanguage
1052 {
1053 CSS,
1054 HTML,
1055 JAVASCRIPT,
1056 JSON,
1057 XML
1058 }
1059  
1060 /// <summary>
1061 /// Indicates that the marked parameter, field, or property is accepting a string literal
1062 /// containing code fragment in a language specified by the <see cref="InjectedLanguage" />.
1063 /// </summary>
1064 /// <example>
1065 /// <code>
1066 /// void Foo([LanguageInjection(InjectedLanguage.CSS, Prefix = "body{", Suffix = "}")] string cssProps)
1067 /// {
1068 /// // cssProps should only contains a list of CSS properties
1069 /// }
1070 /// </code>
1071 /// </example>
1072 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1073 public sealed class LanguageInjectionAttribute : Attribute
1074 {
1075 public LanguageInjectionAttribute(InjectedLanguage injectedLanguage)
1076 {
1077 InjectedLanguage = injectedLanguage;
1078 }
1079  
1080 /// <summary>Specify a language of injected code fragment.</summary>
1081 public InjectedLanguage InjectedLanguage { get; }
1082  
1083 /// <summary>Specify a string that "precedes" injected string literal.</summary>
1084 [CanBeNull]
1085 public string Prefix { get; set; }
1086  
1087 /// <summary>Specify a string that "follows" injected string literal.</summary>
1088 [CanBeNull]
1089 public string Suffix { get; set; }
1090 }
1091  
1092 /// <summary>
1093 /// Prevents the Member Reordering feature from tossing members of the marked class.
1094 /// </summary>
1095 /// <remarks>
1096 /// The attribute must be mentioned in your member reordering patterns.
1097 /// </remarks>
1098 [AttributeUsage(
1099 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)]
1100 public sealed class NoReorderAttribute : Attribute
1101 {
1102 }
1103  
1104 /// <summary>
1105 /// <para>
1106 /// Defines the code search template using the Structural Search and Replace syntax.
1107 /// It allows you to find and, if necessary, replace blocks of code that match a specific pattern.
1108 /// Search and replace patterns consist of a textual part and placeholders.
1109 /// Textural part must contain only identifiers allowed in the target language and will be matched exactly (white
1110 /// spaces, tabulation characters, and line breaks are ignored).
1111 /// Placeholders allow matching variable parts of the target code blocks.
1112 /// A placeholder has the following format: $placeholder_name$- where placeholder_name is an arbitrary identifier.
1113 /// </para>
1114 /// <para>
1115 /// Available placeholders:
1116 /// <list type="bullet">
1117 /// <item>$this$ - expression of containing type</item>
1118 /// <item>$thisType$ - containing type</item>
1119 /// <item>$member$ - current member placeholder</item>
1120 /// <item>
1121 /// $qualifier$ - this placeholder is available in the replace pattern and can be used to insert qualifier
1122 /// expression matched by the $member$ placeholder.
1123 /// (Note that if $qualifier$ placeholder is used, then $member$ placeholder will match only qualified
1124 /// references)
1125 /// </item>
1126 /// <item>$expression$ - expression of any type</item>
1127 /// <item>$identifier$ - identifier placeholder</item>
1128 /// <item>$args$ - any number of arguments</item>
1129 /// <item>$arg$ - single argument</item>
1130 /// <item>$arg1$ ... $arg10$ - single argument</item>
1131 /// <item>$stmts$ - any number of statements</item>
1132 /// <item>$stmt$ - single statement</item>
1133 /// <item>$stmt1$ ... $stmt10$ - single statement</item>
1134 /// <item>$name{Expression, 'Namespace.FooType'}$ - expression with 'Namespace.FooType' type</item>
1135 /// <item>$expression{'Namespace.FooType'}$ - expression with 'Namespace.FooType' type</item>
1136 /// <item>$name{Type, 'Namespace.FooType'}$ - 'Namespace.FooType' type</item>
1137 /// <item>$type{'Namespace.FooType'}$ - 'Namespace.FooType' type</item>
1138 /// <item>$statement{1,2}$ - 1 or 2 statements</item>
1139 /// </list>
1140 /// </para>
1141 /// <para>
1142 /// Note that you can also define your own placeholders of the supported types and specify arguments for each
1143 /// placeholder type.
1144 /// This can be done using the following format: $name{type, arguments}$. Where 'name' - is the name of your
1145 /// placeholder,
1146 /// 'type' - is the type of your placeholder (one of the following: Expression, Type, Identifier, Statement,
1147 /// Argument, Member),
1148 /// 'arguments' - arguments list for your placeholder. Each placeholder type supports it's own arguments, check
1149 /// examples below for mode details.
1150 /// Placeholder type may be omitted and determined from the placeholder name, if name has one of the following
1151 /// prefixes:
1152 /// <list type="bullet">
1153 /// <item>expr, expression - expression placeholder, e.g. $exprPlaceholder{}$, $expressionFoo{}$</item>
1154 /// <item>arg, argument - argument placeholder, e.g. $argPlaceholder{}$, $argumentFoo{}$</item>
1155 /// <item>ident, identifier - identifier placeholder, e.g. $identPlaceholder{}$, $identifierFoo{}$</item>
1156 /// <item>stmt, statement - statement placeholder, e.g. $stmtPlaceholder{}$, $statementFoo{}$</item>
1157 /// <item>type - type placeholder, e.g. $typePlaceholder{}$, $typeFoo{}$</item>
1158 /// <item>member - member placeholder, e.g. $memberPlaceholder{}$, $memberFoo{}$</item>
1159 /// </list>
1160 /// </para>
1161 /// <para>
1162 /// Expression placeholder arguments:
1163 /// <list type="bullet">
1164 /// <item>
1165 /// expressionType - string value in single quotes, specifies full type name to match (empty string by
1166 /// default)
1167 /// </item>
1168 /// <item>exactType - boolean value, specifies if expression should have exact type match (false by default)</item>
1169 /// </list>
1170 /// Examples:
1171 /// <list type="bullet">
1172 /// <item>
1173 /// $myExpr{Expression, 'Namespace.FooType', true}$ - defines expression placeholder, matching
1174 /// expressions of the 'Namespace.FooType' type with exact matching.
1175 /// </item>
1176 /// <item>
1177 /// $myExpr{Expression, 'Namespace.FooType'}$ - defines expression placeholder, matching expressions of
1178 /// the 'Namespace.FooType' type or expressions which can be implicitly converted to 'Namespace.FooType'.
1179 /// </item>
1180 /// <item>$myExpr{Expression}$ - defines expression placeholder, matching expressions of any type.</item>
1181 /// <item>
1182 /// $exprFoo{'Namespace.FooType', true}$ - defines expression placeholder, matching expressions of the
1183 /// 'Namespace.FooType' type with exact matching.
1184 /// </item>
1185 /// </list>
1186 /// </para>
1187 /// <para>
1188 /// Type placeholder arguments:
1189 /// <list type="bullet">
1190 /// <item>type - string value in single quotes, specifies full type name to match (empty string by default)</item>
1191 /// <item>exactType - boolean value, specifies if expression should have exact type match (false by default)</item>
1192 /// </list>
1193 /// Examples:
1194 /// <list type="bullet">
1195 /// <item>
1196 /// $myType{Type, 'Namespace.FooType', true}$ - defines type placeholder, matching 'Namespace.FooType'
1197 /// types with exact matching.
1198 /// </item>
1199 /// <item>
1200 /// $myType{Type, 'Namespace.FooType'}$ - defines type placeholder, matching 'Namespace.FooType' types or
1201 /// types, which can be implicitly converted to 'Namespace.FooType'.
1202 /// </item>
1203 /// <item>$myType{Type}$ - defines type placeholder, matching any type.</item>
1204 /// <item>
1205 /// $typeFoo{'Namespace.FooType', true}$ - defines types placeholder, matching 'Namespace.FooType' types
1206 /// with exact matching.
1207 /// </item>
1208 /// </list>
1209 /// </para>
1210 /// <para>
1211 /// Identifier placeholder arguments:
1212 /// <list type="bullet">
1213 /// <item>
1214 /// nameRegex - string value in single quotes, specifies regex to use for matching (empty string by
1215 /// default)
1216 /// </item>
1217 /// <item>nameRegexCaseSensitive - boolean value, specifies if name regex is case sensitive (true by default)</item>
1218 /// <item>type - string value in single quotes, specifies full type name to match (empty string by default)</item>
1219 /// <item>exactType - boolean value, specifies if expression should have exact type match (false by default)</item>
1220 /// </list>
1221 /// Examples:
1222 /// <list type="bullet">
1223 /// <item>
1224 /// $myIdentifier{Identifier, 'my.*', false, 'Namespace.FooType', true}$ - defines identifier
1225 /// placeholder, matching identifiers (ignoring case) starting with 'my' prefix with 'Namespace.FooType'
1226 /// type.
1227 /// </item>
1228 /// <item>
1229 /// $myIdentifier{Identifier, 'my.*', true, 'Namespace.FooType', true}$ - defines identifier placeholder,
1230 /// matching identifiers (case sensitively) starting with 'my' prefix with 'Namespace.FooType' type.
1231 /// </item>
1232 /// <item>
1233 /// $identFoo{'my.*'}$ - defines identifier placeholder, matching identifiers (case sensitively) starting
1234 /// with 'my' prefix.
1235 /// </item>
1236 /// </list>
1237 /// </para>
1238 /// <para>
1239 /// Statement placeholder arguments:
1240 /// <list type="bullet">
1241 /// <item>minimalOccurrences - minimal number of statements to match (-1 by default)</item>
1242 /// <item>maximalOccurrences - maximal number of statements to match (-1 by default)</item>
1243 /// </list>
1244 /// Examples:
1245 /// <list type="bullet">
1246 /// <item>$myStmt{Statement, 1, 2}$ - defines statement placeholder, matching 1 or 2 statements.</item>
1247 /// <item>$myStmt{Statement}$ - defines statement placeholder, matching any number of statements.</item>
1248 /// <item>$stmtFoo{1, 2}$ - defines statement placeholder, matching 1 or 2 statements.</item>
1249 /// </list>
1250 /// </para>
1251 /// <para>
1252 /// Argument placeholder arguments:
1253 /// <list type="bullet">
1254 /// <item>minimalOccurrences - minimal number of arguments to match (-1 by default)</item>
1255 /// <item>maximalOccurrences - maximal number of arguments to match (-1 by default)</item>
1256 /// </list>
1257 /// Examples:
1258 /// <list type="bullet">
1259 /// <item>$myArg{Argument, 1, 2}$ - defines argument placeholder, matching 1 or 2 arguments.</item>
1260 /// <item>$myArg{Argument}$ - defines argument placeholder, matching any number of arguments.</item>
1261 /// <item>$argFoo{1, 2}$ - defines argument placeholder, matching 1 or 2 arguments.</item>
1262 /// </list>
1263 /// </para>
1264 /// <para>
1265 /// Member placeholder arguments:
1266 /// <list type="bullet">
1267 /// <item>
1268 /// docId - string value in single quotes, specifies XML documentation id of the member to match (empty
1269 /// by default)
1270 /// </item>
1271 /// </list>
1272 /// Examples:
1273 /// <list type="bullet">
1274 /// <item>
1275 /// $myMember{Member, 'M:System.String.IsNullOrEmpty(System.String)'}$ - defines member placeholder,
1276 /// matching 'IsNullOrEmpty' member of the 'System.String' type.
1277 /// </item>
1278 /// <item>
1279 /// $memberFoo{'M:System.String.IsNullOrEmpty(System.String)'}$ - defines member placeholder, matching
1280 /// 'IsNullOrEmpty' member of the 'System.String' type.
1281 /// </item>
1282 /// </list>
1283 /// </para>
1284 /// <para>
1285 /// For more information please refer to the
1286 /// <a href="https://www.jetbrains.com/help/resharper/Navigation_and_Search__Structural_Search_and_Replace.html">
1287 /// Structural
1288 /// Search and Replace
1289 /// </a>
1290 /// article.
1291 /// </para>
1292 /// </summary>
1293 [AttributeUsage(
1294 AttributeTargets.Method
1295 | AttributeTargets.Constructor
1296 | AttributeTargets.Property
1297 | AttributeTargets.Field
1298 | AttributeTargets.Event
1299 | AttributeTargets.Interface
1300 | AttributeTargets.Class
1301 | AttributeTargets.Struct
1302 | AttributeTargets.Enum,
1303 AllowMultiple = true,
1304 Inherited = false)]
1305 public sealed class CodeTemplateAttribute : Attribute
1306 {
1307 public CodeTemplateAttribute(string searchTemplate)
1308 {
1309 SearchTemplate = searchTemplate;
1310 }
1311  
1312 /// <summary>
1313 /// Structural search pattern to use in the code template.
1314 /// Pattern includes textual part, which must contain only identifiers allowed in the target language,
1315 /// and placeholders, which allow matching variable parts of the target code blocks.
1316 /// </summary>
1317 public string SearchTemplate { get; }
1318  
1319 /// <summary>
1320 /// Message to show when the search pattern was found.
1321 /// You can also prepend the message text with "Error:", "Warning:", "Suggestion:" or "Hint:" prefix to specify the
1322 /// pattern severity.
1323 /// Code patterns with replace template produce suggestions by default.
1324 /// However, if replace template is not provided, then warning severity will be used.
1325 /// </summary>
1326 public string Message { get; set; }
1327  
1328 /// <summary>
1329 /// Structural search replace pattern to use in code template replacement.
1330 /// </summary>
1331 public string ReplaceTemplate { get; set; }
1332  
1333 /// <summary>
1334 /// Replace message to show in the light bulb.
1335 /// </summary>
1336 public string ReplaceMessage { get; set; }
1337  
1338 /// <summary>
1339 /// Apply code formatting after code replacement.
1340 /// </summary>
1341 public bool FormatAfterReplace { get; set; } = true;
1342  
1343 /// <summary>
1344 /// Whether similar code blocks should be matched.
1345 /// </summary>
1346 public bool MatchSimilarConstructs { get; set; }
1347  
1348 /// <summary>
1349 /// Automatically insert namespace import directives or remove qualifiers that become redundant after the template is
1350 /// applied.
1351 /// </summary>
1352 public bool ShortenReferences { get; set; }
1353  
1354 /// <summary>
1355 /// String to use as a suppression key.
1356 /// By default the following suppression key is used 'CodeTemplate_SomeType_SomeMember',
1357 /// where 'SomeType' and 'SomeMember' are names of the associated containing type and member to which this attribute is
1358 /// applied.
1359 /// </summary>
1360 public string SuppressionKey { get; set; }
1361 }
1362  
1363 #region ASP.NET
1364  
1365 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
1366 public sealed class AspChildControlTypeAttribute : Attribute
1367 {
1368 public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType)
1369 {
1370 TagName = tagName;
1371 ControlType = controlType;
1372 }
1373  
1374 [NotNull] public string TagName { get; }
1375  
1376 [NotNull] public Type ControlType { get; }
1377 }
1378  
1379 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
1380 public sealed class AspDataFieldAttribute : Attribute
1381 {
1382 }
1383  
1384 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
1385 public sealed class AspDataFieldsAttribute : Attribute
1386 {
1387 }
1388  
1389 [AttributeUsage(AttributeTargets.Property)]
1390 public sealed class AspMethodPropertyAttribute : Attribute
1391 {
1392 }
1393  
1394 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
1395 public sealed class AspRequiredAttributeAttribute : Attribute
1396 {
1397 public AspRequiredAttributeAttribute([NotNull] string attribute)
1398 {
1399 Attribute = attribute;
1400 }
1401  
1402 [NotNull] public string Attribute { get; }
1403 }
1404  
1405 [AttributeUsage(AttributeTargets.Property)]
1406 public sealed class AspTypePropertyAttribute : Attribute
1407 {
1408 public AspTypePropertyAttribute(bool createConstructorReferences)
1409 {
1410 CreateConstructorReferences = createConstructorReferences;
1411 }
1412  
1413 public bool CreateConstructorReferences { get; }
1414 }
1415  
1416 #endregion
1417  
1418 #region ASP.NET MVC
1419  
1420 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1421 AllowMultiple = true)]
1422 public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
1423 {
1424 public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format)
1425 {
1426 Format = format;
1427 }
1428  
1429 [NotNull] public string Format { get; }
1430 }
1431  
1432 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1433 AllowMultiple = true)]
1434 public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
1435 {
1436 public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format)
1437 {
1438 Format = format;
1439 }
1440  
1441 [NotNull] public string Format { get; }
1442 }
1443  
1444 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1445 AllowMultiple = true)]
1446 public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
1447 {
1448 public AspMvcAreaViewLocationFormatAttribute([NotNull] string format)
1449 {
1450 Format = format;
1451 }
1452  
1453 [NotNull] public string Format { get; }
1454 }
1455  
1456 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1457 AllowMultiple = true)]
1458 public sealed class AspMvcMasterLocationFormatAttribute : Attribute
1459 {
1460 public AspMvcMasterLocationFormatAttribute([NotNull] string format)
1461 {
1462 Format = format;
1463 }
1464  
1465 [NotNull] public string Format { get; }
1466 }
1467  
1468 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1469 AllowMultiple = true)]
1470 public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
1471 {
1472 public AspMvcPartialViewLocationFormatAttribute([NotNull] string format)
1473 {
1474 Format = format;
1475 }
1476  
1477 [NotNull] public string Format { get; }
1478 }
1479  
1480 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1481 AllowMultiple = true)]
1482 public sealed class AspMvcViewLocationFormatAttribute : Attribute
1483 {
1484 public AspMvcViewLocationFormatAttribute([NotNull] string format)
1485 {
1486 Format = format;
1487 }
1488  
1489 [NotNull] public string Format { get; }
1490 }
1491  
1492 /// <summary>
1493 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1494 /// is an MVC action. If applied to a method, the MVC action name is calculated
1495 /// implicitly from the context. Use this attribute for custom wrappers similar to
1496 /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
1497 /// </summary>
1498 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1499 AttributeTargets.Property)]
1500 public sealed class AspMvcActionAttribute : Attribute
1501 {
1502 public AspMvcActionAttribute()
1503 {
1504 }
1505  
1506 public AspMvcActionAttribute([NotNull] string anonymousProperty)
1507 {
1508 AnonymousProperty = anonymousProperty;
1509 }
1510  
1511 [CanBeNull] public string AnonymousProperty { get; }
1512 }
1513  
1514 /// <summary>
1515 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC area.
1516 /// Use this attribute for custom wrappers similar to
1517 /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
1518 /// </summary>
1519 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1520 public sealed class AspMvcAreaAttribute : Attribute
1521 {
1522 public AspMvcAreaAttribute()
1523 {
1524 }
1525  
1526 public AspMvcAreaAttribute([NotNull] string anonymousProperty)
1527 {
1528 AnonymousProperty = anonymousProperty;
1529 }
1530  
1531 [CanBeNull] public string AnonymousProperty { get; }
1532 }
1533  
1534 /// <summary>
1535 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is
1536 /// an MVC controller. If applied to a method, the MVC controller name is calculated
1537 /// implicitly from the context. Use this attribute for custom wrappers similar to
1538 /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>.
1539 /// </summary>
1540 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1541 AttributeTargets.Property)]
1542 public sealed class AspMvcControllerAttribute : Attribute
1543 {
1544 public AspMvcControllerAttribute()
1545 {
1546 }
1547  
1548 public AspMvcControllerAttribute([NotNull] string anonymousProperty)
1549 {
1550 AnonymousProperty = anonymousProperty;
1551 }
1552  
1553 [CanBeNull] public string AnonymousProperty { get; }
1554 }
1555  
1556 /// <summary>
1557 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC Master. Use this attribute
1558 /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.
1559 /// </summary>
1560 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1561 public sealed class AspMvcMasterAttribute : Attribute
1562 {
1563 }
1564  
1565 /// <summary>
1566 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC model type. Use this attribute
1567 /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>.
1568 /// </summary>
1569 [AttributeUsage(AttributeTargets.Parameter)]
1570 public sealed class AspMvcModelTypeAttribute : Attribute
1571 {
1572 }
1573  
1574 /// <summary>
1575 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC
1576 /// partial view. If applied to a method, the MVC partial view name is calculated implicitly
1577 /// from the context. Use this attribute for custom wrappers similar to
1578 /// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.
1579 /// </summary>
1580 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1581 AttributeTargets.Property)]
1582 public sealed class AspMvcPartialViewAttribute : Attribute
1583 {
1584 }
1585  
1586 /// <summary>
1587 /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.
1588 /// </summary>
1589 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
1590 public sealed class AspMvcSuppressViewErrorAttribute : Attribute
1591 {
1592 }
1593  
1594 /// <summary>
1595 /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
1596 /// Use this attribute for custom wrappers similar to
1597 /// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.
1598 /// </summary>
1599 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1600 public sealed class AspMvcDisplayTemplateAttribute : Attribute
1601 {
1602 }
1603  
1604 /// <summary>
1605 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC editor template.
1606 /// Use this attribute for custom wrappers similar to
1607 /// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>.
1608 /// </summary>
1609 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1610 public sealed class AspMvcEditorTemplateAttribute : Attribute
1611 {
1612 }
1613  
1614 /// <summary>
1615 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC template.
1616 /// Use this attribute for custom wrappers similar to
1617 /// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.
1618 /// </summary>
1619 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1620 public sealed class AspMvcTemplateAttribute : Attribute
1621 {
1622 }
1623  
1624 /// <summary>
1625 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1626 /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly
1627 /// from the context. Use this attribute for custom wrappers similar to
1628 /// <c>System.Web.Mvc.Controller.View(Object)</c>.
1629 /// </summary>
1630 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1631 AttributeTargets.Property)]
1632 public sealed class AspMvcViewAttribute : Attribute
1633 {
1634 }
1635  
1636 /// <summary>
1637 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1638 /// is an MVC view component name.
1639 /// </summary>
1640 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1641 public sealed class AspMvcViewComponentAttribute : Attribute
1642 {
1643 }
1644  
1645 /// <summary>
1646 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1647 /// is an MVC view component view. If applied to a method, the MVC view component view name is default.
1648 /// </summary>
1649 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1650 AttributeTargets.Property)]
1651 public sealed class AspMvcViewComponentViewAttribute : Attribute
1652 {
1653 }
1654  
1655 /// <summary>
1656 /// ASP.NET MVC attribute. When applied to a parameter of an attribute,
1657 /// indicates that this parameter is an MVC action name.
1658 /// </summary>
1659 /// <example>
1660 /// <code>
1661 /// [ActionName("Foo")]
1662 /// public ActionResult Login(string returnUrl) {
1663 /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
1664 /// return RedirectToAction("Bar"); // Error: Cannot resolve action
1665 /// }
1666 /// </code>
1667 /// </example>
1668 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
1669 public sealed class AspMvcActionSelectorAttribute : Attribute
1670 {
1671 }
1672  
1673 #endregion
1674  
1675 #region ASP.NET Routing
1676  
1677 /// <summary>
1678 /// Indicates that the marked parameter, field, or property is a route template.
1679 /// </summary>
1680 /// <remarks>
1681 /// This attribute allows IDE to recognize the use of web frameworks' route templates
1682 /// to enable syntax highlighting, code completion, navigation, rename and other features in string literals.
1683 /// </remarks>
1684 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1685 public sealed class RouteTemplateAttribute : Attribute
1686 {
1687 }
1688  
1689 /// <summary>
1690 /// Indicates that the marked type is custom route parameter constraint,
1691 /// which is registered in application's Startup with name <c>ConstraintName</c>
1692 /// </summary>
1693 /// <remarks>
1694 /// You can specify <c>ProposedType</c> if target constraint matches only route parameters of specific type,
1695 /// it will allow IDE to create method's parameter from usage in route template
1696 /// with specified type instead of default <c>System.String</c>
1697 /// and check if constraint's proposed type conflicts with matched parameter's type
1698 /// </remarks>
1699 [AttributeUsage(AttributeTargets.Class)]
1700 public sealed class RouteParameterConstraintAttribute : Attribute
1701 {
1702 public RouteParameterConstraintAttribute([NotNull] string constraintName)
1703 {
1704 ConstraintName = constraintName;
1705 }
1706  
1707 [NotNull] public string ConstraintName { get; }
1708 [CanBeNull] public Type ProposedType { get; set; }
1709 }
1710  
1711 /// <summary>
1712 /// Indicates that the marked parameter, field, or property is an URI string.
1713 /// </summary>
1714 /// <remarks>
1715 /// This attribute enables code completion, navigation, rename and other features
1716 /// in URI string literals assigned to annotated parameter, field or property.
1717 /// </remarks>
1718 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1719 public sealed class UriStringAttribute : Attribute
1720 {
1721 public UriStringAttribute()
1722 {
1723 }
1724  
1725 public UriStringAttribute(string httpVerb)
1726 {
1727 HttpVerb = httpVerb;
1728 }
1729  
1730 [CanBeNull] public string HttpVerb { get; }
1731 }
1732  
1733 /// <summary>
1734 /// Indicates that the marked method declares routing convention for ASP.NET
1735 /// </summary>
1736 /// <remarks>
1737 /// IDE will analyze all usages of methods marked with this attribute,
1738 /// and will add all routes to completion, navigation and other features over URI strings
1739 /// </remarks>
1740 [AttributeUsage(AttributeTargets.Method)]
1741 public sealed class AspRouteConventionAttribute : Attribute
1742 {
1743 public AspRouteConventionAttribute()
1744 {
1745 }
1746  
1747 public AspRouteConventionAttribute(string predefinedPattern)
1748 {
1749 PredefinedPattern = predefinedPattern;
1750 }
1751  
1752 [CanBeNull] public string PredefinedPattern { get; }
1753 }
1754  
1755 /// <summary>
1756 /// Indicates that the marked method parameter contains default route values of routing convention for ASP.NET
1757 /// </summary>
1758 [AttributeUsage(AttributeTargets.Parameter)]
1759 public sealed class AspDefaultRouteValuesAttribute : Attribute
1760 {
1761 }
1762  
1763 /// <summary>
1764 /// Indicates that the marked method parameter contains constraints on route values of routing convention for ASP.NET
1765 /// </summary>
1766 [AttributeUsage(AttributeTargets.Parameter)]
1767 public sealed class AspRouteValuesConstraintsAttribute : Attribute
1768 {
1769 }
1770  
1771 /// <summary>
1772 /// Indicates that the marked parameter or property contains routing order provided by ASP.NET routing attribute
1773 /// </summary>
1774 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
1775 public sealed class AspRouteOrderAttribute : Attribute
1776 {
1777 }
1778  
1779 /// <summary>
1780 /// Indicates that the marked parameter or property contains HTTP verbs provided by ASP.NET routing attribute
1781 /// </summary>
1782 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
1783 public sealed class AspRouteVerbsAttribute : Attribute
1784 {
1785 }
1786  
1787 /// <summary>
1788 /// Indicates that the marked attribute is used for attribute routing in ASP.NET
1789 /// </summary>
1790 /// <remarks>
1791 /// IDE will analyze all usages of attributes marked with this attribute,
1792 /// and will add all routes to completion, navigation and other features over URI strings
1793 /// </remarks>
1794 [AttributeUsage(AttributeTargets.Class)]
1795 public sealed class AspAttributeRoutingAttribute : Attribute
1796 {
1797 public string HttpVerb { get; set; }
1798 }
1799  
1800 /// <summary>
1801 /// Indicates that the marked method declares ASP.NET Minimal API endpoint
1802 /// </summary>
1803 /// <remarks>
1804 /// IDE will analyze all usages of methods marked with this attribute,
1805 /// and will add all routes to completion, navigation and other features over URI strings
1806 /// </remarks>
1807 [AttributeUsage(AttributeTargets.Method)]
1808 public sealed class AspMinimalApiDeclarationAttribute : Attribute
1809 {
1810 public string HttpVerb { get; set; }
1811 }
1812  
1813 /// <summary>
1814 /// Indicates that the marked parameter contains ASP.NET Minimal API endpoint handler
1815 /// </summary>
1816 [AttributeUsage(AttributeTargets.Parameter)]
1817 public sealed class AspMinimalApiHandlerAttribute : Attribute
1818 {
1819 }
1820  
1821 #endregion
1822  
1823 #region Razor
1824  
1825 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]
1826 public sealed class HtmlElementAttributesAttribute : Attribute
1827 {
1828 public HtmlElementAttributesAttribute()
1829 {
1830 }
1831  
1832 public HtmlElementAttributesAttribute([NotNull] string name)
1833 {
1834 Name = name;
1835 }
1836  
1837 [CanBeNull] public string Name { get; }
1838 }
1839  
1840 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1841 public sealed class HtmlAttributeValueAttribute : Attribute
1842 {
1843 public HtmlAttributeValueAttribute([NotNull] string name)
1844 {
1845 Name = name;
1846 }
1847  
1848 [NotNull] public string Name { get; }
1849 }
1850  
1851 /// <summary>
1852 /// Razor attribute. Indicates that the marked parameter or method is a Razor section.
1853 /// Use this attribute for custom wrappers similar to
1854 /// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>.
1855 /// </summary>
1856 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
1857 public sealed class RazorSectionAttribute : Attribute
1858 {
1859 }
1860  
1861 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1862 public sealed class RazorImportNamespaceAttribute : Attribute
1863 {
1864 public RazorImportNamespaceAttribute([NotNull] string name)
1865 {
1866 Name = name;
1867 }
1868  
1869 [NotNull] public string Name { get; }
1870 }
1871  
1872 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1873 public sealed class RazorInjectionAttribute : Attribute
1874 {
1875 public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName)
1876 {
1877 Type = type;
1878 FieldName = fieldName;
1879 }
1880  
1881 [NotNull] public string Type { get; }
1882  
1883 [NotNull] public string FieldName { get; }
1884 }
1885  
1886 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1887 public sealed class RazorDirectiveAttribute : Attribute
1888 {
1889 public RazorDirectiveAttribute([NotNull] string directive)
1890 {
1891 Directive = directive;
1892 }
1893  
1894 [NotNull] public string Directive { get; }
1895 }
1896  
1897 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1898 public sealed class RazorPageBaseTypeAttribute : Attribute
1899 {
1900 public RazorPageBaseTypeAttribute([NotNull] string baseType)
1901 {
1902 BaseType = baseType;
1903 }
1904  
1905 public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName)
1906 {
1907 BaseType = baseType;
1908 PageName = pageName;
1909 }
1910  
1911 [NotNull] public string BaseType { get; }
1912 [CanBeNull] public string PageName { get; }
1913 }
1914  
1915 [AttributeUsage(AttributeTargets.Method)]
1916 public sealed class RazorHelperCommonAttribute : Attribute
1917 {
1918 }
1919  
1920 [AttributeUsage(AttributeTargets.Property)]
1921 public sealed class RazorLayoutAttribute : Attribute
1922 {
1923 }
1924  
1925 [AttributeUsage(AttributeTargets.Method)]
1926 public sealed class RazorWriteLiteralMethodAttribute : Attribute
1927 {
1928 }
1929  
1930 [AttributeUsage(AttributeTargets.Method)]
1931 public sealed class RazorWriteMethodAttribute : Attribute
1932 {
1933 }
1934  
1935 [AttributeUsage(AttributeTargets.Parameter)]
1936 public sealed class RazorWriteMethodParameterAttribute : Attribute
1937 {
1938 }
1939  
1940 #endregion
1941  
1942 #region XAML
1943  
1944 /// <summary>
1945 /// XAML attribute. Indicates the type that has <c>ItemsSource</c> property and should be treated
1946 /// as <c>ItemsControl</c>-derived type, to enable inner items <c>DataContext</c> type resolve.
1947 /// </summary>
1948 [AttributeUsage(AttributeTargets.Class)]
1949 public sealed class XamlItemsControlAttribute : Attribute
1950 {
1951 }
1952  
1953 /// <summary>
1954 /// XAML attribute. Indicates the property of some <c>BindingBase</c>-derived type, that
1955 /// is used to bind some item of <c>ItemsControl</c>-derived type. This annotation will
1956 /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
1957 /// </summary>
1958 /// <remarks>
1959 /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
1960 /// marked with the <see cref="XamlItemsControlAttribute" /> attribute.
1961 /// </remarks>
1962 [AttributeUsage(AttributeTargets.Property)]
1963 public sealed class XamlItemBindingOfItemsControlAttribute : Attribute
1964 {
1965 }
1966  
1967 /// <summary>
1968 /// XAML attribute. Indicates the property of some <c>Style</c>-derived type, that
1969 /// is used to style items of <c>ItemsControl</c>-derived type. This annotation will
1970 /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
1971 /// </summary>
1972 /// <remarks>
1973 /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
1974 /// marked with the <see cref="XamlItemsControlAttribute" /> attribute.
1975 /// </remarks>
1976 [AttributeUsage(AttributeTargets.Property)]
1977 public sealed class XamlItemStyleOfItemsControlAttribute : Attribute
1978 {
1979 }
1980  
1981 /// <summary>
1982 /// XAML attribute. Indicates that DependencyProperty has <c>OneWay</c> binding mode by default.
1983 /// </summary>
1984 /// <remarks>
1985 /// This attribute must be applied to DependencyProperty's CLR accessor property if it is present, to
1986 /// DependencyProperty descriptor field otherwise.
1987 /// </remarks>
1988 [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
1989 public sealed class XamlOneWayBindingModeByDefaultAttribute : Attribute
1990 {
1991 }
1992  
1993 /// <summary>
1994 /// XAML attribute. Indicates that DependencyProperty has <c>TwoWay</c> binding mode by default.
1995 /// </summary>
1996 /// <remarks>
1997 /// This attribute must be applied to DependencyProperty's CLR accessor property if it is present, to
1998 /// DependencyProperty descriptor field otherwise.
1999 /// </remarks>
2000 [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
2001 public sealed class XamlTwoWayBindingModeByDefaultAttribute : Attribute
2002 {
2003 }
2004  
2005 #endregion
2006 }