Exemple #1
0
        private static string GetCompilerVersionFor20Or35()
        {
            string cSharpCompilerVersion      = GetCSharpCompilerVersion();
            string visualBasicCompilerVersion = GetVisualBasicCompilerVersion();

            cSharpCompilerVersion      = ReplaceCompilerVersionFor20Or35(cSharpCompilerVersion);
            visualBasicCompilerVersion = ReplaceCompilerVersionFor20Or35(visualBasicCompilerVersion);
            Version versionFromVString = CompilationUtil.GetVersionFromVString(cSharpCompilerVersion);
            Version version2           = CompilationUtil.GetVersionFromVString(visualBasicCompilerVersion);

            if (versionFromVString > version2)
            {
                return(cSharpCompilerVersion);
            }
            return(visualBasicCompilerVersion);
        }
Exemple #2
0
 private static void ValidateCompilerVersionFor40AndAbove(string compilerVersion)
 {
     if (compilerVersion != null)
     {
         Exception exception = null;
         if ((compilerVersion.Length < 4) || (compilerVersion[0] != 'v'))
         {
             ReportInvalidCompilerVersion(compilerVersion);
         }
         try
         {
             if (CompilationUtil.GetVersionFromVString(compilerVersion) < Version40)
             {
                 throw new ConfigurationErrorsException(System.Web.SR.GetString("Compiler_version_40_required", new object[] { s_configTargetFrameworkAttributeName }));
             }
         }
         catch (ArgumentNullException exception2)
         {
             exception = exception2;
         }
         catch (ArgumentOutOfRangeException exception3)
         {
             exception = exception3;
         }
         catch (ArgumentException exception4)
         {
             exception = exception4;
         }
         catch (FormatException exception5)
         {
             exception = exception5;
         }
         catch (OverflowException exception6)
         {
             exception = exception6;
         }
         if (exception != null)
         {
             ReportInvalidCompilerVersion(compilerVersion);
         }
     }
 }
        /// <summary>
        /// Returns the higher compilerVersion specified in codedom for the case when targeting 2.0/3.5.
        /// Either "v3.5" is returned, or "v2.0" is returned if the compilerVersion
        /// is anything other that "v3.5". This is because the root web.config has compilerVersion=v4.0. If we
        /// know that we are compiling for 2.0 or 3.5, then we override the value to 2.0 if it is not 3.5.
        /// </summary>
        private static string GetCompilerVersionFor20Or35()
        {
            string vbCompilerVersion     = GetCSharpCompilerVersion();
            string csharpCompilerVersion = GetVisualBasicCompilerVersion();

            // The root web.config will have compilerVersion=4.0, so if we are targeting 2.0 or 3.5, we need to
            // use compilerVersion=2.0 if the compilerVersion is NOT 3.5.
            vbCompilerVersion     = ReplaceCompilerVersionFor20Or35(vbCompilerVersion);
            csharpCompilerVersion = ReplaceCompilerVersionFor20Or35(csharpCompilerVersion);

            Version vbVersion = CompilationUtil.GetVersionFromVString(vbCompilerVersion);
            Version csVersion = CompilationUtil.GetVersionFromVString(csharpCompilerVersion);

            // Return the larger value as the intended version
            if (vbVersion > csVersion)
            {
                return(vbCompilerVersion);
            }
            return(csharpCompilerVersion);
        }
 private static void ValidateCompilerVersionFor40AndAbove(string compilerVersion)
 {
     if (compilerVersion != null)
     {
         Exception exception = null;
         if (compilerVersion.Length < 4 || compilerVersion[0] != 'v')
         {
             ReportInvalidCompilerVersion(compilerVersion);
         }
         try {
             Version version = CompilationUtil.GetVersionFromVString(compilerVersion);
             if (version < Version40)
             {
                 throw new ConfigurationErrorsException(SR.GetString(SR.Compiler_version_40_required, s_configTargetFrameworkAttributeName));
             }
         }
         catch (ArgumentNullException e) {
             exception = e;
         }
         catch (ArgumentOutOfRangeException e) {
             exception = e;
         }
         catch (ArgumentException e) {
             exception = e;
         }
         catch (FormatException e) {
             exception = e;
         }
         catch (OverflowException e) {
             exception = e;
         }
         if (exception != null)
         {
             ReportInvalidCompilerVersion(compilerVersion);
         }
     }
 }