CompilerParameters.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. //
  2. // System.CodeDom.Compiler.CompilerParameters.cs
  3. //
  4. // Authors:
  5. // Daniel Stodden ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) 2002 Ximian, Inc.
  9. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  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. using System.Collections.Specialized;
  31. using System.Runtime.InteropServices;
  32. using System.Security.Permissions;
  33. using System.Security.Policy;
  34. namespace System.CodeDom.Compiler {
  35. #if NET_2_0
  36. [Serializable]
  37. #else
  38. [ComVisible (false)]
  39. #endif
  40. [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
  41. [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
  42. public class CompilerParameters {
  43. private string compilerOptions;
  44. #if NET_1_1
  45. private Evidence evidence;
  46. #endif
  47. private bool generateExecutable = false;
  48. private bool generateInMemory = false;
  49. private bool includeDebugInformation = false;
  50. private string mainClass;
  51. private string outputAssembly;
  52. private StringCollection referencedAssemblies;
  53. private TempFileCollection tempFiles;
  54. private bool treatWarningsAsErrors = false;
  55. private IntPtr userToken = IntPtr.Zero;
  56. private int warningLevel = -1;
  57. private string win32Resource;
  58. #if NET_2_0
  59. private StringCollection embedded_resources;
  60. private StringCollection linked_resources;
  61. #endif
  62. //
  63. // Constructors
  64. //
  65. public CompilerParameters()
  66. {
  67. }
  68. public CompilerParameters (string[] assemblyNames)
  69. {
  70. referencedAssemblies = new StringCollection();
  71. referencedAssemblies.AddRange (assemblyNames);
  72. }
  73. public CompilerParameters (string[] assemblyNames, string output)
  74. {
  75. referencedAssemblies = new StringCollection();
  76. referencedAssemblies.AddRange (assemblyNames);
  77. outputAssembly = output;
  78. }
  79. public CompilerParameters (string[] assemblyNames, string output, bool includeDebugInfo)
  80. {
  81. referencedAssemblies = new StringCollection();
  82. referencedAssemblies.AddRange (assemblyNames);
  83. outputAssembly = output;
  84. includeDebugInformation = includeDebugInfo;
  85. }
  86. //
  87. // Properties
  88. //
  89. public string CompilerOptions {
  90. get {
  91. return compilerOptions;
  92. }
  93. set {
  94. compilerOptions = value;
  95. }
  96. }
  97. #if NET_1_1
  98. public Evidence Evidence {
  99. get { return evidence; }
  100. [SecurityPermission (SecurityAction.Demand, ControlEvidence = true)]
  101. set { evidence = value; }
  102. }
  103. #endif
  104. public bool GenerateExecutable {
  105. get {
  106. return generateExecutable;
  107. }
  108. set {
  109. generateExecutable = value;
  110. }
  111. }
  112. public bool GenerateInMemory {
  113. get {
  114. return generateInMemory;
  115. }
  116. set {
  117. generateInMemory = value;
  118. }
  119. }
  120. public bool IncludeDebugInformation {
  121. get {
  122. return includeDebugInformation;
  123. }
  124. set {
  125. includeDebugInformation = value;
  126. }
  127. }
  128. public string MainClass {
  129. get {
  130. return mainClass;
  131. }
  132. set {
  133. mainClass = value;
  134. }
  135. }
  136. public string OutputAssembly {
  137. get {
  138. return outputAssembly;
  139. }
  140. set {
  141. outputAssembly = value;
  142. }
  143. }
  144. public StringCollection ReferencedAssemblies {
  145. get {
  146. if (referencedAssemblies == null)
  147. referencedAssemblies = new StringCollection ();
  148. return referencedAssemblies;
  149. }
  150. }
  151. public TempFileCollection TempFiles {
  152. get {
  153. if (tempFiles == null)
  154. tempFiles = new TempFileCollection ();
  155. return tempFiles;
  156. }
  157. set {
  158. tempFiles = value;
  159. }
  160. }
  161. public bool TreatWarningsAsErrors {
  162. get {
  163. return treatWarningsAsErrors;
  164. }
  165. set {
  166. treatWarningsAsErrors = value;
  167. }
  168. }
  169. public IntPtr UserToken {
  170. get {
  171. return userToken;
  172. }
  173. set {
  174. userToken = value;
  175. }
  176. }
  177. public int WarningLevel {
  178. get {
  179. return warningLevel;
  180. }
  181. set {
  182. warningLevel = value;
  183. }
  184. }
  185. public string Win32Resource {
  186. get {
  187. return win32Resource;
  188. }
  189. set {
  190. win32Resource = value;
  191. }
  192. }
  193. #if NET_2_0
  194. [ComVisible (false)]
  195. public StringCollection EmbeddedResources {
  196. get {
  197. if (embedded_resources == null)
  198. embedded_resources = new StringCollection ();
  199. return embedded_resources;
  200. }
  201. }
  202. [ComVisible (false)]
  203. public StringCollection LinkedResources {
  204. get {
  205. if (linked_resources == null)
  206. linked_resources = new StringCollection ();
  207. return linked_resources;
  208. }
  209. }
  210. #endif
  211. }
  212. }