Skip to content

Commit 408a5e0

Browse files
authored
Attribute value now accepts null string (#201)
***NO_CI***
1 parent a63a2c6 commit 408a5e0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

MetadataProcessor.Shared/Tables/nanoSignaturesTable.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,15 @@ private void WriteAttributeArgumentValue(
817817
break;
818818
case NanoCLRDataType.DATATYPE_STRING:
819819
writer.Write((byte)nanoSerializationType.ELEMENT_TYPE_STRING);
820-
writer.Write(_context.StringTable.GetOrCreateStringId((string)argument.Value));
820+
if (argument.Value == null)
821+
{
822+
// write sentinel for null string
823+
writer.Write((ushort)0xFFFF);
824+
}
825+
else
826+
{
827+
writer.Write(_context.StringTable.GetOrCreateStringId((string)argument.Value));
828+
}
821829
break;
822830
default:
823831
Debug.Fail(dataType.ToString());

MetadataProcessor.Tests/TestNFApp/MyClass1.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public void MyMethodWithData()
3131
{
3232
}
3333

34+
[DataRow(999, null)]
35+
public void MyMethodWithDataRowWithNull()
36+
{
37+
}
38+
3439
private readonly int _myField;
3540

3641
[Ignore("I'm ignoring you!")]

0 commit comments

Comments
 (0)