~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/addins/VBNetBinding/VBBindingCompilerServices.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//  VBBindingCompilerServices.cs
2
2
//
3
 
//  This file was derived from a file from #Develop. 
 
3
//  This file was derived from a file from #Develop.
 
4
//
 
5
//  Authors:
 
6
//    Markus Palme <MarkusPalme@gmx.de>
 
7
//    Rolf Bjarne Kvinge <RKvinge@novell.com>
4
8
//
5
9
//  Copyright (C) 2001-2007 Markus Palme <MarkusPalme@gmx.de>
 
10
//  Copyright (C) 2008 Novell, Inc (http://www.novell.com)
6
11
// 
7
12
//  This program is free software; you can redistribute it and/or modify
8
13
//  it under the terms of the GNU General Public License as published by
17
22
//  You should have received a copy of the GNU General Public License
18
23
//  along with this program; if not, write to the Free Software
19
24
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
 
 
21
 
using System;
 
25
 
 
26
using System;
22
27
using System.Text;
23
 
using System.Text.RegularExpressions;
24
 
using System.Collections;
25
 
using System.IO;
26
 
using System.Diagnostics;
 
28
using System.Text.RegularExpressions;
 
29
using System.Collections;
 
30
using System.IO;
 
31
using System.Diagnostics;
27
32
using System.CodeDom.Compiler;
28
33
using System.Threading;
29
 
 
30
 
using MonoDevelop.Core;
 
34
 
 
35
using MonoDevelop.Core;
31
36
using MonoDevelop.Core.Execution;
32
37
using MonoDevelop.Core.Gui;
33
 
using MonoDevelop.Core.Gui.Components;
 
38
using MonoDevelop.Core.Gui.Components;
 
39
using MonoDevelop.Core.Serialization;
34
40
using MonoDevelop.Projects;
35
 
 
36
 
namespace VBBinding {
37
 
        
38
 
        /// <summary>
39
 
        /// This class controls the compilation of VB.net files and VB.net projects
40
 
        /// </summary>
41
 
