From d6bd25591bf2c50bee29f0c66579d2d81795bf33 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Wed, 25 Feb 2015 00:54:38 +0800 Subject: import System.Diagnostics.Trace etc. from referencesource. --- data/net_4_5/machine.config | 2 +- .../System.Xml.Serialization/XmlSerializer.cs | 19 ++++-- mcs/class/System/ReferenceSources/AssertWrapper.cs | 13 +++++ .../ConfigurationManagerInternalFactory.cs | 12 ++++ mcs/class/System/ReferenceSources/SR.cs | 25 ++++++++ .../System/ReferenceSources/SafeNativeMethods.cs | 10 ++++ .../DiagnosticsConfigurationHandler.cs | 11 +++- mcs/class/System/System.Diagnostics/TraceImpl.cs | 6 +- .../System/System.Diagnostics/TraceSourceInfo.cs | 4 +- mcs/class/System/System.dll.sources | 67 ++++++++++++++-------- mcs/class/System/mobile_System.dll.sources | 43 ++++++++------ 11 files changed, 157 insertions(+), 55 deletions(-) create mode 100644 mcs/class/System/ReferenceSources/AssertWrapper.cs create mode 100644 mcs/class/System/ReferenceSources/ConfigurationManagerInternalFactory.cs create mode 100644 mcs/class/System/ReferenceSources/SafeNativeMethods.cs diff --git a/data/net_4_5/machine.config b/data/net_4_5/machine.config index b98a4d3e007..5d4e12b80b0 100644 --- a/data/net_4_5/machine.config +++ b/data/net_4_5/machine.config @@ -13,7 +13,7 @@
-
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs index 8e9fe3e91bf..35d149a4ebe 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs @@ -151,14 +151,21 @@ namespace System.Xml.Serialization #endif deleteTempFiles = (db == null || db == "no"); #if !NET_2_1 - IDictionary table = (IDictionary) ConfigurationSettings.GetConfig("system.diagnostics"); + // DiagnosticsSection + ConfigurationSection table = (ConfigurationSection) ConfigurationSettings.GetConfig("system.diagnostics"); + var bf = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; if (table != null) { - table = (IDictionary) table["switches"]; - if (table != null) - { - string val = (string) table ["XmlSerialization.Compilation"]; - if (val == "1") deleteTempFiles = false; + // SwitchElementsCollection + var pi = table.GetType ().GetProperty ("Switches", bf); + var switchesElement = (ConfigurationElementCollection) pi.GetValue (table, null); + foreach (ConfigurationElement e in switchesElement) { + // SwitchElement + if (e.GetType ().GetProperty ("Name", bf).GetValue (e, null) as string == "XmlSerialization.Compilation") { + if (e.GetType ().GetProperty ("Value", bf).GetValue (e, null) as string == "1") + deleteTempFiles = false; + break; + } } } #endif diff --git a/mcs/class/System/ReferenceSources/AssertWrapper.cs b/mcs/class/System/ReferenceSources/AssertWrapper.cs new file mode 100644 index 00000000000..8bcd613ef22 --- /dev/null +++ b/mcs/class/System/ReferenceSources/AssertWrapper.cs @@ -0,0 +1,13 @@ +using System; +using System.IO; + +namespace System.Diagnostics +{ + class AssertWrapper + { + public static void ShowAssert(string stackTrace, StackFrame frame, string message, string detailMessage) + { + } + } +} + diff --git a/mcs/class/System/ReferenceSources/ConfigurationManagerInternalFactory.cs b/mcs/class/System/ReferenceSources/ConfigurationManagerInternalFactory.cs new file mode 100644 index 00000000000..1589cfcfdc1 --- /dev/null +++ b/mcs/class/System/ReferenceSources/ConfigurationManagerInternalFactory.cs @@ -0,0 +1,12 @@ +using System; + +namespace System.Diagnostics +{ + class ConfigurationManagerInternalFactory + { + public class Instance + { + public static bool SetConfigurationSystemInProgress = false; + } + } +} diff --git a/mcs/class/System/ReferenceSources/SR.cs b/mcs/class/System/ReferenceSources/SR.cs index ce12a738854..e4ec63bdb49 100644 --- a/mcs/class/System/ReferenceSources/SR.cs +++ b/mcs/class/System/ReferenceSources/SR.cs @@ -879,4 +879,29 @@ partial class SR public const string net_wrongversion = "net_wrongversion"; public const string security_ExtendedProtection_NoOSSupport = "security_ExtendedProtection_NoOSSupport"; +public const string DebugAssertBanner = @"---- DEBUG ASSERTION FAILED ----"; +public const string ExceptionOccurred = @"An exception occurred writing trace output to log file '{0}'. {1}"; +public const string TraceSwitchLevelTooHigh = @"Attempted to set {0} to a value that is too high. Setting level to TraceLevel.Verbose"; +public const string TraceSwitchLevelTooLow = @"Attempted to set {0} to a value that is too low. Setting level to TraceLevel.Off"; +public const string TraceSwitchInvalidLevel = @"The Level must be set to a value in the enumeration TraceLevel."; +public const string TraceListenerIndentSize = @"The IndentSize property must be non-negative."; +public const string TraceListenerFail = @"Fail:"; +public const string TraceAsTraceSource = @"Trace"; +public const string MustAddListener = @"Only TraceListeners can be added to a TraceListenerCollection."; +public const string DebugAssertShortMessage = @"---- Assert Short Message ----"; +public const string DebugAssertLongMessage = @"---- Assert Long Message ----"; + +public const string BadConfigSwitchValue = @"The config value for Switch '{0}' was invalid."; +public const string AttributeNotSupported = @"'{0}' is not a valid configuration attribute for type '{1}'."; + +public const string Could_not_create_listener = @"Couldn't create listener '{0}'."; +public const string TL_InitializeData_NotSpecified = @"initializeData needs to be valid for this TraceListener."; +public const string Could_not_create_type_instance = @"Could not create {0}."; +public const string Could_not_find_type = @"Couldn't find type for class {0}."; +public const string Could_not_get_constructor = @"Couldn't find constructor for class {0}."; +public const string EmptyTypeName_NotAllowed = @"switchType needs to be a valid class name. It can't be empty."; +public const string Incorrect_base_type = @"The specified type, '{0}' is not derived from the appropriate base type, '{1}'."; +public const string Only_specify_one = @"'switchValue' and 'switchName' cannot both be specified on source '{0}'."; +public const string Reference_listener_cant_have_properties = @"A listener with no type name specified references the sharedListeners section and cannot have any attributes other than 'Name'. Listener: '{0}'."; +public const string Reference_to_nonexistent_listener = @"Listener '{0}' does not exist in the sharedListeners section."; } diff --git a/mcs/class/System/ReferenceSources/SafeNativeMethods.cs b/mcs/class/System/ReferenceSources/SafeNativeMethods.cs new file mode 100644 index 00000000000..ac7f10e3403 --- /dev/null +++ b/mcs/class/System/ReferenceSources/SafeNativeMethods.cs @@ -0,0 +1,10 @@ + +namespace Microsoft.Win32 +{ + static class SafeNativeMethods + { + public static void OutputDebugString (string message) + { + } + } +} diff --git a/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs b/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs index c3937530f66..f1f9b8027e8 100644 --- a/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs +++ b/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs @@ -42,6 +42,7 @@ using System.Xml; #endif namespace System.Diagnostics { +/* // It handles following elements in : // - [2.0] // - @@ -81,6 +82,8 @@ namespace System.Diagnostics } } } +*/ + #if (XML_DEP) [Obsolete ("This class is obsoleted")] public class DiagnosticsConfigurationHandler : IConfigurationSectionHandler @@ -305,7 +308,7 @@ namespace System.Diagnostics { TraceListenerCollection shared_listeners = d ["sharedListeners"] as TraceListenerCollection; if (shared_listeners == null) { - shared_listeners = new TraceListenerCollection (false); + shared_listeners = new TraceListenerCollection (); d ["sharedListeners"] = shared_listeners; } return shared_listeners; @@ -434,7 +437,8 @@ namespace System.Diagnostics "Listener '{0}' references a shared " + "listener and can only have a 'Name' " + "attribute.", name)); - listeners.Add (shared, configValues); + shared.IndentSize = configValues.IndentSize; + listeners.Add (shared); return; } #else @@ -501,7 +505,8 @@ namespace System.Diagnostics } #endif - listeners.Add (l, configValues); + l.IndentSize = configValues.IndentSize; + listeners.Add (l); } private void RemoveTraceListener (string name) diff --git a/mcs/class/System/System.Diagnostics/TraceImpl.cs b/mcs/class/System/System.Diagnostics/TraceImpl.cs index 79904212eec..f719c37d95e 100644 --- a/mcs/class/System/System.Diagnostics/TraceImpl.cs +++ b/mcs/class/System/System.Diagnostics/TraceImpl.cs @@ -47,15 +47,16 @@ namespace System.Diagnostics { #pragma warning restore //public int IndentLevel; public int IndentSize = 4; - public TraceListenerCollection Listeners = new TraceListenerCollection (false); + public TraceListenerCollection Listeners = new TraceListenerCollection (); public TraceImplSettings () { - Listeners.Add (new DefaultTraceListener (), this); + Listeners.Add (new DefaultTraceListener () { IndentSize = this.IndentSize }); } } #endif +/* static class TraceImpl { #if !MOBILE @@ -413,5 +414,6 @@ namespace System.Diagnostics { WriteLine (message, category); } } +*/ } diff --git a/mcs/class/System/System.Diagnostics/TraceSourceInfo.cs b/mcs/class/System/System.Diagnostics/TraceSourceInfo.cs index f516579a030..1ed07cdf1db 100644 --- a/mcs/class/System/System.Diagnostics/TraceSourceInfo.cs +++ b/mcs/class/System/System.Diagnostics/TraceSourceInfo.cs @@ -49,8 +49,8 @@ namespace System.Diagnostics { this.name = name; this.levels = levels; - this.listeners = new TraceListenerCollection (false); - this.listeners.Add (new DefaultTraceListener(), settings); + this.listeners = new TraceListenerCollection (); + this.listeners.Add (new DefaultTraceListener() { IndentSize = settings.IndentSize }); } public string Name { diff --git a/mcs/class/System/System.dll.sources b/mcs/class/System/System.dll.sources index 9c6332ddbbb..b3055c4a327 100644 --- a/mcs/class/System/System.dll.sources +++ b/mcs/class/System/System.dll.sources @@ -200,18 +200,12 @@ System.Configuration/UserSettingsGroup.cs System.Configuration/UserScopedSettingAttribute.cs System/DefaultUriParser.cs System.Diagnostics/AlphabeticalEnumConverter.cs -System.Diagnostics/BooleanSwitch.cs -System.Diagnostics/ConsoleTraceListener.cs -System.Diagnostics/CorrelationManager.cs System.Diagnostics/CounterCreationDataCollection.cs System.Diagnostics/CounterCreationData.cs System.Diagnostics/CounterSampleCalculator.cs System.Diagnostics/CounterSample.cs System.Diagnostics/DataReceivedEventArgs.cs System.Diagnostics/DataReceivedEventHandler.cs -System.Diagnostics/Debug.cs -System.Diagnostics/DefaultTraceListener.cs -System.Diagnostics/DelimitedListTraceListener.cs System.Diagnostics/DiagnosticsConfigurationHandler.cs System.Diagnostics/EntryWrittenEventArgs.cs System.Diagnostics/EntryWrittenEventHandler.cs @@ -229,7 +223,6 @@ System.Diagnostics/EventLogPermissionEntryCollection.cs System.Diagnostics/EventLogPermissionEntry.cs System.Diagnostics/EventLogTraceListener.cs System.Diagnostics/EventSourceCreationData.cs -System.Diagnostics/EventTypeFilter.cs System.Diagnostics/FileVersionInfo.cs System.Diagnostics/ICollectData.cs System.Diagnostics/InstanceDataCollectionCollection.cs @@ -259,31 +252,13 @@ System.Diagnostics/ProcessStartInfo.cs System.Diagnostics/ProcessThreadCollection.cs System.Diagnostics/ProcessThread.cs System.Diagnostics/ProcessWindowStyle.cs -System.Diagnostics/SourceFilter.cs -System.Diagnostics/SourceLevels.cs -System.Diagnostics/SourceSwitch.cs -System.Diagnostics/Switch.cs -System.Diagnostics/SwitchAttribute.cs -System.Diagnostics/SwitchLevelAttribute.cs System.Diagnostics/Stopwatch.cs -System.Diagnostics/TextWriterTraceListener.cs System.Diagnostics/ThreadPriorityLevel.cs System.Diagnostics/ThreadState.cs System.Diagnostics/ThreadWaitReason.cs -System.Diagnostics/Trace.cs -System.Diagnostics/TraceEventCache.cs -System.Diagnostics/TraceEventType.cs -System.Diagnostics/TraceFilter.cs System.Diagnostics/TraceImpl.cs -System.Diagnostics/TraceLevel.cs -System.Diagnostics/TraceListenerCollection.cs -System.Diagnostics/TraceListener.cs -System.Diagnostics/TraceOptions.cs -System.Diagnostics/TraceSource.cs System.Diagnostics/TraceSourceInfo.cs -System.Diagnostics/TraceSwitch.cs System.Diagnostics/Win32EventLog.cs -System.Diagnostics/XmlWriterTraceListener.cs System.Diagnostics.CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs System/FileStyleUriParser.cs System/FtpStyleUriParser.cs @@ -734,9 +709,12 @@ Mono.Net.Dns/SimpleResolverEventArgs.cs System.Net/DnsAsyncResult.cs System.Windows.Input/ICommand.cs +ReferenceSources/AssertWrapper.cs ReferenceSources/BinaryCompatibility.cs +ReferenceSources/ConfigurationManagerInternalFactory.cs ReferenceSources/Logging.cs ReferenceSources/NativeMethods.cs +ReferenceSources/SafeNativeMethods.cs ReferenceSources/SettingsSectionInternal.cs ReferenceSources/Socket.cs ReferenceSources/SR.cs @@ -745,6 +723,7 @@ ReferenceSources/SystemNetworkCredential.cs ReferenceSources/WebHeaderCollectionType.cs ReferenceSources/Win32Exception.cs +../../../external/referencesource/System/misc/PrivilegedConfigurationManager.cs ../../../external/referencesource/System/regex/system/text/regularexpressions/Regex.cs ../../../external/referencesource/System/regex/system/text/regularexpressions/RegexBoyerMoore.cs ../../../external/referencesource/System/regex/system/text/regularexpressions/RegexCapture.cs @@ -1072,6 +1051,44 @@ ReferenceSources/Win32Exception.cs ../../../external/referencesource/System/compmod/system/componentmodel/WarningException.cs ../../../external/referencesource/System/compmod/system/componentmodel/Win32Exception.cs +../../../external/referencesource/System/compmod/system/diagnostics/AssertSection.cs +../../../external/referencesource/System/compmod/system/diagnostics/BooleanSwitch.cs +../../../external/referencesource/System/compmod/system/diagnostics/ConsoleTraceListener.cs +../../../external/referencesource/System/compmod/system/diagnostics/CorrelationManager.cs +../../../external/referencesource/System/compmod/system/diagnostics/Debug.cs +../../../external/referencesource/System/compmod/system/diagnostics/DefaultTraceListener.cs +../../../external/referencesource/System/compmod/system/diagnostics/DelimitedListTraceListener.cs +../../../external/referencesource/System/compmod/system/diagnostics/DiagnosticsConfiguration.cs +../../../external/referencesource/System/compmod/system/diagnostics/FilterElement.cs +../../../external/referencesource/System/compmod/system/diagnostics/ListenerElementsCollection.cs +../../../external/referencesource/System/compmod/system/diagnostics/PerfCounterSection.cs +../../../external/referencesource/System/compmod/system/diagnostics/SeverityFilter.cs +../../../external/referencesource/System/compmod/system/diagnostics/SourceElementsCollection.cs +../../../external/referencesource/System/compmod/system/diagnostics/SourceFilter.cs +../../../external/referencesource/System/compmod/system/diagnostics/SourceLevels.cs +../../../external/referencesource/System/compmod/system/diagnostics/SourceSwitch.cs +../../../external/referencesource/System/compmod/system/diagnostics/SwitchAttribute.cs +../../../external/referencesource/System/compmod/system/diagnostics/Switch.cs +../../../external/referencesource/System/compmod/system/diagnostics/SwitchElementsCollection.cs +../../../external/referencesource/System/compmod/system/diagnostics/SwitchLevelAttribute.cs +../../../external/referencesource/System/compmod/system/diagnostics/SystemDiagnosticsSection.cs +../../../external/referencesource/System/compmod/system/diagnostics/TextWriterTraceListener.cs +../../../external/referencesource/System/compmod/system/diagnostics/Trace.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceEventCache.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceEventType.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceFilter.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceInternal.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceLevel.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceListener.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceListeners.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceOptions.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceSection.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceSource.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceSwitch.cs +../../../external/referencesource/System/compmod/system/diagnostics/traceutils.cs +../../../external/referencesource/System/compmod/system/diagnostics/TypedElement.cs +../../../external/referencesource/System/compmod/system/diagnostics/XmlWriterTraceListener.cs + ../../../external/referencesource/System/net/System/Net/_BufferOffsetSize.cs ../../../external/referencesource/System/net/System/Net/_LazyAsyncResult.cs ../../../external/referencesource/System/net/System/Net/_LoggingObject.cs diff --git a/mcs/class/System/mobile_System.dll.sources b/mcs/class/System/mobile_System.dll.sources index 313e54b7432..81f5a64cd3c 100644 --- a/mcs/class/System/mobile_System.dll.sources +++ b/mcs/class/System/mobile_System.dll.sources @@ -4,12 +4,8 @@ ReferenceSources/SR.cs Mono.Http/NtlmClient.cs System.CodeDom.Compiler/GeneratedCodeAttribute.cs System.CodeDom.Compiler/IndentedTextWriter.cs -System.Diagnostics/BooleanSwitch.cs -System.Diagnostics/CorrelationManager.cs System.Diagnostics/DataReceivedEventArgs.cs System.Diagnostics/DataReceivedEventHandler.cs -System.Diagnostics/Debug.cs -System.Diagnostics/DefaultTraceListener.cs System.Diagnostics/FileVersionInfo.cs System.Diagnostics/MonitoringDescriptionAttribute.cs System.Diagnostics/Process.cs @@ -20,23 +16,11 @@ System.Diagnostics/ProcessStartInfo.cs System.Diagnostics/ProcessThread.cs System.Diagnostics/ProcessThreadCollection.cs System.Diagnostics/ProcessWindowStyle.cs -System.Diagnostics/SourceLevels.cs -System.Diagnostics/SourceSwitch.cs System.Diagnostics/Stopwatch.cs -System.Diagnostics/Switch.cs -System.Diagnostics/SwitchAttribute.cs -System.Diagnostics/SwitchLevelAttribute.cs System.Diagnostics/ThreadPriorityLevel.cs System.Diagnostics/ThreadState.cs System.Diagnostics/ThreadWaitReason.cs -System.Diagnostics/Trace.cs -System.Diagnostics/TraceEventType.cs System.Diagnostics/TraceImpl.cs -System.Diagnostics/TraceLevel.cs -System.Diagnostics/TraceListener.cs -System.Diagnostics/TraceListenerCollection.cs -System.Diagnostics/TraceOptions.cs -System.Diagnostics/TraceSwitch.cs System.IO.Compression/CompressionLevel.cs System.IO.Compression/CompressionMode.cs System.IO.Compression/DeflateStream.cs @@ -361,8 +345,10 @@ System.Runtime.InteropServices/DefaultParameterValueAttribute.cs System.Runtime.InteropServices/HandleCollector.cs System.Windows.Input/ICommand.cs +ReferenceSources/AssertWrapper.cs ReferenceSources/Logging.cs ReferenceSources/NativeMethods.cs +ReferenceSources/SafeNativeMethods.cs ReferenceSources/SR.cs ReferenceSources/SRCategoryAttribute.cs ReferenceSources/SystemNetworkCredential.cs @@ -696,6 +682,31 @@ ReferenceSources/Win32Exception.cs ../../../external/referencesource/System/compmod/system/componentmodel/WarningException.cs ../../../external/referencesource/System/compmod/system/componentmodel/Win32Exception.cs +../../../external/referencesource/System/compmod/system/diagnostics/AssertSection.cs +../../../external/referencesource/System/compmod/system/diagnostics/BooleanSwitch.cs +../../../external/referencesource/System/compmod/system/diagnostics/CorrelationManager.cs +../../../external/referencesource/System/compmod/system/diagnostics/Debug.cs +../../../external/referencesource/System/compmod/system/diagnostics/DefaultTraceListener.cs +../../../external/referencesource/System/compmod/system/diagnostics/DiagnosticsConfiguration.cs +../../../external/referencesource/System/compmod/system/diagnostics/ListenerElementsCollection.cs +../../../external/referencesource/System/compmod/system/diagnostics/SourceLevels.cs +../../../external/referencesource/System/compmod/system/diagnostics/SourceSwitch.cs +../../../external/referencesource/System/compmod/system/diagnostics/SwitchAttribute.cs +../../../external/referencesource/System/compmod/system/diagnostics/Switch.cs +../../../external/referencesource/System/compmod/system/diagnostics/SwitchLevelAttribute.cs +../../../external/referencesource/System/compmod/system/diagnostics/Trace.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceEventCache.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceEventType.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceFilter.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceInternal.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceLevel.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceListener.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceListeners.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceOptions.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceSource.cs +../../../external/referencesource/System/compmod/system/diagnostics/TraceSwitch.cs +../../../external/referencesource/System/compmod/system/diagnostics/traceutils.cs + ../../../external/referencesource/System/net/System/Net/_BufferOffsetSize.cs ../../../external/referencesource/System/net/System/Net/_LazyAsyncResult.cs ../../../external/referencesource/System/net/System/Net/_LoggingObject.cs -- cgit v1.2.3