PageRenderTime 21ms CodeModel.GetById 8ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/ICSharpCode.Decompiler/Tests/CustomAttributes/S_CustomAttributes.cs

http://github.com/icsharpcode/ILSpy
C# | 84 lines | 62 code | 2 blank | 20 comment | 0 complexity | 08b71b3c39c73c616a89c02eae0e1e9a MD5 | raw file
 1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
 2// 
 3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
 4// software and associated documentation files (the "Software"), to deal in the Software
 5// without restriction, including without limitation the rights to use, copy, modify, merge,
 6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
 7// to whom the Software is furnished to do so, subject to the following conditions:
 8// 
 9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11// 
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20
21namespace aa
22{
23	public static class CustomAttributes
24	{
25		[Flags]
26		public enum EnumWithFlag
27		{
28			All = 15,
29			None = 0,
30			Item1 = 1,
31			Item2 = 2,
32			Item3 = 4,
33			Item4 = 8
34		}
35		[AttributeUsage(AttributeTargets.All)]
36		public class MyAttribute : Attribute
37		{
38			public MyAttribute(object val)
39			{
40			}
41		}
42		[CustomAttributes.MyAttribute(CustomAttributes.ULongEnum.MaxUInt64)]
43		public enum ULongEnum : ulong
44		{
45			MaxUInt64 = 18446744073709551615uL
46		}
47		[CustomAttributes.MyAttribute(CustomAttributes.EnumWithFlag.Item1 | CustomAttributes.EnumWithFlag.Item2)]
48		private static int field;
49		[CustomAttributes.MyAttribute(CustomAttributes.EnumWithFlag.All)]
50		public static string Property
51		{
52			get
53			{
54				return "aa";
55			}
56		}
57		[Obsolete("some message")]
58		public static void ObsoletedMethod()
59		{
60			//Console.WriteLine("{0} $$$ {1}", AttributeTargets.Interface, (AttributeTargets)(AttributeTargets.Property | AttributeTargets.Field));
61			Console.WriteLine("{0} $$$ {1}", AttributeTargets.Interface, AttributeTargets.Property | AttributeTargets.Field);
62			AttributeTargets attributeTargets = AttributeTargets.Property | AttributeTargets.Field;
63			Console.WriteLine("{0} $$$ {1}", AttributeTargets.Interface, attributeTargets);
64		}
65		// No Boxing
66		[CustomAttributes.MyAttribute(new StringComparison[]
67		{
68			StringComparison.Ordinal, 
69			StringComparison.CurrentCulture
70		})]
71		public static void ArrayAsAttribute1()
72		{
73		}
74		// Boxing of each array element
75		[CustomAttributes.MyAttribute(new object[]
76		{
77			StringComparison.Ordinal, 
78			StringComparison.CurrentCulture
79		})]
80		public static void ArrayAsAttribute2()
81		{
82		}
83	}
84}