internal CodeDomCompilationConfiguration() {
            // First time initialization. This must be kept consistent with machine.config.comments in that it 
            // must initialize the config system as if that block was present.

            _compilerLanguages = new Hashtable(StringComparer.OrdinalIgnoreCase);
            _compilerExtensions = new Hashtable(StringComparer.OrdinalIgnoreCase);
            _allCompilerInfo = new ArrayList();            
            
            CompilerInfo compilerInfo;
            CompilerParameters compilerParameters;
            String typeName;
            
            // C#
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName = "Microsoft.CSharp.CSharpCodeProvider, " + AssemblyRef.System;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages = new string[] {"c#", "cs", "csharp"};
            compilerInfo._compilerExtensions = new string[] {".cs", "cs"};
            AddCompilerInfo(compilerInfo);


            // JScript
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName = "Microsoft.JScript.JScriptCodeProvider, " + AssemblyRef.MicrosoftJScript;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages = new string[] {"js", "jscript", "javascript"};
            compilerInfo._compilerExtensions = new string[] {".js", "js"};
            AddCompilerInfo(compilerInfo);


        }
Esempio n. 2
0
        static CompilerCollection()
        {
            properties          = new ConfigurationPropertyCollection();
            compiler_infos      = new List <CompilerInfo> ();
            compiler_languages  = new Dictionary <string, CompilerInfo> (16, StringComparer.OrdinalIgnoreCase);
            compiler_extensions = new Dictionary <string, CompilerInfo> (6, StringComparer.OrdinalIgnoreCase);

            CompilerInfo compiler = new CompilerInfo(null, "Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
                                                     new [] { ".cs" }, new [] { "c#", "cs", "csharp" });

            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);

            compiler = new CompilerInfo(null, "Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
                                        new [] { ".vb" }, new [] { "vb", "vbs", "visualbasic", "vbscript" });
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);

            compiler = new CompilerInfo(null, "Microsoft.JScript.JScriptCodeProvider, Microsoft.JScript, Version=8.0.1100.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
                                        new [] { ".js" }, new [] { "js", "jscript", "javascript" });
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);

            compiler = new CompilerInfo(null, "Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
                                        new [] { ".jsl", ".java" }, new [] { "vj#", "vjs", "vjsharp" });
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);

            compiler = new CompilerInfo(null, "Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
                                        new [] { ".h" }, new [] { "c++", "mc", "cpp" });
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);
        }
        internal CodeDomCompilationConfiguration()
        {
            // First time initialization. This must be kept consistent with machine.config.comments in that it
            // must initialize the config system as if that block was present.

            _compilerLanguages  = new Hashtable(StringComparer.OrdinalIgnoreCase);
            _compilerExtensions = new Hashtable(StringComparer.OrdinalIgnoreCase);
            _allCompilerInfo    = new ArrayList();

            CompilerInfo       compilerInfo;
            CompilerParameters compilerParameters;
            String             typeName;

            // C#
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName     = "Microsoft.CSharp.CSharpCodeProvider, " + AssemblyRef.System;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages  = new string[] { "c#", "cs", "csharp" };
            compilerInfo._compilerExtensions = new string[] { ".cs", "cs" };
            AddCompilerInfo(compilerInfo);


            // JScript
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName     = "Microsoft.JScript.JScriptCodeProvider, " + AssemblyRef.MicrosoftJScript;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages  = new string[] { "js", "jscript", "javascript" };
            compilerInfo._compilerExtensions = new string[] { ".js", "js" };
            AddCompilerInfo(compilerInfo);
        }
Esempio n. 4
0
        static void AddCompilerInfo(Compiler compiler)
        {
            CompilerInfo ci = new CompilerInfo(null, compiler.Type, new [] { compiler.Extension }, new [] { compiler.Language });

            ci.CompilerParams.CompilerOptions = compiler.CompilerOptions;
            ci.CompilerParams.WarningLevel    = compiler.WarningLevel;
            AddCompilerInfo(ci);
        }
Esempio n. 5
0
        public static string GetLanguageFromExtension(string extension)
        {
            CompilerInfo compilerInfo = GetCompilerInfoForExtensionNoThrow(extension);

            if (compilerInfo == null)
            {
                throw new ConfigurationErrorsException(SR.CodeDomProvider_NotDefined);
            }
            return(compilerInfo._compilerLanguages[0]);
        }
Esempio n. 6
0
        public static CompilerInfo GetCompilerInfo(string language)
        {
            CompilerInfo compilerInfo = GetCompilerInfoForLanguageNoThrow(language);

            if (compilerInfo == null)
            {
                throw new ConfigurationErrorsException(SR.CodeDomProvider_NotDefined);
            }
            return(compilerInfo);
        }
Esempio n. 7
0
        public static String GetLanguageFromExtension(String extension)
        {
            CompilerInfo compilerInfo = (CompilerInfo)GetCompilerInfoForExtensionNoThrow(extension);

            if (compilerInfo == null)
            {
                throw new ConfigurationErrorsException(SR.GetString(SR.CodeDomProvider_NotDefined));
            }
            return(compilerInfo._compilerLanguages[0]); // Return the first language name. There has to be one.
        }
