Skip to content
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
10 changes: 10 additions & 0 deletions Tests/NFUnitTestSystemLib/UnitTestInitLocalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,24 @@ public void SystemType1_ArrayListToArrayForStruct_Test()
// make sure boxing of struct value type (Guid) is handled properly
// this test was a result of a bug found by a customer.
Guid ret = new Guid();

ArrayList guidList = new ArrayList();
guidList.Add(Guid.NewGuid());
guidList.Add(Guid.NewGuid());

Guid[] guidArray = (Guid[])guidList.ToArray(typeof(Guid));

// Verify the array has the correct length
Assert.AreEqual(2, guidArray.Length);

// Verify each element is not empty and matches the source list
int i = 0;
foreach (Guid g in guidArray)
{
Assert.IsFalse(Guid.Empty.Equals(g), "Guid should not be empty");
Assert.AreEqual(guidList[i], g, "Guid should match the source ArrayList element");
ret = g;
i++;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/NFUnitTestTypes/UnitTestGuid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ public void Guid_TryParseGuidWithDashes_Valid()
{
var g1 = Guid.NewGuid();
var str = g1.ToString();
bool parsed = Guid.TryParseGuidWithDashes(str, out var g2);
bool parsed = Guid.TryParse(str, out var g2);
Assert.IsTrue(parsed);
Assert.AreEqual(g1, g2);
}

[TestMethod]
public void Guid_TryParseGuidWithDashes_Invalid()
{
bool parsed = Guid.TryParseGuidWithDashes("invalid-guid", out var g2);
bool parsed = Guid.TryParse("invalid-guid", out var g2);
Assert.IsFalse(parsed);
Assert.AreEqual(Guid.Empty, g2);
}
Expand Down
8 changes: 1 addition & 7 deletions nanoFramework.CoreLibrary/System/Guid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@ namespace System
[Serializable]
public struct Guid
{
private int[] _data;
private int[] _data = new int[4];

/// <summary>
/// A read-only instance of the Guid class which consists of all zeros.
/// </summary>
public static readonly Guid Empty = new Guid(new byte[16]);

public Guid()
{
// All zeros
_data = new int[4];
}

/// <summary>
/// Initializes a new instance of the <see cref="Guid"/> structure by using the specified integers and bytes.
/// </summary>
Expand Down
Loading