Skip to content

Commit 828fb06

Browse files
committed
Ensure we test both in-project IDs and "external" IDs
1 parent 626b08f commit 828fb06

File tree

6 files changed

+177
-22
lines changed

6 files changed

+177
-22
lines changed

StronglyTypedId.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StronglyTypedIds.Nuget.Attr
3434
EndProject
3535
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StronglyTypedIds.Templates", "src\StronglyTypedIds.Templates\StronglyTypedIds.Templates.csproj", "{336D7EE4-90BA-4BFC-99F6-D70B8D494E8C}"
3636
EndProject
37+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StronglyTypedIds.IntegrationTests.Types", "test\StronglyTypedIds.IntegrationTests.Types\StronglyTypedIds.IntegrationTests.Types.csproj", "{A5804404-E5A5-4F05-86E2-B2A11D370498}"
38+
EndProject
39+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StronglyTypedIds.IntegrationTests.ExternalIds", "test\StronglyTypedIds.IntegrationTests.ExternalIds\StronglyTypedIds.IntegrationTests.ExternalIds.csproj", "{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}"
40+
EndProject
3741
Global
3842
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3943
Debug|Any CPU = Debug|Any CPU
@@ -118,6 +122,30 @@ Global
118122
{336D7EE4-90BA-4BFC-99F6-D70B8D494E8C}.Release|x64.Build.0 = Release|Any CPU
119123
{336D7EE4-90BA-4BFC-99F6-D70B8D494E8C}.Release|x86.ActiveCfg = Release|Any CPU
120124
{336D7EE4-90BA-4BFC-99F6-D70B8D494E8C}.Release|x86.Build.0 = Release|Any CPU
125+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
126+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Debug|Any CPU.Build.0 = Debug|Any CPU
127+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Debug|x64.ActiveCfg = Debug|Any CPU
128+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Debug|x64.Build.0 = Debug|Any CPU
129+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Debug|x86.ActiveCfg = Debug|Any CPU
130+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Debug|x86.Build.0 = Debug|Any CPU
131+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Release|Any CPU.ActiveCfg = Release|Any CPU
132+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Release|Any CPU.Build.0 = Release|Any CPU
133+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Release|x64.ActiveCfg = Release|Any CPU
134+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Release|x64.Build.0 = Release|Any CPU
135+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Release|x86.ActiveCfg = Release|Any CPU
136+
{A5804404-E5A5-4F05-86E2-B2A11D370498}.Release|x86.Build.0 = Release|Any CPU
137+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
138+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Debug|Any CPU.Build.0 = Debug|Any CPU
139+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Debug|x64.ActiveCfg = Debug|Any CPU
140+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Debug|x64.Build.0 = Debug|Any CPU
141+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Debug|x86.ActiveCfg = Debug|Any CPU
142+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Debug|x86.Build.0 = Debug|Any CPU
143+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Release|Any CPU.ActiveCfg = Release|Any CPU
144+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Release|Any CPU.Build.0 = Release|Any CPU
145+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Release|x64.ActiveCfg = Release|Any CPU
146+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Release|x64.Build.0 = Release|Any CPU
147+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Release|x86.ActiveCfg = Release|Any CPU
148+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047}.Release|x86.Build.0 = Release|Any CPU
121149
EndGlobalSection
122150
GlobalSection(SolutionProperties) = preSolution
123151
HideSolutionNode = FALSE
@@ -130,6 +158,8 @@ Global
130158
{A7355210-7DDC-4968-84B7-79002113EA6E} = {D1907D86-8FFC-4178-A3DB-0ADBDD282C64}
131159
{19A9B323-8C0B-4D1B-A20C-8CECFFD37F23} = {D1907D86-8FFC-4178-A3DB-0ADBDD282C64}
132160
{336D7EE4-90BA-4BFC-99F6-D70B8D494E8C} = {EE1258BD-3422-4F55-B9CF-B4D6C95DAD68}
161+
{A5804404-E5A5-4F05-86E2-B2A11D370498} = {D1907D86-8FFC-4178-A3DB-0ADBDD282C64}
162+
{07875BB0-EFEE-4F90-AAB8-4B11F78C8047} = {D1907D86-8FFC-4178-A3DB-0ADBDD282C64}
133163
EndGlobalSection
134164
GlobalSection(ExtensibilityGlobals) = postSolution
135165
SolutionGuid = {8D1F0534-B8AD-4CFA-9C14-CBC757BCB1E1}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
5+
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net48;$(TargetFrameworks)</TargetFrameworks>
6+
<IsPackable>false</IsPackable>
7+
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<Compile Include="..\StronglyTypedIds.IntegrationTests\*.cs" Link="%(Filename)%(Extension)" />
12+
<Compile Remove="..\StronglyTypedIds.IntegrationTests\Enums.cs" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\StronglyTypedIds.IntegrationTests.Types\StronglyTypedIds.IntegrationTests.Types.csproj" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
21+
</ItemGroup>
22+
23+
<Import Project="$(MSBuildThisFileDirectory)..\IntegrationLibraries.props" />
24+
25+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3+
"shadowCopy": false
4+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#nullable enable
2+
using System;
3+
4+
namespace StronglyTypedIds.IntegrationTests.Types;
5+
6+
7+
[StronglyTypedId]
8+
public partial struct DefaultId1 { }
9+
10+
[StronglyTypedId]
11+
public partial struct DefaultId2 { }
12+
13+
[StronglyTypedId(Template.Guid)]
14+
public partial struct GuidId1 { }
15+
16+
[StronglyTypedId("guid-full")]
17+
public partial struct ConvertersGuidId { }
18+
19+
[StronglyTypedId(Template.Guid, "guid-efcore", "guid-dapper", "guid-newtonsoftjson")]
20+
public partial struct ConvertersGuidId2 { }
21+
22+
[StronglyTypedId(Template.Guid)]
23+
public partial struct GuidId2 { }
24+
25+
[StronglyTypedId(Template.Int)]
26+
public partial struct IntId { }
27+
28+
[StronglyTypedId("int-full")]
29+
public partial struct ConvertersIntId { }
30+
31+
[StronglyTypedId(Template.Int, "int-efcore", "int-dapper", "int-newtonsoftjson")]
32+
public partial struct ConvertersIntId2 { }
33+
34+
[StronglyTypedId(Template.Long)]
35+
public partial struct LongId { }
36+
37+
[StronglyTypedId("long-full")]
38+
public partial struct ConvertersLongId { }
39+
40+
[StronglyTypedId(Template.Long, "long-efcore", "long-dapper", "long-newtonsoftjson")]
41+
public partial struct ConvertersLongId2 { }
42+
43+
[StronglyTypedId("newid-full")]
44+
public partial struct NewIdId1 { }
45+
46+
[StronglyTypedId("newid-full")]
47+
public partial struct NewIdId2 { }
48+
49+
[StronglyTypedId(Template.String)]
50+
public partial struct StringId { }
51+
52+
[StronglyTypedId("string-full")]
53+
public partial struct ConvertersStringId { }
54+
55+
[StronglyTypedId(Template.String, "string-efcore", "string-dapper", "string-newtonsoftjson")]
56+
public partial struct ConvertersStringId2 { }
57+
58+
[StronglyTypedId("nullablestring-full")]
59+
public partial struct NullableStringId { }
60+
61+
public partial class SomeType<T> where T : new()
62+
{
63+
public partial record struct NestedType<TKey, TValue>
64+
{
65+
public partial struct MoreNesting
66+
{
67+
[StronglyTypedId]
68+
public readonly partial struct VeryNestedId
69+
{
70+
}
71+
}
72+
}
73+
}
74+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
5+
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net48;$(TargetFrameworks)</TargetFrameworks>
6+
<IsPackable>false</IsPackable>
7+
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
8+
<IsTestProject>false</IsTestProject>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\..\src\StronglyTypedIds\StronglyTypedIds.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
13+
<ProjectReference Include="..\..\src\StronglyTypedIds.Attributes\StronglyTypedIds.Attributes.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\..\src\StronglyTypedIds.Templates\*.typedid" Link="Templates\%(Filename)%(Extension)" />
18+
</ItemGroup>
19+
20+
<Import Project="$(MSBuildThisFileDirectory)..\IntegrationLibraries.props" />
21+
22+
</Project>