Esempio n. 8
0
        static void AddCompilerInfo(Compiler compiler)
        {
            CompilerInfo ci = new CompilerInfo();

            ci.Languages       = compiler.Language;
            ci.Extensions      = compiler.Extension;
            ci.TypeName        = compiler.Type;
            ci.ProviderOptions = compiler.ProviderOptionsDictionary;
            AddCompilerInfo(ci);
        }
Esempio n. 9
0
        public override bool Equals(object o)
        {
            CompilerInfo info = o as CompilerInfo;

            if (o == null)
            {
                return(false);
            }
            return((((this.CodeDomProviderType == info.CodeDomProviderType) && (this.CompilerParams.WarningLevel == info.CompilerParams.WarningLevel)) && (this.CompilerParams.IncludeDebugInformation == info.CompilerParams.IncludeDebugInformation)) && (this.CompilerParams.CompilerOptions == info.CompilerParams.CompilerOptions));
        }
        internal CodeDomCompilationConfiguration()
        {
            // First time initialization. This must be kept consistent with machine.config.comments in that it
            // must initialize the config system as if that block was present.

            _compilerLanguages  = new Hashtable(StringComparer.OrdinalIgnoreCase);
            _compilerExtensions = new Hashtable(StringComparer.OrdinalIgnoreCase);
            _allCompilerInfo    = new ArrayList();

            CompilerInfo       compilerInfo;
            CompilerParameters compilerParameters;
            String             typeName;

            // C#
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName     = "Microsoft.CSharp.CSharpCodeProvider, " + AssemblyRef.System;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages  = new string[] { "c#", "cs", "csharp" };
            compilerInfo._compilerExtensions = new string[] { ".cs", "cs" };
            compilerInfo._providerOptions    = new Dictionary <string, string>();
            compilerInfo._providerOptions[RedistVersionInfo.NameTag] = RedistVersionInfo.DefaultVersion;
            AddCompilerInfo(compilerInfo);

            // VB
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName     = "Microsoft.VisualBasic.VBCodeProvider, " + AssemblyRef.System;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages  = new string[] { "vb", "vbs", "visualbasic", "vbscript" };
            compilerInfo._compilerExtensions = new string[] { ".vb", "vb" };
            compilerInfo._providerOptions    = new Dictionary <string, string>();
            compilerInfo._providerOptions[RedistVersionInfo.NameTag] = RedistVersionInfo.DefaultVersion;
            AddCompilerInfo(compilerInfo);

            // JScript
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName     = "Microsoft.JScript.JScriptCodeProvider, " + AssemblyRef.MicrosoftJScript;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages  = new string[] { "js", "jscript", "javascript" };
            compilerInfo._compilerExtensions = new string[] { ".js", "js" };
            compilerInfo._providerOptions    = new Dictionary <string, string>();
            AddCompilerInfo(compilerInfo);

            //// C++
            //compilerParameters = new CompilerParameters();
            //compilerParameters.WarningLevel = 4;
            //typeName = "Microsoft.VisualC.CppCodeProvider, " + AssemblyRef.MicrosoftVisualCCppCodeProvider;
            //compilerInfo = new CompilerInfo(compilerParameters, typeName);
            //compilerInfo._compilerLanguages = new string[] {"c++", "mc", "cpp"};
            //compilerInfo._compilerExtensions = new string[] {".h", "h"};
            //compilerInfo._providerOptions = new Dictionary<string, string>();
            //AddCompilerInfo(compilerInfo);
        }
        internal CodeDomCompilationConfiguration() {
            // First time initialization. This must be kept consistent with machine.config.comments in that it 
            // must initialize the config system as if that block was present.

            _compilerLanguages = new Hashtable(StringComparer.OrdinalIgnoreCase);
            _compilerExtensions = new Hashtable(StringComparer.OrdinalIgnoreCase);
            _allCompilerInfo = new ArrayList();            
            
            CompilerInfo compilerInfo;
            CompilerParameters compilerParameters;
            String typeName;
            
            // C#
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName = "Microsoft.CSharp.CSharpCodeProvider, " + AssemblyRef.System;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages = new string[] {"c#", "cs", "csharp"};
            compilerInfo._compilerExtensions = new string[] {".cs", "cs"};
            compilerInfo._providerOptions = new Dictionary<string, string>();
            compilerInfo._providerOptions[RedistVersionInfo.NameTag] = RedistVersionInfo.DefaultVersion;
            AddCompilerInfo(compilerInfo);

            // VB
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName = "Microsoft.VisualBasic.VBCodeProvider, " + AssemblyRef.System;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages = new string[] {"vb", "vbs", "visualbasic", "vbscript"};
            compilerInfo._compilerExtensions = new string[] {".vb", "vb"};
            compilerInfo._providerOptions = new Dictionary<string, string>();
            compilerInfo._providerOptions[RedistVersionInfo.NameTag] = RedistVersionInfo.DefaultVersion;
            AddCompilerInfo(compilerInfo);

            // JScript
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName = "Microsoft.JScript.JScriptCodeProvider, " + AssemblyRef.MicrosoftJScript;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages = new string[] {"js", "jscript", "javascript"};
            compilerInfo._compilerExtensions = new string[] {".js", "js"};
            compilerInfo._providerOptions = new Dictionary<string, string>();
            AddCompilerInfo(compilerInfo);

            // C++
            compilerParameters = new CompilerParameters();
            compilerParameters.WarningLevel = 4;
            typeName = "Microsoft.VisualC.CppCodeProvider, " + AssemblyRef.MicrosoftVisualCCppCodeProvider;
            compilerInfo = new CompilerInfo(compilerParameters, typeName);
            compilerInfo._compilerLanguages = new string[] {"c++", "mc", "cpp"};
            compilerInfo._compilerExtensions = new string[] {".h", "h"};
            compilerInfo._providerOptions = new Dictionary<string, string>();
            AddCompilerInfo(compilerInfo);
            
        }
