Skip to content

Commit 13175cf

Browse files
committed
fix expected value running on .NET Framework
1 parent bf4d129 commit 13175cf

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

tests/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating.Tests.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,14 @@ SPDX-License-Identifier: MIT
1111

1212
<ItemGroup>
1313
<ProjectReference Include="..\..\src\Smdn.Reflection.ReverseGenerating\Smdn.Reflection.ReverseGenerating.csproj" />
14+
<PackageReference
15+
Include="System.Runtime.InteropServices.RuntimeInformation"
16+
Version="4.3.0"
17+
Condition = "(
18+
$(TargetFramework.StartsWith('net45')) or
19+
$(TargetFramework.StartsWith('net46')) or
20+
$(TargetFramework.StartsWith('net47'))
21+
)"
22+
/>
1423
</ItemGroup>
1524
</Project>

tests/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.Attributes.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,25 @@ class AttributeTargetsMember {
4646

4747
class AttributeTargetsReturnValue {
4848
#if NETFRAMEWORK
49-
[return: AttributeTestCase("[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]")]
49+
static string M0_ExpectedResult =>
50+
RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal)
51+
? "[return: System.Runtime.InteropServices.MarshalAs(" +
52+
"System.Runtime.InteropServices.UnmanagedType.Bool, "+
53+
"ArraySubType = default(System.Runtime.InteropServices.UnmanagedType), " +
54+
"SizeParamIndex = 0, " +
55+
"SizeConst = 0, " +
56+
"IidParameterIndex = 0, " +
57+
"SafeArraySubType = System.Runtime.InteropServices.VarEnum.VT_EMPTY" +
58+
")]"
59+
: "[return: System.Runtime.InteropServices.MarshalAs(" +
60+
"System.Runtime.InteropServices.UnmanagedType.Bool)" +
61+
"]";
62+
63+
[return: AttributeTestCase(
64+
expected: null,
65+
ExpectedValueGeneratorType = typeof(AttributeTargetsReturnValue),
66+
ExpectedValueGeneratorMemberName = nameof(M0_ExpectedResult)
67+
)]
5068
[return: MarshalAs(UnmanagedType.Bool)]
5169
public bool M0() => throw new NotImplementedException();
5270
#endif

0 commit comments

Comments
 (0)