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

Fixed Issue of Guid.Empty Being Changed #93

merged 2 commits into from Aug 17, 2019
Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -88,15 +88,18 @@ private static bool IsNullableType(Type type)

protected virtual void SetValue<T>(MemberInfo memberInfo, T obj, object value)
if (value != null)
if (value == null) return;
if (memberInfo.Name == "Empty" && memberInfo.DeclaringType == typeof(Guid)) return;
This conversation was marked as resolved by DHemken97

This comment has been minimized.

Copy link

crmckenzie Aug 12, 2019


I don't think this is the right approach. The code shouldn't special-case Guid. The root problem is that NBuilder is altering a static readonly member field. The code should be modified to not set members that are readonly and/or static.

This comment has been minimized.

Copy link

DHemken97 Aug 12, 2019

Author Contributor

I started to think this too... This has been changed

switch (memberInfo)
if (memberInfo is FieldInfo)
((FieldInfo)memberInfo).SetValue(obj, value);

if (memberInfo is PropertyInfo)
case FieldInfo info:
info.SetValue(obj, value);
case PropertyInfo info:
if (((PropertyInfo)memberInfo).CanWrite)
((PropertyInfo)memberInfo).SetValue(obj, value, null);
if (info.CanWrite)
info.SetValue(obj, value, null);
@@ -161,15 +161,12 @@ protected override Enum GetEnum(MemberInfo memberInfo)
protected override Guid GetGuid(MemberInfo memberInfo)
var bytes = new byte[16];
var convertedBytes = BitConverter.GetBytes(_sequenceNumber);

bytes[12] = convertedBytes[3];
bytes[13] = convertedBytes[2];
bytes[14] = convertedBytes[1];
bytes[15] = convertedBytes[0];

BitConverter.GetBytes(_sequenceNumber).CopyTo(bytes, 0);
if (BitConverter.IsLittleEndian)
return new Guid(bytes);

protected override TimeSpan GetTimeSpan(MemberInfo memberInfo)
@@ -13,12 +13,13 @@ namespace FizzWare.NBuilder.Tests.Integration
public class IssueTests

public void Guid_ShouldNotChangeValueOfStaticMember()
var guid1 = Guid.Empty;
new Guid();
var guid4 = Guid.Empty;

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.