Esempio n. 12
0
        // Do argument validation but don't throw if there's no compiler defined for a language.
        private static CompilerInfo GetCompilerInfoForExtensionNoThrow(String extension)
        {
            if (extension == null)
            {
                throw new ArgumentNullException("extension");
            }

            CompilerInfo compilerInfo = (CompilerInfo)Config._compilerExtensions[extension.Trim()];

            return(compilerInfo);
        }
Esempio n. 13
0
        // Do argument validation but don't throw if there's no compiler defined for a language.
        private static CompilerInfo GetCompilerInfoForLanguageNoThrow(String language)
        {
            if (language == null)
            {
                throw new ArgumentNullException("language");
            }

            CompilerInfo compilerInfo = (CompilerInfo)Config._compilerLanguages[language.Trim()];

            return(compilerInfo);
        }
Esempio n. 14
0
        public override bool Equals(object o)
        {
            if (!(o is CompilerInfo))
            {
                return(false);
            }

            CompilerInfo c = (CompilerInfo)o;

            return(c.TypeName == TypeName);
        }
Esempio n. 15
0
 private void AddCompilerInfo(CompilerInfo compilerInfo)
 {
     foreach (string str in compilerInfo._compilerLanguages)
     {
         this._compilerLanguages[str] = compilerInfo;
     }
     foreach (string str2 in compilerInfo._compilerExtensions)
     {
         this._compilerExtensions[str2] = compilerInfo;
     }
     this._allCompilerInfo.Add(compilerInfo);
 }
Esempio n. 16
0
        public ScriptClass(string ns, CompilerInfo compilerInfo) {
            this.ns             = ns;
            this.compilerInfo   = compilerInfo;
            this.refAssemblies  = new StringCollection();
            this.nsImports      = new StringCollection();
            this.typeDecl       = new CodeTypeDeclaration(GenerateUniqueClassName());
            this.refAssembliesByHref = false;
            this.scriptUris     = new Dictionary<string, string>(
#if !FEATURE_CASE_SENSITIVE_FILESYSTEM            
                StringComparer.OrdinalIgnoreCase
#endif
            );
        }
Esempio n. 17
0
        private static void AddCompilerInfo(CompilerInfo compilerInfo)
        {
            foreach (string language in compilerInfo._compilerLanguages)
            {
                s_compilerLanguages[language] = compilerInfo;
            }

            foreach (string extension in compilerInfo._compilerExtensions)
            {
                s_compilerExtensions[extension] = compilerInfo;
            }

            s_allCompilerInfo.Add(compilerInfo);
        }
Esempio n. 18
0
        private static void AddCompilerInfo(CompilerInfo compilerInfo)
        {
            foreach (string language in compilerInfo._compilerLanguages)
            {
                s_compilerLanguages[language] = compilerInfo;
            }

            foreach (string extension in compilerInfo._compilerExtensions)
            {
                s_compilerExtensions[extension] = compilerInfo;
            }

            s_allCompilerInfo.Add(compilerInfo);
        }
		public AppResourcesAssemblyBuilder (string canonicAssemblyName, string baseAssemblyPath, AppResourcesCompiler appres)
		{
			this.appResourcesCompiler = appres;
			this.baseAssemblyPath = baseAssemblyPath;
			this.baseAssemblyDirectory = Path.GetDirectoryName (baseAssemblyPath);
			this.canonicAssemblyName = canonicAssemblyName;
			
			config = WebConfigurationManager.GetWebApplicationSection ("system.web/compilation") as CompilationSection;
			if (config == null || !CodeDomProvider.IsDefinedLanguage (config.DefaultLanguage))
				throw new ApplicationException ("Could not get the default compiler.");
			ci = CodeDomProvider.GetCompilerInfo (config.DefaultLanguage);
			if (ci == null || !ci.IsCodeDomProviderTypeValid)
				throw new ApplicationException ("Failed to obtain the default compiler information.");
		}
