HamBook – Blame information for rev 54

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 UnusedType.Global
26  
27 #pragma warning disable 1591
28 // ReSharper disable UnusedMember.Global
29 // ReSharper disable MemberCanBePrivate.Global
30 // ReSharper disable UnusedAutoPropertyAccessor.Global
31 // ReSharper disable IntroduceOptionalParameters.Global
32 // ReSharper disable MemberCanBeProtected.Global
33 // ReSharper disable InconsistentNaming
34  
35 namespace Configuration.Annotations
36 {
37 /// <summary>
38 /// Indicates that the value of the marked element could be <c>null</c> sometimes,
39 /// so checking for <c>null</c> is required before its usage.
40 /// </summary>
41 /// <example>
42 /// <code>
43 /// [CanBeNull] object Test() => null;
44 ///
45 /// void UseTest() {
46 /// var p = Test();
47 /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
48 /// }
49 /// </code>
50 /// </example>
51 [AttributeUsage(
52 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
53 AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
54 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
55 public sealed class CanBeNullAttribute : Attribute
56 {
57 }
58  
59 /// <summary>
60 /// Indicates that the value of the marked element can never be <c>null</c>.
61 /// </summary>
62 /// <example>
63 /// <code>
64 /// [NotNull] object Foo() {
65 /// return null; // Warning: Possible 'null' assignment
66 /// }
67 /// </code>
68 /// </example>
69 [AttributeUsage(
70 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
71 AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
72 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
73 public sealed class NotNullAttribute : Attribute
74 {
75 }
76  
77 /// <summary>
78 /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
79 /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
80 /// or of the Lazy.Value property can never be null.
81 /// </summary>
82 /// <example>
83 /// <code>
84 /// public void Foo([ItemNotNull]List&lt;string&gt; books)
85 /// {
86 /// foreach (var book in books) {
87 /// if (book != null) // Warning: Expression is always true
88 /// Console.WriteLine(book.ToUpper());
89 /// }
90 /// }
91 /// </code>
92 /// </example>
93 [AttributeUsage(
94 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
95 AttributeTargets.Delegate | AttributeTargets.Field)]
96 public sealed class ItemNotNullAttribute : Attribute
97 {
98 }
99  
100 /// <summary>
101 /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
102 /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
103 /// or of the Lazy.Value property can be null.
104 /// </summary>
105 /// <example>
106 /// <code>
107 /// public void Foo([ItemCanBeNull]List&lt;string&gt; books)
108 /// {
109 /// foreach (var book in books)
110 /// {
111 /// // Warning: Possible 'System.NullReferenceException'
112 /// Console.WriteLine(book.ToUpper());
113 /// }
114 /// }
115 /// </code>
116 /// </example>
117 [AttributeUsage(
118 AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
119 AttributeTargets.Delegate | AttributeTargets.Field)]
120 public sealed class ItemCanBeNullAttribute : Attribute
121 {
122 }
123  
124 /// <summary>
125 /// Indicates that the marked method builds string by the format pattern and (optional) arguments.
126 /// The parameter, which contains the format string, should be given in the constructor. The format string
127 /// should be in <see cref="string.Format(IFormatProvider,string,object[])" />-like form.
128 /// </summary>
129 /// <example>
130 /// <code>
131 /// [StringFormatMethod("message")]
132 /// void ShowError(string message, params object[] args) { /* do something */ }
133 ///
134 /// void Foo() {
135 /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
136 /// }
137 /// </code>
138 /// </example>
139 [AttributeUsage(
140 AttributeTargets.Constructor | AttributeTargets.Method |
141 AttributeTargets.Property | AttributeTargets.Delegate)]
142 public sealed class StringFormatMethodAttribute : Attribute
143 {
144 /// <param name="formatParameterName">
145 /// Specifies which parameter of an annotated method should be treated as the format string
146 /// </param>
147 public StringFormatMethodAttribute([NotNull] string formatParameterName)
148 {
149 FormatParameterName = formatParameterName;
150 }
151  
54 office 152 [NotNull] public string FormatParameterName { get; }
1 office 153 }
154  
155 /// <summary>
156 /// Indicates that the marked parameter is a message template where placeholders are to be replaced by the following
157 /// arguments
158 /// in the order in which they appear
159 /// </summary>
160 /// <example>
161 /// <code>
162 /// void LogInfo([StructuredMessageTemplate]string message, params object[] args) { /* do something */ }
163 ///
164 /// void Foo() {
165 /// LogInfo("User created: {username}"); // Warning: Non-existing argument in format string
166 /// }
167 /// </code>
168 /// </example>
169 [AttributeUsage(AttributeTargets.Parameter)]
170 public sealed class StructuredMessageTemplateAttribute : Attribute
171 {
172 }
173  
174 /// <summary>
175 /// Use this annotation to specify a type that contains static or const fields
176 /// with values for the annotated property/field/parameter.
177 /// The specified type will be used to improve completion suggestions.
178 /// </summary>
179 /// <example>
180 /// <code>
181 /// namespace TestNamespace
182 /// {
183 /// public class Constants
184 /// {
185 /// public static int INT_CONST = 1;
186 /// public const string STRING_CONST = "1";
187 /// }
188 ///
189 /// public class Class1
190 /// {
191 /// [ValueProvider("TestNamespace.Constants")] public int myField;
192 /// public void Foo([ValueProvider("TestNamespace.Constants")] string str) { }
193 ///
194 /// public void Test()
195 /// {
196 /// Foo(/*try completion here*/);//
197 /// myField = /*try completion here*/
198 /// }
199 /// }
200 /// }
201 /// </code>
202 /// </example>
203 [AttributeUsage(
204 AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field,
205 AllowMultiple = true)]
206 public sealed class ValueProviderAttribute : Attribute
207 {
208 public ValueProviderAttribute([NotNull] string name)
209 {
210 Name = name;
211 }
212  
54 office 213 [NotNull] public string Name { get; }
1 office 214 }
215  
216 /// <summary>
217 /// Indicates that the integral value falls into the specified interval.
218 /// It's allowed to specify multiple non-intersecting intervals.
219 /// Values of interval boundaries are inclusive.
220 /// </summary>
221 /// <example>
222 /// <code>
223 /// void Foo([ValueRange(0, 100)] int value) {
224 /// if (value == -1) { // Warning: Expression is always 'false'
225 /// ...
226 /// }
227 /// }
228 /// </code>
229 /// </example>
230 [AttributeUsage(
231 AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |
232 AttributeTargets.Method | AttributeTargets.Delegate,
233 AllowMultiple = true)]
234 public sealed class ValueRangeAttribute : Attribute
235 {
236 public ValueRangeAttribute(long from, long to)
237 {
238 From = from;
239 To = to;
240 }
241  
242 public ValueRangeAttribute(ulong from, ulong to)
243 {
244 From = from;
245 To = to;
246 }
247  
248 public ValueRangeAttribute(long value)
249 {
250 From = To = value;
251 }
252  
253 public ValueRangeAttribute(ulong value)
254 {
255 From = To = value;
256 }
257  
258 public object From { get; }
259  
260 public object To { get; }
261 }
262  
263 /// <summary>
264 /// Indicates that the integral value never falls below zero.
265 /// </summary>
266 /// <example>
267 /// <code>
268 /// void Foo([NonNegativeValue] int value) {
269 /// if (value == -1) { // Warning: Expression is always 'false'
270 /// ...
271 /// }
272 /// }
273 /// </code>
274 /// </example>
275 [AttributeUsage(
276 AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |
277 AttributeTargets.Method | AttributeTargets.Delegate)]
278 public sealed class NonNegativeValueAttribute : Attribute
279 {
280 }
281  
282 /// <summary>
283 /// Indicates that the function argument should be a string literal and match
284 /// one of the parameters of the caller function. This annotation is used for paramerers
285 /// like 'string paramName' parameter of the <see cref="System.ArgumentNullException" /> constuctor.
286 /// </summary>
287 /// <example>
288 /// <code>
289 /// void Foo(string param) {
290 /// if (param == null)
291 /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
292 /// }
293 /// </code>
294 /// </example>
295 [AttributeUsage(AttributeTargets.Parameter)]
296 public sealed class InvokerParameterNameAttribute : Attribute
297 {
298 }
299  
300 /// <summary>
301 /// Indicates that the method is contained in a type that implements
302 /// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method
303 /// is used to notify that some property value changed.
304 /// </summary>
305 /// <remarks>
306 /// The method should be non-static and conform to one of the supported signatures:
307 /// <list>
308 /// <item>
309 /// <c>NotifyChanged(string)</c>
310 /// </item>
311 /// <item>
312 /// <c>NotifyChanged(params string[])</c>
313 /// </item>
314 /// <item>
315 /// <c>NotifyChanged{T}(Expression{Func{T}})</c>
316 /// </item>
317 /// <item>
318 /// <c>NotifyChanged{T,U}(Expression{Func{T,U}})</c>
319 /// </item>
320 /// <item>
321 /// <c>SetProperty{T}(ref T, T, string)</c>
322 /// </item>
323 /// </list>
324 /// </remarks>
325 /// <example>
326 /// <code>
327 /// public class Foo : INotifyPropertyChanged {
328 /// public event PropertyChangedEventHandler PropertyChanged;
329 ///
330 /// [NotifyPropertyChangedInvocator]
331 /// protected virtual void NotifyChanged(string propertyName) { ... }
332 ///
333 /// string _name;
334 ///
335 /// public string Name {
336 /// get { return _name; }
337 /// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
338 /// }
339 /// }
340 /// </code>
341 /// Examples of generated notifications:
342 /// <list>
343 /// <item>
344 /// <c>NotifyChanged("Property")</c>
345 /// </item>
346 /// <item>
347 /// <c>NotifyChanged(() =&gt; Property)</c>
348 /// </item>
349 /// <item>
350 /// <c>NotifyChanged((VM x) =&gt; x.Property)</c>
351 /// </item>
352 /// <item>
353 /// <c>SetProperty(ref myField, value, "Property")</c>
354 /// </item>
355 /// </list>
356 /// </example>
357 [AttributeUsage(AttributeTargets.Method)]
358 public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
359 {
360 public NotifyPropertyChangedInvocatorAttribute()
361 {
362 }
363  
364 public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
365 {
366 ParameterName = parameterName;
367 }
368  
54 office 369 [CanBeNull] public string ParameterName { get; }
1 office 370 }
371  
372 /// <summary>
373 /// Describes dependency between method input and output.
374 /// </summary>
375 /// <syntax>
376 /// <p>Function Definition Table syntax:</p>
377 /// <list>
378 /// <item>FDT ::= FDTRow [;FDTRow]*</item>
379 /// <item>FDTRow ::= Input =&gt; Output | Output &lt;= Input</item>
380 /// <item>Input ::= ParameterName: Value [, Input]*</item>
381 /// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>
382 /// <item>Value ::= true | false | null | notnull | canbenull</item>
383 /// </list>
384 /// If the method has a single input parameter, its name could be omitted.<br />
385 /// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for the method output
386 /// means that the method doesn't return normally (throws or terminates the process).<br />
387 /// Value <c>canbenull</c> is only applicable for output parameters.<br />
388 /// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute
389 /// with rows separated by the semicolon. There is no notion of order rows, all rows are checked
390 /// for applicability and applied per each program state tracked by the analysis engine.<br />
391 /// </syntax>
392 /// <examples>
393 /// <list>
394 /// <item>
395 /// <code>
396 /// [ContractAnnotation("=&gt; halt")]
397 /// public void TerminationMethod()
398 /// </code>
399 /// </item>
400 /// <item>
401 /// <code>
402 /// [ContractAnnotation("null &lt;= param:null")] // reverse condition syntax
403 /// public string GetName(string surname)
404 /// </code>
405 /// </item>
406 /// <item>
407 /// <code>
408 /// [ContractAnnotation("s:null =&gt; true")]
409 /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
410 /// </code>
411 /// </item>
412 /// <item>
413 /// <code>
414 /// // A method that returns null if the parameter is null,
415 /// // and not null if the parameter is not null
416 /// [ContractAnnotation("null =&gt; null; notnull =&gt; notnull")]
417 /// public object Transform(object data)
418 /// </code>
419 /// </item>
420 /// <item>
421 /// <code>
422 /// [ContractAnnotation("=&gt; true, result: notnull; =&gt; false, result: null")]
423 /// public bool TryParse(string s, out Person result)
424 /// </code>
425 /// </item>
426 /// </list>
427 /// </examples>
428 [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
429 public sealed class ContractAnnotationAttribute : Attribute
430 {
431 public ContractAnnotationAttribute([NotNull] string contract)
432 : this(contract, false)
433 {
434 }
435  
436 public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
437 {
438 Contract = contract;
439 ForceFullStates = forceFullStates;
440 }
441  
54 office 442 [NotNull] public string Contract { get; }
1 office 443  
444 public bool ForceFullStates { get; }
445 }
446  
447 /// <summary>
448 /// Indicates whether the marked element should be localized.
449 /// </summary>
450 /// <example>
451 /// <code>
452 /// [LocalizationRequiredAttribute(true)]
453 /// class Foo {
454 /// string str = "my string"; // Warning: Localizable string
455 /// }
456 /// </code>
457 /// </example>
458 [AttributeUsage(AttributeTargets.All)]
459 public sealed class LocalizationRequiredAttribute : Attribute
460 {
461 public LocalizationRequiredAttribute() : this(true)
462 {
463 }
464  
465 public LocalizationRequiredAttribute(bool required)
466 {
467 Required = required;
468 }
469  
470 public bool Required { get; }
471 }
472  
473 /// <summary>
474 /// Indicates that the value of the marked type (or its derivatives)
475 /// cannot be compared using '==' or '!=' operators and <c>Equals()</c>
476 /// should be used instead. However, using '==' or '!=' for comparison
477 /// with <c>null</c> is always permitted.
478 /// </summary>
479 /// <example>
480 /// <code>
481 /// [CannotApplyEqualityOperator]
482 /// class NoEquality { }
483 ///
484 /// class UsesNoEquality {
485 /// void Test() {
486 /// var ca1 = new NoEquality();
487 /// var ca2 = new NoEquality();
488 /// if (ca1 != null) { // OK
489 /// bool condition = ca1 == ca2; // Warning
490 /// }
491 /// }
492 /// }
493 /// </code>
494 /// </example>
495 [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]
496 public sealed class CannotApplyEqualityOperatorAttribute : Attribute
497 {
498 }
499  
500 /// <summary>
501 /// When applied to a target attribute, specifies a requirement for any type marked
502 /// with the target attribute to implement or inherit specific type or types.
503 /// </summary>
504 /// <example>
505 /// <code>
506 /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
507 /// class ComponentAttribute : Attribute { }
508 ///
509 /// [Component] // ComponentAttribute requires implementing IComponent interface
510 /// class MyComponent : IComponent { }
511 /// </code>
512 /// </example>
513 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
514 [BaseTypeRequired(typeof(Attribute))]
515 public sealed class BaseTypeRequiredAttribute : Attribute
516 {
517 public BaseTypeRequiredAttribute([NotNull] Type baseType)
518 {
519 BaseType = baseType;
520 }
521  
54 office 522 [NotNull] public Type BaseType { get; }
1 office 523 }
524  
525 /// <summary>
526 /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library),
527 /// so this symbol will be ignored by usage-checking inspections. <br />
528 /// You can use <see cref="ImplicitUseKindFlags" /> and <see cref="ImplicitUseTargetFlags" />
529 /// to configure how this attribute is applied.
530 /// </summary>
531 /// <example>
532 /// <code>
533 /// [UsedImplicitly]
534 /// public class TypeConverter {}
535 ///
536 /// public class SummaryData
537 /// {
538 /// [UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
539 /// public SummaryData() {}
540 /// }
541 ///
542 /// [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors | ImplicitUseTargetFlags.Default)]
543 /// public interface IService {}
544 /// </code>
545 /// </example>
546 [AttributeUsage(AttributeTargets.All)]
547 public sealed class UsedImplicitlyAttribute : Attribute
548 {
549 public UsedImplicitlyAttribute()
550 : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
551 {
552 }
553  
554 public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
555 : this(useKindFlags, ImplicitUseTargetFlags.Default)
556 {
557 }
558  
559 public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
560 : this(ImplicitUseKindFlags.Default, targetFlags)
561 {
562 }
563  
564 public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
565 {
566 UseKindFlags = useKindFlags;
567 TargetFlags = targetFlags;
568 }
569  
570 public ImplicitUseKindFlags UseKindFlags { get; }
571  
572 public ImplicitUseTargetFlags TargetFlags { get; }
573 }
574  
575 /// <summary>
576 /// Can be applied to attributes, type parameters, and parameters of a type assignable from <see cref="System.Type" />
577 /// .
578 /// When applied to an attribute, the decorated attribute behaves the same as <see cref="UsedImplicitlyAttribute" />.
579 /// When applied to a type parameter or to a parameter of type <see cref="System.Type" />,
580 /// indicates that the corresponding type is used implicitly.
581 /// </summary>
582 [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter | AttributeTargets.Parameter)]
583 public sealed class MeansImplicitUseAttribute : Attribute
584 {
585 public MeansImplicitUseAttribute()
586 : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
587 {
588 }
589  
590 public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
591 : this(useKindFlags, ImplicitUseTargetFlags.Default)
592 {
593 }
594  
595 public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
596 : this(ImplicitUseKindFlags.Default, targetFlags)
597 {
598 }
599  
600 public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
601 {
602 UseKindFlags = useKindFlags;
603 TargetFlags = targetFlags;
604 }
605  
54 office 606 [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; }
1 office 607  
54 office 608 [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; }
1 office 609 }
610  
611 /// <summary>
612 /// Specifies the details of implicitly used symbol when it is marked
613 /// with <see cref="MeansImplicitUseAttribute" /> or <see cref="UsedImplicitlyAttribute" />.
614 /// </summary>
615 [Flags]
616 public enum ImplicitUseKindFlags
617 {
618 Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
619  
620 /// <summary>Only entity marked with attribute considered used.</summary>
621 Access = 1,
622  
623 /// <summary>Indicates implicit assignment to a member.</summary>
624 Assign = 2,
625  
626 /// <summary>
627 /// Indicates implicit instantiation of a type with fixed constructor signature.
628 /// That means any unused constructor parameters won't be reported as such.
629 /// </summary>
630 InstantiatedWithFixedConstructorSignature = 4,
631  
632 /// <summary>Indicates implicit instantiation of a type.</summary>
633 InstantiatedNoFixedConstructorSignature = 8
634 }
635  
636 /// <summary>
637 /// Specifies what is considered to be used implicitly when marked
638 /// with <see cref="MeansImplicitUseAttribute" /> or <see cref="UsedImplicitlyAttribute" />.
639 /// </summary>
640 [Flags]
641 public enum ImplicitUseTargetFlags
642 {
643 Default = Itself,
644  
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  
54 office 674 [CanBeNull] public string Comment { get; }
1 office 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  
54 office 738 [CanBeNull] public string Justification { get; }
1 office 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  
54 office 796 public PathReferenceAttribute([NotNull] [PathReference] string basePath)
1 office 797 {
798 BasePath = basePath;
799 }
800  
54 office 801 [CanBeNull] public string BasePath { get; }
1 office 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  
1055 HTML,
1056  
1057 JAVASCRIPT,
1058  
1059 JSON,
1060  
1061 XML
1062 }
1063  
1064 /// <summary>
1065 /// Indicates that the marked parameter, field, or property is accepting a string literal
1066 /// containing code fragment in a language specified by the <see cref="InjectedLanguage" />.
1067 /// </summary>
1068 /// <example>
1069 /// <code>
1070 /// void Foo([LanguageInjection(InjectedLanguage.CSS, Prefix = "body{", Suffix = "}")] string cssProps)
1071 /// {
1072 /// // cssProps should only contains a list of CSS properties
1073 /// }
1074 /// </code>
1075 /// </example>
1076 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1077 public sealed class LanguageInjectionAttribute : Attribute
1078 {
1079 public LanguageInjectionAttribute(InjectedLanguage injectedLanguage)
1080 {
1081 InjectedLanguage = injectedLanguage;
1082 }
1083  
1084 /// <summary>Specify a language of injected code fragment.</summary>
1085 public InjectedLanguage InjectedLanguage { get; }
1086  
1087 /// <summary>Specify a string that "precedes" injected string literal.</summary>
1088 [CanBeNull]
1089 public string Prefix { get; set; }
1090  
1091 /// <summary>Specify a string that "follows" injected string literal.</summary>
1092 [CanBeNull]
1093 public string Suffix { get; set; }
1094 }
1095  
1096 /// <summary>
1097 /// Prevents the Member Reordering feature from tossing members of the marked class.
1098 /// </summary>
1099 /// <remarks>
1100 /// The attribute must be mentioned in your member reordering patterns.
1101 /// </remarks>
1102 [AttributeUsage(
1103 AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)]
1104 public sealed class NoReorderAttribute : Attribute
1105 {
1106 }
1107  
1108 /// <summary>
1109 /// <para>
1110 /// Defines the code search template using the Structural Search and Replace syntax.
1111 /// It allows you to find and, if necessary, replace blocks of code that match a specific pattern.
1112 /// Search and replace patterns consist of a textual part and placeholders.
1113 /// Textural part must contain only identifiers allowed in the target language and will be matched exactly (white
1114 /// spaces, tabulation characters, and line breaks are ignored).
1115 /// Placeholders allow matching variable parts of the target code blocks.
1116 /// A placeholder has the following format: $placeholder_name$- where placeholder_name is an arbitrary identifier.
1117 /// </para>
1118 /// <para>
1119 /// Available placeholders:
1120 /// <list type="bullet">
1121 /// <item>$this$ - expression of containing type</item>
1122 /// <item>$thisType$ - containing type</item>
1123 /// <item>$member$ - current member placeholder</item>
1124 /// <item>
1125 /// $qualifier$ - this placeholder is available in the replace pattern and can be used to insert qualifier
1126 /// expression matched by the $member$ placeholder.
1127 /// (Note that if $qualifier$ placeholder is used, then $member$ placeholder will match only qualified
1128 /// references)
1129 /// </item>
1130 /// <item>$expression$ - expression of any type</item>
1131 /// <item>$identifier$ - identifier placeholder</item>
1132 /// <item>$args$ - any number of arguments</item>
1133 /// <item>$arg$ - single argument</item>
1134 /// <item>$arg1$ ... $arg10$ - single argument</item>
1135 /// <item>$stmts$ - any number of statements</item>
1136 /// <item>$stmt$ - single statement</item>
1137 /// <item>$stmt1$ ... $stmt10$ - single statement</item>
1138 /// <item>$name{Expression, 'Namespace.FooType'}$ - expression with 'Namespace.FooType' type</item>
1139 /// <item>$expression{'Namespace.FooType'}$ - expression with 'Namespace.FooType' type</item>
1140 /// <item>$name{Type, 'Namespace.FooType'}$ - 'Namespace.FooType' type</item>
1141 /// <item>$type{'Namespace.FooType'}$ - 'Namespace.FooType' type</item>
1142 /// <item>$statement{1,2}$ - 1 or 2 statements</item>
1143 /// </list>
1144 /// </para>
1145 /// <para>
1146 /// Note that you can also define your own placeholders of the supported types and specify arguments for each
1147 /// placeholder type.
1148 /// This can be done using the following format: $name{type, arguments}$. Where 'name' - is the name of your
1149 /// placeholder,
1150 /// 'type' - is the type of your placeholder (one of the following: Expression, Type, Identifier, Statement,
1151 /// Argument, Member),
1152 /// 'arguments' - arguments list for your placeholder. Each placeholder type supports it's own arguments, check
1153 /// examples below for mode details.
1154 /// Placeholder type may be omitted and determined from the placeholder name, if name has one of the following
1155 /// prefixes:
1156 /// <list type="bullet">
1157 /// <item>expr, expression - expression placeholder, e.g. $exprPlaceholder{}$, $expressionFoo{}$</item>
1158 /// <item>arg, argument - argument placeholder, e.g. $argPlaceholder{}$, $argumentFoo{}$</item>
1159 /// <item>ident, identifier - identifier placeholder, e.g. $identPlaceholder{}$, $identifierFoo{}$</item>
1160 /// <item>stmt, statement - statement placeholder, e.g. $stmtPlaceholder{}$, $statementFoo{}$</item>
1161 /// <item>type - type placeholder, e.g. $typePlaceholder{}$, $typeFoo{}$</item>
1162 /// <item>member - member placeholder, e.g. $memberPlaceholder{}$, $memberFoo{}$</item>
1163 /// </list>
1164 /// </para>
1165 /// <para>
1166 /// Expression placeholder arguments:
1167 /// <list type="bullet">
1168 /// <item>
1169 /// expressionType - string value in single quotes, specifies full type name to match (empty string by
1170 /// default)
1171 /// </item>
1172 /// <item>exactType - boolean value, specifies if expression should have exact type match (false by default)</item>
1173 /// </list>
1174 /// Examples:
1175 /// <list type="bullet">
1176 /// <item>
1177 /// $myExpr{Expression, 'Namespace.FooType', true}$ - defines expression placeholder, matching
1178 /// expressions of the 'Namespace.FooType' type with exact matching.
1179 /// </item>
1180 /// <item>
1181 /// $myExpr{Expression, 'Namespace.FooType'}$ - defines expression placeholder, matching expressions of
1182 /// the 'Namespace.FooType' type or expressions which can be implicitly converted to 'Namespace.FooType'.
1183 /// </item>
1184 /// <item>$myExpr{Expression}$ - defines expression placeholder, matching expressions of any type.</item>
1185 /// <item>
1186 /// $exprFoo{'Namespace.FooType', true}$ - defines expression placeholder, matching expressions of the
1187 /// 'Namespace.FooType' type with exact matching.
1188 /// </item>
1189 /// </list>
1190 /// </para>
1191 /// <para>
1192 /// Type placeholder arguments:
1193 /// <list type="bullet">
1194 /// <item>type - string value in single quotes, specifies full type name to match (empty string by default)</item>
1195 /// <item>exactType - boolean value, specifies if expression should have exact type match (false by default)</item>
1196 /// </list>
1197 /// Examples:
1198 /// <list type="bullet">
1199 /// <item>
1200 /// $myType{Type, 'Namespace.FooType', true}$ - defines type placeholder, matching 'Namespace.FooType'
1201 /// types with exact matching.
1202 /// </item>
1203 /// <item>
1204 /// $myType{Type, 'Namespace.FooType'}$ - defines type placeholder, matching 'Namespace.FooType' types or
1205 /// types, which can be implicitly converted to 'Namespace.FooType'.
1206 /// </item>
1207 /// <item>$myType{Type}$ - defines type placeholder, matching any type.</item>
1208 /// <item>
1209 /// $typeFoo{'Namespace.FooType', true}$ - defines types placeholder, matching 'Namespace.FooType' types
1210 /// with exact matching.
1211 /// </item>
1212 /// </list>
1213 /// </para>
1214 /// <para>
1215 /// Identifier placeholder arguments:
1216 /// <list type="bullet">
1217 /// <item>
1218 /// nameRegex - string value in single quotes, specifies regex to use for matching (empty string by
1219 /// default)
1220 /// </item>
1221 /// <item>nameRegexCaseSensitive - boolean value, specifies if name regex is case sensitive (true by default)</item>
1222 /// <item>type - string value in single quotes, specifies full type name to match (empty string by default)</item>
1223 /// <item>exactType - boolean value, specifies if expression should have exact type match (false by default)</item>
1224 /// </list>
1225 /// Examples:
1226 /// <list type="bullet">
1227 /// <item>
1228 /// $myIdentifier{Identifier, 'my.*', false, 'Namespace.FooType', true}$ - defines identifier
1229 /// placeholder, matching identifiers (ignoring case) starting with 'my' prefix with 'Namespace.FooType'
1230 /// type.
1231 /// </item>
1232 /// <item>
1233 /// $myIdentifier{Identifier, 'my.*', true, 'Namespace.FooType', true}$ - defines identifier placeholder,
1234 /// matching identifiers (case sensitively) starting with 'my' prefix with 'Namespace.FooType' type.
1235 /// </item>
1236 /// <item>
1237 /// $identFoo{'my.*'}$ - defines identifier placeholder, matching identifiers (case sensitively) starting
1238 /// with 'my' prefix.
1239 /// </item>
1240 /// </list>
1241 /// </para>
1242 /// <para>
1243 /// Statement placeholder arguments:
1244 /// <list type="bullet">
1245 /// <item>minimalOccurrences - minimal number of statements to match (-1 by default)</item>
1246 /// <item>maximalOccurrences - maximal number of statements to match (-1 by default)</item>
1247 /// </list>
1248 /// Examples:
1249 /// <list type="bullet">
1250 /// <item>$myStmt{Statement, 1, 2}$ - defines statement placeholder, matching 1 or 2 statements.</item>
1251 /// <item>$myStmt{Statement}$ - defines statement placeholder, matching any number of statements.</item>
1252 /// <item>$stmtFoo{1, 2}$ - defines statement placeholder, matching 1 or 2 statements.</item>
1253 /// </list>
1254 /// </para>
1255 /// <para>
1256 /// Argument placeholder arguments:
1257 /// <list type="bullet">
1258 /// <item>minimalOccurrences - minimal number of arguments to match (-1 by default)</item>
1259 /// <item>maximalOccurrences - maximal number of arguments to match (-1 by default)</item>
1260 /// </list>
1261 /// Examples:
1262 /// <list type="bullet">
1263 /// <item>$myArg{Argument, 1, 2}$ - defines argument placeholder, matching 1 or 2 arguments.</item>
1264 /// <item>$myArg{Argument}$ - defines argument placeholder, matching any number of arguments.</item>
1265 /// <item>$argFoo{1, 2}$ - defines argument placeholder, matching 1 or 2 arguments.</item>
1266 /// </list>
1267 /// </para>
1268 /// <para>
1269 /// Member placeholder arguments:
1270 /// <list type="bullet">
1271 /// <item>
1272 /// docId - string value in single quotes, specifies XML documentation id of the member to match (empty
1273 /// by default)
1274 /// </item>
1275 /// </list>
1276 /// Examples:
1277 /// <list type="bullet">
1278 /// <item>
1279 /// $myMember{Member, 'M:System.String.IsNullOrEmpty(System.String)'}$ - defines member placeholder,
1280 /// matching 'IsNullOrEmpty' member of the 'System.String' type.
1281 /// </item>
1282 /// <item>
1283 /// $memberFoo{'M:System.String.IsNullOrEmpty(System.String)'}$ - defines member placeholder, matching
1284 /// 'IsNullOrEmpty' member of the 'System.String' type.
1285 /// </item>
1286 /// </list>
1287 /// </para>
1288 /// <para>
1289 /// For more information please refer to the
1290 /// <a href="https://www.jetbrains.com/help/resharper/Navigation_and_Search__Structural_Search_and_Replace.html">
1291 /// Structural
1292 /// Search and Replace
1293 /// </a>
1294 /// article.
1295 /// </para>
1296 /// </summary>
1297 [AttributeUsage(
1298 AttributeTargets.Method
1299 | AttributeTargets.Constructor
1300 | AttributeTargets.Property
1301 | AttributeTargets.Field
1302 | AttributeTargets.Event
1303 | AttributeTargets.Interface
1304 | AttributeTargets.Class
1305 | AttributeTargets.Struct
1306 | AttributeTargets.Enum,
1307 AllowMultiple = true,
1308 Inherited = false)]
1309 public sealed class CodeTemplateAttribute : Attribute
1310 {
1311 public CodeTemplateAttribute(string searchTemplate)
1312 {
1313 SearchTemplate = searchTemplate;
1314 }
1315  
1316 /// <summary>
1317 /// Structural search pattern to use in the code template.
1318 /// Pattern includes textual part, which must contain only identifiers allowed in the target language,
1319 /// and placeholders, which allow matching variable parts of the target code blocks.
1320 /// </summary>
1321 public string SearchTemplate { get; }
1322  
1323 /// <summary>
1324 /// Message to show when the search pattern was found.
1325 /// You can also prepend the message text with "Error:", "Warning:", "Suggestion:" or "Hint:" prefix to specify the
1326 /// pattern severity.
1327 /// Code patterns with replace template produce suggestions by default.
1328 /// However, if replace template is not provided, then warning severity will be used.
1329 /// </summary>
1330 public string Message { get; set; }
1331  
1332 /// <summary>
1333 /// Structural search replace pattern to use in code template replacement.
1334 /// </summary>
1335 public string ReplaceTemplate { get; set; }
1336  
1337 /// <summary>
1338 /// Replace message to show in the light bulb.
1339 /// </summary>
1340 public string ReplaceMessage { get; set; }
1341  
1342 /// <summary>
1343 /// Apply code formatting after code replacement.
1344 /// </summary>
1345 public bool FormatAfterReplace { get; set; } = true;
1346  
1347 /// <summary>
1348 /// Whether similar code blocks should be matched.
1349 /// </summary>
1350 public bool MatchSimilarConstructs { get; set; }
1351  
1352 /// <summary>
1353 /// Automatically insert namespace import directives or remove qualifiers that become redundant after the template is
1354 /// applied.
1355 /// </summary>
1356 public bool ShortenReferences { get; set; }
1357  
1358 /// <summary>
1359 /// String to use as a suppression key.
1360 /// By default the following suppression key is used 'CodeTemplate_SomeType_SomeMember',
1361 /// where 'SomeType' and 'SomeMember' are names of the associated containing type and member to which this attribute is
1362 /// applied.
1363 /// </summary>
1364 public string SuppressionKey { get; set; }
1365 }
1366  
1367 #region ASP.NET
1368  
1369 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
1370 public sealed class AspChildControlTypeAttribute : Attribute
1371 {
1372 public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType)
1373 {
1374 TagName = tagName;
1375 ControlType = controlType;
1376 }
1377  
54 office 1378 [NotNull] public string TagName { get; }
1 office 1379  
54 office 1380 [NotNull] public Type ControlType { get; }
1 office 1381 }
1382  
1383 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
1384 public sealed class AspDataFieldAttribute : Attribute
1385 {
1386 }
1387  
1388 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
1389 public sealed class AspDataFieldsAttribute : Attribute
1390 {
1391 }
1392  
1393 [AttributeUsage(AttributeTargets.Property)]
1394 public sealed class AspMethodPropertyAttribute : Attribute
1395 {
1396 }
1397  
1398 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
1399 public sealed class AspRequiredAttributeAttribute : Attribute
1400 {
1401 public AspRequiredAttributeAttribute([NotNull] string attribute)
1402 {
1403 Attribute = attribute;
1404 }
1405  
54 office 1406 [NotNull] public string Attribute { get; }
1 office 1407 }
1408  
1409 [AttributeUsage(AttributeTargets.Property)]
1410 public sealed class AspTypePropertyAttribute : Attribute
1411 {
1412 public AspTypePropertyAttribute(bool createConstructorReferences)
1413 {
1414 CreateConstructorReferences = createConstructorReferences;
1415 }
1416  
1417 public bool CreateConstructorReferences { get; }
1418 }
1419  
1420 #endregion
1421  
1422 #region ASP.NET MVC
1423  
1424 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1425 AllowMultiple = true)]
1426 public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
1427 {
1428 public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format)
1429 {
1430 Format = format;
1431 }
1432  
54 office 1433 [NotNull] public string Format { get; }
1 office 1434 }
1435  
1436 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1437 AllowMultiple = true)]
1438 public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
1439 {
1440 public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format)
1441 {
1442 Format = format;
1443 }
1444  
54 office 1445 [NotNull] public string Format { get; }
1 office 1446 }
1447  
1448 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1449 AllowMultiple = true)]
1450 public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
1451 {
1452 public AspMvcAreaViewLocationFormatAttribute([NotNull] string format)
1453 {
1454 Format = format;
1455 }
1456  
54 office 1457 [NotNull] public string Format { get; }
1 office 1458 }
1459  
1460 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1461 AllowMultiple = true)]
1462 public sealed class AspMvcMasterLocationFormatAttribute : Attribute
1463 {
1464 public AspMvcMasterLocationFormatAttribute([NotNull] string format)
1465 {
1466 Format = format;
1467 }
1468  
54 office 1469 [NotNull] public string Format { get; }
1 office 1470 }
1471  
1472 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1473 AllowMultiple = true)]
1474 public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
1475 {
1476 public AspMvcPartialViewLocationFormatAttribute([NotNull] string format)
1477 {
1478 Format = format;
1479 }
1480  
54 office 1481 [NotNull] public string Format { get; }
1 office 1482 }
1483  
1484 [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property,
1485 AllowMultiple = true)]
1486 public sealed class AspMvcViewLocationFormatAttribute : Attribute
1487 {
1488 public AspMvcViewLocationFormatAttribute([NotNull] string format)
1489 {
1490 Format = format;
1491 }
1492  
54 office 1493 [NotNull] public string Format { get; }
1 office 1494 }
1495  
1496 /// <summary>
1497 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1498 /// is an MVC action. If applied to a method, the MVC action name is calculated
1499 /// implicitly from the context. Use this attribute for custom wrappers similar to
1500 /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
1501 /// </summary>
1502 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1503 AttributeTargets.Property)]
1504 public sealed class AspMvcActionAttribute : Attribute
1505 {
1506 public AspMvcActionAttribute()
1507 {
1508 }
1509  
1510 public AspMvcActionAttribute([NotNull] string anonymousProperty)
1511 {
1512 AnonymousProperty = anonymousProperty;
1513 }
1514  
54 office 1515 [CanBeNull] public string AnonymousProperty { get; }
1 office 1516 }
1517  
1518 /// <summary>
1519 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC area.
1520 /// Use this attribute for custom wrappers similar to
1521 /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
1522 /// </summary>
1523 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1524 public sealed class AspMvcAreaAttribute : Attribute
1525 {
1526 public AspMvcAreaAttribute()
1527 {
1528 }
1529  
1530 public AspMvcAreaAttribute([NotNull] string anonymousProperty)
1531 {
1532 AnonymousProperty = anonymousProperty;
1533 }
1534  
54 office 1535 [CanBeNull] public string AnonymousProperty { get; }
1 office 1536 }
1537  
1538 /// <summary>
1539 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is
1540 /// an MVC controller. If applied to a method, the MVC controller name is calculated
1541 /// implicitly from the context. Use this attribute for custom wrappers similar to
1542 /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>.
1543 /// </summary>
1544 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1545 AttributeTargets.Property)]
1546 public sealed class AspMvcControllerAttribute : Attribute
1547 {
1548 public AspMvcControllerAttribute()
1549 {
1550 }
1551  
1552 public AspMvcControllerAttribute([NotNull] string anonymousProperty)
1553 {
1554 AnonymousProperty = anonymousProperty;
1555 }
1556  
54 office 1557 [CanBeNull] public string AnonymousProperty { get; }
1 office 1558 }
1559  
1560 /// <summary>
1561 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC Master. Use this attribute
1562 /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.
1563 /// </summary>
1564 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1565 public sealed class AspMvcMasterAttribute : Attribute
1566 {
1567 }
1568  
1569 /// <summary>
1570 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC model type. Use this attribute
1571 /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>.
1572 /// </summary>
1573 [AttributeUsage(AttributeTargets.Parameter)]
1574 public sealed class AspMvcModelTypeAttribute : Attribute
1575 {
1576 }
1577  
1578 /// <summary>
1579 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC
1580 /// partial view. If applied to a method, the MVC partial view name is calculated implicitly
1581 /// from the context. Use this attribute for custom wrappers similar to
1582 /// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.
1583 /// </summary>
1584 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1585 AttributeTargets.Property)]
1586 public sealed class AspMvcPartialViewAttribute : Attribute
1587 {
1588 }
1589  
1590 /// <summary>
1591 /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.
1592 /// </summary>
1593 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
1594 public sealed class AspMvcSuppressViewErrorAttribute : Attribute
1595 {
1596 }
1597  
1598 /// <summary>
1599 /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
1600 /// Use this attribute for custom wrappers similar to
1601 /// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.
1602 /// </summary>
1603 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1604 public sealed class AspMvcDisplayTemplateAttribute : Attribute
1605 {
1606 }
1607  
1608 /// <summary>
1609 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC editor template.
1610 /// Use this attribute for custom wrappers similar to
1611 /// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>.
1612 /// </summary>
1613 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1614 public sealed class AspMvcEditorTemplateAttribute : Attribute
1615 {
1616 }
1617  
1618 /// <summary>
1619 /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC template.
1620 /// Use this attribute for custom wrappers similar to
1621 /// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.
1622 /// </summary>
1623 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1624 public sealed class AspMvcTemplateAttribute : Attribute
1625 {
1626 }
1627  
1628 /// <summary>
1629 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1630 /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly
1631 /// from the context. Use this attribute for custom wrappers similar to
1632 /// <c>System.Web.Mvc.Controller.View(Object)</c>.
1633 /// </summary>
1634 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1635 AttributeTargets.Property)]
1636 public sealed class AspMvcViewAttribute : Attribute
1637 {
1638 }
1639  
1640 /// <summary>
1641 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1642 /// is an MVC view component name.
1643 /// </summary>
1644 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1645 public sealed class AspMvcViewComponentAttribute : Attribute
1646 {
1647 }
1648  
1649 /// <summary>
1650 /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
1651 /// is an MVC view component view. If applied to a method, the MVC view component view name is default.
1652 /// </summary>
1653 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field |
1654 AttributeTargets.Property)]
1655 public sealed class AspMvcViewComponentViewAttribute : Attribute
1656 {
1657 }
1658  
1659 /// <summary>
1660 /// ASP.NET MVC attribute. When applied to a parameter of an attribute,
1661 /// indicates that this parameter is an MVC action name.
1662 /// </summary>
1663 /// <example>
1664 /// <code>
1665 /// [ActionName("Foo")]
1666 /// public ActionResult Login(string returnUrl) {
1667 /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
1668 /// return RedirectToAction("Bar"); // Error: Cannot resolve action
1669 /// }
1670 /// </code>
1671 /// </example>
1672 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
1673 public sealed class AspMvcActionSelectorAttribute : Attribute
1674 {
1675 }
1676  
1677 #endregion
1678  
1679 #region ASP.NET Routing
1680  
1681 /// <summary>
1682 /// Indicates that the marked parameter, field, or property is a route template.
1683 /// </summary>
1684 /// <remarks>
1685 /// This attribute allows IDE to recognize the use of web frameworks' route templates
1686 /// to enable syntax highlighting, code completion, navigation, rename and other features in string literals.
1687 /// </remarks>
1688 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1689 public sealed class RouteTemplateAttribute : Attribute
1690 {
1691 }
1692  
1693 /// <summary>
1694 /// Indicates that the marked type is custom route parameter constraint,
1695 /// which is registered in application's Startup with name <c>ConstraintName</c>
1696 /// </summary>
1697 /// <remarks>
1698 /// You can specify <c>ProposedType</c> if target constraint matches only route parameters of specific type,
1699 /// it will allow IDE to create method's parameter from usage in route template
1700 /// with specified type instead of default <c>System.String</c>
1701 /// and check if constraint's proposed type conflicts with matched parameter's type
1702 /// </remarks>
1703 [AttributeUsage(AttributeTargets.Class)]
1704 public sealed class RouteParameterConstraintAttribute : Attribute
1705 {
1706 public RouteParameterConstraintAttribute([NotNull] string constraintName)
1707 {
1708 ConstraintName = constraintName;
1709 }
1710  
54 office 1711 [NotNull] public string ConstraintName { get; }
1 office 1712  
54 office 1713 [CanBeNull] public Type ProposedType { get; set; }
1 office 1714 }
1715  
1716 /// <summary>
1717 /// Indicates that the marked parameter, field, or property is an URI string.
1718 /// </summary>
1719 /// <remarks>
1720 /// This attribute enables code completion, navigation, rename and other features
1721 /// in URI string literals assigned to annotated parameter, field or property.
1722 /// </remarks>
1723 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1724 public sealed class UriStringAttribute : Attribute
1725 {
1726 public UriStringAttribute()
1727 {
1728 }
1729  
1730 public UriStringAttribute(string httpVerb)
1731 {
1732 HttpVerb = httpVerb;
1733 }
1734  
54 office 1735 [CanBeNull] public string HttpVerb { get; }
1 office 1736 }
1737  
1738 /// <summary>
1739 /// Indicates that the marked method declares routing convention for ASP.NET
1740 /// </summary>
1741 /// <remarks>
1742 /// IDE will analyze all usages of methods marked with this attribute,
1743 /// and will add all routes to completion, navigation and other features over URI strings
1744 /// </remarks>
1745 [AttributeUsage(AttributeTargets.Method)]
1746 public sealed class AspRouteConventionAttribute : Attribute
1747 {
1748 public AspRouteConventionAttribute()
1749 {
1750 }
1751  
1752 public AspRouteConventionAttribute(string predefinedPattern)
1753 {
1754 PredefinedPattern = predefinedPattern;
1755 }
1756  
54 office 1757 [CanBeNull] public string PredefinedPattern { get; }
1 office 1758 }
1759  
1760 /// <summary>
1761 /// Indicates that the marked method parameter contains default route values of routing convention for ASP.NET
1762 /// </summary>
1763 [AttributeUsage(AttributeTargets.Parameter)]
1764 public sealed class AspDefaultRouteValuesAttribute : Attribute
1765 {
1766 }
1767  
1768 /// <summary>
1769 /// Indicates that the marked method parameter contains constraints on route values of routing convention for ASP.NET
1770 /// </summary>
1771 [AttributeUsage(AttributeTargets.Parameter)]
1772 public sealed class AspRouteValuesConstraintsAttribute : Attribute
1773 {
1774 }
1775  
1776 /// <summary>
1777 /// Indicates that the marked parameter or property contains routing order provided by ASP.NET routing attribute
1778 /// </summary>
1779 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
1780 public sealed class AspRouteOrderAttribute : Attribute
1781 {
1782 }
1783  
1784 /// <summary>
1785 /// Indicates that the marked parameter or property contains HTTP verbs provided by ASP.NET routing attribute
1786 /// </summary>
1787 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
1788 public sealed class AspRouteVerbsAttribute : Attribute
1789 {
1790 }
1791  
1792 /// <summary>
1793 /// Indicates that the marked attribute is used for attribute routing in ASP.NET
1794 /// </summary>
1795 /// <remarks>
1796 /// IDE will analyze all usages of attributes marked with this attribute,
1797 /// and will add all routes to completion, navigation and other features over URI strings
1798 /// </remarks>
1799 [AttributeUsage(AttributeTargets.Class)]
1800 public sealed class AspAttributeRoutingAttribute : Attribute
1801 {
1802 public string HttpVerb { get; set; }
1803 }
1804  
1805 /// <summary>
1806 /// Indicates that the marked method declares ASP.NET Minimal API endpoint
1807 /// </summary>
1808 /// <remarks>
1809 /// IDE will analyze all usages of methods marked with this attribute,
1810 /// and will add all routes to completion, navigation and other features over URI strings
1811 /// </remarks>
1812 [AttributeUsage(AttributeTargets.Method)]
1813 public sealed class AspMinimalApiDeclarationAttribute : Attribute
1814 {
1815 public string HttpVerb { get; set; }
1816 }
1817  
1818 /// <summary>
1819 /// Indicates that the marked parameter contains ASP.NET Minimal API endpoint handler
1820 /// </summary>
1821 [AttributeUsage(AttributeTargets.Parameter)]
1822 public sealed class AspMinimalApiHandlerAttribute : Attribute
1823 {
1824 }
1825  
1826 #endregion
1827  
1828 #region Razor
1829  
1830 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]
1831 public sealed class HtmlElementAttributesAttribute : Attribute
1832 {
1833 public HtmlElementAttributesAttribute()
1834 {
1835 }
1836  
1837 public HtmlElementAttributesAttribute([NotNull] string name)
1838 {
1839 Name = name;
1840 }
1841  
54 office 1842 [CanBeNull] public string Name { get; }
1 office 1843 }
1844  
1845 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
1846 public sealed class HtmlAttributeValueAttribute : Attribute
1847 {
1848 public HtmlAttributeValueAttribute([NotNull] string name)
1849 {
1850 Name = name;
1851 }
1852  
54 office 1853 [NotNull] public string Name { get; }
1 office 1854 }
1855  
1856 /// <summary>
1857 /// Razor attribute. Indicates that the marked parameter or method is a Razor section.
1858 /// Use this attribute for custom wrappers similar to
1859 /// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>.
1860 /// </summary>
1861 [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
1862 public sealed class RazorSectionAttribute : Attribute
1863 {
1864 }
1865  
1866 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1867 public sealed class RazorImportNamespaceAttribute : Attribute
1868 {
1869 public RazorImportNamespaceAttribute([NotNull] string name)
1870 {
1871 Name = name;
1872 }
1873  
54 office 1874 [NotNull] public string Name { get; }
1 office 1875 }
1876  
1877 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1878 public sealed class RazorInjectionAttribute : Attribute
1879 {
1880 public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName)
1881 {
1882 Type = type;
1883 FieldName = fieldName;
1884 }
1885  
54 office 1886 [NotNull] public string Type { get; }
1 office 1887  
54 office 1888 [NotNull] public string FieldName { get; }
1 office 1889 }
1890  
1891 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1892 public sealed class RazorDirectiveAttribute : Attribute
1893 {
1894 public RazorDirectiveAttribute([NotNull] string directive)
1895 {
1896 Directive = directive;
1897 }
1898  
54 office 1899 [NotNull] public string Directive { get; }
1 office 1900 }
1901  
1902 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
1903 public sealed class RazorPageBaseTypeAttribute : Attribute
1904 {
1905 public RazorPageBaseTypeAttribute([NotNull] string baseType)
1906 {
1907 BaseType = baseType;
1908 }
1909  
1910 public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName)
1911 {
1912 BaseType = baseType;
1913 PageName = pageName;
1914 }
1915  
54 office 1916 [NotNull] public string BaseType { get; }
1 office 1917  
54 office 1918 [CanBeNull] public string PageName { get; }
1 office 1919 }
1920  
1921 [AttributeUsage(AttributeTargets.Method)]
1922 public sealed class RazorHelperCommonAttribute : Attribute
1923 {
1924 }
1925  
1926 [AttributeUsage(AttributeTargets.Property)]
1927 public sealed class RazorLayoutAttribute : Attribute
1928 {
1929 }
1930  
1931 [AttributeUsage(AttributeTargets.Method)]
1932 public sealed class RazorWriteLiteralMethodAttribute : Attribute
1933 {
1934 }
1935  
1936 [AttributeUsage(AttributeTargets.Method)]
1937 public sealed class RazorWriteMethodAttribute : Attribute
1938 {
1939 }
1940  
1941 [AttributeUsage(AttributeTargets.Parameter)]
1942 public sealed class RazorWriteMethodParameterAttribute : Attribute
1943 {
1944 }
1945  
1946 #endregion
1947  
1948 #region XAML
1949  
1950 /// <summary>
1951 /// XAML attribute. Indicates the type that has <c>ItemsSource</c> property and should be treated
1952 /// as <c>ItemsControl</c>-derived type, to enable inner items <c>DataContext</c> type resolve.
1953 /// </summary>
1954 [AttributeUsage(AttributeTargets.Class)]
1955 public sealed class XamlItemsControlAttribute : Attribute
1956 {
1957 }
1958  
1959 /// <summary>
1960 /// XAML attribute. Indicates the property of some <c>BindingBase</c>-derived type, that
1961 /// is used to bind some item of <c>ItemsControl</c>-derived type. This annotation will
1962 /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
1963 /// </summary>
1964 /// <remarks>
1965 /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
1966 /// marked with the <see cref="XamlItemsControlAttribute" /> attribute.
1967 /// </remarks>
1968 [AttributeUsage(AttributeTargets.Property)]
1969 public sealed class XamlItemBindingOfItemsControlAttribute : Attribute
1970 {
1971 }
1972  
1973 /// <summary>
1974 /// XAML attribute. Indicates the property of some <c>Style</c>-derived type, that
1975 /// is used to style items of <c>ItemsControl</c>-derived type. This annotation will
1976 /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
1977 /// </summary>
1978 /// <remarks>
1979 /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
1980 /// marked with the <see cref="XamlItemsControlAttribute" /> attribute.
1981 /// </remarks>
1982 [AttributeUsage(AttributeTargets.Property)]
1983 public sealed class XamlItemStyleOfItemsControlAttribute : Attribute
1984 {
1985 }
1986  
1987 /// <summary>
1988 /// XAML attribute. Indicates that DependencyProperty has <c>OneWay</c> binding mode by default.
1989 /// </summary>
1990 /// <remarks>
1991 /// This attribute must be applied to DependencyProperty's CLR accessor property if it is present, to
1992 /// DependencyProperty descriptor field otherwise.
1993 /// </remarks>
1994 [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
1995 public sealed class XamlOneWayBindingModeByDefaultAttribute : Attribute
1996 {
1997 }
1998  
1999 /// <summary>
2000 /// XAML attribute. Indicates that DependencyProperty has <c>TwoWay</c> binding mode by default.
2001 /// </summary>
2002 /// <remarks>
2003 /// This attribute must be applied to DependencyProperty's CLR accessor property if it is present, to
2004 /// DependencyProperty descriptor field otherwise.
2005 /// </remarks>
2006 [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
2007 public sealed class XamlTwoWayBindingModeByDefaultAttribute : Attribute
2008 {
2009 }
2010  
2011 #endregion
2012 }