public static PrecompilationCommandLineArgs Parse(string[] arguments, string baseDirectory)
        {
            var result = new PrecompilationCommandLineArgs { Arguments = arguments, BaseDirectory = baseDirectory };
            if (arguments == null) return result;

            var loadedRsp = new HashSet<string>();
            var references = new HashSet<string>();
            for(var i = 0; i < arguments.Length; i++)
            {
                var arg = arguments[i];
                if(arg.StartsWith("@"))
                {
                    if (!loadedRsp.Add(arg = ParseFileFromArg(arg, '@'))) continue;
                    arguments = arguments.Concat(File.ReadAllLines(arg).SelectMany(SplitCommandLine)).ToArray();
                }
                else if(arg.StartsWith("/r:") || arg.StartsWith("/reference:"))
                {
                    // don't care about extern stuff for now..
                    // https://msdn.microsoft.com/en-us/library/ms173212.aspx
                    references.Add(ParseFileFromArg(arg));
                }
                else if(arg.StartsWith("/appconfig:"))
                {
                    result.AppConfig = ParseFileFromArg(arg);
                }
            }
            result.References = references.ToArray();
            return result;
        }
Exemplo n.º 2
0
        public Compilation(PrecompilationCommandLineArgs precompilationCommandLineArgs)
        {
            _precompilationCommandLineArgs = precompilationCommandLineArgs;

            CurrentDirectory = new DirectoryInfo(_precompilationCommandLineArgs.BaseDirectory);

            AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(CurrentDirectory.FullName, "App_Data")); // HACK mocking ASP.NET's ~/App_Data aka. |DataDirectory|

            // HACK moar HttpRuntime stuff
            AppDomain.CurrentDomain.SetData(".appDomain", AppDomain.CurrentDomain.FriendlyName);
            AppDomain.CurrentDomain.SetData(".appPath", CurrentDirectory.FullName);
            AppDomain.CurrentDomain.SetData(".appVPath", "/");
        }
        public Compilation(PrecompilationCommandLineArgs precompilationCommandLineArgs)
        {
            _precompilationCommandLineArgs = precompilationCommandLineArgs;
            _syntaxTreeLoaders             = new Dictionary <string, Lazy <Parser> >
            {
                { ".cs", new Lazy <Parser>(CSharp, LazyThreadSafetyMode.PublicationOnly) },
                { ".cshtml", new Lazy <Parser>(Razor, LazyThreadSafetyMode.PublicationOnly) },
            };

            CurrentDirectory = new DirectoryInfo(_precompilationCommandLineArgs.BaseDirectory);

            AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(CurrentDirectory.FullName, "App_Data")); // HACK mocking ASP.NET's ~/App_Data aka. |DataDirectory|

            // HACK moar HttpRuntime stuff
            AppDomain.CurrentDomain.SetData(".appDomain", AppDomain.CurrentDomain.FriendlyName);
            AppDomain.CurrentDomain.SetData(".appPath", CurrentDirectory.FullName);
            AppDomain.CurrentDomain.SetData(".appVPath", "/");
        }
Exemplo n.º 4
0
        public static PrecompilationCommandLineArgs Parse(string[] arguments, string baseDirectory)
        {
            var result = new PrecompilationCommandLineArgs {
                Arguments = arguments, BaseDirectory = baseDirectory
            };

            if (arguments == null)
            {
                return(result);
            }

            var loadedRsp  = new HashSet <string>();
            var references = new HashSet <string>();

            for (var i = 0; i < arguments.Length; i++)
            {
                var arg       = arguments[i];
                var reference = Reference.Match(arg);
                if (arg.StartsWith("@"))
                {
                    if (!loadedRsp.Add(arg = ParseFileFromArg(arg, '@')))
                    {
                        continue;
                    }
                    arguments = arguments.Concat(File.ReadAllLines(arg).SelectMany(SplitCommandLine)).ToArray();
                }
                else if (reference.Success)
                {
                    // don't care about reference aliases in the compilation appdomain
                    // https://msdn.microsoft.com/en-us/library/ms173212.aspx
                    references.Add(ParseFileFromArg(arg, reference.Groups["alias"].Success ? '=' : ':'));
                }
                else if (arg.StartsWith("/appconfig:"))
                {
                    result.AppConfig = ParseFileFromArg(arg);
                }
            }
            result.References = references.ToArray();
            return(result);
        }
 // ReSharper disable MemberCanBeMadeStatic.Local
 // making the methods below static would not be a good idea, they need to run in the _compilation app domain
 private bool RunCs(PrecompilationCommandLineArgs precompilationArgs)
 {
     _cts = new CancellationTokenSource();
     return(new Compilation(precompilationArgs).RunAsync(_cts.Token).Result);
 }
 // ReSharper disable MemberCanBeMadeStatic.Local
 // making the methods below static would not be a good idea, they need to run in the compilation app domain
 private bool RunCs(PrecompilationCommandLineArgs precompilationArgs)
 {
     return new Compilation(precompilationArgs).Run();
 }
 // ReSharper disable MemberCanBeMadeStatic.Local
 // making the methods below static would not be a good idea, they need to run in the compilation app domain
 private bool RunCs(PrecompilationCommandLineArgs precompilationArgs)
 {
     return(new Compilation(precompilationArgs).Run());
 }
Exemplo n.º 8
0
 // ReSharper disable MemberCanBeMadeStatic.Local
 // making the methods below static would not be a good idea, they need to run in the compilation app domain
 private bool RunCs(PrecompilationCommandLineArgs precompilationArgs)
 {
     return(new Compilation(precompilationArgs).RunAsync().Result);
 }