tagged [.net-attributes]

What does the [ApiController] attribute do?

What does the [ApiController] attribute do? I've noticed it is the same thing if this attribute is used or not. Am I wrong? As an example: Nothing happened when I removed the `[ApiController]` attribu...

'AssemblyTitle' attribute in the .NET Framework

'AssemblyTitle' attribute in the .NET Framework What is the practical use of the `AssemblyTitle` attribute? MSDN says that it specifies a description for an assembly and that the assembly title is a f...

19 Aug at 17:46

Is it possible to add an attribute to a property in a partial class?

Is it possible to add an attribute to a property in a partial class? I don't think it's possible but since I haven't got a definite clarity from MSDN, I feel that it's best to ask. Suppose that we hav...

25 Dec at 18:40

Is this use of attributes in .Net (C#) expensive?

Is this use of attributes in .Net (C#) expensive? I would like to know whether the usage of Attributes in .Net, specifically C#, is expensive, and why or why not? I am asking about C# specifically, un...

13 Aug at 13:37

How to ignore compiler warning when using Obsolete attribute on a class used with a KnownType attribute

How to ignore compiler warning when using Obsolete attribute on a class used with a KnownType attribute So we are trying to deprecate some of our existing classes, and have started marking them as obs...

26 Aug at 04:25

Get custom attributes of enum value

Get custom attributes of enum value In a WinRT .NET application (C#) I want to get the custom attributes, that are defined on an enum value. Take the following enum for example: Now in "normal" .NET I...

24 May at 06:43

Getting attributes of Enum's value

Getting attributes of Enum's value I would like to know if it is possible to get attributes of the `enum` values and not of the `enum` itself? For example, suppose I have the following `enum`: ``` usi...

27 Feb at 09:39

XmlSerializer and nullable attributes

XmlSerializer and nullable attributes I have a class with numerous Nullable properties which I want to be serializable to XML as attributes. This is apparently a no-no as they are considered 'complex ...

Custom Compiler Warnings

Custom Compiler Warnings When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that the object/method/property is obsolete and somthing else should be used. I'm currently ...

How do I get the count of attributes that an object has?

How do I get the count of attributes that an object has? I've got a class with a number of attributes, and I need to find a way to get a count of the number of attributes it has. I want to do this bec...

12 Nov at 02:43

Deprecation behavior using the [Obsolete] attribute

Deprecation behavior using the [Obsolete] attribute While removing some obsolete code I came across an unexpected scenario, recreated below: ``` class Program { static void Main(string[] args) { ...

16 May at 07:10

Basic implementation of AOP like attribute using standard .NET Framework

Basic implementation of AOP like attribute using standard .NET Framework > [C# wrap method via attributes](https://stackoverflow.com/questions/2206554/c-sharp-wrap-method-via-attributes) I'd like to...

23 May at 11:47

How to access the Description attribute on either a property or a const in C#?

How to access the Description attribute on either a property or a const in C#? How do you access the Description property on either a const or a property, i.e., ``` public static class Group { [Desc...

23 May at 12:16

GetHashCode and Equals are implemented incorrectly in System.Attribute?

GetHashCode and Equals are implemented incorrectly in System.Attribute? Seeing from [Artech's blog](http://www.cnblogs.com/artech/archive/2012/01/12/attribute-gethashcode.html) and then we had a discu...

12 Jan at 17:26

Enforce Attribute Decoration of Classes/Methods

Enforce Attribute Decoration of Classes/Methods Following on from my recent question on [Large, Complex Objects as a Web Service Result](https://stackoverflow.com/questions/17725/large-complex-objects...

Curious ambiguity in attribute specification (two using directives)

Curious ambiguity in attribute specification (two using directives) In an [attribute specification](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/attributes...

What is the correct way to use TypeForwardedToAttribute?

What is the correct way to use TypeForwardedToAttribute? I came across to this attribute in [this post](http://en.csharp-online.net/TypeForwardedToAttribute) and [this one](http://www.codeproject.com/...

4 Feb at 18:23