        public class VBBindingCompilerServices
 
41
using MonoDevelop.Projects.Text;
 
42
 
 
43
using MonoDevelop.VBNetBinding.Extensions;
 
44
 
 
45
namespace MonoDevelop.VBNetBinding {
 
46
        
 
47
        /// <summary>
 
48
        /// This class controls the compilation of VB.net files and VB.net projects
 
49
        /// </summary>
 
50
        public class VBBindingCompilerServices
42
51
        {
43
52
                //matches "/home/path/Default.aspx.vb (40,31) : Error VBNC30205: Expected end of statement."
44
53
                //and "Error : VBNC99999: vbnc crashed nearby this location in the source code."
45
54
                //and "Error : VBNC99999: Unexpected error: Object reference not set to an instance of an object" 
46
 
                static Regex regexError = new Regex (@"^\s*((?<file>.*)\((?<line>\d*),(?<column>\d*)\) : )?(?<level>\w+) :? ?(?<number>[^:]*): (?<message>.*)$",
 
55
                static Regex regexError = new Regex (@"^\s*((?<file>.*) \((?<line>\d*),(?<column>\d*)\) : )?(?<level>\w+) :? ?(?<number>[^:]*): (?<message>.*)$",
47
56
                                                     RegexOptions.Compiled | RegexOptions.ExplicitCapture);
48
57
                
49
 
                public bool CanCompile(string fileName)
50
 
                {
51
 
                        return Path.GetExtension(fileName) == ".vb";
52
 
                }
53
 
                
54
 
                string GetCompilerName(string compilerVersion)
55
 
                {
56
 
                        //string runtimeDirectory = Path.Combine(fileUtilityService.NETFrameworkInstallRoot, compilerVersion);
57
 
                        //if (compilerVersion.Length == 0 || compilerVersion == "Standard" || !Directory.Exists(runtimeDirectory)) {
58
 
                        //      runtimeDirectory = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory();
59
 
                        //}
60
 
                        //return String.Concat('"', Path.Combine(runtimeDirectory, "vbc.exe"), '"');
61
 
                        return "vbnc";
62
 
                }
63
 
                
64
 
                string GenerateOptions (DotNetProjectConfiguration configuration, VBCompilerParameters compilerparameters, string outputFileName)
65
 
                {
66
 
                        StringBuilder sb = new StringBuilder();
67
 
                        bool hasWin32Resource = false;
68
 
                        
69
 
                        sb.Append("-out:");sb.Append("\"" + outputFileName + "\"");/*sb.Append('"');*/sb.Append(Environment.NewLine);
70
 
                        
71
 
                        sb.Append("-nologo");sb.Append(Environment.NewLine);
72
 
                        sb.Append("-utf8output");sb.Append(Environment.NewLine);
73
 
                        
74
 
//                      if (compilerparameters.DebugMode) {
75
 
//                              sb.Append("--debug+");sb.Append(Environment.NewLine);
76
 
//                              sb.Append("--debug:full");sb.Append(Environment.NewLine);
77
 
//                      }
78
 
                        
79
 
                        //if (compilerparameters.Optimize) {
80
 
                        //      sb.Append("-optimize");sb.Append(Environment.NewLine);
81
 
                        //}
82
 
                        
83
 
                        //if (compilerparameters.OptionStrict) {
84
 
                        //      sb.Append("-optionstrict");sb.Append(Environment.NewLine);
85
 
                        //}
86
 
                        
87
 
                        //if (compilerparameters.OptionExplicit) {
88
 
                        //      sb.Append("-optionexplicit");sb.Append(Environment.NewLine);
89
 
                        //}// else {
90
 
                        //      sb.Append("--optionexplicit-");sb.Append(Environment.NewLine);
91
 
                        //}
92
 
                        
93
 
                        if (compilerparameters.Win32Resource != null && compilerparameters.Win32Resource.Length > 0 && File.Exists(compilerparameters.Win32Resource)) {
94
 
                                sb.Append("-win32resource:");sb.Append('"');sb.Append(compilerparameters.Win32Resource);sb.Append('"');sb.Append(Environment.NewLine);
95
 
                                hasWin32Resource = true;
96
 
                        }
97
 
                        if (compilerparameters.Win32Icon != null && compilerparameters.Win32Icon.Length > 0 && File.Exists(compilerparameters.Win32Icon)) {
98
 
                                if (hasWin32Resource)
99
 
                                        Console.WriteLine ("Warning: Both Win32 icon and Win32 resource cannot be specified. Ignoring the icon.");
100
 
                                else
101
 
                                        sb.Append("-win32icon:");sb.Append('"');sb.Append(compilerparameters.Win32Icon);sb.Append('"');sb.Append(Environment.NewLine);
102
 
                        }
103
 
                        
104
 
                        if (compilerparameters.RootNamespace!= null && compilerparameters.RootNamespace.Length > 0) {
105
 
                                sb.Append("-rootnamespace:");sb.Append('"');sb.Append(compilerparameters.RootNamespace);sb.Append('"');sb.Append(Environment.NewLine);
106
 
                        }
107
 
                        
108
 
                        if (compilerparameters.DefineSymbols.Length > 0) {
109
 
                                sb.Append("-define:");sb.Append('"');sb.Append(compilerparameters.DefineSymbols);sb.Append('"');sb.Append(Environment.NewLine);
110
 
                        }
 
58
                string GenerateOptions (DotNetProjectConfiguration configuration, VBCompilerParameters compilerparameters, string outputFileName)
 
59
                {
 
60
                        DotNetProject project = (DotNetProject) configuration.ParentItem;
 
61
                        StringBuilder sb = new StringBuilder ();
 
62
                        
 
63
                        sb.AppendFormat ("\"-out:{0}\"", outputFileName);
 
64
                        sb.AppendLine ();
 
65
                        
 
66
                        sb.AppendLine ("-nologo");
 
67
                        sb.AppendLine ("-utf8output");
 
68
 
 
69
                        sb.AppendFormat ("-debug:{0}", compilerparameters.DebugType);
 
70
                        sb.AppendLine ();
 
71
 
 
72
                        if (compilerparameters.Optimize)
 
73
                                sb.AppendLine ("-optimize+");
 
74
 
 
75
                        
 
76
                        switch (project.GetOptionStrict ()) {
 
77
                        case "On":
 
78
                                sb.AppendLine ("-optionstrict+");
 
79
                                break;
 
80
                        case "Off":
 
81
                                sb.AppendLine ("-optionstrict-");
 
82
                                break;                          
 
83
                        }
 
84
                        
 
85
                        switch (project.GetOptionExplicit ()) {
 
86
                        case "On":
 
87
                                sb.AppendLine ("-optionexplicit+");
 
88
                                break;
 
89
                        case "Off":
 
90
                                sb.AppendLine ("-optionexplicit-");
 
91
                                break;
 
92
                        }
 
93
 
 
94
                        switch (project.GetOptionCompare ()) {
 
95
                        case "Binary":
 
96
                                sb.AppendLine ("-optioncompare:binary");
 
97
                                break;
 
98
                        case "Text":
 
99
                                sb.AppendLine ("-optioncompare:text");
 
100
                                break;
 
101
                        }
 
102
 
 
103
                        switch (project.GetOptionInfer ()) {
 
104
                        case "On":
 
105
                                sb.AppendLine ("-optioninfer+");
 
106
                                break;
 
107
                        case "Off":
 
108
                                sb.AppendLine ("-optioninfer-");
 
109
                                break;
 
110
                        }
 
111
 
 
112
                        string mytype = project.GetMyType ();
 
113
                        if (!string.IsNullOrEmpty (mytype)) {
 
114
                                sb.AppendFormat ("-define:_MYTYPE=\\\"{0}\\\"", mytype);
 
115
                                sb.AppendLine ();
 
116
                        }
 
117
                        
 
118
                        string win32IconPath = project.GetApplicationIconPath ();
 
119
                        if (!string.IsNullOrEmpty (win32IconPath) && File.Exists (win32IconPath)) {
 
120
                                sb.AppendFormat ("\"-win32icon:{0}\"", win32IconPath);
 
121
                                sb.AppendLine ();
 
122
                        }
 
123
 
 
124
                        if (!string.IsNullOrEmpty (project.GetCodePage ())) {
 
125
                                TextEncoding enc = TextEncoding.GetEncoding (project.GetCodePage ());
 
126
                                sb.AppendFormat ("-codepage:{0}", enc.CodePage);
 
127
                                sb.AppendLine ();
 
128
                        }
 
129
                        
 
130
                        if (!string.IsNullOrEmpty (project.GetRootNamespace ())) {
 
131
                                sb.AppendFormat ("-rootnamespace:{0}", project.GetRootNamespace ());
 
132
                                sb.AppendLine ();
 
133
                        }
 
134
                        
 
135
                        if (!string.IsNullOrEmpty (compilerparameters.DefineConstants)) {
 
136
                                sb.AppendFormat ("\"-define:{0}\"", compilerparameters.DefineConstants);
 
137
                                sb.AppendLine ();
 
138
                        }
 
139
 
 
140
                        if (compilerparameters.DefineDebug)
 
141
                                sb.AppendLine ("-define:DEBUG=-1");
 
142
 
 
143
                        if (compilerparameters.DefineTrace)
 
144
                                sb.AppendLine ("-define:TRACE=-1");
 
145
 
 
146
                        if (compilerparameters.WarningsDisabled) {
 
147
                                sb.AppendLine ("-nowarn");
 
148
                        } else if (!string.IsNullOrEmpty (compilerparameters.NoWarn)) {
 
149
                                sb.AppendFormat ("-nowarn:{0}", compilerparameters.NoWarn);
 
150
                                sb.AppendLine ();
 
151
                        }
 
152
 
 
153
                        if (!string.IsNullOrEmpty (compilerparameters.WarningsAsErrors)) {
 
154
                                sb.AppendFormat ("-warnaserror+:{0}", compilerparameters.WarningsAsErrors);
 
155
                                sb.AppendLine ();
 
156
                        }
 
157
                        
111
158
                        if (configuration.SignAssembly) {
112
159
                                if (File.Exists (configuration.AssemblyKeyFile)) {
113
 
                                        sb.Append("-keyfile:");sb.Append('"');sb.Append(configuration.AssemblyKeyFile);sb.Append('"');sb.Append(Environment.NewLine);
114
 
                                }
115
 
                        }
116
 
                        
117
 
                        if (compilerparameters.MainClass != null && compilerparameters.MainClass.Length > 0) {
118
 
                                sb.Append("-main:");sb.Append(compilerparameters.MainClass);sb.Append(Environment.NewLine);
119
 
                        }
120
 
                        
121
 
                        if(compilerparameters.Imports.Length > 0) {
122
 
                                sb.Append("-imports:");sb.Append(compilerparameters.Imports);sb.Append(Environment.NewLine);
123
 
                        }
124
 
                        
125
 
                        switch (configuration.CompileTarget) {
126
 
                                case CompileTarget.Exe:
127
 
                                        sb.Append("-target:exe");
128
 
                                        break;
129
 
                                case CompileTarget.WinExe:
130
 
                                        sb.Append("-target:winexe");
131
 
                                        break;
132
 
                                case CompileTarget.Library:
133
 
                                        sb.Append("-target:library");
134
 
                                        break;
135
 
                                case CompileTarget.Module:
136
 
                                        sb.Append("-target:module");
137
 
                                        break;
138
 
                                default:
139
 
                                        throw new NotSupportedException("unknown compile target:" + configuration.CompileTarget);
140
 
                        }
141
 
                        sb.Append(Environment.NewLine);
142
 
                        return sb.ToString();
143
 
                }
144
 
                
145
 
                public ICompilerResult Compile (ProjectFileCollection projectFiles, ProjectReferenceCollection references, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
 
160
                                        sb.AppendFormat ("\"-keyfile:{0}\"", configuration.AssemblyKeyFile);
 
161
                                        sb.AppendLine ();
 
162
                                }
 
163
                        }
 
164
 
 
165
                        if (!string.IsNullOrEmpty (compilerparameters.DocumentationFile)) {
 
166
                                sb.AppendFormat ("-doc:{0}", compilerparameters.DocumentationFile);
 
167
                                sb.AppendLine ();
 
168
                        }
 
169
 
 
170
                        string mainClass = project.GetMainClass ();
 
171
                        if (!string.IsNullOrEmpty (mainClass) && mainClass != "Sub Main") {
 
172
                                sb.Append ("-main:");
 
173
                                sb.Append (project.GetMainClass ());
 
174
                                sb.AppendLine ();
 
175
                        }
 
176
 
 
177
                        if (compilerparameters.RemoveIntegerChecks)
 
178
                                sb.AppendLine ("-removeintchecks+");
 
179
                        
 
180
                        if (!string.IsNullOrEmpty (compilerparameters.AdditionalParameters)) {
 
181
                                sb.Append (compilerparameters.AdditionalParameters);
 
182
                                sb.AppendLine ();
 
183
                        }
 
184
                                                
 
185
                        switch (configuration.CompileTarget) {
 
186
                                case CompileTarget.Exe:
 
187
                                        sb.AppendLine ("-target:exe");
 
188
                                        break;
 
189
                                case CompileTarget.WinExe:
 
190
                                        sb.AppendLine ("-target:winexe");
 
191
                                        break;
 
192
                                case CompileTarget.Library:
 
193
                                        sb.AppendLine ("-target:library");
 
194
                                        break;
 
195
                                case CompileTarget.Module:
 
196
                                        sb.AppendLine ("-target:module");
 
197
                                        break;
 
198
                                default:
 
199
                                        throw new NotSupportedException("unknown compile target:" + configuration.CompileTarget);
 
200
                        }
 
201
                        
 
202
                        return sb.ToString();
 
203
                }
 
204
                
 
205
                public BuildResult Compile (ProjectFileCollection projectFiles, ProjectReferenceCollection references, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
146
206
                {
147
207
                        VBCompilerParameters compilerparameters = (VBCompilerParameters) configuration.CompilationParameters;
148
 
                        if (compilerparameters == null) compilerparameters = new VBCompilerParameters ();
149
 
                        
 
208
                        if (compilerparameters == null)
 
209
                                compilerparameters = new VBCompilerParameters ();
 
210
                        
150
211
                        string exe = configuration.CompiledOutputName;
151
 
                        string responseFileName = Path.GetTempFileName();
152
 
                        StreamWriter writer = new StreamWriter(responseFileName);
153
 
                        
154
 
                        writer.WriteLine(GenerateOptions (configuration, compilerparameters, exe));
155
 
                        
156
 
                        foreach (ProjectReference lib in references) {
157
 
                                foreach (string fileName in lib.GetReferencedFileNames())
158
 
                                        writer.WriteLine(String.Concat("-r:", fileName));
159
 
                        }
160
 
                        
161
 
                        // write source files and embedded resources
162
 
                        foreach (ProjectFile finfo in projectFiles) {
163
 
                                if (finfo.Subtype != Subtype.Directory) {
164
 
                                        switch (finfo.BuildAction) {
165
 
                                                case BuildAction.Compile:
166
 
                                                        writer.WriteLine("\"" + finfo.Name + "\"");
167
 
                                                break;
168
 
                                                
169
 
                                                case BuildAction.EmbedAsResource:
 
212
                        string responseFileName = Path.GetTempFileName();
 
213
                        StreamWriter writer = new StreamWriter (responseFileName);
 
214
                        
 
215
                        writer.WriteLine (GenerateOptions (configuration, compilerparameters, exe));
 
216
 
 
217
                        // Write references
 
218
                        foreach (ProjectReference lib in references) {
 
219
                                foreach (string fileName in lib.GetReferencedFileNames(configuration.Id)) {
 
220
                                        writer.Write ("\"-r:");
 
221
                                        writer.Write (fileName);
 
222
                                        writer.WriteLine ("\"");
 
223
                                }
 
224
                        }
 
225
                        
 
226
                        // Write source files and embedded resources
 
227
                        foreach (ProjectFile finfo in projectFiles) {
 
228
                                if (finfo.Subtype != Subtype.Directory) {
 
229
                                        switch (finfo.BuildAction) {
 
230
                                                case "Compile":
 
231
                                                        writer.WriteLine("\"" + finfo.Name + "\"");
 
232
                                                break;
 
233
                                                
 
234
                                                case "EmbeddedResource":
170
235
                                                        string fname = finfo.Name;
171
236
                                                        if (String.Compare (Path.GetExtension (fname), ".resx", true) == 0)
172
237
                                                                fname = Path.ChangeExtension (fname, ".resources");
173
238
 
174
 
                                                        writer.WriteLine(@"""-resource:{0},{1}""", fname, finfo.ResourceId);
175
 
                                                        break;
 
239
                                                        writer.WriteLine("\"-resource:{0},{1}\"", fname, finfo.ResourceId);
 
240
                                                        break;
 
241
 
 
242
                                                case "Import":
 
243
                                                        writer.WriteLine ("-imports:{0}", Path.GetFileName (finfo.Name));
 
244
                                                        break;
 
245
                                                
176
246
                                                default:
177
247
                                                        continue;
178
 
                                        }
179
 
                                }
180
 
                        }
181
 
                        
182
 
                        TempFileCollection tf = new TempFileCollection ();
183
 
                        writer.Close();
184
 
                        
185
 
                        string output = "";
186
 
                        string compilerName = GetCompilerName(compilerparameters.VBCompilerVersion);
187
 
                        string outstr = String.Concat(compilerName, " @", responseFileName);
188
 
                        
189
 
                        
 
248
                                        }
 
249
                                }
 
250
                        }
 
251
                        
 
252
                        TempFileCollection tf = new TempFileCollection ();
 
253
                        writer.Close();
 
254
                        
 
255
                        string output = "";
 
256
                        string compilerName = "vbnc";
 
257
                        string outstr = String.Concat (compilerName, " @", responseFileName);
 
258
                        
 
259
                        
190
260
                        string workingDir = ".";
191
261
                        if (projectFiles != null && projectFiles.Count > 0)
192
262
                                workingDir = projectFiles [0].Project.BaseDirectory;
195
265
                        monitor.Log.WriteLine (compilerName + " " + string.Join (" ", File.ReadAllLines (responseFileName)));
196
266
                        exitCode = DoCompilation (outstr, tf, workingDir, ref output);
197
267
                        
198
 
                        CompilerResults results = new CompilerResults (tf);
199
 
                        DefaultCompilerResult result = new DefaultCompilerResult (results, output);
200
 
                                
201
268
                        monitor.Log.WriteLine (output);                                                                           
202
 
                                                                                  
203
 
                        ParseOutput(tf, output, results);
204
 
 
205
 
                        if (results.Errors.Count == 0 && exitCode != 0) {
 
269
                        BuildResult result = ParseOutput (tf, output);
 
270
                        if (result.Errors.Count == 0 && exitCode != 0) {
206
271
                                // Compilation failed, but no errors?
207
272
                                // Show everything the compiler said.
208
273
                                result.AddError (output);
209
274
                        }
210
 
                        
211
 
                        FileService.DeleteFile (responseFileName);
212
 
                        if (configuration.CompileTarget != CompileTarget.Library) {
213
 
                                WriteManifestFile(exe);
214
 
                        }
215
 
                        return result;
216
 
                }
217
 
                
218
 
                // code duplication: see C# backend : CSharpBindingCompilerManager
219
 
                void WriteManifestFile(string fileName)
220
 
                {
221
 
                        string manifestFile = String.Concat(fileName, ".manifest");
222
 
                        if (File.Exists(manifestFile)) {
223
 
                                return;
224
 
                        }
225
 
                        StreamWriter sw = new StreamWriter(manifestFile);
226
 
                        sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
227
 
                        sw.WriteLine("");
228
 
                        sw.WriteLine("<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">");
229
 
                        sw.WriteLine("  <dependency>");
230
 
                        sw.WriteLine("          <dependentAssembly>");
231
 
                        sw.WriteLine("                  <assemblyIdentity");
232
 
                        sw.WriteLine("                          type=\"win32\"");
233
 
                        sw.WriteLine("                          name=\"Microsoft.Windows.Common-Controls\"");
234
 
                        sw.WriteLine("                          version=\"6.0.0.0\"");
235
 
                        sw.WriteLine("                          processorArchitecture=\"X86\"");
236
 
                        sw.WriteLine("                          publicKeyToken=\"6595b64144ccf1df\"");
237
 
                        sw.WriteLine("                          language=\"*\"");
238
 
                        sw.WriteLine("                  />");
239
 
                        sw.WriteLine("          </dependentAssembly>");
240
 
                        sw.WriteLine("  </dependency>");
241
 
                        sw.WriteLine("</assembly>");
242
 
                        sw.Close();
243
 
                }
244
 
                
245
 
                void ParseOutput(TempFileCollection tf, string output, CompilerResults cr)
246
 
                {
 
275
                        
 
276
                        FileService.DeleteFile (responseFileName);
 
277
                        if (configuration.CompileTarget != CompileTarget.Library) {
 
278
                                WriteManifestFile (exe);
 
279
                        }
 
280
                        return result;
 
281
                }
 
282
                
 
283
                // code duplication: see C# backend : CSharpBindingCompilerManager
 
284
                void WriteManifestFile(string fileName)
 
285
                {
 
286
                        string manifestFile = String.Concat(fileName, ".manifest");
 
287
                        if (File.Exists(manifestFile)) {
 
288
                                return;
 
289
                        }
 
290
                        StreamWriter sw = new StreamWriter(manifestFile);
 
291
                        sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
 
292
                        sw.WriteLine("");
 
293
                        sw.WriteLine("<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">");
 
294
                        sw.WriteLine("  <dependency>");
 
295
                        sw.WriteLine("          <dependentAssembly>");
 
296
                        sw.WriteLine("                  <assemblyIdentity");
 
297
                        sw.WriteLine("                          type=\"win32\"");
 
298
                        sw.WriteLine("                          name=\"Microsoft.Windows.Common-Controls\"");
 
299
                        sw.WriteLine("                          version=\"6.0.0.0\"");
 
300
                        sw.WriteLine("                          processorArchitecture=\"X86\"");
 
301
                        sw.WriteLine("                          publicKeyToken=\"6595b64144ccf1df\"");
 
302
                        sw.WriteLine("                          language=\"*\"");
 
303
                        sw.WriteLine("                  />");
 
304
                        sw.WriteLine("          </dependentAssembly>");
 
305
                        sw.WriteLine("  </dependency>");
 
306
                        sw.WriteLine("</assembly>");
 
307
                        sw.Close();
 
308
                }
 
309
                
 
310
                BuildResult ParseOutput(TempFileCollection tf, string output)
 
311
                {
 
312
                        CompilerResults results = new CompilerResults (tf);
 
313
 
247
314
                        using (StringReader sr = new StringReader (output)) {                   
248
315
                                while (true) {
249
316
                                        string curLine = sr.ReadLine();
260
327
                                        CompilerError error = CreateErrorFromString (curLine);
261
328
                                        
262
329
                                        if (error != null)
263
 
                                                cr.Errors.Add (error);
 
330
                                                results.Errors.Add (error);
264
331
                                }
265
332
                        }
 
333
                        return new BuildResult (results, output);
266
334
                }
267
335
                
268
336
                
269
 
                private static CompilerError CreateErrorFromString(string error_string)
 
337
                private static CompilerError CreateErrorFromString (string error_string)
270
338
                {
271
 
                        // When IncludeDebugInformation is true, prevents the debug symbols stats from braeking this.
272
 
                        if (error_string.StartsWith ("WROTE SYMFILE") ||
273
 
                            error_string.StartsWith ("OffsetTable") ||
274
 
                            error_string.StartsWith ("Compilation succeeded") ||
275
 
                            error_string.StartsWith ("Compilation failed") || 
276
 
                            error_string.StartsWith("MonoBASIC") || 
277
 
                            error_string.StartsWith("Type:"))
278
 
                                return null;
279
 
 
280
 
                        CompilerError error = new CompilerError();
281
 
 
282
 
                        Match match=regexError.Match(error_string);
283
 
                        if (!match.Success) {
284
 
                                return null;
 
339
                        Match match;
 
340
                        int i;
 
341
                        
 
342
                        match = regexError.Match (error_string);
 
343
                            
 
344
                        if (match.Success) {
 
345
                                CompilerError error = new CompilerError ();
 
346
 
 
347
                                error.IsWarning = match.Result ("${level}").ToLowerInvariant () == "warning";
 
348
                                error.ErrorNumber = match.Result("${number}");
 
349
                                error.ErrorText = match.Result("${message}");
 
350
                                error.FileName = match.Result ("${file}");
 
351
                                if (int.TryParse (match.Result ("${line}"), out i))
 
352
                                        error.Line = i;
 
353
                                if (int.TryParse (match.Result ("${column}"), out i))
 
354
                                        error.Column = i;
 
355
                                                                
 
356
                                return error;
285
357
                        }
286
 
                        if (String.Empty != match.Result("${file}"))
287
 
                                error.FileName=match.Result("${file}");
288
 
                        if (String.Empty != match.Result("${line}"))
289
 
                                error.Line=Int32.Parse(match.Result("${line}"));
290
 
                        if (String.Empty != match.Result("${column}"))
291
 
                                error.Column=Int32.Parse(match.Result("${column}"));
292
 
                        if (match.Result("${level}")=="warning")
293
 
                                error.IsWarning=true;
294
 
                        error.ErrorNumber=match.Result("${number}");
295
 
                        error.ErrorText=match.Result("${message}");
296
 
                        return error;
 
358
 
 
359
                        return null;
297
360
                }
298
361
                
299
362
                private int DoCompilation (string outstr, TempFileCollection tf, string working_dir, ref string output)
312
375
                                        outwr.Dispose ();
313
376
                        }
314
377
                }
315
 
        }
 
378
        }
316
379
}