// TODO: rsp is used?
        /// <summary>
        ///		Compiles specified source files to an assembly as serialization target type assembly.
        /// </summary>
        /// <param name="sourceFilePathes">The source code file pathes.</param>
        /// <param name="referenceAssemblies">The additional reference assembly file pathes to compile specified files.</param>
        /// <returns>An assembly which contains serialization target types.</returns>
        /// <exception cref="System.Exception">Failed to generate serializer source code because of compilation error.</exception>
        public Assembly CompileTargetTypeAssembly(
            IEnumerable <string> sourceFilePathes,
            IEnumerable <string> referenceAssemblies
            )
        {
            var sourceAssembly =
                this.CompileSourceFiles(
                    sourceFilePathes,
                    referenceAssemblies,
                    this.OutputWriter ?? Console.Out,
                    this.ErrorWriter == null
                                                ? ColorizedTextWriter.ForConsoleError()
                                                : this.ErrorWriter == Console.Out
                                                        ? ColorizedTextWriter.ForConsoleOutput()
                                                        : this.ErrorWriter == Console.Error
                                                                ? ColorizedTextWriter.ForConsoleError()
                                                                : ColorizedTextWriter.ForTextWriter(this.ErrorWriter)
                    );

            if (sourceAssembly == null)
            {
                throw new Exception("Failed to generate serializer source code because target type compilation.");
            }

            return(sourceAssembly);
        }
		private Assembly CompileSourceFiles(
			IEnumerable<string> sourceFilePathes,
			IEnumerable<string> referenceAssemblies,
			TextWriter outputWriter,
			ColorizedTextWriter errorWriter
			)
		{
			var compilerParameters =
				new CompilerParameters
				{
					GenerateExecutable = false,
					IncludeDebugInformation = false,
					GenerateInMemory = true,
					OutputAssembly = "MsgPackSerializers",
					TreatWarningsAsErrors = this.TreatWarningsAsErrors,
					WarningLevel = this.WarningLevel
				};

			foreach ( var referenceAssembly in referenceAssemblies )
			{
				compilerParameters.ReferencedAssemblies.Add( referenceAssembly );
			}

			if (
				!typeof( CodeDomProvider ).Assembly.CodeBase.StartsWith(
					Environment.ExpandEnvironmentVariables( "file:///%SystemDrive%/Windows/" ),
					StringComparison.OrdinalIgnoreCase ) )
			{
				// may be mcs, so add C# 3.5 option.
				compilerParameters.CompilerOptions = "-langversion=3 -sdk=2";
			}

			var results =
				CodeDomProvider.CreateProvider( "C#" ).CompileAssemblyFromFile(
					compilerParameters,
					sourceFilePathes.ToArray()
					);

			foreach ( var stdout in results.Output )
			{
				outputWriter.WriteLine( stdout );
			}

			outputWriter.Flush();

			foreach ( CompilerError error in results.Errors )
			{
				string message =
					String.Format(
						CultureInfo.CurrentCulture,
						"Source '{1}'{0}  Line:{2}, Column:{3}{0}  {4}{0}{5}",
						Environment.NewLine,
						error.FileName,
						error.Line,
						error.Column,
						error.ErrorNumber,
						error.ErrorText
						);

				if ( error.IsWarning )
				{
					errorWriter.WriteWarning( message );
				}
				else
				{
					errorWriter.WriteError( message );
				}
			}

			errorWriter.Flush();

			return results.CompiledAssembly;
		}
        private Assembly CompileSourceFiles(
            IEnumerable <string> sourceFilePathes,
            IEnumerable <string> referenceAssemblies,
            TextWriter outputWriter,
            ColorizedTextWriter errorWriter
            )
        {
            var compilerParameters =
                new CompilerParameters
            {
                GenerateExecutable      = false,
                IncludeDebugInformation = false,
                GenerateInMemory        = true,
                OutputAssembly          = "MsgPackSerializers",
                TreatWarningsAsErrors   = this.TreatWarningsAsErrors,
                WarningLevel            = this.WarningLevel
            };

            foreach (var referenceAssembly in referenceAssemblies)
            {
                compilerParameters.ReferencedAssemblies.Add(referenceAssembly);
            }

            if (
                !typeof(CodeDomProvider).Assembly.CodeBase.StartsWith(
                    Environment.ExpandEnvironmentVariables("file:///%SystemDrive%/Windows/"),
                    StringComparison.OrdinalIgnoreCase))
            {
                // may be mcs, so add C# 3.5 option.
                compilerParameters.CompilerOptions = "-langversion=3 -sdk=2";
            }

            var results =
                CodeDomProvider.CreateProvider("C#").CompileAssemblyFromFile(
                    compilerParameters,
                    sourceFilePathes.ToArray()
                    );

            foreach (var stdout in results.Output)
            {
                outputWriter.WriteLine(stdout);
            }

            outputWriter.Flush();

            foreach (CompilerError error in results.Errors)
            {
                string message =
                    String.Format(
                        CultureInfo.CurrentCulture,
                        "Source '{1}'{0}  Line:{2}, Column:{3}{0}  {4}{0}{5}",
                        Environment.NewLine,
                        error.FileName,
                        error.Line,
                        error.Column,
                        error.ErrorNumber,
                        error.ErrorText
                        );

                if (error.IsWarning)
                {
                    errorWriter.WriteWarning(message);
                }
                else
                {
                    errorWriter.WriteError(message);
                }
            }

            errorWriter.Flush();

            return(results.CompiledAssembly);
        }
        private Assembly CompileSourceFiles(
            IEnumerable <string> sourceFilePathes,
            IEnumerable <string> referenceAssemblies,
            TextWriter outputWriter,
            ColorizedTextWriter errorWriter
            )
        {
            var compilerParameters =
                new CompilerParameters
            {
                GenerateExecutable      = false,
                IncludeDebugInformation = false,
                GenerateInMemory        = true,
                OutputAssembly          = "MsgPackSerializers",
                TreatWarningsAsErrors   = this.TreatWarningsAsErrors,
                WarningLevel            = this.WarningLevel
            };

            foreach (var referenceAssembly in referenceAssemblies)
            {
                compilerParameters.ReferencedAssemblies.Add(referenceAssembly);
            }

            var results =
                CodeDomProvider.CreateProvider("C#").CompileAssemblyFromFile(
                    compilerParameters,
                    sourceFilePathes.ToArray()
                    );

            foreach (var stdout in results.Output)
            {
                outputWriter.WriteLine(stdout);
            }

            outputWriter.Flush();

            foreach (CompilerError error in results.Errors)
            {
                string message =
                    String.Format(
                        CultureInfo.CurrentCulture,
                        "Source '{1}'{0}  Line:{2}, Column:{3}{0}  {4}{0}{5}",
                        Environment.NewLine,
                        error.FileName,
                        error.Line,
                        error.Column,
                        error.ErrorNumber,
                        error.ErrorText
                        );

                if (error.IsWarning)
                {
                    errorWriter.WriteWarning(message);
                }
                else
                {
                    errorWriter.WriteError(message);
                }
            }

            errorWriter.Flush();

            return(results.CompiledAssembly);
        }
		private Assembly CompileSourceFiles(
			IEnumerable<string> sourceFilePathes,
			IEnumerable<string> referenceAssemblies,
			TextWriter outputWriter,
			ColorizedTextWriter errorWriter
			)
		{
			var compilerParameters =
				new CompilerParameters
				{
					GenerateExecutable = false,
					IncludeDebugInformation = false,
					GenerateInMemory = true,
					OutputAssembly = "MsgPackSerializers",
					TreatWarningsAsErrors = this.TreatWarningsAsErrors,
					WarningLevel = this.WarningLevel
				};

			foreach ( var referenceAssembly in referenceAssemblies )
			{
				compilerParameters.ReferencedAssemblies.Add( referenceAssembly );
			}

			var results =
				CodeDomProvider.CreateProvider( "C#" ).CompileAssemblyFromFile(
					compilerParameters,
					sourceFilePathes.ToArray()
					);

			foreach ( var stdout in results.Output )
			{
				outputWriter.WriteLine( stdout );
			}

			outputWriter.Flush();

			foreach ( CompilerError error in results.Errors )
			{
				string message =
					String.Format(
						CultureInfo.CurrentCulture,
						"Source '{1}'{0}  Line:{2}, Column:{3}{0}  {4}{0}{5}",
						Environment.NewLine,
						error.FileName,
						error.Line,
						error.Column,
						error.ErrorNumber,
						error.ErrorText
						);

				if ( error.IsWarning )
				{
					errorWriter.WriteWarning( message );
				}
				else
				{
					errorWriter.WriteError( message );
				}
			}

			errorWriter.Flush();

			return results.CompiledAssembly;
		}