Skip to content

Commit

Permalink
import System.Diagnostics.Trace etc. from referencesource.
Browse files Browse the repository at this point in the history
  • Loading branch information
atsushieno committed Feb 24, 2015
1 parent c34def6 commit d6bd255
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 55 deletions.
2 changes: 1 addition & 1 deletion data/net_4_5/machine.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<section name="startup" type="System.Configuration.IgnoreSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowLocation="false"/>
<section name="system.codedom" type="System.CodeDom.Compiler.CodeDomConfigurationHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="system.data" type="System.Data.Common.DbProviderFactoriesConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="system.diagnostics" type="System.Diagnostics.SystemDiagnosticsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="system.runtime.remoting" type="System.Configuration.IgnoreSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowLocation="false"/>
<section name="system.windows.forms" type="System.Windows.Forms.WindowsFormsSection, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="windows" type="System.Configuration.IgnoreSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowLocation="false" />
Expand Down
19 changes: 13 additions & 6 deletions mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,21 @@ static XmlSerializer ()
#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
Expand Down
13 changes: 13 additions & 0 deletions mcs/class/System/ReferenceSources/AssertWrapper.cs
Original file line number Diff line number Diff line change
@@ -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)
{
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace System.Diagnostics
{
class ConfigurationManagerInternalFactory
{
public class Instance
{
public static bool SetConfigurationSystemInProgress = false;
}
}
}
25 changes: 25 additions & 0 deletions mcs/class/System/ReferenceSources/SR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -879,4 +879,29 @@ public static object GetObject (string name)
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.";
}
10 changes: 10 additions & 0 deletions mcs/class/System/ReferenceSources/SafeNativeMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

namespace Microsoft.Win32
{
static class SafeNativeMethods
{
public static void OutputDebugString (string message)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#endif
namespace System.Diagnostics
{
/*
// It handles following elements in <system.diagnostics> :
// - <sharedListeners> [2.0]
// - <sources>
Expand Down Expand Up @@ -81,6 +82,8 @@ public static IDictionary Settings {
}
}
}
*/

#if (XML_DEP)
[Obsolete ("This class is obsoleted")]
public class DiagnosticsConfigurationHandler : IConfigurationSectionHandler
Expand Down Expand Up @@ -305,7 +308,7 @@ private TraceListenerCollection GetSharedListeners (IDictionary d)
{
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;
Expand Down Expand Up @@ -434,7 +437,8 @@ private void AddTraceListener (IDictionary d, XmlNode child, XmlAttributeCollect
"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
Expand Down Expand Up @@ -501,7 +505,8 @@ private void AddTraceListener (IDictionary d, XmlNode child, XmlAttributeCollect
}
#endif

listeners.Add (l, configValues);
l.IndentSize = configValues.IndentSize;
listeners.Add (l);
}

private void RemoveTraceListener (string name)
Expand Down
6 changes: 4 additions & 2 deletions mcs/class/System/System.Diagnostics/TraceImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ internal class TraceImplSettings {
#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
Expand Down Expand Up @@ -413,5 +414,6 @@ public static void WriteLineIf (bool condition, string message,
WriteLine (message, category);
}
}
*/
}

4 changes: 2 additions & 2 deletions mcs/class/System/System.Diagnostics/TraceSourceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ internal TraceSourceInfo (string name, SourceLevels levels, TraceImplSettings se
{
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 {
Expand Down
67 changes: 42 additions & 25 deletions mcs/class/System/System.dll.sources
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
43 changes: 27 additions & 16 deletions mcs/class/System/mobile_System.dll.sources
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d6bd255

Please sign in to comment.