Esempio n. 20
0
        public override bool Equals(Object o)
        {
            CompilerInfo other = o as CompilerInfo;

            if (o == null)
            {
                return(false);
            }

            return(CodeDomProviderType == other.CodeDomProviderType &&
                   CompilerParams.WarningLevel == other.CompilerParams.WarningLevel &&
                   CompilerParams.IncludeDebugInformation == other.CompilerParams.IncludeDebugInformation &&
                   CompilerParams.CompilerOptions == other.CompilerParams.CompilerOptions);
        }
        public string GetLanguageFromExtension(string extension)
        {
            CompilerInfo ci = GetCompilerInfoForExtension(extension);

            if (ci == null)
            {
                return(null);
            }
            string[] languages = ci.GetLanguages();
            if (languages != null && languages.Length > 0)
            {
                return(languages [0]);
            }
            return(null);
        }
        static CompilerCollection()
        {
            properties          = new ConfigurationPropertyCollection();
            compiler_infos      = new List <CompilerInfo> ();
            compiler_languages  = new Dictionary <string, CompilerInfo> (16, StringComparer.OrdinalIgnoreCase);
            compiler_extensions = new Dictionary <string, CompilerInfo> (6, StringComparer.OrdinalIgnoreCase);

            CompilerInfo compiler = new CompilerInfo();

            compiler.Languages       = "c#;cs;csharp";
            compiler.Extensions      = ".cs";
            compiler.TypeName        = "Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
            compiler.ProviderOptions = new Dictionary <string, string> (1);
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);

            compiler                 = new CompilerInfo();
            compiler.Languages       = "vb;vbs;visualbasic;vbscript";
            compiler.Extensions      = ".vb";
            compiler.TypeName        = "Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
            compiler.ProviderOptions = new Dictionary <string, string> (1);
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);

            compiler                 = new CompilerInfo();
            compiler.Languages       = "js;jscript;javascript";
            compiler.Extensions      = ".js";
            compiler.TypeName        = "Microsoft.JScript.JScriptCodeProvider, Microsoft.JScript, Version=8.0.1100.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            compiler.ProviderOptions = new Dictionary <string, string> (1);
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);

            compiler                 = new CompilerInfo();
            compiler.Languages       = "vj#;vjs;vjsharp";
            compiler.Extensions      = ".jsl;.java";
            compiler.TypeName        = "Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            compiler.ProviderOptions = new Dictionary <string, string> (1);
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);

            compiler                 = new CompilerInfo();
            compiler.Languages       = "c++;mc;cpp";
            compiler.Extensions      = ".h";
            compiler.TypeName        = "Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            compiler.ProviderOptions = new Dictionary <string, string> (1);
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);
        }
Esempio n. 23
0
		static CompilerCollection ()
		{
			properties = new ConfigurationPropertyCollection ();
			compiler_infos = new List <CompilerInfo> ();
			compiler_languages = new Dictionary <string, CompilerInfo> (16, StringComparer.OrdinalIgnoreCase);
			compiler_extensions = new Dictionary <string, CompilerInfo> (6, StringComparer.OrdinalIgnoreCase);
				
			CompilerInfo compiler = new CompilerInfo ();
                        compiler.Languages = "c#;cs;csharp";
                        compiler.Extensions = ".cs";
                        compiler.TypeName = "Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
			compiler.ProviderOptions = new Dictionary <string, string> (1);
			compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
			AddCompilerInfo (compiler);

			compiler = new CompilerInfo ();
			compiler.Languages = "vb;vbs;visualbasic;vbscript";
                        compiler.Extensions = ".vb";
                        compiler.TypeName = "Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
			compiler.ProviderOptions = new Dictionary <string, string> (1);
			compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
			AddCompilerInfo (compiler);

			compiler = new CompilerInfo ();
                        compiler.Languages = "js;jscript;javascript";
                        compiler.Extensions = ".js";
                        compiler.TypeName = "Microsoft.JScript.JScriptCodeProvider, Microsoft.JScript, Version=8.0.1100.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
			compiler.ProviderOptions = new Dictionary <string, string> (1);
			compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
			AddCompilerInfo (compiler);

			compiler = new CompilerInfo ();
                        compiler.Languages = "vj#;vjs;vjsharp";
                        compiler.Extensions = ".jsl;.java";
                        compiler.TypeName = "Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
			compiler.ProviderOptions = new Dictionary <string, string> (1);
			compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
			AddCompilerInfo (compiler);

			compiler = new CompilerInfo ();
                        compiler.Languages = "c++;mc;cpp";
                        compiler.Extensions = ".h";
                        compiler.TypeName = "Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
			compiler.ProviderOptions = new Dictionary <string, string> (1);
			compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
			AddCompilerInfo (compiler);
		}
