[sgen] Don't reallocate mod_union at each major
[mono.git] / mcs / class / System / System.CodeDom.Compiler / Compiler.cs
1 //
2 // System.Web.Configuration.CompilerCollection
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if CONFIGURATION_DEP
32 extern alias PrebuiltSystem;
33 using TypeDescriptor = PrebuiltSystem.System.ComponentModel.TypeDescriptor;
34
35 using System;
36 using System.Collections.Generic;
37 using System.ComponentModel;
38 using System.Configuration;
39
40 namespace System.CodeDom.Compiler
41 {
42         internal sealed class Compiler : ConfigurationElement
43         {
44                 static ConfigurationProperty compilerOptionsProp;
45                 static ConfigurationProperty extensionProp;
46                 static ConfigurationProperty languageProp;
47                 static ConfigurationProperty typeProp;
48                 static ConfigurationProperty warningLevelProp;
49                 static ConfigurationProperty providerOptionsProp;
50                 
51                 static ConfigurationPropertyCollection properties;
52
53                 static Compiler ()
54                 {
55                         compilerOptionsProp = new ConfigurationProperty("compilerOptions", typeof (string), "");
56                         extensionProp = new ConfigurationProperty("extension", typeof (string), "");
57                         languageProp = new ConfigurationProperty("language", typeof (string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
58                         typeProp = new ConfigurationProperty("type", typeof (string), "", ConfigurationPropertyOptions.IsRequired);
59                         warningLevelProp = new ConfigurationProperty("warningLevel", typeof (int), 0,
60                                                                      TypeDescriptor.GetConverter (typeof (int)),
61                                                                      new IntegerValidator (0, 4),
62                                                                      ConfigurationPropertyOptions.None);
63                         providerOptionsProp = new ConfigurationProperty ("", typeof (CompilerProviderOptionsCollection), null, null, null,
64                                                                          ConfigurationPropertyOptions.IsDefaultCollection);
65                         
66                         properties = new ConfigurationPropertyCollection ();
67                         properties.Add (compilerOptionsProp);
68                         properties.Add (extensionProp);
69                         properties.Add (languageProp);
70                         properties.Add (typeProp);
71                         properties.Add (warningLevelProp);
72                         properties.Add (providerOptionsProp);
73                 }
74
75                 internal Compiler ()
76                 {
77                 }
78
79                 public Compiler (string compilerOptions, string extension, string language, string type, int warningLevel)
80                 {
81                         this.CompilerOptions = compilerOptions;
82                         this.Extension = extension;
83                         this.Language = language;
84                         this.Type = type;
85                         this.WarningLevel = warningLevel;
86                 }
87
88                 [ConfigurationProperty ("compilerOptions", DefaultValue = "")]
89                 public string CompilerOptions {
90                         get { return (string) base[compilerOptionsProp]; }
91                         internal set { base[compilerOptionsProp] = value; }
92                 }
93
94                 [ConfigurationProperty ("extension", DefaultValue = "")]
95                 public string Extension {
96                         get { return (string) base[extensionProp]; }
97                         internal set { base[extensionProp] = value; }
98                 }
99
100                 [ConfigurationProperty ("language", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
101                 public string Language {
102                         get { return (string) base[languageProp]; }
103                         internal set { base[languageProp] = value; }
104                 }
105
106                 [ConfigurationProperty ("type", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired)]
107                 public string Type {
108                         get { return (string) base[typeProp]; }
109                         internal set { base[typeProp] = value; }
110                 }
111
112                 [IntegerValidator (MinValue = 0, MaxValue = 4)]
113                 [ConfigurationProperty ("warningLevel", DefaultValue = "0")]
114                 public int WarningLevel {
115                         get { return (int) base[warningLevelProp]; }
116                         internal set { base[warningLevelProp] = value; }
117                 }
118
119                 [ConfigurationProperty ("", Options = ConfigurationPropertyOptions.IsDefaultCollection)]
120                 public CompilerProviderOptionsCollection ProviderOptions {
121                         get { return (CompilerProviderOptionsCollection) base [providerOptionsProp]; }
122                         internal set { base [providerOptionsProp] = value; }
123                 }
124
125                 public Dictionary <string, string> ProviderOptionsDictionary {
126                         get { return ProviderOptions.ProviderOptions; }
127                 }
128                 
129                 protected override ConfigurationPropertyCollection Properties {
130                         get { return properties; }
131                 }
132         }
133 }
134 #endif