test/StronglyTypedIds.IntegrationTests/Enums.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,67 @@ namespace StronglyTypedIds.IntegrationTests.Types;
55

66

77
[StronglyTypedId]
8-
partial struct DefaultId1 { }
8+
internal partial struct DefaultId1 { }
99

1010
[StronglyTypedId]
11-
public partial struct DefaultId2 { }
11+
internal partial struct DefaultId2 { }
1212

1313
[StronglyTypedId(Template.Guid)]
14-
partial struct GuidId1 { }
14+
internal partial struct GuidId1 { }
1515

1616
[StronglyTypedId("guid-full")]
17-
partial struct ConvertersGuidId { }
17+
internal partial struct ConvertersGuidId { }
1818

1919
[StronglyTypedId(Template.Guid, "guid-efcore", "guid-dapper", "guid-newtonsoftjson")]
20-
partial struct ConvertersGuidId2 { }
20+
internal partial struct ConvertersGuidId2 { }
2121

2222
[StronglyTypedId(Template.Guid)]
23-
public partial struct GuidId2 { }
23+
internal partial struct GuidId2 { }
2424

2525
[StronglyTypedId(Template.Int)]
26-
partial struct IntId { }
26+
internal partial struct IntId { }
2727

2828
[StronglyTypedId("int-full")]
29-
partial struct ConvertersIntId { }
29+
internal partial struct ConvertersIntId { }
3030

