Followup to:
http://forums.xamarin.com/discussion/comment/11823/#Comment_11823
These are Switches with a labotomy: the MOBILE profile does not
support System.Configuration.dll, so there is no support for
.exe.config files or
System.Diagnostics.DiagnosticsConfigurationHandler.
Consequently these Switches are largely a compatibility/portability
aid: they DO NOT have the full functionality that the desktop
profile affords. Specifically, there is no way to provide an XML
config file that contains the Switch values to use. If you need to set
the Switch values, this MUST be done manually, e.g. through a Switch
constructor's `defaultSwitchValue` parameter or through a property,
e.g. for SourceSwitch:
http://msdn.microsoft.com/en-us/library/w65awck1.aspxhttp://msdn.microsoft.com/en-us/library/system.diagnostics.sourceswitch.level.aspx
Modulo the GUID in the assembly and the GUID embedded in some
field initializers that use the assembly GUID for their name, the
assemblies are idential before and after the patch.
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.
svn path=/trunk/mcs/; revision=86220
to GetSwitchValue. On 2.0 profile, leave the type conversion to
Switch implementations. Minor corrections to exception messages to
match MS.
* Switch.cs: Avoid unnecessary inits. On 2.0 profile, catch and
rethrow exceptions in setter for Value. Do not hide exceptions thrown
in GetConfigFileSetting. Only set value from config file if switch is
actually defined.
* SourceSwitch.cs: Use SwitchSetting for getting/storing value instead
of new field. In OnValueChanged, parse enum value.
* TraceSwitch.cs: If SwitchSetting is changed to value > 4, then set
it to Verbose. In OnValueChanged, parse value case-insensitively, and
assign it to SwitchSetting (to allow other integral values).
svn path=/trunk/mcs/; revision=86141
/system.diagnostics/switch/add/@value attribute only contain numeric data and
some other fixes (thread-safety in the Debug- and Trace-related classes).
* System/System.Diagnostics/DiagnosticsConfigurationHandler.cs
(DiagnosticsConfiguration): Don't read the .config file from the
static ctor (again), as if it fails we'll get a TypeLoadException -- bad! Instead, lazy-read the .config file.
* System/System.Diagnostics/DiagnosticsConfigurationHandler.cs
(DiagnosticsConfigurationHandler): Require that the /switch/add/@value
attribute contains only numeric values.
* System/System.Diagnostics/DiagnosticsConfigurationHandler.cs:
* System/System.Diagnostics/TraceImpl.cs: Don't initialize everything in
the static ctor, as if it fails (due to an invalid .confg file) we get a
TypeLoadException, while .NET generates a ConfigurationException.
Instead, initialize everything the first time the Listeners property is
accessed, which allows the static ctor to run without chance of failure,
avoiding the TypeLoadException.
* System/System.Diagnostics/TraceListenerCollection.cs: This should be
thread-safe, as it's accessible from a static member of TraceImpl
(available through the public Debug and Trace classes).
* System/System.Diagnostics/Switch.cs: Leave the original switch value alone.
If it isn't valid (i.e. numeric), the DiagnosticsConfigurationHandler
will catch it.
* System/Test/test-config-file: Remove "string-value" switch, as it causes
ConfigurationExceptions under .NET 1.1 (the value attribute can't be
non-numeric), and Mono now follows this behavior. Add a "custom-switch"
value, which is used in the regression tests.
* System/Test/System.Diagnostics/DiagnosticsConfigurationHandlerTest.cs:
.NET 1.1 requires that the value attribute be a numeric value; check for
that and update the success test so that they'll actually pass.
* System/Test/System.Diagnostics/SwitchesTest.cs: TestNewSwitch reads
"custom-switch" now, and the switches value is now "42", not "0".
Remove warning about unused variable.
svn path=/trunk/mcs/; revision=39090
thread-safe (double-checked locking isn't thread safe on .NET without
using a volatile variable, and setting the variable in the static
constructor is easier anyway).
* Switch.cs (GetConfigFileSetting): If the setting is non-numeric, set the
attribute value to the string "0". This is apparently what .NET 1.1 does,
and allows the SwitchTest NUnit test to work w/o failures.
svn path=/trunk/mcs/; revision=38902
Switch derived classes should match that of .NET.
Go forth and use Swiches! ;-)
ChangeLog:
* BooleanSwitch.cs: Complete re-write. It works now.
* DefaultTraceListener.cs:
- Use `const' strings, so I don't worry about copy/paste errors
- Give `AssertUiEnabled' an actual backing member
* DiagnosticsConfigurationHandler.cs: To avoid race conditions, let the
configuration handler set .config-specified properties on
DefaultTraceListener (AssertUiEnabled, LogFileName) and TraceImpl
(AutoFlush, IndentSize).
* Switch.cs: Near complete re-write. Actually works, and is (should be)
comformant with .NET behavior. Changed member names because they were
confusing me. (Yes, that doesn't say much about my memory.)
* TextWriterTraceListener.cs: Append text to already existing files, don't
overwrite them.
* TraceImpl.cs:
- Added private destructor, to ensure no instances are created.
- Move members declarations to be closer to each other.
* TraceSwitch.cs: Complete re-write. It works now.
svn path=/trunk/mcs/; revision=9747
* ChangeLog: added this file
* Switch.cs: call OnSwitchSettingChanged() when the switch setting is,
yes you gessed it, changed.
svn path=/trunk/mcs/; revision=773