Esempio n. 24
0
        static CompilerCollection()
        {
            properties          = new ConfigurationPropertyCollection();
            compiler_infos      = new List <CompilerInfo> ();
            compiler_languages  = new Dictionary <string, CompilerInfo> (16, StringComparer.OrdinalIgnoreCase);
            compiler_extensions = new Dictionary <string, CompilerInfo> (4, StringComparer.OrdinalIgnoreCase);

            CompilerInfo compiler = new CompilerInfo(null, "Microsoft.CSharp.CSharpCodeProvider, " + Consts.AssemblySystem,
                                                     new [] { "c#", "cs", "csharp" }, new [] { ".cs" });

            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);

            compiler = new CompilerInfo(null, "Microsoft.VisualBasic.VBCodeProvider, " + Consts.AssemblySystem,
                                        new [] { "vb", "vbs", "visualbasic", "vbscript" }, new [] { ".vb" });
            compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
            AddCompilerInfo(compiler);
        }
        private CompilerInfo FindExistingCompilerInfo(string[] languageList, string[] extensionList)
        {
            CompilerInfo compilerInfo = null;

            foreach (CompilerInfo ci in _allCompilerInfo)
            {
                if (ci._compilerExtensions.Length == extensionList.Length &&
                    ci._compilerLanguages.Length == languageList.Length)
                {
                    bool differ = false;
                    for (int i = 0; i < ci._compilerExtensions.Length; i++)
                    {
                        if (ci._compilerExtensions[i] != extensionList[i])
                        {
                            differ = true;
                            break;
                        }
                    }

                    for (int i = 0; i < ci._compilerLanguages.Length; i++)
                    {
                        if (ci._compilerLanguages[i] != languageList[i])
                        {
                            differ = true;
                            break;
                        }
                    }

                    if (!differ)
                    {
                        compilerInfo = ci;
                        break;
                    }
                }
            }

            return(compilerInfo);
        }
        static void AddCompilerInfo(CompilerInfo ci)
        {
            ci.Init();
            compiler_infos.Add(ci);

            string[] languages = ci.GetLanguages();
            if (languages != null)
            {
                foreach (string language in languages)
                {
                    compiler_languages [language] = ci;
                }
            }

            string[] extensions = ci.GetExtensions();
            if (extensions != null)
            {
                foreach (string extension in extensions)
                {
                    compiler_extensions [extension] = ci;
                }
            }
        }
            private static void ProcessCompilersElement(CodeDomCompilationConfiguration result, XmlNode node) {

                // reject attributes
                HandlerBase.CheckForUnrecognizedAttributes(node);

                String configFile = ConfigurationErrorsException.GetFilename(node);

                foreach(XmlNode child in node.ChildNodes) {
                    int configLineNumber = ConfigurationErrorsException.GetLineNumber(child);

                    // skip whitespace and comments
                    // reject nonelements
                    if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                        continue;

                    if (child.Name != "compiler") {
                        HandlerBase.ThrowUnrecognizedElement(child);
                    }

                    String languages = String.Empty;
                    XmlNode languageNode = HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "language", ref languages);
                    String extensions = String.Empty;
                    HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "extension", ref extensions);
                    String compilerTypeName = null;
                    HandlerBase.GetAndRemoveStringAttribute(child, "type", ref compilerTypeName);

                    // Create a CompilerParameters for this compiler.
                    CompilerParameters compilerParams = new CompilerParameters();

                    int warningLevel = 0;
                    if (HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(child, "warningLevel", ref warningLevel) != null) {
                        compilerParams.WarningLevel = warningLevel;

                        // Need to be false if the warning level is 0
                        compilerParams.TreatWarningsAsErrors = (warningLevel>0);
                    }
                    String compilerOptions = null;
                    if (HandlerBase.GetAndRemoveStringAttribute(child, "compilerOptions", ref compilerOptions) != null) {
                        compilerParams.CompilerOptions = compilerOptions;
                    }

                    IDictionary<string, string> provOptions = GetProviderOptions(child);

                    HandlerBase.CheckForUnrecognizedAttributes(child);

                    // Parse the semicolon separated lists
                    string[] languageList = languages.Split(s_fieldSeparators);
                    string[] extensionList = extensions.Split(s_fieldSeparators);

                    for( int i =0 ; i < languageList.Length; i++) {
                        languageList[i] = languageList[i].Trim();
                    }

                    for( int i =0 ; i < extensionList.Length; i++) {
                        extensionList[i] = extensionList[i].Trim();
                    }


                    // Validate language names, language names must have length and extensions must start with a period.
                    foreach (string language in languageList) {
                        if (language.Length == 0)
                            throw new ConfigurationErrorsException(SR.GetString(SR.Language_Names_Cannot_Be_Empty));
                    }

                    foreach (string extension in extensionList) {
                        if (extension.Length == 0 || extension[0] != '.')
                            throw new ConfigurationErrorsException(SR.GetString(SR.Extension_Names_Cannot_Be_Empty_Or_Non_Period_Based));
                    }

                    
                    // Create a CompilerInfo structure for this compiler, or get
                    // an existing one if no type was provided
                    CompilerInfo compilerInfo = null;
                    if (compilerTypeName != null) {
                        compilerInfo = new CompilerInfo(compilerParams, compilerTypeName);
                    } else {
                        // reconfiguring an existing entry
                        compilerInfo = result.FindExistingCompilerInfo(languageList, extensionList);

                        if (compilerInfo == null) 
                            throw new ConfigurationErrorsException();                        
                    }

                    compilerInfo.configFileName = configFile;
                    compilerInfo.configFileLineNumber = configLineNumber;


                    if (compilerTypeName != null) {
                        compilerInfo._compilerLanguages = languageList;
                        compilerInfo._compilerExtensions = extensionList;
                        compilerInfo._providerOptions = provOptions;

                        result.AddCompilerInfo(compilerInfo);
                    } else {
                        // merge in new options, replacing any previous values w/
                        // new ones.
                        foreach (KeyValuePair<string, string> kvp in provOptions) {
                            compilerInfo._providerOptions[kvp.Key] = kvp.Value;
                        }
                    }
                }
                // Allow config options to replace redundant compiler entries
                result.RemoveUnmapped();
            }
