Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Write and WriteLine to Debug class #83

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions source/nanoFramework.Runtime.Native/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public static class Debug
/// <param name="force">true if garbage collection should be forced; otherwise, false.</param>
/// <returns>The amount of free (unused) memory, in bytes.</returns>
[MethodImpl(MethodImplOptions.InternalCall)]
#pragma warning disable S4200 // Native methods should be wrapped
extern static public uint GC(bool force);
#pragma warning restore S4200 // Native methods should be wrapped

/// <summary>
/// Specifies whether GC (garbage collection) messages are enabled.
Expand All @@ -31,15 +33,17 @@ public static class Debug
/// RTM builds (which remove all non essential features) are one of those situations.
/// </remarks>
[MethodImpl(MethodImplOptions.InternalCall)]
#pragma warning disable S4200 // Native methods should be wrapped
extern static public void EnableGCMessages(bool enable);
#pragma warning restore S4200 // Native methods should be wrapped

//--//

/// <summary>
/// Causes a break in execution if the specified assertion (condition) evaluates to false.
/// </summary>
/// <param name="condition">The condition to be evaluated. If the value is false, program execution stops.</param>
[System.Diagnostics.Conditional("DEBUG")]
[Conditional("DEBUG")]
static public void Assert(bool condition)
{
if (!condition)
Expand All @@ -53,7 +57,7 @@ static public void Assert(bool condition)
/// </summary>
/// <param name="condition">The condition to be evaluated. If the value is false, program execution stops.</param>
/// <param name="message">The text to be output if the assertion is false.</param>
[System.Diagnostics.Conditional("DEBUG")]
[Conditional("DEBUG")]
static public void Assert(bool condition, string message)
{
if (!condition)
Expand All @@ -68,13 +72,41 @@ static public void Assert(bool condition, string message)
/// <param name="condition">The condition to be evaluated. If the value is false, program execution stops.</param>
/// <param name="message">The text to be output if the assertion is false.</param>
/// <param name="detailedMessage">The detailed message to be displayed if the assertion is false.</param>
[System.Diagnostics.Conditional("DEBUG")]
[Conditional("DEBUG")]
static public void Assert(bool condition, string message, string detailedMessage)
{
if (!condition)
{
Debugger.Break();
}
}

/// <summary>
/// Writes a message to the trace listeners in the Listeners collection.
/// </summary>
/// <param name="message">A message to write.</param>
/// <remarks>
/// In nanoFramework implementation the message is output to Visual Studio debugger window.
/// </remarks>
[Conditional("DEBUG")]
#pragma warning disable S4200 // Native methods should be wrapped
public static void Write(string message) => WriteLineNative(message, false);
#pragma warning restore S4200 // Native methods should be wrapped

/// <summary>
/// Writes a message followed by a line terminator to the trace listeners in the Listeners collection.
/// </summary>
/// <param name="message">A message to write.</param>
/// <remarks>
/// In nanoFramework implementation the message is output to Visual Studio debugger window.
/// </remarks>
[Conditional("DEBUG")]
#pragma warning disable S4200 // Native methods should be wrapped
public static void WriteLine(string message) => WriteLineNative(message, true);
#pragma warning restore S4200 // Native methods should be wrapped


[MethodImpl(MethodImplOptions.InternalCall)]
extern static private void WriteLineNative(string text, bool addLineFeed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

////////////////////////////////////////////////////////////////
// update this whenever the native assembly signature changes //
[assembly: AssemblyNativeVersion("100.0.6.1")]
[assembly: AssemblyNativeVersion("100.0.6.2")]
////////////////////////////////////////////////////////////////

// Setting ComVisible to false makes the types in this assembly not visible
Expand Down
5 changes: 2 additions & 3 deletions source/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.2.0-preview.{height}",
"version": "1.2.1-preview.{height}",
"assemblyVersion": {
"precision": "revision"
},
Expand All @@ -13,8 +13,7 @@
"^refs/heads/v\\d+(?:\\.\\d+)?$"
],
"cloudBuild": {
"setAllVariables": true,
"buildNumber": null
"setAllVariables": true
},
"release": {
"branchName": "release-v{version}",
Expand Down