Skip to content

Commit d0ae80d

Browse files
authored
Add System.Diagnostics.Debug class (#106)
***PUBLISH_RELEASE***
1 parent 951da55 commit d0ae80d

File tree

5 files changed

+91
-2
lines changed

5 files changed

+91
-2
lines changed

Diff for: source/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<Compile Include="..\nanoFramework.CoreLibrary\System\Decimal.cs" Link="System\Decimal.cs"/>
7979
<Compile Include="..\nanoFramework.CoreLibrary\System\Delegate.cs" Link="System\v.cs"/>
8080
<Compile Include="..\nanoFramework.CoreLibrary\System\Diagnostics\ConditionalAttribute.cs" Link="System\Diagnostics\ConditionalAttribute.cs"/>
81+
<Compile Include="..\nanoFramework.CoreLibrary\System\Diagnostics\Debug.cs" Link="System\Diagnostics\Debug.cs"/>
8182
<Compile Include="..\nanoFramework.CoreLibrary\System\Diagnostics\Debugger.cs" Link="System\Diagnostics\Debugger.cs"/>
8283
<Compile Include="..\nanoFramework.CoreLibrary\System\Diagnostics\DebuggerAttributes.cs" Link="System\Diagnostics\DebuggerAttributes.cs"/>
8384
<Compile Include="..\nanoFramework.CoreLibrary\System\Double.cs" Link="System\Double.cs"/>

Diff for: source/nanoFramework.CoreLibrary/CoreLibrary.nfproj

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<Compile Include="System\Decimal.cs" />
7979
<Compile Include="System\Delegate.cs" />
8080
<Compile Include="System\Diagnostics\ConditionalAttribute.cs" />
81+
<Compile Include="System\Diagnostics\Debug.cs" />
8182
<Compile Include="System\Diagnostics\Debugger.cs" />
8283
<Compile Include="System\Diagnostics\DebuggerAttributes.cs" />
8384
<Compile Include="System\Double.cs" />

Diff for: source/nanoFramework.CoreLibrary/System/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
[assembly: AssemblyProduct("nanoFramework mscorlib")]
1515
[assembly: AssemblyCopyright("Copyright © nanoFramework Contributors 2017")]
1616

17-
[assembly: AssemblyNativeVersion("100.4.9.0")]
17+
[assembly: AssemblyNativeVersion("100.4.10.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
4+
// See LICENSE file in the project root for full license information.
5+
//
6+
7+
using System.Runtime.CompilerServices;
8+
9+
namespace System.Diagnostics
10+
{
11+
/// <summary>
12+
/// Provides a set of methods and properties that help debug your code.
13+
/// </summary>
14+
public static class Debug
15+
{
16+
17+
/// <summary>
18+
/// Causes a break in execution if the specified assertion (condition) evaluates to false.
19+
/// </summary>
20+
/// <param name="condition">The condition to be evaluated. If the value is false, program execution stops.</param>
21+
[Conditional("DEBUG")]
22+
static public void Assert(bool condition)
23+
{
24+
if (!condition)
25+
{
26+
Debugger.Break();
27+
}
28+
}
29+
30+
/// <summary>
31+
/// Causes a break in execution if the specified assertion (condition) evaluates to false.
32+
/// </summary>
33+
/// <param name="condition">The condition to be evaluated. If the value is false, program execution stops.</param>
34+
/// <param name="message">The text to be output if the assertion is false.</param>
35+
[Conditional("DEBUG")]
36+
static public void Assert(bool condition, string message)
37+
{
38+
if (!condition)
39+
{
40+
Debugger.Break();
41+
}
42+
}
43+
44+
/// <summary>
45+
/// Causes a break in execution if the specified assertion (condition) evaluates to false.
46+
/// </summary>
47+
/// <param name="condition">The condition to be evaluated. If the value is false, program execution stops.</param>
48+
/// <param name="message">The text to be output if the assertion is false.</param>
49+
/// <param name="detailedMessage">The detailed message to be displayed if the assertion is false.</param>
50+
[Conditional("DEBUG")]
51+
static public void Assert(bool condition, string message, string detailedMessage)
52+
{
53+
if (!condition)
54+
{
55+
Debugger.Break();
56+
}
57+
}
58+
59+
/// <summary>
60+
/// Writes a message to the trace listeners in the Listeners collection.
61+
/// </summary>
62+
/// <param name="message">A message to write.</param>
63+
/// <remarks>
64+
/// In nanoFramework implementation the message is output to Visual Studio debugger window.
65+
/// </remarks>
66+
[Conditional("DEBUG")]
67+
#pragma warning disable S4200 // Native methods should be wrapped
68+
public static void Write(string message) => WriteLineNative(message, false);
69+
#pragma warning restore S4200 // Native methods should be wrapped
70+
71+
/// <summary>
72+
/// Writes a message followed by a line terminator to the trace listeners in the Listeners collection.
73+
/// </summary>
74+
/// <param name="message">A message to write.</param>
75+
/// <remarks>
76+
/// In nanoFramework implementation the message is output to Visual Studio debugger window.
77+
/// </remarks>
78+
[Conditional("DEBUG")]
79+
#pragma warning disable S4200 // Native methods should be wrapped
80+
public static void WriteLine(string message) => WriteLineNative(message, true);
81+
#pragma warning restore S4200 // Native methods should be wrapped
82+
83+
84+
[MethodImpl(MethodImplOptions.InternalCall)]
85+
extern static private void WriteLineNative(string text, bool addLineFeed);
86+
}
87+
}

Diff for: source/version.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "1.7.2-preview.{height}",
3+
"version": "1.7.3-preview.{height}",
44
"buildNumberOffset": 3,
55
"assemblyVersion": {
66
"precision": "revision"

0 commit comments

Comments
 (0)