Skip to content

Commit 212bfc8

Browse files
committed
Fix assembly default to nullable, remove pointer support, bump to v2
1 parent 260949f commit 212bfc8

28 files changed

+117
-182
lines changed

Source/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Nullable>enable</Nullable>
55
<AnnotatedReferenceAssemblyVersion>6.0.0</AnnotatedReferenceAssemblyVersion>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
7-
<Version>1.0.6</Version>
7+
<Version>2.0.0</Version>
88
<DefineConstants Condition="'$(IsCI)' == 'true'">$(DefineConstants);CI</DefineConstants>
99
</PropertyGroup>
1010

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using TestAssembly;
3+
4+
namespace RuntimeNullables.Fody.Tests;
5+
6+
[TestClass]
7+
public class NullableDisabledTests
8+
{
9+
[TestMethod]
10+
public void NonNull() => NullableDisabled.NonNull(null);
11+
}
Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
32
using TestAssemblyPointers;
43

54
namespace RuntimeNullables.Fody.Tests;
@@ -10,31 +9,11 @@ public class PointerTests
109
private readonly int _value = 5;
1110

1211
[TestMethod]
13-
public unsafe void ReturnSameValueNullableParameter()
12+
public unsafe void PointerIgnored()
1413
{
1514
fixed (int* value = &_value) {
16-
Pointers.ReturnSameValueNullableParameter(value);
17-
var ex = Assert.ThrowsException<NullReferenceException>(() => Pointers.ReturnSameValueNullableParameter(null));
18-
Assert.IsTrue(ex.Message.Contains("return", StringComparison.OrdinalIgnoreCase), "Exception message did not apply to return value.");
19-
}
20-
}
21-
22-
[TestMethod]
23-
public unsafe void AllowNullOnlyNoOp()
24-
{
25-
fixed (int* value = &_value) {
26-
Pointers.AllowNullOnlyNoOp(value);
27-
var ex = Assert.ThrowsException<NullReferenceException>(() => Pointers.AllowNullOnlyNoOp(null));
28-
Assert.IsTrue(ex.Message.Contains("output", StringComparison.OrdinalIgnoreCase), "Exception message did not apply to output value.");
29-
}
30-
}
31-
32-
[TestMethod]
33-
public unsafe void NonNullParameter()
34-
{
35-
fixed (int* value = &_value) {
36-
Pointers.NonNullParameter(value);
37-
Assert.ThrowsException<ArgumentNullException>(() => Pointers.NonNullParameter(null));
15+
Pointers.Ignored(value);
16+
Pointers.Ignored(null);
3817
}
3918
}
4019
}

Source/RuntimeNullables.Fody.Tests/RuntimeNullables.Fody.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="FodyHelpers" Version="6.8.0" />
21+
<PackageReference Include="FodyHelpers" Version="6.8.2" />
2222
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
2323
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
2424
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />

Source/RuntimeNullables.Fody.Tests/VerifyILTests.InjectedThrowHelpers.Debug.DotNet6_0.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
extends [System.Runtime]System.Object
33
{
44
string) = ( 01 00 15 52 75 6E 74 69 6D 65 4E 75 6C 6C 61 62 // ...RuntimeNullab
5-
6C 65 73 2E 46 6F 64 79 07 31 2E 30 2E 36 2E 30 // les.Fody.1.0.6.0
5+
6C 65 73 2E 46 6F 64 79 07 32 2E 30 2E 30 2E 30 // les.Fody.2.0.0.0
66
00 00 )
77
.method assembly hidebysig static void
88
ThrowArgumentNull(string paramName) cil managed

Source/RuntimeNullables.Fody.Tests/VerifyILTests.InjectedThrowHelpers.Debug.DotNet7_0.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
extends [System.Runtime]System.Object
33
{
44
string) = ( 01 00 15 52 75 6E 74 69 6D 65 4E 75 6C 6C 61 62 // ...RuntimeNullab
5-
6C 65 73 2E 46 6F 64 79 07 31 2E 30 2E 36 2E 30 // les.Fody.1.0.6.0
5+
6C 65 73 2E 46 6F 64 79 07 32 2E 30 2E 30 2E 30 // les.Fody.2.0.0.0
66
00 00 )
77
.method assembly hidebysig static void
88
ThrowArgumentNull(string paramName) cil managed

Source/RuntimeNullables.Fody.Tests/VerifyILTests.InjectedThrowHelpers.Release.DotNet6_0.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
extends [System.Runtime]System.Object
33
{
44
string) = ( 01 00 15 52 75 6E 74 69 6D 65 4E 75 6C 6C 61 62 // ...RuntimeNullab
5-
6C 65 73 2E 46 6F 64 79 07 31 2E 30 2E 36 2E 30 // les.Fody.1.0.6.0
5+
6C 65 73 2E 46 6F 64 79 07 32 2E 30 2E 30 2E 30 // les.Fody.2.0.0.0
66
00 00 )
77
.method assembly hidebysig static void
88
ThrowArgumentNull(string paramName) cil managed

Source/RuntimeNullables.Fody.Tests/VerifyILTests.InjectedThrowHelpers.Release.DotNet7_0.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
extends [System.Runtime]System.Object
33
{
44
string) = ( 01 00 15 52 75 6E 74 69 6D 65 4E 75 6C 6C 61 62 // ...RuntimeNullab
5-
6C 65 73 2E 46 6F 64 79 07 31 2E 30 2E 36 2E 30 // les.Fody.1.0.6.0
5+
6C 65 73 2E 46 6F 64 79 07 32 2E 30 2E 30 2E 30 // les.Fody.2.0.0.0
66
00 00 )
77
.method assembly hidebysig static void
88
ThrowArgumentNull(string paramName) cil managed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.class public abstract auto ansi sealed beforefieldinit TestAssembly.NullableDisabled
2+
extends [System.Runtime]System.Object
3+
{
4+
.method public hidebysig static string
5+
NonNull(string x) cil managed
6+
{
7+
.maxstack 8
8+
IL_0000: ldarg.0
9+
IL_0001: ret
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.class public abstract auto ansi sealed beforefieldinit TestAssembly.NullableDisabled
2+
extends [System.Runtime]System.Object
3+
{
4+
.method public hidebysig static string
5+
NonNull(string x) cil managed
6+
{
7+
.maxstack 8
8+
IL_0000: ldarg.0
9+
IL_0001: ret
10+
}
11+
}

0 commit comments

Comments
 (0)