Skip to content

Commit

Permalink
configure for unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Nov 2, 2022
1 parent ec668a4 commit a5ec759
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down
7 changes: 6 additions & 1 deletion src/MemoryPack.Generator.Roslyn3/MemoryPackGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public void Execute(GeneratorExecutionContext context)
var compiation = context.Compilation;
var generateContext = new GeneratorContext(context);

if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.MemoryPackGenerator_DebugNonUnityMode", out var nonUnity))
{
generateContext.IsForUnity = !bool.Parse(nonUnity);
}

foreach (var syntax in receiver.ClassDeclarations)
{
Generate(syntax, compiation, logPath, generateContext);
Expand Down Expand Up @@ -82,7 +87,7 @@ public GeneratorContext(GeneratorExecutionContext context)

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

public bool IsForUnity => true;
public bool IsForUnity { get; set; } = true;

public void AddSource(string hintName, string source)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"MemoryPack.Generator.Roslyn3.11": {
"commandName": "DebugRoslynComponent",
"targetProject": "..\\..\\sandbox\\SandboxNet6\\SandboxNet6.csproj"
"targetProject": "..\\..\\tests\\MemoryPack.Tests.Roslyn3\\MemoryPack.Tests.Roslyn3.csproj"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<CompilerVisibleProperty Include="MemoryPackGenerator_DebugNonUnityMode" />
</ItemGroup>
<PropertyGroup>
<MemoryPackGenerator_DebugNonUnityMode>true</MemoryPackGenerator_DebugNonUnityMode>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MemoryPack.Core\MemoryPack.Core.csproj" />
<ProjectReference Include="..\..\src\MemoryPack.Generator.Roslyn3\MemoryPack.Generator.Roslyn3.csproj" />
Expand Down

0 comments on commit a5ec759

Please sign in to comment.