diff options
author | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2014-02-18 02:21:11 +0400 |
---|---|---|
committer | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2014-02-18 21:04:23 +0400 |
commit | 4f025a381cdc16ee28dd843611ccadc19994fe70 (patch) | |
tree | 6825dddb4a948d11a8c31cbf0c198333683d8e2b /mcs/class/Microsoft.Build.Framework | |
parent | ec7288ea3cb1d1ad64ee552f3203f01a92d2bb83 (diff) |
[xbuild] Clean up some API to match .NET
Some .NET 4 API had leaked into .NET 2 builds.
Diffstat (limited to 'mcs/class/Microsoft.Build.Framework')
7 files changed, 163 insertions, 42 deletions
diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildErrorEventArgs.cs b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildErrorEventArgs.cs index 6de198a97e4..a6e27f24b05 100644 --- a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildErrorEventArgs.cs +++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildErrorEventArgs.cs @@ -26,13 +26,16 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#if NET_2_0 - using System; namespace Microsoft.Build.Framework { [Serializable] - public class BuildErrorEventArgs : BuildEventArgs { + public class BuildErrorEventArgs +#if NET_4_0 + : LazyFormattedBuildEventArgs { +#else + : BuildEventArgs { +#endif string code; int columnNumber; @@ -41,7 +44,10 @@ namespace Microsoft.Build.Framework { string file; int lineNumber; string subcategory; - +#if NET_4_0 + string projectFile; +#endif + protected BuildErrorEventArgs () { } @@ -64,6 +70,35 @@ namespace Microsoft.Build.Framework { this.endColumnNumber = endColumnNumber; } +#if NET_4_0 + public BuildErrorEventArgs (string subcategory, string code, + string file, int lineNumber, int columnNumber, + int endLineNumber, int endColumnNumber, string message, + string helpKeyword, string senderName, DateTime eventTimestamp) + : this (subcategory, code, file, lineNumber, columnNumber, + endLineNumber, endColumnNumber, message, helpKeyword, + senderName, eventTimestamp, new object[0]) + { + } + + public BuildErrorEventArgs (string subcategory, string code, + string file, int lineNumber, int columnNumber, int endLineNumber, + int endColumnNumber, string message, string helpKeyword, + string senderName, DateTime eventTimestamp, + params object[] messageArgs) + : base (message, helpKeyword, senderName, eventTimestamp, messageArgs) + { + this.subcategory = subcategory; + this.code = code; + this.file = file; + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + this.endLineNumber = endLineNumber; + this.endColumnNumber = endColumnNumber; + + } +#endif + public string Code { get { return code; @@ -105,7 +140,14 @@ namespace Microsoft.Build.Framework { return subcategory; } } + +#if NET_4_0 + public string ProjectFile { + get { return projectFile; } + set { projectFile = value; } + } +#endif + } } -#endif
\ No newline at end of file diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildEventArgs.cs b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildEventArgs.cs index fd2c709dd04..c23e7427cce 100644 --- a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildEventArgs.cs +++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildEventArgs.cs @@ -26,8 +26,6 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#if NET_2_0 - using System; using System.Threading; @@ -41,7 +39,9 @@ namespace Microsoft.Build.Framework string senderName; int threadId; DateTime timestamp; +#if NET_3_5 BuildEventContext context; +#endif protected BuildEventArgs () : this (null, null, null) @@ -54,15 +54,20 @@ namespace Microsoft.Build.Framework { } - protected BuildEventArgs (string message, string helpKeyword, - string senderName, DateTime eventTimestamp) +#if NET_4_0 + protected +#endif + BuildEventArgs (string message, string helpKeyword, + string senderName, DateTime eventTimestamp) { this.message = message; this.helpKeyword = helpKeyword; this.senderName = senderName; this.threadId = Thread.CurrentThread.GetHashCode (); this.timestamp = eventTimestamp; +#if NET_3_5 this.context = BuildEventContext.NewInstance (); +#endif } public string HelpKeyword { @@ -71,6 +76,9 @@ namespace Microsoft.Build.Framework } } +#if NET_4_0 + virtual +#endif public string Message { get { return message; @@ -96,6 +104,7 @@ namespace Microsoft.Build.Framework } } +#if NET_3_5 public BuildEventContext BuildEventContext { get { return context; } set { @@ -104,7 +113,7 @@ namespace Microsoft.Build.Framework context = value; } } +#endif } } -#endif diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildFinishedEventArgs.cs b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildFinishedEventArgs.cs index 6595f05f0d9..4655d80e0f7 100644 --- a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildFinishedEventArgs.cs +++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildFinishedEventArgs.cs @@ -26,8 +26,6 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#if NET_2_0 - using System; namespace Microsoft.Build.Framework { @@ -43,10 +41,12 @@ namespace Microsoft.Build.Framework { public BuildFinishedEventArgs (string message, string helpKeyword, bool succeeded) - : this (message, helpKeyword, succeeded, DateTime.Now) + : base (message, helpKeyword, null) { + this.succeeded = succeeded; } +#if NET_4_0 public BuildFinishedEventArgs (string message, string helpKeyword, bool succeeded, @@ -65,6 +65,7 @@ namespace Microsoft.Build.Framework { { this.succeeded = succeeded; } +#endif public bool Succeeded { get { @@ -74,4 +75,3 @@ namespace Microsoft.Build.Framework { } } -#endif diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildStartedEventArgs.cs b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildStartedEventArgs.cs index 54b0303b301..e6497b0f3d0 100644 --- a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildStartedEventArgs.cs +++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildStartedEventArgs.cs @@ -26,14 +26,16 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#if NET_2_0 - using System; using System.Collections.Generic; namespace Microsoft.Build.Framework { [Serializable] public class BuildStartedEventArgs : BuildStatusEventArgs { + +#if NET_4_0 + IDictionary<string, string> buildEnvironment; +#endif protected BuildStartedEventArgs () { @@ -41,17 +43,17 @@ namespace Microsoft.Build.Framework { public BuildStartedEventArgs (string message, string helpKeyword) - : this (message, helpKeyword, DateTime.Now) + : base (message, helpKeyword, null) { } +#if NET_4_0 public BuildStartedEventArgs (string message, string helpKeyword, IDictionary<string, string> environmentOfBuild) : base (message, helpKeyword, null) { - // deal with environmentOfBuild - throw new NotImplementedException (); + buildEnvironment = environmentOfBuild; } public BuildStartedEventArgs (string message, @@ -68,7 +70,11 @@ namespace Microsoft.Build.Framework { : base (message, helpKeyword, null, eventTimestamp, messageArgs) { } + + public IDictionary<string, string> BuildEnvironment { + get { return buildEnvironment; } + } +#endif } } -#endif diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildStatusEventArgs.cs b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildStatusEventArgs.cs index cad96026ff1..c0b5b3c0526 100644 --- a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildStatusEventArgs.cs +++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildStatusEventArgs.cs @@ -26,14 +26,17 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#if NET_2_0 - using System; namespace Microsoft.Build.Framework { [Serializable] - public abstract class BuildStatusEventArgs : LazyFormattedBuildEventArgs { + public abstract class BuildStatusEventArgs +#if NET_4_0 + : LazyFormattedBuildEventArgs { +#else + : BuildEventArgs { +#endif protected BuildStatusEventArgs () { @@ -46,6 +49,7 @@ namespace Microsoft.Build.Framework { } +#if NET_4_0 protected BuildStatusEventArgs (string message, string helpKeyword, string senderName, @@ -62,7 +66,7 @@ namespace Microsoft.Build.Framework : base (message, helpKeyword, senderName, eventTimestamp, messageArgs) { } +#endif } } -#endif diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildWarningEventArgs.cs b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildWarningEventArgs.cs index 0d7c8f40c8d..a928e6187b7 100644 --- a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildWarningEventArgs.cs +++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/BuildWarningEventArgs.cs @@ -26,13 +26,16 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#if NET_2_0 - using System; namespace Microsoft.Build.Framework { [Serializable] - public class BuildWarningEventArgs : BuildEventArgs { + public class BuildWarningEventArgs +#if NET_4_0 + : LazyFormattedBuildEventArgs { +#else + : BuildEventArgs { +#endif string subcategory; string code; @@ -41,7 +44,10 @@ namespace Microsoft.Build.Framework { int columnNumber; int endLineNumber; int endColumnNumber; - +#if NET_4_0 + string projectFile; +#endif + protected BuildWarningEventArgs () { } @@ -65,6 +71,35 @@ namespace Microsoft.Build.Framework { this.endColumnNumber = endColumnNumber; } +#if NET_4_0 + public BuildWarningEventArgs (string subcategory, string code, + string file, int lineNumber, int columnNumber, + int endLineNumber, int endColumnNumber, string message, + string helpKeyword, string senderName, DateTime eventTimestamp) + : this (subcategory, code, file, lineNumber, columnNumber, + endLineNumber, endColumnNumber, message, helpKeyword, + senderName, eventTimestamp, new object[0]) + { + } + + public BuildWarningEventArgs (string subcategory, string code, + string file, int lineNumber, int columnNumber, int endLineNumber, + int endColumnNumber, string message, string helpKeyword, + string senderName, DateTime eventTimestamp, + params object[] messageArgs) + : base (message, helpKeyword, senderName, eventTimestamp, messageArgs) + { + this.subcategory = subcategory; + this.code = code; + this.file = file; + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + this.endLineNumber = endLineNumber; + this.endColumnNumber = endColumnNumber; + + } +#endif + public string Code { get { return code; @@ -106,7 +141,12 @@ namespace Microsoft.Build.Framework { return subcategory; } } + +#if NET_4_0 + public string ProjectFile { + get { return projectFile; } + set { projectFile = value; } + } +#endif } } - -#endif
\ No newline at end of file diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/LazyFormattedBuildEventArgs.cs b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/LazyFormattedBuildEventArgs.cs index 398578430f0..ad629ec180a 100644 --- a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/LazyFormattedBuildEventArgs.cs +++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/LazyFormattedBuildEventArgs.cs @@ -25,31 +25,51 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#if NET_4_0 + using System; -using System.Threading; namespace Microsoft.Build.Framework { [Serializable] - public abstract class LazyFormattedBuildEventArgs : BuildEventArgs - { - + public abstract class LazyFormattedBuildEventArgs : BuildEventArgs { + + string message, format; + object[] args; + protected LazyFormattedBuildEventArgs () - : this (null, null, null) { } - protected LazyFormattedBuildEventArgs (string message, string helpKeyword, - string senderName) - : this (message, helpKeyword, senderName, DateTime.Now) + public LazyFormattedBuildEventArgs (string message, + string helpKeyword, string senderName) + : base (message, helpKeyword, senderName) + { + this.message = message; } - protected LazyFormattedBuildEventArgs (string message, string helpKeyword, - string senderName, DateTime eventTimestamp, - params object [] messageArgs) - : base (string.Format (message, messageArgs), helpKeyword, senderName, eventTimestamp) + public LazyFormattedBuildEventArgs (string message, + string helpKeyword, string senderName, + DateTime eventTimestamp, params object[] messageArgs) + : base (message, helpKeyword, senderName, eventTimestamp) { + if (messageArgs != null && messageArgs.Length > 0) { + args = messageArgs; + format = message; + } else { + this.message = message; + } + } + + public override string Message { + get { + if (message == null && format != null) + message = string.Format (format, args); + return message; + } } } } + +#endif |