Esempio n. 28
0
        internal CodeDomCompilationConfiguration()
        {
            this._compilerLanguages  = new Hashtable(StringComparer.OrdinalIgnoreCase);
            this._compilerExtensions = new Hashtable(StringComparer.OrdinalIgnoreCase);
            this._allCompilerInfo    = new ArrayList();
            CompilerParameters compilerParams = new CompilerParameters {
                WarningLevel = 4
            };
            string       codeDomProviderTypeName = "Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
            CompilerInfo compilerInfo            = new CompilerInfo(compilerParams, codeDomProviderTypeName)
            {
                _compilerLanguages  = new string[] { "c#", "cs", "csharp" },
                _compilerExtensions = new string[] { ".cs", "cs" },
                _providerOptions    = new Dictionary <string, string>()
            };

            compilerInfo._providerOptions["CompilerVersion"] = "v4.0";
            this.AddCompilerInfo(compilerInfo);
            compilerParams = new CompilerParameters {
                WarningLevel = 4
            };
            codeDomProviderTypeName = "Microsoft.VisualBasic.VBCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
            compilerInfo            = new CompilerInfo(compilerParams, codeDomProviderTypeName)
            {
                _compilerLanguages  = new string[] { "vb", "vbs", "visualbasic", "vbscript" },
                _compilerExtensions = new string[] { ".vb", "vb" },
                _providerOptions    = new Dictionary <string, string>()
            };
            compilerInfo._providerOptions["CompilerVersion"] = "v4.0";
            this.AddCompilerInfo(compilerInfo);
            compilerParams = new CompilerParameters {
                WarningLevel = 4
            };
            codeDomProviderTypeName = "Microsoft.JScript.JScriptCodeProvider, Microsoft.JScript, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            compilerInfo            = new CompilerInfo(compilerParams, codeDomProviderTypeName)
            {
                _compilerLanguages  = new string[] { "js", "jscript", "javascript" },
                _compilerExtensions = new string[] { ".js", "js" },
                _providerOptions    = new Dictionary <string, string>()
            };
            this.AddCompilerInfo(compilerInfo);
            compilerParams = new CompilerParameters {
                WarningLevel = 4
            };
            codeDomProviderTypeName = "Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            compilerInfo            = new CompilerInfo(compilerParams, codeDomProviderTypeName)
            {
                _compilerLanguages  = new string[] { "vj#", "vjs", "vjsharp" },
                _compilerExtensions = new string[] { ".jsl", "jsl", ".java", "java" },
                _providerOptions    = new Dictionary <string, string>()
            };
            this.AddCompilerInfo(compilerInfo);
            compilerParams = new CompilerParameters {
                WarningLevel = 4
            };
            codeDomProviderTypeName = "Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            compilerInfo            = new CompilerInfo(compilerParams, codeDomProviderTypeName)
            {
                _compilerLanguages  = new string[] { "c++", "mc", "cpp" },
                _compilerExtensions = new string[] { ".h", "h" },
                _providerOptions    = new Dictionary <string, string>()
            };
            this.AddCompilerInfo(compilerInfo);
        }
Esempio n. 29
0
        public static CodeDomProvider CreateProvider(string language)
        {
            CompilerInfo ci = GetCompilerInfo(language);

            return((ci == null) ? null : ci.CreateProvider());
        }
Esempio n. 30
0
        public static CodeDomProvider CreateProvider(string language, IDictionary <string, string> providerOptions)
        {
            CompilerInfo ci = GetCompilerInfo(language);

            return(ci == null ? null : ci.CreateProvider(providerOptions));
        }
Esempio n. 31
0
		public void FixtureSetUp ()
		{
			ci = CodeDomProvider.GetCompilerInfo ("c#");
		}
