Skip to content

Commit a5ec759

Browse files
committed
configure for unit test
1 parent ec668a4 commit a5ec759

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/MemoryPack.Generator.Roslyn3/MemoryPack.Generator.Roslyn3.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>

src/MemoryPack.Generator.Roslyn3/MemoryPackGenerator.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public void Execute(GeneratorExecutionContext context)
3030
var compiation = context.Compilation;
3131
var generateContext = new GeneratorContext(context);
3232

33+
if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.MemoryPackGenerator_DebugNonUnityMode", out var nonUnity))
34+
{
35+
generateContext.IsForUnity = !bool.Parse(nonUnity);
36+
}
37+
3338
foreach (var syntax in receiver.ClassDeclarations)
3439
{
3540
Generate(syntax, compiation, logPath, generateContext);
@@ -82,7 +87,7 @@ public GeneratorContext(GeneratorExecutionContext context)
8287

8388
public bool IsNet7OrGreater => false; // No IncrementalGenerator is always not NET7
8489

85-
public bool IsForUnity => true;
90+
public bool IsForUnity { get; set; } = true;
8691

8792
public void AddSource(string hintName, string source)
8893
{

src/MemoryPack.Generator.Roslyn3/Properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"MemoryPack.Generator.Roslyn3.11": {
44
"commandName": "DebugRoslynComponent",
5-
"targetProject": "..\\..\\sandbox\\SandboxNet6\\SandboxNet6.csproj"
5+
"targetProject": "..\\..\\tests\\MemoryPack.Tests.Roslyn3\\MemoryPack.Tests.Roslyn3.csproj"
66
}
77
}
8-
}
8+
}

tests/MemoryPack.Tests.Roslyn3/MemoryPack.Tests.Roslyn3.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
</PackageReference>
2121
</ItemGroup>
2222

23+
<ItemGroup>
24+
<CompilerVisibleProperty Include="MemoryPackGenerator_DebugNonUnityMode" />
25+
</ItemGroup>
26+
<PropertyGroup>
27+
<MemoryPackGenerator_DebugNonUnityMode>true</MemoryPackGenerator_DebugNonUnityMode>
28+
</PropertyGroup>
29+
2330
<ItemGroup>
2431
<ProjectReference Include="..\..\src\MemoryPack.Core\MemoryPack.Core.csproj" />
2532
<ProjectReference Include="..\..\src\MemoryPack.Generator.Roslyn3\MemoryPack.Generator.Roslyn3.csproj" />

0 commit comments

Comments
 (0)