-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature-source-generators'
- Loading branch information
Showing
45 changed files
with
655 additions
and
152 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
Weave.Tests.Generated/ConfigTest/AbsentConfig/TestAbsentConfig.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@namespace Weave.Tests.Generated.ConfigTest.AbsentConfig | ||
@accessibility public | ||
Hello, world! |
1 change: 1 addition & 0 deletions
1
Weave.Tests.Generated/ConfigTest/CompiledConfig/TestCompiledConfig.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, world! |
2 changes: 2 additions & 0 deletions
2
Weave.Tests.Generated/ConfigTest/CompiledConfig/_config.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@namespace Weave.Tests.Generated.ConfigTest.CompiledConfig | ||
@accessibility public |
1 change: 1 addition & 0 deletions
1
Weave.Tests.Generated/ConfigTest/GeneratedConfig/TestGeneratedConfig.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, world! |
2 changes: 2 additions & 0 deletions
2
Weave.Tests.Generated/ConfigTest/GeneratedConfig/_config.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@namespace Weave.Tests.Generated.ConfigTest.GeneratedConfig | ||
@accessibility public |
1 change: 1 addition & 0 deletions
1
Weave.Tests.Generated/ConfigTest/LegacyCompiledConfig/LegacyCompiledConfig.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, world! |
2 changes: 2 additions & 0 deletions
2
Weave.Tests.Generated/ConfigTest/LegacyCompiledConfig/_config.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@namespace Weave.Tests.Generated.ConfigTest.LegacyCompiledConfig | ||
@accessibility public |
1 change: 1 addition & 0 deletions
1
Weave.Tests.Generated/ConfigTest/LegacyGeneratedConfig/LegacyGeneratedConfig.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, world! |
2 changes: 2 additions & 0 deletions
2
Weave.Tests.Generated/ConfigTest/LegacyGeneratedConfig/_config.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@namespace Weave.Tests.Generated.ConfigTest.LegacyGeneratedConfig | ||
@accessibility public |
1 change: 1 addition & 0 deletions
1
Weave.Tests.Generated/ConfigTest/NoneConfig/TestNoneConfig.weave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@namespace Weave.Tests.Generated.ConfigTest.NoneConfig | ||
@accessibility public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// <auto-generated /> | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Weave.Tests")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Pegasus" Version="4.2.0-alpha0009" GeneratePathProperty="true" PrivateAssets="all" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Weave\Weave.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" SetTargetFramework="TargetFramework=netstandard2.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<WeaveTemplate Include="ConfigTest\AbsentConfig\TestAbsentConfig.weave" /> | ||
<None Remove="ConfigTest\CompiledConfig\_config.weave" /> | ||
<WeaveTemplate Include="ConfigTest\CompiledConfig\_config.weave"> | ||
<UseSourceGeneration>false</UseSourceGeneration> | ||
</WeaveTemplate> | ||
<None Remove="ConfigTest\CompiledConfig\TestCompiledConfig.weave" /> | ||
<WeaveTemplate Include="ConfigTest\CompiledConfig\TestCompiledConfig.weave" /> | ||
<None Remove="ConfigTest\GeneratedConfig\_config.weave" /> | ||
<WeaveTemplate Include="ConfigTest\GeneratedConfig\_config.weave" /> | ||
<None Remove="ConfigTest\GeneratedConfig\TestGeneratedConfig.weave" /> | ||
<WeaveTemplate Include="ConfigTest\GeneratedConfig\TestGeneratedConfig.weave" /> | ||
<WeaveTemplate Include="ConfigTest\LegacyCompiledConfig\_config.weave"> | ||
<UseSourceGeneration>false</UseSourceGeneration> | ||
</WeaveTemplate> | ||
<None Remove="ConfigTest\LegacyCompiledConfig\_config.weave" /> | ||
<None Remove="ConfigTest\LegacyCompiledConfig\LegacyCompiledConfig.weave" /> | ||
<WeaveTemplate Include="ConfigTest\LegacyCompiledConfig\LegacyCompiledConfig.weave"> | ||
<UseSourceGeneration>false</UseSourceGeneration> | ||
</WeaveTemplate> | ||
<None Remove="ConfigTest\LegacyGeneratedConfig\_config.weave" /> | ||
<WeaveTemplate Include="ConfigTest\LegacyGeneratedConfig\_config.weave" /> | ||
<None Remove="ConfigTest\LegacyGeneratedConfig\LegacyGeneratedConfig.weave" /> | ||
<WeaveTemplate Include="ConfigTest\LegacyGeneratedConfig\LegacyGeneratedConfig.weave"> | ||
<UseSourceGeneration>false</UseSourceGeneration> | ||
</WeaveTemplate> | ||
<None Remove="ConfigTest\NoneConfig\TestNoneConfig.weave" /> | ||
<WeaveTemplate Include="ConfigTest\NoneConfig\TestNoneConfig.weave" /> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn> | ||
</PropertyGroup> | ||
<Import Project="..\Weave\bin\$(Configuration)\Weave.targets" /> | ||
<Target Name="GetDependencyTargetPaths"> | ||
<ItemGroup> | ||
<TargetPathWithTargetPlatformMoniker Include="$(PKGPegasus)\lib\netstandard2.0\Pegasus.Common.dll" IncludeRuntimeDependency="false" /> | ||
</ItemGroup> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information. | ||
|
||
namespace Weave.Tests.IntegrationTests | ||
{ | ||
using System; | ||
using System.IO; | ||
using Xunit; | ||
|
||
public class ConfigTests | ||
{ | ||
private static readonly string ExpectedConfigOutput = ""; | ||
private static readonly string ExpectedTemplateOutput = $"Hello, world!{Environment.NewLine}"; | ||
|
||
[Fact] | ||
public void AbsentConfig() | ||
{ | ||
TestHelper( | ||
Generated.ConfigTest.AbsentConfig.Templates.RenderTestAbsentConfig, ExpectedTemplateOutput); | ||
} | ||
|
||
[Fact] | ||
public void CompiledConfig() | ||
{ | ||
TestHelper( | ||
(Generated.ConfigTest.CompiledConfig.Templates.Render_config, ExpectedConfigOutput), | ||
(Generated.ConfigTest.CompiledConfig.Templates.RenderTestCompiledConfig, ExpectedTemplateOutput)); | ||
} | ||
|
||
[Fact] | ||
public void GeneratedConfig() | ||
{ | ||
TestHelper( | ||
(Generated.ConfigTest.GeneratedConfig.Templates.Render_config, ExpectedConfigOutput), | ||
(Generated.ConfigTest.GeneratedConfig.Templates.RenderTestGeneratedConfig, ExpectedTemplateOutput)); | ||
} | ||
|
||
[Fact] | ||
public void LegacyCompiledConfig() | ||
{ | ||
TestHelper( | ||
(Generated.ConfigTest.LegacyCompiledConfig.Templates.Render_config, ExpectedConfigOutput), | ||
(Generated.ConfigTest.LegacyCompiledConfig.Templates.RenderLegacyCompiledConfig, ExpectedTemplateOutput)); | ||
} | ||
|
||
[Fact] | ||
public void LegacyGeneratedConfig() | ||
{ | ||
TestHelper( | ||
(Generated.ConfigTest.LegacyGeneratedConfig.Templates.Render_config, ExpectedConfigOutput), | ||
(Generated.ConfigTest.LegacyGeneratedConfig.Templates.RenderLegacyGeneratedConfig, ExpectedTemplateOutput)); | ||
} | ||
|
||
[Fact] | ||
public void NoneConfig() | ||
{ | ||
TestHelper( | ||
Generated.ConfigTest.NoneConfig.Templates.RenderTestNoneConfig, ExpectedTemplateOutput); | ||
} | ||
|
||
private static void TestHelper(params (Action<dynamic, TextWriter, string> render, string expected)[] tests) | ||
{ | ||
foreach (var (render, expected) in tests) | ||
{ | ||
TestHelper(render, expected); | ||
} | ||
} | ||
|
||
private static void TestHelper(Action<dynamic, TextWriter, string> render, string expected) | ||
{ | ||
var output = TestHelper(render); | ||
Assert.Equal(expected, output); | ||
} | ||
|
||
private static string TestHelper(Action<dynamic, TextWriter, string> render) | ||
{ | ||
var writer = new StringWriter(); | ||
render(null, writer, null); | ||
return writer.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.