Esempio n. 32
0
 public ScriptClass(string ns, CompilerInfo compilerInfo) {
     this.ns           = ns;
     this.compilerInfo = compilerInfo;
     this.typeDecl     = new CodeTypeDeclaration(GenerateUniqueClassName());
 }
Esempio n. 33
0
        public static CodeDomProvider CreateProvider(string language, System.Collections.Generic.IDictionary <string, string> providerOptions)
        {
            CompilerInfo compilerInfo = GetCompilerInfo(language);

            return(compilerInfo.CreateProvider(providerOptions));
        }
Esempio n. 34
0
        public static CodeDomProvider CreateProvider(string language)
        {
            CompilerInfo compilerInfo = GetCompilerInfo(language);

            return(compilerInfo.CreateProvider());
        }
Esempio n. 35
0
            private static void ProcessCompilersElement(CodeDomCompilationConfiguration result, XmlNode node)
            {
                System.CodeDom.Compiler.HandlerBase.CheckForUnrecognizedAttributes(node);
                string filename = ConfigurationErrorsException.GetFilename(node);

                foreach (XmlNode node2 in node.ChildNodes)
                {
                    int lineNumber = ConfigurationErrorsException.GetLineNumber(node2);
                    if (!System.CodeDom.Compiler.HandlerBase.IsIgnorableAlsoCheckForNonElement(node2))
                    {
                        if (node2.Name != "compiler")
                        {
                            System.CodeDom.Compiler.HandlerBase.ThrowUnrecognizedElement(node2);
                        }
                        string val = string.Empty;
                        System.CodeDom.Compiler.HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(node2, "language", ref val);
                        string str3 = string.Empty;
                        System.CodeDom.Compiler.HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(node2, "extension", ref str3);
                        string str4 = null;
                        System.CodeDom.Compiler.HandlerBase.GetAndRemoveStringAttribute(node2, "type", ref str4);
                        CompilerParameters compilerParams = new CompilerParameters();
                        int num2 = 0;
                        if (System.CodeDom.Compiler.HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(node2, "warningLevel", ref num2) != null)
                        {
                            compilerParams.WarningLevel          = num2;
                            compilerParams.TreatWarningsAsErrors = num2 > 0;
                        }
                        string str5 = null;
                        if (System.CodeDom.Compiler.HandlerBase.GetAndRemoveStringAttribute(node2, "compilerOptions", ref str5) != null)
                        {
                            compilerParams.CompilerOptions = str5;
                        }
                        IDictionary <string, string> providerOptions = GetProviderOptions(node2);
                        System.CodeDom.Compiler.HandlerBase.CheckForUnrecognizedAttributes(node2);
                        string[] languageList  = val.Split(CodeDomCompilationConfiguration.s_fieldSeparators);
                        string[] extensionList = str3.Split(CodeDomCompilationConfiguration.s_fieldSeparators);
                        for (int i = 0; i < languageList.Length; i++)
                        {
                            languageList[i] = languageList[i].Trim();
                        }
                        for (int j = 0; j < extensionList.Length; j++)
                        {
                            extensionList[j] = extensionList[j].Trim();
                        }
                        foreach (string str6 in languageList)
                        {
                            if (str6.Length == 0)
                            {
                                throw new ConfigurationErrorsException(System.SR.GetString("Language_Names_Cannot_Be_Empty"));
                            }
                        }
                        foreach (string str7 in extensionList)
                        {
                            if ((str7.Length == 0) || (str7[0] != '.'))
                            {
                                throw new ConfigurationErrorsException(System.SR.GetString("Extension_Names_Cannot_Be_Empty_Or_Non_Period_Based"));
                            }
                        }
                        CompilerInfo compilerInfo = null;
                        if (str4 != null)
                        {
                            compilerInfo = new CompilerInfo(compilerParams, str4);
                        }
                        else
                        {
                            compilerInfo = result.FindExistingCompilerInfo(languageList, extensionList);
                            if (compilerInfo == null)
                            {
                                throw new ConfigurationErrorsException();
                            }
                        }
                        compilerInfo.configFileName       = filename;
                        compilerInfo.configFileLineNumber = lineNumber;
                        if (str4 != null)
                        {
                            compilerInfo._compilerLanguages  = languageList;
                            compilerInfo._compilerExtensions = extensionList;
                            compilerInfo._providerOptions    = providerOptions;
                            result.AddCompilerInfo(compilerInfo);
                        }
                        else
                        {
                            foreach (KeyValuePair <string, string> pair in providerOptions)
                            {
                                compilerInfo._providerOptions[pair.Key] = pair.Value;
                            }
                        }
                    }
                }
                result.RemoveUnmapped();
            }
            private static void ProcessCompilersElement(CodeDomCompilationConfiguration result, XmlNode node)
            {
                // reject attributes
                HandlerBase.CheckForUnrecognizedAttributes(node);

                String configFile = ConfigurationErrorsException.GetFilename(node);

                foreach (XmlNode child in node.ChildNodes)
                {
                    int configLineNumber = ConfigurationErrorsException.GetLineNumber(child);

                    // skip whitespace and comments
                    // reject nonelements
                    if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                    {
                        continue;
                    }

                    if (child.Name != "compiler")
                    {
                        HandlerBase.ThrowUnrecognizedElement(child);
                    }

                    String  languages    = String.Empty;
                    XmlNode languageNode = HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "language", ref languages);
                    String  extensions   = String.Empty;
                    HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "extension", ref extensions);
                    String compilerTypeName = null;
                    HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "type", ref compilerTypeName);

                    // Create a CompilerParameters for this compiler.
                    CompilerParameters compilerParams = new CompilerParameters();

                    int warningLevel = 0;
                    if (HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(child, "warningLevel", ref warningLevel) != null)
                    {
                        compilerParams.WarningLevel = warningLevel;

                        // Need to be false if the warning level is 0
                        compilerParams.TreatWarningsAsErrors = (warningLevel > 0);
                    }
                    String compilerOptions = null;
                    if (HandlerBase.GetAndRemoveStringAttribute(child, "compilerOptions", ref compilerOptions) != null)
                    {
                        compilerParams.CompilerOptions = compilerOptions;
                    }

                    HandlerBase.CheckForUnrecognizedAttributes(child);
                    HandlerBase.CheckForChildNodes(child);

                    // Create a CompilerInfo structure for this compiler
                    CompilerInfo compilerInfo = new CompilerInfo(compilerParams, compilerTypeName);
                    compilerInfo.configFileName       = configFile;
                    compilerInfo.configFileLineNumber = configLineNumber;

                    // Parse the semicolon separated lists
                    string[] languageList  = languages.Split(s_fieldSeparators);
                    string[] extensionList = extensions.Split(s_fieldSeparators);

                    for (int i = 0; i < languageList.Length; i++)
                    {
                        languageList[i] = languageList[i].Trim();
                    }

                    for (int i = 0; i < extensionList.Length; i++)
                    {
                        extensionList[i] = extensionList[i].Trim();
                    }


                    // Validate language names, language names must have length and extensions must start with a period.
                    foreach (string language in languageList)
                    {
                        if (language.Length == 0)
                        {
                            throw new ConfigurationErrorsException(SR.GetString(SR.Language_Names_Cannot_Be_Empty));
                        }
                    }

                    foreach (string extension in extensionList)
                    {
                        if (extension.Length == 0 || extension[0] != '.')
                        {
                            throw new ConfigurationErrorsException(SR.GetString(SR.Extension_Names_Cannot_Be_Empty_Or_Non_Period_Based));
                        }
                    }


                    compilerInfo._compilerLanguages  = languageList;
                    compilerInfo._compilerExtensions = extensionList;

                    result.AddCompilerInfo(compilerInfo);
                }
                // Allow config options to replace redundant compiler entries
                result.RemoveUnmapped();
            }
