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 | #pragma warning disable 1591
|
---|
26 | // ReSharper disable UnusedMember.Global
|
---|
27 | // ReSharper disable MemberCanBePrivate.Global
|
---|
28 | // ReSharper disable UnusedAutoPropertyAccessor.Global
|
---|
29 | // ReSharper disable IntroduceOptionalParameters.Global
|
---|
30 | // ReSharper disable MemberCanBeProtected.Global
|
---|
31 | // ReSharper disable InconsistentNaming
|
---|
32 |
|
---|
33 | namespace HeuristicLab.Problems.DataAnalysis.Annotations
|
---|
34 | {
|
---|
35 | /// <summary>
|
---|
36 | /// Indicates that the value of the marked element could be <c>null</c> sometimes,
|
---|
37 | /// so the check for <c>null</c> is necessary before its usage.
|
---|
38 | /// </summary>
|
---|
39 | /// <example><code>
|
---|
40 | /// [CanBeNull] object Test() => null;
|
---|
41 | ///
|
---|
42 | /// void UseTest() {
|
---|
43 | /// var p = Test();
|
---|
44 | /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
|
---|
45 | /// }
|
---|
46 | /// </code></example>
|
---|
47 | [AttributeUsage(
|
---|
48 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
|
---|
49 | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
|
---|
50 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
|
---|
51 | public sealed class CanBeNullAttribute : Attribute { }
|
---|
52 |
|
---|
53 | /// <summary>
|
---|
54 | /// Indicates that the value of the marked element could never be <c>null</c>.
|
---|
55 | /// </summary>
|
---|
56 | /// <example><code>
|
---|
57 | /// [NotNull] object Foo() {
|
---|
58 | /// return null; // Warning: Possible 'null' assignment
|
---|
59 | /// }
|
---|
60 | /// </code></example>
|
---|
61 | [AttributeUsage(
|
---|
62 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
|
---|
63 | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
|
---|
64 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
|
---|
65 | public sealed class NotNullAttribute : Attribute { }
|
---|
66 |
|
---|
67 | /// <summary>
|
---|
68 | /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task
|
---|
69 | /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
|
---|
70 | /// or of the Lazy.Value property can never be null.
|
---|
71 | /// </summary>
|
---|
72 | [AttributeUsage(
|
---|
73 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
|
---|
74 | AttributeTargets.Delegate | AttributeTargets.Field)]
|
---|
75 | public sealed class ItemNotNullAttribute : Attribute { }
|
---|
76 |
|
---|
77 | /// <summary>
|
---|
78 | /// Can be appplied 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 be null.
|
---|
81 | /// </summary>
|
---|
82 | [AttributeUsage(
|
---|
83 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
|
---|
84 | AttributeTargets.Delegate | AttributeTargets.Field)]
|
---|
85 | public sealed class ItemCanBeNullAttribute : Attribute { }
|
---|
86 |
|
---|
87 | /// <summary>
|
---|
88 | /// Indicates that the marked method builds string by format pattern and (optional) arguments.
|
---|
89 | /// Parameter, which contains format string, should be given in constructor. The format string
|
---|
90 | /// should be in <see cref="string.Format(IFormatProvider,string,object[])"/>-like form.
|
---|
91 | /// </summary>
|
---|
92 | /// <example><code>
|
---|
93 | /// [StringFormatMethod("message")]
|
---|
94 | /// void ShowError(string message, params object[] args) { /* do something */ }
|
---|
95 | ///
|
---|
96 | /// void Foo() {
|
---|
97 | /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
|
---|
98 | /// }
|
---|
99 | /// </code></example>
|
---|
100 | [AttributeUsage(
|
---|
101 | AttributeTargets.Constructor | AttributeTargets.Method |
|
---|
102 | AttributeTargets.Property | AttributeTargets.Delegate)]
|
---|
103 | public sealed class StringFormatMethodAttribute : Attribute
|
---|
104 | {
|
---|
105 | /// <param name="formatParameterName">
|
---|
106 | /// Specifies which parameter of an annotated method should be treated as format-string
|
---|
107 | /// </param>
|
---|
108 | public StringFormatMethodAttribute([NotNull] string formatParameterName)
|
---|
109 | {
|
---|
110 | FormatParameterName = formatParameterName;
|
---|
111 | }
|
---|
112 |
|
---|
113 | [NotNull] public string FormatParameterName { get; private set; }
|
---|
114 | }
|
---|
115 |
|
---|
116 | /// <summary>
|
---|
117 | /// For a parameter that is expected to be one of the limited set of values.
|
---|
118 | /// Specify fields of which type should be used as values for this parameter.
|
---|
119 | /// </summary>
|
---|
120 | [AttributeUsage(
|
---|
121 | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field,
|
---|
122 | AllowMultiple = true)]
|
---|
123 | public sealed class ValueProviderAttribute : Attribute
|
---|
124 | {
|
---|
125 | public ValueProviderAttribute([NotNull] string name)
|
---|
126 | {
|
---|
127 | Name = name;
|
---|
128 | }
|
---|
129 |
|
---|
130 | [NotNull] public string Name { get; private set; }
|
---|
131 | }
|
---|
132 |
|
---|
133 | /// <summary>
|
---|
134 | /// Indicates that the function argument should be string literal and match one
|
---|
135 | /// of the parameters of the caller function. For example, ReSharper annotates
|
---|
136 | /// the parameter of <see cref="System.ArgumentNullException"/>.
|
---|
137 | /// </summary>
|
---|
138 | /// <example><code>
|
---|
139 | /// void Foo(string param) {
|
---|
140 | /// if (param == null)
|
---|
141 | /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
|
---|
142 | /// }
|
---|
143 | /// </code></example>
|
---|
144 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
145 | public sealed class InvokerParameterNameAttribute : Attribute { }
|
---|
146 |
|
---|
147 | /// <summary>
|
---|
148 | /// Indicates that the method is contained in a type that implements
|
---|
149 | /// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method
|
---|
150 | /// is used to notify that some property value changed.
|
---|
151 | /// </summary>
|
---|
152 | /// <remarks>
|
---|
153 | /// The method should be non-static and conform to one of the supported signatures:
|
---|
154 | /// <list>
|
---|
155 | /// <item><c>NotifyChanged(string)</c></item>
|
---|
156 | /// <item><c>NotifyChanged(params string[])</c></item>
|
---|
157 | /// <item><c>NotifyChanged{T}(Expression{Func{T}})</c></item>
|
---|
158 | /// <item><c>NotifyChanged{T,U}(Expression{Func{T,U}})</c></item>
|
---|
159 | /// <item><c>SetProperty{T}(ref T, T, string)</c></item>
|
---|
160 | /// </list>
|
---|
161 | /// </remarks>
|
---|
162 | /// <example><code>
|
---|
163 | /// public class Foo : INotifyPropertyChanged {
|
---|
164 | /// public event PropertyChangedEventHandler PropertyChanged;
|
---|
165 | ///
|
---|
166 | /// [NotifyPropertyChangedInvocator]
|
---|
167 | /// protected virtual void NotifyChanged(string propertyName) { ... }
|
---|
168 | ///
|
---|
169 | /// string _name;
|
---|
170 | ///
|
---|
171 | /// public string Name {
|
---|
172 | /// get { return _name; }
|
---|
173 | /// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
|
---|
174 | /// }
|
---|
175 | /// }
|
---|
176 | /// </code>
|
---|
177 | /// Examples of generated notifications:
|
---|
178 | /// <list>
|
---|
179 | /// <item><c>NotifyChanged("Property")</c></item>
|
---|
180 | /// <item><c>NotifyChanged(() => Property)</c></item>
|
---|
181 | /// <item><c>NotifyChanged((VM x) => x.Property)</c></item>
|
---|
182 | /// <item><c>SetProperty(ref myField, value, "Property")</c></item>
|
---|
183 | /// </list>
|
---|
184 | /// </example>
|
---|
185 | [AttributeUsage(AttributeTargets.Method)]
|
---|
186 | public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
|
---|
187 | {
|
---|
188 | public NotifyPropertyChangedInvocatorAttribute() { }
|
---|
189 | public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
|
---|
190 | {
|
---|
191 | ParameterName = parameterName;
|
---|
192 | }
|
---|
193 |
|
---|
194 | [CanBeNull] public string ParameterName { get; private set; }
|
---|
195 | }
|
---|
196 |
|
---|
197 | /// <summary>
|
---|
198 | /// Describes dependency between method input and output.
|
---|
199 | /// </summary>
|
---|
200 | /// <syntax>
|
---|
201 | /// <p>Function Definition Table syntax:</p>
|
---|
202 | /// <list>
|
---|
203 | /// <item>FDT ::= FDTRow [;FDTRow]*</item>
|
---|
204 | /// <item>FDTRow ::= Input => Output | Output <= Input</item>
|
---|
205 | /// <item>Input ::= ParameterName: Value [, Input]*</item>
|
---|
206 | /// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>
|
---|
207 | /// <item>Value ::= true | false | null | notnull | canbenull</item>
|
---|
208 | /// </list>
|
---|
209 | /// If method has single input parameter, it's name could be omitted.<br/>
|
---|
210 | /// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for method output
|
---|
211 | /// means that the methos doesn't return normally (throws or terminates the process).<br/>
|
---|
212 | /// Value <c>canbenull</c> is only applicable for output parameters.<br/>
|
---|
213 | /// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute
|
---|
214 | /// with rows separated by semicolon. There is no notion of order rows, all rows are checked
|
---|
215 | /// for applicability and applied per each program state tracked by R# analysis.<br/>
|
---|
216 | /// </syntax>
|
---|
217 | /// <examples><list>
|
---|
218 | /// <item><code>
|
---|
219 | /// [ContractAnnotation("=> halt")]
|
---|
220 | /// public void TerminationMethod()
|
---|
221 | /// </code></item>
|
---|
222 | /// <item><code>
|
---|
223 | /// [ContractAnnotation("halt <= condition: false")]
|
---|
224 | /// public void Assert(bool condition, string text) // regular assertion method
|
---|
225 | /// </code></item>
|
---|
226 | /// <item><code>
|
---|
227 | /// [ContractAnnotation("s:null => true")]
|
---|
228 | /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
|
---|
229 | /// </code></item>
|
---|
230 | /// <item><code>
|
---|
231 | /// // A method that returns null if the parameter is null,
|
---|
232 | /// // and not null if the parameter is not null
|
---|
233 | /// [ContractAnnotation("null => null; notnull => notnull")]
|
---|
234 | /// public object Transform(object data)
|
---|
235 | /// </code></item>
|
---|
236 | /// <item><code>
|
---|
237 | /// [ContractAnnotation("=> true, result: notnull; => false, result: null")]
|
---|
238 | /// public bool TryParse(string s, out Person result)
|
---|
239 | /// </code></item>
|
---|
240 | /// </list></examples>
|
---|
241 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
---|
242 | public sealed class ContractAnnotationAttribute : Attribute
|
---|
243 | {
|
---|
244 | public ContractAnnotationAttribute([NotNull] string contract)
|
---|
245 | : this(contract, false) { }
|
---|
246 |
|
---|
247 | public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
|
---|
248 | {
|
---|
249 | Contract = contract;
|
---|
250 | ForceFullStates = forceFullStates;
|
---|
251 | }
|
---|
252 |
|
---|
253 | [NotNull] public string Contract { get; private set; }
|
---|
254 |
|
---|
255 | public bool ForceFullStates { get; private set; }
|
---|
256 | }
|
---|
257 |
|
---|
258 | /// <summary>
|
---|
259 | /// Indicates that marked element should be localized or not.
|
---|
260 | /// </summary>
|
---|
261 | /// <example><code>
|
---|
262 | /// [LocalizationRequiredAttribute(true)]
|
---|
263 | /// class Foo {
|
---|
264 | /// string str = "my string"; // Warning: Localizable string
|
---|
265 | /// }
|
---|
266 | /// </code></example>
|
---|
267 | [AttributeUsage(AttributeTargets.All)]
|
---|
268 | public sealed class LocalizationRequiredAttribute : Attribute
|
---|
269 | {
|
---|
270 | public LocalizationRequiredAttribute() : this(true) { }
|
---|
271 |
|
---|
272 | public LocalizationRequiredAttribute(bool required)
|
---|
273 | {
|
---|
274 | Required = required;
|
---|
275 | }
|
---|
276 |
|
---|
277 | public bool Required { get; private set; }
|
---|
278 | }
|
---|
279 |
|
---|
280 | /// <summary>
|
---|
281 | /// Indicates that the value of the marked type (or its derivatives)
|
---|
282 | /// cannot be compared using '==' or '!=' operators and <c>Equals()</c>
|
---|
283 | /// should be used instead. However, using '==' or '!=' for comparison
|
---|
284 | /// with <c>null</c> is always permitted.
|
---|
285 | /// </summary>
|
---|
286 | /// <example><code>
|
---|
287 | /// [CannotApplyEqualityOperator]
|
---|
288 | /// class NoEquality { }
|
---|
289 | ///
|
---|
290 | /// class UsesNoEquality {
|
---|
291 | /// void Test() {
|
---|
292 | /// var ca1 = new NoEquality();
|
---|
293 | /// var ca2 = new NoEquality();
|
---|
294 | /// if (ca1 != null) { // OK
|
---|
295 | /// bool condition = ca1 == ca2; // Warning
|
---|
296 | /// }
|
---|
297 | /// }
|
---|
298 | /// }
|
---|
299 | /// </code></example>
|
---|
300 | [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]
|
---|
301 | public sealed class CannotApplyEqualityOperatorAttribute : Attribute { }
|
---|
302 |
|
---|
303 | /// <summary>
|
---|
304 | /// When applied to a target attribute, specifies a requirement for any type marked
|
---|
305 | /// with the target attribute to implement or inherit specific type or types.
|
---|
306 | /// </summary>
|
---|
307 | /// <example><code>
|
---|
308 | /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
|
---|
309 | /// class ComponentAttribute : Attribute { }
|
---|
310 | ///
|
---|
311 | /// [Component] // ComponentAttribute requires implementing IComponent interface
|
---|
312 | /// class MyComponent : IComponent { }
|
---|
313 | /// </code></example>
|
---|
314 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
---|
315 | [BaseTypeRequired(typeof(Attribute))]
|
---|
316 | public sealed class BaseTypeRequiredAttribute : Attribute
|
---|
317 | {
|
---|
318 | public BaseTypeRequiredAttribute([NotNull] Type baseType)
|
---|
319 | {
|
---|
320 | BaseType = baseType;
|
---|
321 | }
|
---|
322 |
|
---|
323 | [NotNull] public Type BaseType { get; private set; }
|
---|
324 | }
|
---|
325 |
|
---|
326 | /// <summary>
|
---|
327 | /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library),
|
---|
328 | /// so this symbol will not be marked as unused (as well as by other usage inspections).
|
---|
329 | /// </summary>
|
---|
330 | [AttributeUsage(AttributeTargets.All)]
|
---|
331 | public sealed class UsedImplicitlyAttribute : Attribute
|
---|
332 | {
|
---|
333 | public UsedImplicitlyAttribute()
|
---|
334 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }
|
---|
335 |
|
---|
336 | public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
|
---|
337 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { }
|
---|
338 |
|
---|
339 | public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
|
---|
340 | : this(ImplicitUseKindFlags.Default, targetFlags) { }
|
---|
341 |
|
---|
342 | public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
|
---|
343 | {
|
---|
344 | UseKindFlags = useKindFlags;
|
---|
345 | TargetFlags = targetFlags;
|
---|
346 | }
|
---|
347 |
|
---|
348 | public ImplicitUseKindFlags UseKindFlags { get; private set; }
|
---|
349 |
|
---|
350 | public ImplicitUseTargetFlags TargetFlags { get; private set; }
|
---|
351 | }
|
---|
352 |
|
---|
353 | /// <summary>
|
---|
354 | /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes
|
---|
355 | /// as unused (as well as by other usage inspections)
|
---|
356 | /// </summary>
|
---|
357 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)]
|
---|
358 | public sealed class MeansImplicitUseAttribute : Attribute
|
---|
359 | {
|
---|
360 | public MeansImplicitUseAttribute()
|
---|
361 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }
|
---|
362 |
|
---|
363 | public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
|
---|
364 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { }
|
---|
365 |
|
---|
366 | public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
|
---|
367 | : this(ImplicitUseKindFlags.Default, targetFlags) { }
|
---|
368 |
|
---|
369 | public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
|
---|
370 | {
|
---|
371 | UseKindFlags = useKindFlags;
|
---|
372 | TargetFlags = targetFlags;
|
---|
373 | }
|
---|
374 |
|
---|
375 | [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; }
|
---|
376 |
|
---|
377 | [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; }
|
---|
378 | }
|
---|
379 |
|
---|
380 | [Flags]
|
---|
381 | public enum ImplicitUseKindFlags
|
---|
382 | {
|
---|
383 | Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
|
---|
384 | /// <summary>Only entity marked with attribute considered used.</summary>
|
---|
385 | Access = 1,
|
---|
386 | /// <summary>Indicates implicit assignment to a member.</summary>
|
---|
387 | Assign = 2,
|
---|
388 | /// <summary>
|
---|
389 | /// Indicates implicit instantiation of a type with fixed constructor signature.
|
---|
390 | /// That means any unused constructor parameters won't be reported as such.
|
---|
391 | /// </summary>
|
---|
392 | InstantiatedWithFixedConstructorSignature = 4,
|
---|
393 | /// <summary>Indicates implicit instantiation of a type.</summary>
|
---|
394 | InstantiatedNoFixedConstructorSignature = 8,
|
---|
395 | }
|
---|
396 |
|
---|
397 | /// <summary>
|
---|
398 | /// Specify what is considered used implicitly when marked
|
---|
399 | /// with <see cref="MeansImplicitUseAttribute"/> or <see cref="UsedImplicitlyAttribute"/>.
|
---|
400 | /// </summary>
|
---|
401 | [Flags]
|
---|
402 | public enum ImplicitUseTargetFlags
|
---|
403 | {
|
---|
404 | Default = Itself,
|
---|
405 | Itself = 1,
|
---|
406 | /// <summary>Members of entity marked with attribute are considered used.</summary>
|
---|
407 | Members = 2,
|
---|
408 | /// <summary>Entity marked with attribute and all its members considered used.</summary>
|
---|
409 | WithMembers = Itself | Members
|
---|
410 | }
|
---|
411 |
|
---|
412 | /// <summary>
|
---|
413 | /// This attribute is intended to mark publicly available API
|
---|
414 | /// which should not be removed and so is treated as used.
|
---|
415 | /// </summary>
|
---|
416 | [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)]
|
---|
417 | public sealed class PublicAPIAttribute : Attribute
|
---|
418 | {
|
---|
419 | public PublicAPIAttribute() { }
|
---|
420 |
|
---|
421 | public PublicAPIAttribute([NotNull] string comment)
|
---|
422 | {
|
---|
423 | Comment = comment;
|
---|
424 | }
|
---|
425 |
|
---|
426 | [CanBeNull] public string Comment { get; private set; }
|
---|
427 | }
|
---|
428 |
|
---|
429 | /// <summary>
|
---|
430 | /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack.
|
---|
431 | /// If the parameter is a delegate, indicates that delegate is executed while the method is executed.
|
---|
432 | /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed.
|
---|
433 | /// </summary>
|
---|
434 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
435 | public sealed class InstantHandleAttribute : Attribute { }
|
---|
436 |
|
---|
437 | /// <summary>
|
---|
438 | /// Indicates that a method does not make any observable state changes.
|
---|
439 | /// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>.
|
---|
440 | /// </summary>
|
---|
441 | /// <example><code>
|
---|
442 | /// [Pure] int Multiply(int x, int y) => x * y;
|
---|
443 | ///
|
---|
444 | /// void M() {
|
---|
445 | /// Multiply(123, 42); // Waring: Return value of pure method is not used
|
---|
446 | /// }
|
---|
447 | /// </code></example>
|
---|
448 | [AttributeUsage(AttributeTargets.Method)]
|
---|
449 | public sealed class PureAttribute : Attribute { }
|
---|
450 |
|
---|
451 | /// <summary>
|
---|
452 | /// Indicates that the return value of method invocation must be used.
|
---|
453 | /// </summary>
|
---|
454 | [AttributeUsage(AttributeTargets.Method)]
|
---|
455 | public sealed class MustUseReturnValueAttribute : Attribute
|
---|
456 | {
|
---|
457 | public MustUseReturnValueAttribute() { }
|
---|
458 |
|
---|
459 | public MustUseReturnValueAttribute([NotNull] string justification)
|
---|
460 | {
|
---|
461 | Justification = justification;
|
---|
462 | }
|
---|
463 |
|
---|
464 | [CanBeNull] public string Justification { get; private set; }
|
---|
465 | }
|
---|
466 |
|
---|
467 | /// <summary>
|
---|
468 | /// Indicates the type member or parameter of some type, that should be used instead of all other ways
|
---|
469 | /// to get the value that type. This annotation is useful when you have some "context" value evaluated
|
---|
470 | /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one.
|
---|
471 | /// </summary>
|
---|
472 | /// <example><code>
|
---|
473 | /// class Foo {
|
---|
474 | /// [ProvidesContext] IBarService _barService = ...;
|
---|
475 | ///
|
---|
476 | /// void ProcessNode(INode node) {
|
---|
477 | /// DoSomething(node, node.GetGlobalServices().Bar);
|
---|
478 | /// // ^ Warning: use value of '_barService' field
|
---|
479 | /// }
|
---|
480 | /// }
|
---|
481 | /// </code></example>
|
---|
482 | [AttributeUsage(
|
---|
483 | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method |
|
---|
484 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)]
|
---|
485 | public sealed class ProvidesContextAttribute : Attribute { }
|
---|
486 |
|
---|
487 | /// <summary>
|
---|
488 | /// Indicates that a parameter is a path to a file or a folder within a web project.
|
---|
489 | /// Path can be relative or absolute, starting from web root (~).
|
---|
490 | /// </summary>
|
---|
491 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
492 | public sealed class PathReferenceAttribute : Attribute
|
---|
493 | {
|
---|
494 | public PathReferenceAttribute() { }
|
---|
495 |
|
---|
496 | public PathReferenceAttribute([NotNull, PathReference] string basePath)
|
---|
497 | {
|
---|
498 | BasePath = basePath;
|
---|
499 | }
|
---|
500 |
|
---|
501 | [CanBeNull] public string BasePath { get; private set; }
|
---|
502 | }
|
---|
503 |
|
---|
504 | /// <summary>
|
---|
505 | /// An extension method marked with this attribute is processed by ReSharper code completion
|
---|
506 | /// as a 'Source Template'. When extension method is completed over some expression, it's source code
|
---|
507 | /// is automatically expanded like a template at call site.
|
---|
508 | /// </summary>
|
---|
509 | /// <remarks>
|
---|
510 | /// Template method body can contain valid source code and/or special comments starting with '$'.
|
---|
511 | /// Text inside these comments is added as source code when the template is applied. Template parameters
|
---|
512 | /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs.
|
---|
513 | /// Use the <see cref="MacroAttribute"/> attribute to specify macros for parameters.
|
---|
514 | /// </remarks>
|
---|
515 | /// <example>
|
---|
516 | /// In this example, the 'forEach' method is a source template available over all values
|
---|
517 | /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:
|
---|
518 | /// <code>
|
---|
519 | /// [SourceTemplate]
|
---|
520 | /// public static void forEach<T>(this IEnumerable<T> xs) {
|
---|
521 | /// foreach (var x in xs) {
|
---|
522 | /// //$ $END$
|
---|
523 | /// }
|
---|
524 | /// }
|
---|
525 | /// </code>
|
---|
526 | /// </example>
|
---|
527 | [AttributeUsage(AttributeTargets.Method)]
|
---|
528 | public sealed class SourceTemplateAttribute : Attribute { }
|
---|
529 |
|
---|
530 | /// <summary>
|
---|
531 | /// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>.
|
---|
532 | /// </summary>
|
---|
533 | /// <remarks>
|
---|
534 | /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression
|
---|
535 | /// is defined in the <see cref="MacroAttribute.Expression"/> property. When applied on a method, the target
|
---|
536 | /// template parameter is defined in the <see cref="MacroAttribute.Target"/> property. To apply the macro silently
|
---|
537 | /// for the parameter, set the <see cref="MacroAttribute.Editable"/> property value = -1.
|
---|
538 | /// </remarks>
|
---|
539 | /// <example>
|
---|
540 | /// Applying the attribute on a source template method:
|
---|
541 | /// <code>
|
---|
542 | /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
|
---|
543 | /// public static void forEach<T>(this IEnumerable<T> collection) {
|
---|
544 | /// foreach (var item in collection) {
|
---|
545 | /// //$ $END$
|
---|
546 | /// }
|
---|
547 | /// }
|
---|
548 | /// </code>
|
---|
549 | /// Applying the attribute on a template method parameter:
|
---|
550 | /// <code>
|
---|
551 | /// [SourceTemplate]
|
---|
552 | /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
|
---|
553 | /// /*$ var $x$Id = "$newguid$" + x.ToString();
|
---|
554 | /// x.DoSomething($x$Id); */
|
---|
555 | /// }
|
---|
556 | /// </code>
|
---|
557 | /// </example>
|
---|
558 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)]
|
---|
559 | public sealed class MacroAttribute : Attribute
|
---|
560 | {
|
---|
561 | /// <summary>
|
---|
562 | /// Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see>
|
---|
563 | /// parameter when the template is expanded.
|
---|
564 | /// </summary>
|
---|
565 | [CanBeNull] public string Expression { get; set; }
|
---|
566 |
|
---|
567 | /// <summary>
|
---|
568 | /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
|
---|
569 | /// </summary>
|
---|
570 | /// <remarks>
|
---|
571 | /// If the target parameter is used several times in the template, only one occurrence becomes editable;
|
---|
572 | /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence,
|
---|
573 | /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1.
|
---|
574 | /// </remarks>>
|
---|
575 | public int Editable { get; set; }
|
---|
576 |
|
---|
577 | /// <summary>
|
---|
578 | /// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the
|
---|
579 | /// <see cref="MacroAttribute"/> is applied on a template method.
|
---|
580 | /// </summary>
|
---|
581 | [CanBeNull] public string Target { get; set; }
|
---|
582 | }
|
---|
583 |
|
---|
584 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
|
---|
585 | public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
|
---|
586 | {
|
---|
587 | public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format)
|
---|
588 | {
|
---|
589 | Format = format;
|
---|
590 | }
|
---|
591 |
|
---|
592 | [NotNull] public string Format { get; private set; }
|
---|
593 | }
|
---|
594 |
|
---|
595 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
|
---|
596 | public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
|
---|
597 | {
|
---|
598 | public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format)
|
---|
599 | {
|
---|
600 | Format = format;
|
---|
601 | }
|
---|
602 |
|
---|
603 | [NotNull] public string Format { get; private set; }
|
---|
604 | }
|
---|
605 |
|
---|
606 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
|
---|
607 | public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
|
---|
608 | {
|
---|
609 | public AspMvcAreaViewLocationFormatAttribute([NotNull] string format)
|
---|
610 | {
|
---|
611 | Format = format;
|
---|
612 | }
|
---|
613 |
|
---|
614 | [NotNull] public string Format { get; private set; }
|
---|
615 | }
|
---|
616 |
|
---|
617 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
|
---|
618 | public sealed class AspMvcMasterLocationFormatAttribute : Attribute
|
---|
619 | {
|
---|
620 | public AspMvcMasterLocationFormatAttribute([NotNull] string format)
|
---|
621 | {
|
---|
622 | Format = format;
|
---|
623 | }
|
---|
624 |
|
---|
625 | [NotNull] public string Format { get; private set; }
|
---|
626 | }
|
---|
627 |
|
---|
628 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
|
---|
629 | public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
|
---|
630 | {
|
---|
631 | public AspMvcPartialViewLocationFormatAttribute([NotNull] string format)
|
---|
632 | {
|
---|
633 | Format = format;
|
---|
634 | }
|
---|
635 |
|
---|
636 | [NotNull] public string Format { get; private set; }
|
---|
637 | }
|
---|
638 |
|
---|
639 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
|
---|
640 | public sealed class AspMvcViewLocationFormatAttribute : Attribute
|
---|
641 | {
|
---|
642 | public AspMvcViewLocationFormatAttribute([NotNull] string format)
|
---|
643 | {
|
---|
644 | Format = format;
|
---|
645 | }
|
---|
646 |
|
---|
647 | [NotNull] public string Format { get; private set; }
|
---|
648 | }
|
---|
649 |
|
---|
650 | /// <summary>
|
---|
651 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
|
---|
652 | /// is an MVC action. If applied to a method, the MVC action name is calculated
|
---|
653 | /// implicitly from the context. Use this attribute for custom wrappers similar to
|
---|
654 | /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
|
---|
655 | /// </summary>
|
---|
656 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
---|
657 | public sealed class AspMvcActionAttribute : Attribute
|
---|
658 | {
|
---|
659 | public AspMvcActionAttribute() { }
|
---|
660 |
|
---|
661 | public AspMvcActionAttribute([NotNull] string anonymousProperty)
|
---|
662 | {
|
---|
663 | AnonymousProperty = anonymousProperty;
|
---|
664 | }
|
---|
665 |
|
---|
666 | [CanBeNull] public string AnonymousProperty { get; private set; }
|
---|
667 | }
|
---|
668 |
|
---|
669 | /// <summary>
|
---|
670 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area.
|
---|
671 | /// Use this attribute for custom wrappers similar to
|
---|
672 | /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
|
---|
673 | /// </summary>
|
---|
674 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
675 | public sealed class AspMvcAreaAttribute : Attribute
|
---|
676 | {
|
---|
677 | public AspMvcAreaAttribute() { }
|
---|
678 |
|
---|
679 | public AspMvcAreaAttribute([NotNull] string anonymousProperty)
|
---|
680 | {
|
---|
681 | AnonymousProperty = anonymousProperty;
|
---|
682 | }
|
---|
683 |
|
---|
684 | [CanBeNull] public string AnonymousProperty { get; private set; }
|
---|
685 | }
|
---|
686 |
|
---|
687 | /// <summary>
|
---|
688 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is
|
---|
689 | /// an MVC controller. If applied to a method, the MVC controller name is calculated
|
---|
690 | /// implicitly from the context. Use this attribute for custom wrappers similar to
|
---|
691 | /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>.
|
---|
692 | /// </summary>
|
---|
693 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
---|
694 | public sealed class AspMvcControllerAttribute : Attribute
|
---|
695 | {
|
---|
696 | public AspMvcControllerAttribute() { }
|
---|
697 |
|
---|
698 | public AspMvcControllerAttribute([NotNull] string anonymousProperty)
|
---|
699 | {
|
---|
700 | AnonymousProperty = anonymousProperty;
|
---|
701 | }
|
---|
702 |
|
---|
703 | [CanBeNull] public string AnonymousProperty { get; private set; }
|
---|
704 | }
|
---|
705 |
|
---|
706 | /// <summary>
|
---|
707 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute
|
---|
708 | /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.
|
---|
709 | /// </summary>
|
---|
710 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
711 | public sealed class AspMvcMasterAttribute : Attribute { }
|
---|
712 |
|
---|
713 | /// <summary>
|
---|
714 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute
|
---|
715 | /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>.
|
---|
716 | /// </summary>
|
---|
717 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
718 | public sealed class AspMvcModelTypeAttribute : Attribute { }
|
---|
719 |
|
---|
720 | /// <summary>
|
---|
721 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC
|
---|
722 | /// partial view. If applied to a method, the MVC partial view name is calculated implicitly
|
---|
723 | /// from the context. Use this attribute for custom wrappers similar to
|
---|
724 | /// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.
|
---|
725 | /// </summary>
|
---|
726 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
---|
727 | public sealed class AspMvcPartialViewAttribute : Attribute { }
|
---|
728 |
|
---|
729 | /// <summary>
|
---|
730 | /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.
|
---|
731 | /// </summary>
|
---|
732 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
---|
733 | public sealed class AspMvcSuppressViewErrorAttribute : Attribute { }
|
---|
734 |
|
---|
735 | /// <summary>
|
---|
736 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
|
---|
737 | /// Use this attribute for custom wrappers similar to
|
---|
738 | /// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.
|
---|
739 | /// </summary>
|
---|
740 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
741 | public sealed class AspMvcDisplayTemplateAttribute : Attribute { }
|
---|
742 |
|
---|
743 | /// <summary>
|
---|
744 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template.
|
---|
745 | /// Use this attribute for custom wrappers similar to
|
---|
746 | /// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>.
|
---|
747 | /// </summary>
|
---|
748 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
749 | public sealed class AspMvcEditorTemplateAttribute : Attribute { }
|
---|
750 |
|
---|
751 | /// <summary>
|
---|
752 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template.
|
---|
753 | /// Use this attribute for custom wrappers similar to
|
---|
754 | /// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.
|
---|
755 | /// </summary>
|
---|
756 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
757 | public sealed class AspMvcTemplateAttribute : Attribute { }
|
---|
758 |
|
---|
759 | /// <summary>
|
---|
760 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
|
---|
761 | /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly
|
---|
762 | /// from the context. Use this attribute for custom wrappers similar to
|
---|
763 | /// <c>System.Web.Mvc.Controller.View(Object)</c>.
|
---|
764 | /// </summary>
|
---|
765 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
---|
766 | public sealed class AspMvcViewAttribute : Attribute { }
|
---|
767 |
|
---|
768 | /// <summary>
|
---|
769 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
|
---|
770 | /// is an MVC view component name.
|
---|
771 | /// </summary>
|
---|
772 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
773 | public sealed class AspMvcViewComponentAttribute : Attribute { }
|
---|
774 |
|
---|
775 | /// <summary>
|
---|
776 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
|
---|
777 | /// is an MVC view component view. If applied to a method, the MVC view component view name is default.
|
---|
778 | /// </summary>
|
---|
779 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
---|
780 | public sealed class AspMvcViewComponentViewAttribute : Attribute { }
|
---|
781 |
|
---|
782 | /// <summary>
|
---|
783 | /// ASP.NET MVC attribute. When applied to a parameter of an attribute,
|
---|
784 | /// indicates that this parameter is an MVC action name.
|
---|
785 | /// </summary>
|
---|
786 | /// <example><code>
|
---|
787 | /// [ActionName("Foo")]
|
---|
788 | /// public ActionResult Login(string returnUrl) {
|
---|
789 | /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
|
---|
790 | /// return RedirectToAction("Bar"); // Error: Cannot resolve action
|
---|
791 | /// }
|
---|
792 | /// </code></example>
|
---|
793 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
|
---|
794 | public sealed class AspMvcActionSelectorAttribute : Attribute { }
|
---|
795 |
|
---|
796 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]
|
---|
797 | public sealed class HtmlElementAttributesAttribute : Attribute
|
---|
798 | {
|
---|
799 | public HtmlElementAttributesAttribute() { }
|
---|
800 |
|
---|
801 | public HtmlElementAttributesAttribute([NotNull] string name)
|
---|
802 | {
|
---|
803 | Name = name;
|
---|
804 | }
|
---|
805 |
|
---|
806 | [CanBeNull] public string Name { get; private set; }
|
---|
807 | }
|
---|
808 |
|
---|
809 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
|
---|
810 | public sealed class HtmlAttributeValueAttribute : Attribute
|
---|
811 | {
|
---|
812 | public HtmlAttributeValueAttribute([NotNull] string name)
|
---|
813 | {
|
---|
814 | Name = name;
|
---|
815 | }
|
---|
816 |
|
---|
817 | [NotNull] public string Name { get; private set; }
|
---|
818 | }
|
---|
819 |
|
---|
820 | /// <summary>
|
---|
821 | /// Razor attribute. Indicates that a parameter or a method is a Razor section.
|
---|
822 | /// Use this attribute for custom wrappers similar to
|
---|
823 | /// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>.
|
---|
824 | /// </summary>
|
---|
825 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
---|
826 | public sealed class RazorSectionAttribute : Attribute { }
|
---|
827 |
|
---|
828 | /// <summary>
|
---|
829 | /// Indicates how method, constructor invocation or property access
|
---|
830 | /// over collection type affects content of the collection.
|
---|
831 | /// </summary>
|
---|
832 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)]
|
---|
833 | public sealed class CollectionAccessAttribute : Attribute
|
---|
834 | {
|
---|
835 | public CollectionAccessAttribute(CollectionAccessType collectionAccessType)
|
---|
836 | {
|
---|
837 | CollectionAccessType = collectionAccessType;
|
---|
838 | }
|
---|
839 |
|
---|
840 | public CollectionAccessType CollectionAccessType { get; private set; }
|
---|
841 | }
|
---|
842 |
|
---|
843 | [Flags]
|
---|
844 | public enum CollectionAccessType
|
---|
845 | {
|
---|
846 | /// <summary>Method does not use or modify content of the collection.</summary>
|
---|
847 | None = 0,
|
---|
848 | /// <summary>Method only reads content of the collection but does not modify it.</summary>
|
---|
849 | Read = 1,
|
---|
850 | /// <summary>Method can change content of the collection but does not add new elements.</summary>
|
---|
851 | ModifyExistingContent = 2,
|
---|
852 | /// <summary>Method can add new elements to the collection.</summary>
|
---|
853 | UpdatedContent = ModifyExistingContent | 4
|
---|
854 | }
|
---|
855 |
|
---|
856 | /// <summary>
|
---|
857 | /// Indicates that the marked method is assertion method, i.e. it halts control flow if
|
---|
858 | /// one of the conditions is satisfied. To set the condition, mark one of the parameters with
|
---|
859 | /// <see cref="AssertionConditionAttribute"/> attribute.
|
---|
860 | /// </summary>
|
---|
861 | [AttributeUsage(AttributeTargets.Method)]
|
---|
862 | public sealed class AssertionMethodAttribute : Attribute { }
|
---|
863 |
|
---|
864 | /// <summary>
|
---|
865 | /// Indicates the condition parameter of the assertion method. The method itself should be
|
---|
866 | /// marked by <see cref="AssertionMethodAttribute"/> attribute. The mandatory argument of
|
---|
867 | /// the attribute is the assertion type.
|
---|
868 | /// </summary>
|
---|
869 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
870 | public sealed class AssertionConditionAttribute : Attribute
|
---|
871 | {
|
---|
872 | public AssertionConditionAttribute(AssertionConditionType conditionType)
|
---|
873 | {
|
---|
874 | ConditionType = conditionType;
|
---|
875 | }
|
---|
876 |
|
---|
877 | public AssertionConditionType ConditionType { get; private set; }
|
---|
878 | }
|
---|
879 |
|
---|
880 | /// <summary>
|
---|
881 | /// Specifies assertion type. If the assertion method argument satisfies the condition,
|
---|
882 | /// then the execution continues. Otherwise, execution is assumed to be halted.
|
---|
883 | /// </summary>
|
---|
884 | public enum AssertionConditionType
|
---|
885 | {
|
---|
886 | /// <summary>Marked parameter should be evaluated to true.</summary>
|
---|
887 | IS_TRUE = 0,
|
---|
888 | /// <summary>Marked parameter should be evaluated to false.</summary>
|
---|
889 | IS_FALSE = 1,
|
---|
890 | /// <summary>Marked parameter should be evaluated to null value.</summary>
|
---|
891 | IS_NULL = 2,
|
---|
892 | /// <summary>Marked parameter should be evaluated to not null value.</summary>
|
---|
893 | IS_NOT_NULL = 3,
|
---|
894 | }
|
---|
895 |
|
---|
896 | /// <summary>
|
---|
897 | /// Indicates that the marked method unconditionally terminates control flow execution.
|
---|
898 | /// For example, it could unconditionally throw exception.
|
---|
899 | /// </summary>
|
---|
900 | [Obsolete("Use [ContractAnnotation('=> halt')] instead")]
|
---|
901 | [AttributeUsage(AttributeTargets.Method)]
|
---|
902 | public sealed class TerminatesProgramAttribute : Attribute { }
|
---|
903 |
|
---|
904 | /// <summary>
|
---|
905 | /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select,
|
---|
906 | /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters
|
---|
907 | /// of delegate type by analyzing LINQ method chains.
|
---|
908 | /// </summary>
|
---|
909 | [AttributeUsage(AttributeTargets.Method)]
|
---|
910 | public sealed class LinqTunnelAttribute : Attribute { }
|
---|
911 |
|
---|
912 | /// <summary>
|
---|
913 | /// Indicates that IEnumerable, passed as parameter, is not enumerated.
|
---|
914 | /// </summary>
|
---|
915 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
916 | public sealed class NoEnumerationAttribute : Attribute { }
|
---|
917 |
|
---|
918 | /// <summary>
|
---|
919 | /// Indicates that parameter is regular expression pattern.
|
---|
920 | /// </summary>
|
---|
921 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
922 | public sealed class RegexPatternAttribute : Attribute { }
|
---|
923 |
|
---|
924 | /// <summary>
|
---|
925 | /// Prevents the Member Reordering feature from tossing members of the marked class.
|
---|
926 | /// </summary>
|
---|
927 | /// <remarks>
|
---|
928 | /// The attribute must be mentioned in your member reordering patterns
|
---|
929 | /// </remarks>
|
---|
930 | [AttributeUsage(
|
---|
931 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)]
|
---|
932 | public sealed class NoReorderAttribute : Attribute { }
|
---|
933 |
|
---|
934 | /// <summary>
|
---|
935 | /// XAML attribute. Indicates the type that has <c>ItemsSource</c> property and should be treated
|
---|
936 | /// as <c>ItemsControl</c>-derived type, to enable inner items <c>DataContext</c> type resolve.
|
---|
937 | /// </summary>
|
---|
938 | [AttributeUsage(AttributeTargets.Class)]
|
---|
939 | public sealed class XamlItemsControlAttribute : Attribute { }
|
---|
940 |
|
---|
941 | /// <summary>
|
---|
942 | /// XAML attribute. Indicates the property of some <c>BindingBase</c>-derived type, that
|
---|
943 | /// is used to bind some item of <c>ItemsControl</c>-derived type. This annotation will
|
---|
944 | /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
|
---|
945 | /// </summary>
|
---|
946 | /// <remarks>
|
---|
947 | /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
|
---|
948 | /// marked with the <see cref="XamlItemsControlAttribute"/> attribute.
|
---|
949 | /// </remarks>
|
---|
950 | [AttributeUsage(AttributeTargets.Property)]
|
---|
951 | public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { }
|
---|
952 |
|
---|
953 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
---|
954 | public sealed class AspChildControlTypeAttribute : Attribute
|
---|
955 | {
|
---|
956 | public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType)
|
---|
957 | {
|
---|
958 | TagName = tagName;
|
---|
959 | ControlType = controlType;
|
---|
960 | }
|
---|
961 |
|
---|
962 | [NotNull] public string TagName { get; private set; }
|
---|
963 |
|
---|
964 | [NotNull] public Type ControlType { get; private set; }
|
---|
965 | }
|
---|
966 |
|
---|
967 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
|
---|
968 | public sealed class AspDataFieldAttribute : Attribute { }
|
---|
969 |
|
---|
970 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
|
---|
971 | public sealed class AspDataFieldsAttribute : Attribute { }
|
---|
972 |
|
---|
973 | [AttributeUsage(AttributeTargets.Property)]
|
---|
974 | public sealed class AspMethodPropertyAttribute : Attribute { }
|
---|
975 |
|
---|
976 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
---|
977 | public sealed class AspRequiredAttributeAttribute : Attribute
|
---|
978 | {
|
---|
979 | public AspRequiredAttributeAttribute([NotNull] string attribute)
|
---|
980 | {
|
---|
981 | Attribute = attribute;
|
---|
982 | }
|
---|
983 |
|
---|
984 | [NotNull] public string Attribute { get; private set; }
|
---|
985 | }
|
---|
986 |
|
---|
987 | [AttributeUsage(AttributeTargets.Property)]
|
---|
988 | public sealed class AspTypePropertyAttribute : Attribute
|
---|
989 | {
|
---|
990 | public bool CreateConstructorReferences { get; private set; }
|
---|
991 |
|
---|
992 | public AspTypePropertyAttribute(bool createConstructorReferences)
|
---|
993 | {
|
---|
994 | CreateConstructorReferences = createConstructorReferences;
|
---|
995 | }
|
---|
996 | }
|
---|
997 |
|
---|
998 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
|
---|
999 | public sealed class RazorImportNamespaceAttribute : Attribute
|
---|
1000 | {
|
---|
1001 | public RazorImportNamespaceAttribute([NotNull] string name)
|
---|
1002 | {
|
---|
1003 | Name = name;
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 | [NotNull] public string Name { get; private set; }
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
|
---|
1010 | public sealed class RazorInjectionAttribute : Attribute
|
---|
1011 | {
|
---|
1012 | public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName)
|
---|
1013 | {
|
---|
1014 | Type = type;
|
---|
1015 | FieldName = fieldName;
|
---|
1016 | }
|
---|
1017 |
|
---|
1018 | [NotNull] public string Type { get; private set; }
|
---|
1019 |
|
---|
1020 | [NotNull] public string FieldName { get; private set; }
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
|
---|
1024 | public sealed class RazorDirectiveAttribute : Attribute
|
---|
1025 | {
|
---|
1026 | public RazorDirectiveAttribute([NotNull] string directive)
|
---|
1027 | {
|
---|
1028 | Directive = directive;
|
---|
1029 | }
|
---|
1030 |
|
---|
1031 | [NotNull] public string Directive { get; private set; }
|
---|
1032 | }
|
---|
1033 |
|
---|
1034 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
|
---|
1035 | public sealed class RazorPageBaseTypeAttribute : Attribute
|
---|
1036 | {
|
---|
1037 | public RazorPageBaseTypeAttribute([NotNull] string baseType)
|
---|
1038 | {
|
---|
1039 | BaseType = baseType;
|
---|
1040 | }
|
---|
1041 | public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName)
|
---|
1042 | {
|
---|
1043 | BaseType = baseType;
|
---|
1044 | PageName = pageName;
|
---|
1045 | }
|
---|
1046 |
|
---|
1047 | [NotNull] public string BaseType { get; private set; }
|
---|
1048 | [CanBeNull] public string PageName { get; private set; }
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | [AttributeUsage(AttributeTargets.Method)]
|
---|
1052 | public sealed class RazorHelperCommonAttribute : Attribute { }
|
---|
1053 |
|
---|
1054 | [AttributeUsage(AttributeTargets.Property)]
|
---|
1055 | public sealed class RazorLayoutAttribute : Attribute { }
|
---|
1056 |
|
---|
1057 | [AttributeUsage(AttributeTargets.Method)]
|
---|
1058 | public sealed class RazorWriteLiteralMethodAttribute : Attribute { }
|
---|
1059 |
|
---|
1060 | [AttributeUsage(AttributeTargets.Method)]
|
---|
1061 | public sealed class RazorWriteMethodAttribute : Attribute { }
|
---|
1062 |
|
---|
1063 | [AttributeUsage(AttributeTargets.Parameter)]
|
---|
1064 | public sealed class RazorWriteMethodParameterAttribute : Attribute { }
|
---|
1065 | } |
---|