[Mono-list] Patch for mcs/class/Cscompmgd/Microsoft.CSharp/Compiler.cs
(Jackson)
Steve Deobald
steve@citygroup.ca
Mon, 23 Feb 2004 05:04:49 -0600
Here is a patch I wrote weeks (months?) ago to finish a TODO Jackson
pointed me to. Tonight I cleaned it up so it actually works and tested
it by hand and matched it to the MS Cscompmgd.dll output.
There is no unit test for Cscompmgd that I can see... and I'm not sure
if I'm the person to be writing one. ;) If I should just jump in and
create a test for Cscompmgd, please let me know. Thanks.
.steve
PS: This is the first patch I've ever sent, so I would really appreciate
comments from anyone who has a minute for some constructive criticism.
:)
---
/usr/src/monocvs/mcs/class/Cscompmgd/Microsoft.CSharp/Compiler.cs 2002-12-12 02:33:43.000000000 -0600
+++ Compiler.cs 2004-02-23 04:41:31.000000000 -0600
@@ -12,6 +12,7 @@
using System.Collections;
using System.Diagnostics;
using System.Text.RegularExpressions;
+using System.Reflection;
namespace Microsoft.CSharp {
@@ -21,7 +22,6 @@
{
}
- [MonoTODO("Have not implemented bugreports")]
public static CompilerError[] Compile(string[] sourceTexts,
string[] sourceTextNames, string target, string[] imports,
IDictionary options)
@@ -39,7 +39,8 @@
bugreport_path = (string)options["bugreport"];
if (bugreport_path != null) {
- bug_report = CreateBugReport (sourceTexts, sourceTextNames,
bugreport_path);
+ bug_report = CreateBugReport (sourceTexts, sourceTextNames,
bugreport_path,
+ temp_cs_files, target, imports, options);
}
try {
@@ -203,22 +204,42 @@
}
private static StreamWriter CreateBugReport (string[] source_texts,
- string[] source_names, string path)
+ string[] source_names, string path, string[] cs_files,
+ string target, string[] imports, IDictionary options)
{
StreamWriter bug_report = null;
try {
bug_report = new StreamWriter (path);
+
+ // locate mcs.exe and find version info
+ string mcs_location = Path.GetDirectoryName (typeof
(object).Assembly.Location);
+ mcs_location = mcs_location.Substring(0,
+ mcs_location.LastIndexOf(Path.DirectorySeparatorChar)+1);
+ mcs_location += "bin" + Path.DirectorySeparatorChar + "mcs.exe";
+ Assembly mcs_assembly = Assembly.LoadFrom(mcs_location);
+
bug_report.WriteLine ("### C# Compiler Defect Report," +
" created {0}", DateTime.Now);
- // Compiler Version
- // Runtime
- // Operating System
- // Username
+ bug_report.WriteLine ("### Compiler version: {0}.{1}.{2}.{3}",
+ mcs_assembly.GetName().Version.Major.ToString(),
+ mcs_assembly.GetName().Version.Minor.ToString(),
+ mcs_assembly.GetName().Version.Build.ToString(),
+ mcs_assembly.GetName().Version.Revision.ToString()
+ );
+ bug_report.WriteLine ("### Common Language Runtime Version: {0}",
+ System.Environment.Version);
+ bug_report.WriteLine ("### Operating System: {0}",
+ System.Environment.OSVersion);
+ bug_report.WriteLine ("### Compiler command line: {0} {1}",
+ Assembly.GetExecutingAssembly().Location.Substring (
+ Assembly.GetExecutingAssembly().Location.LastIndexOf (
+ Path.DirectorySeparatorChar)+1),
+ BuildArgs (cs_files, target, imports, options));
for (int i=0; i<source_texts.Length; i++) {
bug_report.WriteLine ("### Source file: '{0}'",
source_names[i]);
- bug_report.Write (source_texts[i]);
+ bug_report.WriteLine (source_texts[i]);
}
} catch {
if (bug_report != null)