Is there a built-in attribute for the name / value pair?

Is there a built-in attribute in the .net structure for marking code with an arbitrary key and value? I looked through the list , but I see nothing useful there. We ideally want to say

[NameValuePair("MyKey", "My long bit of text")]

... and then pull it out later

In fact, we really want this to embed additional information in the info assembly with continuous integration build time, for example

[Assembly: NameValuePair("MyKey", "My long bit of text")]

and then pull it out later

I saw Jeff's post about AssemblyInfo Custom Attributes , and that’s fine, but if there is an implicit attribute baked into the framework, it’ll be even better.

+3
source share
1 answer

, /, . , , .

[AttributeUsage(AttributeTargets.Assembly)] 
public KeyValuePairAttribute : Attribute
{
   private string key;
   private string value;

   private KeyValuePairAttribute() { }

   public KeyValuePairAttribute(string key, string value)
   {
      this.key = key;
      this.value = value;
   }
}
+5

Source: https://habr.com/ru/post/1714455/


All Articles