Author: gert
Date: 2007-09-22 13:54:03 -0400 (Sat, 22 Sep 2007)
New Revision: 86220
Modified:
trunk/mcs/class/System/System.Diagnostics/BooleanSwitch.cs
trunk/mcs/class/System/System.Diagnostics/SourceSwitch.cs
trunk/mcs/class/System/System.Diagnostics/Switch.cs
trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog
trunk/mcs/class/System/Test/System.Diagnostics/DiagnosticsConfigurationHandlerTest.cs
Log:
* DiagnosticsConfigurationHandlerTest.cs: No longer derive from
deprecated Assertion class. Code formatting. On 2.0 profile, allow
non-integral values for switches.
* BooleanSwitch.cs: Use base ctor for default value.
* Switch.cs: On 2.0 profile, store default value and use it if no
value is set in config file.
* SourceSwitch.cs: Use null to signal that there's no default value.
Modified: trunk/mcs/class/System/System.Diagnostics/BooleanSwitch.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/BooleanSwitch.cs 2007-09-22
16:50:34 UTC (rev 86219)
+++ trunk/mcs/class/System/System.Diagnostics/BooleanSwitch.cs 2007-09-22
17:54:03 UTC (rev 86220)
@@ -54,9 +54,8 @@
/// Initializes a new instance
/// </summary>
public BooleanSwitch(string displayName, string description,
string defaultSwitchValue)
- : base(displayName, description)
+ : base(displayName, description, defaultSwitchValue)
{
- Value = defaultSwitchValue;
}
#endif
Modified: trunk/mcs/class/System/System.Diagnostics/SourceSwitch.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/SourceSwitch.cs 2007-09-22
16:50:34 UTC (rev 86219)
+++ trunk/mcs/class/System/System.Diagnostics/SourceSwitch.cs 2007-09-22
17:54:03 UTC (rev 86220)
@@ -40,7 +40,7 @@
const string description = "Source switch.";
public SourceSwitch (string displayName)
- : this (displayName, String.Empty)
+ : this (displayName, null)
{
}
Modified: trunk/mcs/class/System/System.Diagnostics/Switch.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/Switch.cs 2007-09-22 16:50:34 UTC
(rev 86219)
+++ trunk/mcs/class/System/System.Diagnostics/Switch.cs 2007-09-22 17:54:03 UTC
(rev 86220)
@@ -45,7 +45,10 @@
private string name;
private string description;
private int switchSetting;
-
+ private string value;
+#if NET_2_0
+ private string defaultSwitchValue;
+#endif
// MS Behavior is that (quoting from MSDN for
OnSwitchSettingChanged()):
// "...It is invoked the first time a switch reads
its value from the
// configuration file..."
@@ -59,7 +62,7 @@
// Thus, we need to keep track of whether or not switchSetting
has been
// initialized. Using `switchSetting=-1' seems logical, but if
someone
// actually wants to use -1 as a switch value that would cause
problems.
- private bool initialized = false;
+ private bool initialized;
protected Switch(string displayName, string description)
{
@@ -67,13 +70,11 @@
this.description = description;
}
- private string value;
-
#if NET_2_0
protected Switch(string displayName, string description, string
defaultSwitchValue)
: this (displayName, description)
{
- this.value = defaultSwitchValue;
+ this.defaultSwitchValue = defaultSwitchValue;
}
#endif
@@ -156,8 +157,16 @@
#else
switchSetting = (int) d [name];
#endif
+ return;
}
}
+
+#if NET_2_0
+ if (defaultSwitchValue != null) {
+ value = defaultSwitchValue;
+ OnValueChanged ();
+ }
+#endif
}
protected virtual void OnSwitchSettingChanged()
@@ -167,4 +176,3 @@
}
}
}
-
Modified: trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog 2007-09-22
16:50:34 UTC (rev 86219)
+++ trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog 2007-09-22
17:54:03 UTC (rev 86220)
@@ -1,3 +1,9 @@
+2007-09-22 Gert Driesen <[EMAIL PROTECTED]>
+
+ * DiagnosticsConfigurationHandlerTest.cs: No longer derive from
+ deprecated Assertion class. Code formatting. On 2.0 profile, allow
+ non-integral values for switches.
+
2007-08-14 Gert Driesen <[EMAIL PROTECTED]>
* EventLogTest.cs: Added tests for validity of machine name. Added
Modified:
trunk/mcs/class/System/Test/System.Diagnostics/DiagnosticsConfigurationHandlerTest.cs
===================================================================
---
trunk/mcs/class/System/Test/System.Diagnostics/DiagnosticsConfigurationHandlerTest.cs
2007-09-22 16:50:34 UTC (rev 86219)
+++
trunk/mcs/class/System/Test/System.Diagnostics/DiagnosticsConfigurationHandlerTest.cs
2007-09-22 17:54:03 UTC (rev 86220)
@@ -16,11 +16,11 @@
using System.Diagnostics;
using System.Xml;
-namespace MonoTests.System.Diagnostics {
-
+namespace MonoTests.System.Diagnostics
+{
[TestFixture]
- public class DiagnosticsConfigurationHandlerTest : Assertion {
-
+ public class DiagnosticsConfigurationHandlerTest
+ {
private const string XmlFormat =
"{0}";
/*
@@ -28,38 +28,34 @@
"{0}" +
"</system.diagnostics>";
*/
-
+
private DiagnosticsConfigurationHandler handler = new
DiagnosticsConfigurationHandler ();
- [Test, Category ("NotDotNet")]
+ [Test]
+ [Category ("NotDotNet")]
public void SwitchesTag_Attributes ()
{
string[] attrs = {"invalid=\"yes\""};
ValidateExceptions ("#TST:A", "<switches
{0}></switches>", attrs);
}
- private void ValidateExceptions (string name, string format,
string[] args)
+ void ValidateExceptions (string name, string format, string[]
args)
{
foreach (string arg in args) {
string xml = string.Format (XmlFormat,
string.Format (format, arg));
try {
CreateHandler (xml);
- Fail (string.Format ("{0}:{1}: no
exception generated", name, arg));
- }
- catch (ConfigurationException) {
- }
- catch (AssertionException) {
+ Assert.Fail (string.Format ("{0}:{1}:
no exception generated", name, arg));
+ } catch (ConfigurationException) {
+ } catch (AssertionException) {
// This is generated by the
Assertion.Fail() statement in the try block.
throw;
+ } catch (Exception e) {
+ Assert.Fail (string.Format ("{0}:{1}:
wrong exception generated: {2} ({3}).",
+ name, arg, e.ToString(),
+ e.InnerException == null ? "" :
e.InnerException.ToString()));
}
- catch (Exception e) {
- Fail (string.Format ("{0}:{1}: wrong
exception generated: {2} ({3}).",
- // name, arg,
e.Message,
- name, arg,
e.ToString(),
- //
e.InnerException == null ? "" : e.InnerException.Message));
-
e.InnerException == null ? "" : e.InnerException.ToString()));
- }
}
}
@@ -70,14 +66,11 @@
string.Format (format, arg));
try {
CreateHandler (xml);
+ } catch (Exception e) {
+ Assert.Fail (string.Format ("{0}:{1}:
exception generated: {2} ({3}).",
+ name, arg, e.ToString(),
+ e.InnerException == null ? "" :
e.InnerException.ToString()));
}
- catch (Exception e) {
- Fail (string.Format ("{0}:{1}:
exception generated: {2} ({3}).",
- // name, arg,
e.Message,
- name, arg,
e.ToString(),
- //
e.InnerException == null ? "" : e.InnerException.Message));
-
e.InnerException == null ? "" : e.InnerException.ToString()));
- }
}
}
@@ -88,7 +81,8 @@
return handler.Create (null, null, d);
}
- [Test, Category ("NotDotNet")]
+ [Test]
+ [Category ("NotDotNet")]
public void SwitchesTag_Elements ()
{
string[] badElements = {
@@ -96,8 +90,22 @@
"<add />",
"<add name=\"a\"/>",
"<add value=\"b\"/>",
+#if !NET_2_0
+ // in the 2.0 profile, we currently allow
non-integral
+ // values
+ //
+ // MS actually introduced new configuration
classes
+ // for the 2.0 profile and did not modify the
original
+ // classes
+ //
+ // Once we add 2.0 configuration classes for
+ // system.diagnostics, the origina behavior
should
+ // be restored and this test should be enabled
again
+ // for the 2.0 profile
+
// non-integral value
"<add name=\"string-value\"
value=\"string-value\"/>",
+#endif
// too many arguments
"<add name=\"a\" value=\"b\" extra=\"c\"/>",
// wrong casing
@@ -123,7 +131,8 @@
ValidateSuccess ("#TST:IE:Good",
"<switches>{0}</switches>", goodElements);
}
- [Test, Category ("NotDotNet")]
+ [Test]
+ [Category ("NotDotNet")]
public void AssertTag ()
{
string[] goodAttributes = {
@@ -148,7 +157,8 @@
ValidateExceptions ("#TAT:BadChildren",
"<assert>{0}</assert>", badChildren);
}
- [Test, Category ("NotDotNet")]
+ [Test]
+ [Category ("NotDotNet")]
public void TraceTag_Attributes ()
{
string[] good = {
@@ -171,7 +181,8 @@
ValidateExceptions ("#TTT:A:Bad", "<trace {0}/>", bad);
}
- [Test, Category ("NotDotNet")]
+ [Test]
+ [Category ("NotDotNet")]
public void TraceTag_Children ()
{
string[] good = {
@@ -187,7 +198,8 @@
ValidateExceptions ("#TTT:C:Bad", "<trace>{0}</trace>",
bad);
}
- [Test, Category ("NotDotNet")]
+ [Test]
+ [Category ("NotDotNet")]
public void TraceTag_Listeners ()
{
const string format =
"<trace><listeners>{0}</listeners></trace>";
@@ -220,4 +232,3 @@
}
}
}
-
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches