public CompilerParameters(IReflectionTypeSystemProvider reflectionProvider, bool loadDefaultReferences) { _libPaths = new List <string>(); _systemDir = Permissions.WithDiscoveryPermission(() => GetSystemDir()); if (_systemDir != null) { _libPaths.Add(_systemDir); _libPaths.Add(Directory.GetCurrentDirectory()); } _input = new CompilerInputCollection(); _resources = new CompilerResourceCollection(); _compilerReferences = new CompilerReferenceCollection(reflectionProvider); MaxExpansionIterations = 12; _outputAssembly = String.Empty; OutputType = CompilerOutputType.Auto; _outputWriter = Console.Out; Debug = true; Checked = true; GenerateInMemory = true; StdLib = true; DelaySign = false; Strict = false; TraceLevel = DefaultTraceLevel(); if (loadDefaultReferences) { LoadDefaultReferences(); } }
public CompilerContext(CompilerParameters options, CompileUnit unit) { if (null == options) { throw new ArgumentNullException("options"); } if (null == unit) { throw new ArgumentNullException("unit"); } _unit = unit; _errors = new CompilerErrorCollection(); _warnings = new CompilerWarningCollection(); _warnings.Adding += OnCompilerWarning; _references = options.References; _parameters = options; if (_parameters.Debug && !_parameters.Defines.ContainsKey("DEBUG")) { _parameters.Defines.Add("DEBUG", null); } _properties = new Hash(); var activator = new InstantiatingEnvironment(); _environment = _parameters.Environment != null ? new CachingEnvironment(new EnvironmentChain(_parameters.Environment, activator)) : new CachingEnvironment(activator); _environment.InstanceCached += InitializeService; // FIXME: temporary hack to make sure the singleton is visible // using the My<IReflectionTypeSystemProvider> idiom RegisterService <IReflectionTypeSystemProvider>(_references.Provider); RegisterService <CompilerParameters>(_parameters); RegisterService <CompilerErrorCollection>(_errors); RegisterService <CompilerWarningCollection>(_warnings); RegisterService <CompileUnit>(_unit); RegisterService <CompilerContext>(this); }