3131
[StronglyTypedId(Template.Int, "int-efcore", "int-dapper", "int-newtonsoftjson")]
32-
partial struct ConvertersIntId2 { }
32+
internal partial struct ConvertersIntId2 { }
3333

3434
[StronglyTypedId(Template.Long)]
35-
partial struct LongId { }
35+
internal partial struct LongId { }
3636

3737
[StronglyTypedId("long-full")]
38-
partial struct ConvertersLongId { }
38+
internal partial struct ConvertersLongId { }
3939

4040
[StronglyTypedId(Template.Long, "long-efcore", "long-dapper", "long-newtonsoftjson")]
41-
partial struct ConvertersLongId2 { }
41+
internal partial struct ConvertersLongId2 { }
4242

4343
[StronglyTypedId("newid-full")]
44-
partial struct NewIdId1 { }
44+
internal partial struct NewIdId1 { }
4545

4646
[StronglyTypedId("newid-full")]
47-
partial struct NewIdId2 { }
47+
internal partial struct NewIdId2 { }
4848

4949
[StronglyTypedId(Template.String)]
50-
partial struct StringId { }
50+
internal partial struct StringId { }
5151

5252
[StronglyTypedId("string-full")]
53-
partial struct ConvertersStringId { }
53+
internal partial struct ConvertersStringId { }
5454

5555
[StronglyTypedId(Template.String, "string-efcore", "string-dapper", "string-newtonsoftjson")]
56-
partial struct ConvertersStringId2 { }
56+
internal partial struct ConvertersStringId2 { }
5757

5858
[StronglyTypedId("nullablestring-full")]
59-
partial struct NullableStringId { }
59+
internal partial struct NullableStringId { }
6060

61-
public partial class SomeType<T> where T : new()
61+
internal partial class SomeType<T> where T : new()
6262
{
63-
public partial record struct NestedType<TKey, TValue>
63+
internal partial record struct NestedType<TKey, TValue>
6464
{
65-
public partial struct MoreNesting
65+
internal partial struct MoreNesting
6666
{
6767
[StronglyTypedId]
68-
public readonly partial struct VeryNestedId
68+
internal readonly partial struct VeryNestedId
6969
{
7070
}
7171
}

0 commit comments

Comments
 (0)