Esempio n. 37
0
 private string GetLanguageName(CompilerInfo compilerInfo)
 {
     Regex alphaNumeric = new Regex("^[0-9a-zA-Z]+$");
     foreach (string name in compilerInfo.GetLanguages())
     {
         if (alphaNumeric.IsMatch(name))
             return name;
     }
     return "script" + (++_assemblyCounter).ToString(CultureInfo.InvariantCulture);
 }
Esempio n. 38
0
 private static IDictionary<string, string> GetProviderOptions(CompilerInfo ci) {
     Debug.Assert(ci != null, "CompilerInfo ci should not be null");
     PropertyInfo pi = ci.GetType().GetProperty("ProviderOptions",
         BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance);
     if (pi != null)
         return (IDictionary<string, string>)pi.GetValue(ci, null);
     return null;
 }
Esempio n. 39
0
		static void AddCompilerInfo (Compiler compiler)
		{
			CompilerInfo ci = new CompilerInfo ();
			ci.Languages = compiler.Language;
			ci.Extensions = compiler.Extension;
			ci.TypeName = compiler.Type;
			ci.ProviderOptions = compiler.ProviderOptionsDictionary;
			ci.CompilerOptions = compiler.CompilerOptions;
			ci.WarningLevel = compiler.WarningLevel;
			AddCompilerInfo (ci);
		}
Esempio n. 40
0
		static void AddCompilerInfo (CompilerInfo ci)
		{
			ci.Init ();
			compiler_infos.Add (ci);

			string[] languages = ci.GetLanguages ();
			if (languages != null)
				foreach (string language in languages)
					compiler_languages [language] = ci;
			
			string[] extensions = ci.GetExtensions ();
			if (extensions != null)
				foreach (string extension in extensions)
					compiler_extensions [extension] = ci;
		}
 private static IDictionary<string, string> GetProviderOptions(CompilerInfo ci)
 {
     PropertyInfo property = ci.GetType().GetProperty("ProviderOptions", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
     if (property != null)
     {
         return (IDictionary<string, string>) property.GetValue(ci, null);
     }
     return null;
 }