diff --git a/Weave.Tests.Generated/ConfigTest/AbsentConfig/TestAbsentConfig.weave b/Weave.Tests.Generated/ConfigTest/AbsentConfig/TestAbsentConfig.weave
new file mode 100644
index 0000000..68e7e0d
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/AbsentConfig/TestAbsentConfig.weave
@@ -0,0 +1,3 @@
+@namespace Weave.Tests.Generated.ConfigTest.AbsentConfig
+@accessibility public
+Hello, world!
diff --git a/Weave.Tests.Generated/ConfigTest/CompiledConfig/TestCompiledConfig.weave b/Weave.Tests.Generated/ConfigTest/CompiledConfig/TestCompiledConfig.weave
new file mode 100644
index 0000000..af5626b
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/CompiledConfig/TestCompiledConfig.weave
@@ -0,0 +1 @@
+Hello, world!
diff --git a/Weave.Tests.Generated/ConfigTest/CompiledConfig/_config.weave b/Weave.Tests.Generated/ConfigTest/CompiledConfig/_config.weave
new file mode 100644
index 0000000..578e6ff
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/CompiledConfig/_config.weave
@@ -0,0 +1,2 @@
+@namespace Weave.Tests.Generated.ConfigTest.CompiledConfig
+@accessibility public
diff --git a/Weave.Tests.Generated/ConfigTest/GeneratedConfig/TestGeneratedConfig.weave b/Weave.Tests.Generated/ConfigTest/GeneratedConfig/TestGeneratedConfig.weave
new file mode 100644
index 0000000..af5626b
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/GeneratedConfig/TestGeneratedConfig.weave
@@ -0,0 +1 @@
+Hello, world!
diff --git a/Weave.Tests.Generated/ConfigTest/GeneratedConfig/_config.weave b/Weave.Tests.Generated/ConfigTest/GeneratedConfig/_config.weave
new file mode 100644
index 0000000..881ce93
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/GeneratedConfig/_config.weave
@@ -0,0 +1,2 @@
+@namespace Weave.Tests.Generated.ConfigTest.GeneratedConfig
+@accessibility public
diff --git a/Weave.Tests.Generated/ConfigTest/LegacyCompiledConfig/LegacyCompiledConfig.weave b/Weave.Tests.Generated/ConfigTest/LegacyCompiledConfig/LegacyCompiledConfig.weave
new file mode 100644
index 0000000..af5626b
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/LegacyCompiledConfig/LegacyCompiledConfig.weave
@@ -0,0 +1 @@
+Hello, world!
diff --git a/Weave.Tests.Generated/ConfigTest/LegacyCompiledConfig/_config.weave b/Weave.Tests.Generated/ConfigTest/LegacyCompiledConfig/_config.weave
new file mode 100644
index 0000000..47323c9
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/LegacyCompiledConfig/_config.weave
@@ -0,0 +1,2 @@
+@namespace Weave.Tests.Generated.ConfigTest.LegacyCompiledConfig
+@accessibility public
diff --git a/Weave.Tests.Generated/ConfigTest/LegacyGeneratedConfig/LegacyGeneratedConfig.weave b/Weave.Tests.Generated/ConfigTest/LegacyGeneratedConfig/LegacyGeneratedConfig.weave
new file mode 100644
index 0000000..af5626b
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/LegacyGeneratedConfig/LegacyGeneratedConfig.weave
@@ -0,0 +1 @@
+Hello, world!
diff --git a/Weave.Tests.Generated/ConfigTest/LegacyGeneratedConfig/_config.weave b/Weave.Tests.Generated/ConfigTest/LegacyGeneratedConfig/_config.weave
new file mode 100644
index 0000000..dd8e00a
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/LegacyGeneratedConfig/_config.weave
@@ -0,0 +1,2 @@
+@namespace Weave.Tests.Generated.ConfigTest.LegacyGeneratedConfig
+@accessibility public
diff --git a/Weave.Tests.Generated/ConfigTest/NoneConfig/TestNoneConfig.weave b/Weave.Tests.Generated/ConfigTest/NoneConfig/TestNoneConfig.weave
new file mode 100644
index 0000000..af5626b
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/NoneConfig/TestNoneConfig.weave
@@ -0,0 +1 @@
+Hello, world!
diff --git a/Weave.Tests.Generated/ConfigTest/NoneConfig/_config.weave b/Weave.Tests.Generated/ConfigTest/NoneConfig/_config.weave
new file mode 100644
index 0000000..35ffc3f
--- /dev/null
+++ b/Weave.Tests.Generated/ConfigTest/NoneConfig/_config.weave
@@ -0,0 +1,2 @@
+@namespace Weave.Tests.Generated.ConfigTest.NoneConfig
+@accessibility public
diff --git a/Weave.Tests.Generated/Properties/AssemblyInfo.cs b/Weave.Tests.Generated/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9fd3dba
--- /dev/null
+++ b/Weave.Tests.Generated/Properties/AssemblyInfo.cs
@@ -0,0 +1,4 @@
+//
+using System.Runtime.CompilerServices;
+
+[assembly: InternalsVisibleTo("Weave.Tests")]
diff --git a/Weave.Tests.Generated/Weave.Tests.Generated.csproj b/Weave.Tests.Generated/Weave.Tests.Generated.csproj
new file mode 100644
index 0000000..f63bfaf
--- /dev/null
+++ b/Weave.Tests.Generated/Weave.Tests.Generated.csproj
@@ -0,0 +1,51 @@
+
+
+
+ net6.0
+ true
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+ false
+
+
+
+
+
+ false
+
+
+
+
+
+ $(GetTargetPathDependsOn);GetDependencyTargetPaths
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Weave.Tests/GeneratedCode/ConfigTests.cs b/Weave.Tests/GeneratedCode/ConfigTests.cs
new file mode 100644
index 0000000..44a5c65
--- /dev/null
+++ b/Weave.Tests/GeneratedCode/ConfigTests.cs
@@ -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 render, string expected)[] tests)
+ {
+ foreach (var (render, expected) in tests)
+ {
+ TestHelper(render, expected);
+ }
+ }
+
+ private static void TestHelper(Action render, string expected)
+ {
+ var output = TestHelper(render);
+ Assert.Equal(expected, output);
+ }
+
+ private static string TestHelper(Action render)
+ {
+ var writer = new StringWriter();
+ render(null, writer, null);
+ return writer.ToString();
+ }
+ }
+}
diff --git a/Weave.Tests/Weave.Tests.csproj b/Weave.Tests/Weave.Tests.csproj
index aa568e2..560c262 100644
--- a/Weave.Tests/Weave.Tests.csproj
+++ b/Weave.Tests/Weave.Tests.csproj
@@ -1,12 +1,11 @@
-
+
Weave.Tests.ruleset
Full
false
- net461
-
+ net6.0
@@ -14,18 +13,26 @@
-
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
-
-
+
+
+
+
+
+
+
diff --git a/Weave.sln b/Weave.sln
index 333de6d..33af191 100644
--- a/Weave.sln
+++ b/Weave.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27428.2037
+# Visual Studio Version 17
+VisualStudioVersion = 17.7.34003.232
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D0E57E35-59EE-487F-852B-864CFC020B46}"
ProjectSection(SolutionItems) = preProject
@@ -25,6 +25,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Weave", "Weave\Weave.csproj
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Weave.Tests", "Weave.Tests\Weave.Tests.csproj", "{F2ECD1F3-7200-4FEA-A456-873F1749E008}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Weave.Tests.Generated", "Weave.Tests.Generated\Weave.Tests.Generated.csproj", "{46D94595-1DBC-49C6-9D77-A1E5E307E21E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +41,10 @@ Global
{F2ECD1F3-7200-4FEA-A456-873F1749E008}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2ECD1F3-7200-4FEA-A456-873F1749E008}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2ECD1F3-7200-4FEA-A456-873F1749E008}.Release|Any CPU.Build.0 = Release|Any CPU
+ {46D94595-1DBC-49C6-9D77-A1E5E307E21E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {46D94595-1DBC-49C6-9D77-A1E5E307E21E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {46D94595-1DBC-49C6-9D77-A1E5E307E21E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {46D94595-1DBC-49C6-9D77-A1E5E307E21E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Weave/CompileManager.cs b/Weave/CompileManager.cs
index a138dd1..fbff68d 100644
--- a/Weave/CompileManager.cs
+++ b/Weave/CompileManager.cs
@@ -1,4 +1,4 @@
-// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
+// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
namespace Weave
{
@@ -13,29 +13,64 @@ namespace Weave
internal static class CompileManager
{
- public static void CompileFile(string inputFile, string outputFile, Action logError)
- {
- outputFile = outputFile ?? inputFile + ".cs";
- var configFile = Path.Combine(Path.GetDirectoryName(inputFile), "_config.weave");
+ public static readonly string ConfigFileName = "_config.weave";
- var template = ParseTemplate(inputFile, logError);
- if (template == null)
+ public static CompileResult ParseTemplate(string inputFileContents, string inputFileName)
+ {
+ var parser = new WeaveParser();
+ var compileResult = new CompileResult();
+ try
{
- return;
+ compileResult.Result = parser.Parse(inputFileContents, fileName: inputFileName);
}
-
- if (File.Exists(configFile))
+ catch (FormatException ex)
{
- var config = ParseTemplate(configFile, logError);
- if (config == null)
+ var cursor = ex.Data["cursor"] as Cursor;
+ if (cursor != null && Regex.IsMatch(ex.Message, @"^WEAVE\d+:"))
+ {
+ var parts = ex.Message.Split(new[] { ':' }, 2);
+ compileResult.Errors.Add(new CompilerError(cursor.FileName, cursor.Line, cursor.Column, parts[0], parts[1]));
+ }
+ else
{
- return;
+ throw;
}
+ }
+
+ return compileResult;
+ }
+
+ public static CompileResult CombineTemplateConfig(CompileResult template, CompileResult config)
+ {
+ if (config == null || (config.Result == null && config.Errors.Count == 0))
+ {
+ return template;
+ }
+
+ var result = new CompileResult
+ {
+ Result = new Template(template.Result, config.Result),
+ };
+
+ foreach (var error in config.Errors)
+ {
+ result.Errors.Add(error);
+ }
- template = new Template(template, config);
+ foreach (var error in result.Errors)
+ {
+ result.Errors.Add(error);
}
- var result = WeaveCompiler.Compile(template);
+ return result;
+ }
+
+#if !NETSTANDARD
+ public static void CompileFile(string inputFileName, string outputFileName, Action logError)
+ {
+ inputFileName = Path.GetFullPath(inputFileName);
+ outputFileName = Path.GetFullPath(outputFileName ?? inputFileName + ".cs");
+ var result = CompileFile(inputFileName, outputFileName);
var hadFatal = false;
foreach (var error in result.Errors)
@@ -46,31 +81,43 @@ public static void CompileFile(string inputFile, string outputFile, Action logError)
+ private static CompileResult CompileFile(string inputFileName, string outputFileName)
{
- var subject = File.ReadAllText(inputFile);
- var parser = new WeaveParser();
- try
- {
- return parser.Parse(subject, fileName: inputFile);
- }
- catch (FormatException ex)
+ var inputResult = ParseTemplateInternal(inputFileName, outputFileName);
+ var inputTemplate = inputResult.Result;
+ if (inputTemplate == null)
{
- var cursor = ex.Data["cursor"] as Cursor;
- if (cursor != null && Regex.IsMatch(ex.Message, @"^WEAVE\d+:"))
+ var errorResult = new CompileResult();
+ foreach (var error in inputResult.Errors)
{
- var parts = ex.Message.Split(new[] { ':' }, 2);
- logError(new CompilerError(cursor.FileName, cursor.Line, cursor.Column, parts[0], parts[1]));
- return null;
+ errorResult.Errors.Add(error);
}
- throw;
+ return errorResult;
}
+
+ return WeaveCompiler.Compile(inputTemplate);
+ }
+
+ private static CompileResult ParseTemplateInternal(string inputFileName, string outputFileName)
+ {
+ var relativePath = PathUtils.MakeRelative(outputFileName, inputFileName);
+ var templateResult = ParseTemplate(File.ReadAllText(inputFileName), relativePath);
+
+ var configFileName = Path.Combine(Path.GetDirectoryName(inputFileName), ConfigFileName);
+ if (File.Exists(configFileName))
+ {
+ var configResult = ParseTemplate(File.ReadAllText(configFileName), PathUtils.MakeRelative(outputFileName, configFileName));
+ templateResult = CombineTemplateConfig(templateResult, configResult);
+ }
+
+ return templateResult;
}
+#endif
}
}
diff --git a/Weave/Compiler/CompileResult.cs b/Weave/Compiler/CompileResult.cs
index 87334ea..ed80dfe 100644
--- a/Weave/Compiler/CompileResult.cs
+++ b/Weave/Compiler/CompileResult.cs
@@ -1,53 +1,19 @@
-// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
+// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
namespace Weave.Compiler
{
- using System;
- using System.CodeDom.Compiler;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq.Expressions;
- using Pegasus.Common;
-
///
/// Encapsulates the results and errors from the compilation of a Weave template.
///
- public class CompileResult
+ public class CompileResult : CompileResult
{
- ///
- /// Initializes a new instance of the class.
- ///
- public CompileResult()
- {
- this.Errors = new List();
- }
-
///
/// Gets or sets the code resulting from compilation.
///
- public string Code { get; set; }
-
- ///
- /// Gets the collection of errors that occurred during compilation.
- ///
- public IList Errors { get; private set; }
-
- internal void AddError(Cursor cursor, Expression> error, params object[] args)
- {
- this.AddCompilerError(cursor, error, args, isWarning: false);
- }
-
- internal void AddWarning(Cursor cursor, Expression> error, params object[] args)
- {
- this.AddCompilerError(cursor, error, args, isWarning: true);
- }
-
- private void AddCompilerError(Cursor cursor, Expression> error, object[] args, bool isWarning)
+ public string Code
{
- var errorId = ((MemberExpression)error.Body).Member.Name.Split('_')[0];
- var errorFormat = error.Compile()();
- var errorText = string.Format(CultureInfo.CurrentCulture, errorFormat, args);
- this.Errors.Add(new CompilerError(cursor.FileName, cursor.Line, cursor.Column, errorId, errorText) { IsWarning = isWarning });
+ get => this.Result;
+ set => this.Result = value;
}
}
}
diff --git a/Weave/Compiler/CompileResult{T}.cs b/Weave/Compiler/CompileResult{T}.cs
new file mode 100644
index 0000000..b55df48
--- /dev/null
+++ b/Weave/Compiler/CompileResult{T}.cs
@@ -0,0 +1,56 @@
+// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
+
+namespace Weave.Compiler
+{
+ using System;
+ using System.CodeDom.Compiler;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Globalization;
+ using System.Linq.Expressions;
+ using Pegasus.Common;
+
+ ///
+ /// Encapsulates the results and errors from the compilation of a Weave resource.
+ ///
+ /// The type resulting from compilation.
+ public class CompileResult
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public CompileResult()
+ {
+ this.Errors = new List();
+ }
+
+ ///
+ /// Gets or sets the value resulting from compilation.
+ ///
+ public T Result { get; set; }
+
+ ///
+ /// Gets the collection of errors that occurred during compilation.
+ ///
+ public IList Errors { get; private set; }
+
+ internal void AddError(Cursor cursor, Expression> error, params object[] args)
+ {
+ this.AddCompilerError(cursor, error, args, isWarning: false);
+ }
+
+ internal void AddWarning(Cursor cursor, Expression> error, params object[] args)
+ {
+ this.AddCompilerError(cursor, error, args, isWarning: true);
+ }
+
+ [SuppressMessage("Usage", "RS1035:Do not use APIs banned for analyzers", Justification = "https://github.com/dotnet/roslyn/issues/71094")]
+ private void AddCompilerError(Cursor cursor, Expression> error, object[] args, bool isWarning)
+ {
+ var errorId = ((MemberExpression)error.Body).Member.Name.Split('_')[0];
+ var errorFormat = error.Compile()();
+ var errorText = string.Format(CultureInfo.CurrentCulture, errorFormat, args);
+ this.Errors.Add(new CompilerError(cursor.FileName, cursor.Line, cursor.Column, errorId, errorText) { IsWarning = isWarning });
+ }
+ }
+}
diff --git a/Weave/Compiler/TemplateWalker.cs b/Weave/Compiler/TemplateWalker.cs
index e6d6a7c..11835f8 100644
--- a/Weave/Compiler/TemplateWalker.cs
+++ b/Weave/Compiler/TemplateWalker.cs
@@ -1,9 +1,10 @@
-// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
+// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
namespace Weave.Compiler
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Weave.Expressions;
@@ -42,6 +43,7 @@ public virtual void WalkEchoTag(EchoTag echoTag)
{
}
+ [SuppressMessage("Usage", "RS1035:Do not use APIs banned for analyzers", Justification = "This is a fall-back mainly intended for tests. It is not a code path that is expected to be hit.")]
public virtual void WalkElement(Element element)
{
if (element is BodyElement bodyElement)
diff --git a/Weave/Compiler/Templates/BodyElement.weave.cs b/Weave/Compiler/Templates/BodyElement.weave.cs
index 1f31220..2b4c703 100644
--- a/Weave/Compiler/Templates/BodyElement.weave.cs
+++ b/Weave/Compiler/Templates/BodyElement.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderBodyElement
diff --git a/Weave/Compiler/Templates/Branch.weave.cs b/Weave/Compiler/Templates/Branch.weave.cs
index 100db1e..df32fa3 100644
--- a/Weave/Compiler/Templates/Branch.weave.cs
+++ b/Weave/Compiler/Templates/Branch.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderBranch
diff --git a/Weave/Compiler/Templates/Code.weave b/Weave/Compiler/Templates/Code.weave
index 46aed1d..813a2c4 100644
--- a/Weave/Compiler/Templates/Code.weave
+++ b/Weave/Compiler/Templates/Code.weave
@@ -1,8 +1,8 @@
-@model object
+@model object
{{ var span = model as SourceSpan; }}
{{if span != null}}
- #line {{= span.Start.Line }} "{{= Path.GetFileName(span.Start.FileName) }}"{{ writer.WriteLine(); }}{{= new string(' ', span.Start.Column - 1) }}{{= span.Value }}
+ #line {{= span.Start.Line }} "{{= span.Start.FileName }}"{{ writer.WriteLine(); }}{{= new string(' ', span.Start.Column - 1) }}{{= span.Value }}
#line default
{{else}}
{{ var value = model.ToString(); }}
diff --git a/Weave/Compiler/Templates/Code.weave.cs b/Weave/Compiler/Templates/Code.weave.cs
index 8c10e9b..4baf446 100644
--- a/Weave/Compiler/Templates/Code.weave.cs
+++ b/Weave/Compiler/Templates/Code.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderCode
@@ -60,23 +60,23 @@ partial class
writer.Write(" \"");
writer.Write(
#line 5 "Code.weave"
- Path.GetFileName(span.Start.FileName)
+ span.Start.FileName
#line default
);
writer.Write("\"");
var __temp1 = indentation;
#line 5 "Code.weave"
- writer.WriteLine();
+ writer.WriteLine();
#line default
indentation = __temp1;
writer.Write(
#line 5 "Code.weave"
- new string(' ', span.Start.Column - 1)
+ new string(' ', span.Start.Column - 1)
#line default
);
writer.Write(
#line 5 "Code.weave"
- span.Value
+ span.Value
#line default
);
writer.WriteLine();
diff --git a/Weave/Compiler/Templates/CodeElement.weave.cs b/Weave/Compiler/Templates/CodeElement.weave.cs
index cd8944b..50ae3ea 100644
--- a/Weave/Compiler/Templates/CodeElement.weave.cs
+++ b/Weave/Compiler/Templates/CodeElement.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderCodeElement
diff --git a/Weave/Compiler/Templates/EachElement.weave.cs b/Weave/Compiler/Templates/EachElement.weave.cs
index c6a3b31..19ddc59 100644
--- a/Weave/Compiler/Templates/EachElement.weave.cs
+++ b/Weave/Compiler/Templates/EachElement.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderEachElement
diff --git a/Weave/Compiler/Templates/EchoTag.weave.cs b/Weave/Compiler/Templates/EchoTag.weave.cs
index c3b3876..3ddb228 100644
--- a/Weave/Compiler/Templates/EchoTag.weave.cs
+++ b/Weave/Compiler/Templates/EchoTag.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderEchoTag
diff --git a/Weave/Compiler/Templates/IfElement.weave.cs b/Weave/Compiler/Templates/IfElement.weave.cs
index d419232..b0f12bd 100644
--- a/Weave/Compiler/Templates/IfElement.weave.cs
+++ b/Weave/Compiler/Templates/IfElement.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderIfElement
diff --git a/Weave/Compiler/Templates/Indentation.weave.cs b/Weave/Compiler/Templates/Indentation.weave.cs
index 475a17a..1105416 100644
--- a/Weave/Compiler/Templates/Indentation.weave.cs
+++ b/Weave/Compiler/Templates/Indentation.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
#line 1 "Indentation.weave"
diff --git a/Weave/Compiler/Templates/IndentationElement.weave.cs b/Weave/Compiler/Templates/IndentationElement.weave.cs
index 4c2657e..02e71ed 100644
--- a/Weave/Compiler/Templates/IndentationElement.weave.cs
+++ b/Weave/Compiler/Templates/IndentationElement.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderIndentationElement
diff --git a/Weave/Compiler/Templates/NewLineElement.weave.cs b/Weave/Compiler/Templates/NewLineElement.weave.cs
index bcec441..d2d2291 100644
--- a/Weave/Compiler/Templates/NewLineElement.weave.cs
+++ b/Weave/Compiler/Templates/NewLineElement.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderNewLineElement
diff --git a/Weave/Compiler/Templates/RenderElement.weave.cs b/Weave/Compiler/Templates/RenderElement.weave.cs
index 208a5f0..78b5289 100644
--- a/Weave/Compiler/Templates/RenderElement.weave.cs
+++ b/Weave/Compiler/Templates/RenderElement.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderRenderElement
diff --git a/Weave/Compiler/Templates/Template.weave.cs b/Weave/Compiler/Templates/Template.weave.cs
index fb593e5..581ea02 100644
--- a/Weave/Compiler/Templates/Template.weave.cs
+++ b/Weave/Compiler/Templates/Template.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -33,7 +33,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderTemplate
diff --git a/Weave/Compiler/Templates/TextElement.weave.cs b/Weave/Compiler/Templates/TextElement.weave.cs
index a842fb2..4571ab2 100644
--- a/Weave/Compiler/Templates/TextElement.weave.cs
+++ b/Weave/Compiler/Templates/TextElement.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderTextElement
diff --git a/Weave/Compiler/Templates/WrapIfElement.weave.cs b/Weave/Compiler/Templates/WrapIfElement.weave.cs
index 70b2702..e355c37 100644
--- a/Weave/Compiler/Templates/WrapIfElement.weave.cs
+++ b/Weave/Compiler/Templates/WrapIfElement.weave.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// This code was generated by Weave 1.2.1.0
+// This code was generated by Weave 2.0.1.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -23,7 +23,7 @@
partial class
Templates
{
- [System.CodeDom.Compiler.GeneratedCode("Weave", "1.2.1.0")]
+ [System.CodeDom.Compiler.GeneratedCode("Weave", "2.0.1.0")]
public
void
RenderWrapIfElement
@@ -50,10 +50,10 @@ partial class
#line default
indentation = __temp0;
writer.Write(indentation);
- writer.Write("var ");
+ writer.Write("bool ");
writer.Write(
#line 9 "WrapIfElement.weave"
- flag
+ flag
#line default
);
writer.Write(" =");
@@ -176,7 +176,7 @@ partial class
}
writer.WriteLine();
indentation = __originalIndentation;
- var __flag0 =
+ bool __flag0 =
#line 29 "WrapIfElement.weave"
alterIndentation
#line default
diff --git a/Weave/Expressions/Template.cs b/Weave/Expressions/Template.cs
index c498e26..8dcd646 100644
--- a/Weave/Expressions/Template.cs
+++ b/Weave/Expressions/Template.cs
@@ -1,4 +1,4 @@
-// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
+// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
namespace Weave.Expressions
{
@@ -58,6 +58,7 @@ public Template(Template template, Template config)
throw new ArgumentNullException(nameof(template));
}
+ // TODO: For recursive config files, should we add a safety check here?
this.config = config;
this.start = template.start;
this.settings = template.settings;
diff --git a/Weave/GenerateWeaveSources.cs b/Weave/GenerateWeaveSources.cs
new file mode 100644
index 0000000..69249f3
--- /dev/null
+++ b/Weave/GenerateWeaveSources.cs
@@ -0,0 +1,159 @@
+// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
+
+namespace Weave
+{
+ using System.CodeDom.Compiler;
+ using System.IO;
+ using System.Linq;
+ using System.Reflection;
+ using Microsoft.CodeAnalysis;
+ using Microsoft.CodeAnalysis.Diagnostics;
+ using Microsoft.CodeAnalysis.Text;
+ using Weave.Compiler;
+ using WeaveTemplateItem = (string path, Microsoft.CodeAnalysis.Text.SourceText text, bool useSourceGeneration, bool? configFileExists);
+
+ [Generator]
+ internal class GenerateWeaveSources : IIncrementalGenerator
+ {
+ private const string UseSourceGeneration = "build_metadata.WeaveTemplateGenerate.UseSourceGeneration";
+ private const string ConfigFileExists = "build_metadata.WeaveTemplateGenerate.ConfigFileExists";
+ private const string ProjectDir = "build_property.projectdir";
+ private const string GeneratedOutputPath = "build_property.compilergeneratedfilesoutputpath";
+
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ var weaveFiles = context.AdditionalTextsProvider
+ .Combine(context.AnalyzerConfigOptionsProvider)
+ .Select((p, ct) =>
+ {
+ var options = p.Right.GetOptions(p.Left);
+ return new
+ {
+ AdditionalText = p.Left,
+ ConfigOptions = options,
+ UseSourceGeneration = GetBooleanOption(options, UseSourceGeneration),
+ };
+ })
+ .Where(p => p.UseSourceGeneration != null)
+ .Select((p, ct) => (
+ path: p.AdditionalText.Path,
+ text: p.AdditionalText.GetText(ct),
+ useSourceGeneration: p.UseSourceGeneration.Value,
+ configFileExists: GetBooleanOption(p.ConfigOptions, ConfigFileExists)));
+
+ // TODO: Go ahead and compile _config files, but make sure that we emit a compile warning (using a pragma directive and a [Deprecated] attribute) about future removal.
+ var sourceGeneratedFiles = weaveFiles
+ .Where(p => p.useSourceGeneration);
+ var allConfigFiles = weaveFiles
+ .Where(p => Path.GetFileName(p.path) == CompileManager.ConfigFileName) // This is case sensitive, but case is controlled by the .targets file.
+ .Collect();
+
+ var outputPath = context.AnalyzerConfigOptionsProvider
+ .Select((p, ct) =>
+ {
+ p.GlobalOptions.TryGetValue(ProjectDir, out var root);
+ p.GlobalOptions.TryGetValue(GeneratedOutputPath, out var generated);
+ var assembly = Assembly.GetExecutingAssembly().FullName;
+ var generator = typeof(GenerateWeaveSources).FullName;
+ return Path.GetFullPath(Path.Combine(root, generated, assembly, generator));
+ });
+
+ var filesWithConfigs = sourceGeneratedFiles
+ .Combine(allConfigFiles)
+ .Combine(outputPath)
+ .Select((p, ct) =>
+ {
+ var source = p.Left.Left;
+ var allConfigs = p.Left.Right;
+ var outputPath = p.Right;
+ var configPath = Path.Combine(Path.GetDirectoryName(source.path), CompileManager.ConfigFileName);
+ return new
+ {
+ Source = source,
+ Config = source.configFileExists ?? true
+ ? allConfigs.Where(f => f.path == configPath).SingleOrDefault() // While case sensitivity can vary by filesystem, this mechanism matches the approach in the MSBuild file and should give consistent results.
+ : default(WeaveTemplateItem?),
+ OutputPath = outputPath,
+ };
+ });
+
+ context.RegisterSourceOutput(
+ filesWithConfigs,
+ (context, pair) => CompileWeaveFile(context, pair.Source, pair.Config, pair.OutputPath));
+ }
+
+ private static bool? GetBooleanOption(AnalyzerConfigOptions options, string key) =>
+ options.TryGetValue(key, out var value) && bool.TryParse(value, out var result)
+ ? result
+ : null;
+
+ private static void CompileWeaveFile(SourceProductionContext context, WeaveTemplateItem template, WeaveTemplateItem? config, string outputPath)
+ {
+ if (template.text != null)
+ {
+ var relativePath = PathUtils.MakeRelative(outputPath, template.path);
+ var templateResult = CompileManager.ParseTemplate(template.text.ToString(), relativePath);
+ if (template.configFileExists ?? (config != null))
+ {
+ if (config is WeaveTemplateItem configItem)
+ {
+ var configResult = CompileManager.ParseTemplate(configItem.text.ToString(), PathUtils.MakeRelative(outputPath, configItem.path));
+ templateResult = CompileManager.CombineTemplateConfig(templateResult, configResult);
+ }
+ else
+ {
+ // TODO: Report a fatal error about failing to locate the config in additional items.
+ ReportErrors(context, templateResult);
+ return;
+ }
+ }
+
+ var hadFatal = ReportErrors(context, templateResult);
+ if (hadFatal)
+ {
+ return;
+ }
+
+ var compileResult = WeaveCompiler.Compile(templateResult.Result);
+ hadFatal = ReportErrors(context, compileResult);
+ if (hadFatal)
+ {
+ return;
+ }
+
+ context.AddSource(PathUtils.EncodePathAsFilename(relativePath) + ".g.cs", compileResult.Code);
+ }
+ }
+
+ private static bool ReportErrors(SourceProductionContext context, CompileResult result)
+ {
+ var hadFatal = false;
+ foreach (var error in result.Errors)
+ {
+ hadFatal |= !error.IsWarning;
+ context.ReportDiagnostic(ConvertToDiagnostic(error));
+ }
+
+ return hadFatal;
+ }
+
+ private static Diagnostic ConvertToDiagnostic(CompilerError error)
+ {
+ var (severity, level) = error.IsWarning
+ ? (DiagnosticSeverity.Warning, 1)
+ : (DiagnosticSeverity.Error, 0);
+
+ var linePosition = new LinePosition(error.Line - 1, error.Column - 1);
+
+ return Diagnostic.Create(
+ error.ErrorNumber,
+ nameof(Weave),
+ error.ErrorText,
+ severity,
+ severity,
+ isEnabledByDefault: true,
+ warningLevel: level,
+ location: Location.Create(error.FileName, new TextSpan(0, 0), new LinePositionSpan(linePosition, linePosition)));
+ }
+ }
+}
diff --git a/Weave/Parser/WeaveParser.peg b/Weave/Parser/WeaveParser.peg
index 9c3c425..ccaab22 100644
--- a/Weave/Parser/WeaveParser.peg
+++ b/Weave/Parser/WeaveParser.peg
@@ -1,4 +1,4 @@
-@namespace Weave.Parser
+@namespace Weave.Parser
@classname WeaveParser
@using System.Globalization
@using System.Linq
@@ -14,7 +14,11 @@
}
template
- = settings:setting* EOL? elements:lines (EOF / unexpected:. #ERROR{ "WEAVE0007:" + string.Format(CultureInfo.CurrentCulture, Resources.WEAVE0007_UNEXPECTED_CHARACTER, unexpected) }) {
+ = settings:setting* EOL? elements:lines (EOF / unexpected:. #ERROR{{
+#pragma warning disable RS1035 // Do not use APIs banned for analyzers https://github.com/dotnet/roslyn/issues/71094
+ return "WEAVE0007:" + string.Format(CultureInfo.CurrentCulture, Resources.WEAVE0007_UNEXPECTED_CHARACTER, unexpected);
+#pragma warning restore RS1035 // Do not use APIs banned for analyzers
+ }}) {
new Template(settingsStart, settings, elementsStart, elements, elementsEnd)
}
diff --git a/Weave/PathUtils.cs b/Weave/PathUtils.cs
new file mode 100644
index 0000000..8cdf839
--- /dev/null
+++ b/Weave/PathUtils.cs
@@ -0,0 +1,24 @@
+// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
+
+namespace Weave
+{
+ using System;
+ using System.IO;
+
+ internal static class PathUtils
+ {
+ public static string MakeRelative(string root, string path)
+ {
+ root = Path.GetFullPath(root);
+ var fullFilePath = Path.GetFullPath(Path.Combine(root, path));
+ var relativeUri = new Uri(root).MakeRelativeUri(new Uri(fullFilePath));
+ var relativePath = Uri.UnescapeDataString(relativeUri.ToString()).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
+ return relativePath;
+ }
+
+ public static string EncodePathAsFilename(string path) =>
+ Uri.EscapeDataString(path)
+ .Replace("_", "__")
+ .Replace("%", "_p");
+ }
+}
diff --git a/Weave/Program.cs b/Weave/Program.cs
index 5a591e5..a2c58f9 100644
--- a/Weave/Program.cs
+++ b/Weave/Program.cs
@@ -1,4 +1,4 @@
-// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
+// Copyright © John Gietzen. All Rights Reserved. This source is subject to the MIT license. Please see license.md for more information.
namespace Weave
{
@@ -6,12 +6,20 @@ namespace Weave
internal class Program
{
- private static void Main(string[] args)
+ private static int Main(string[] args)
{
+#if NETSTANDARD
+ Console.WriteLine("The dotnet standard version of this application is intended to be used as a source generator. You may use the dotnet 4 or dotnet core version of this assembly to generate source code in a stand-alone way.");
+ return -1;
+#else
foreach (var arg in args)
{
CompileManager.CompileFile(arg, null, Console.WriteLine);
}
+
+ // TODO: Return -1 if any error was logged.
+ return 0;
+#endif
}
}
}
diff --git a/Weave/Properties/launchSettings.json b/Weave/Properties/launchSettings.json
new file mode 100644
index 0000000..e23d4be
--- /dev/null
+++ b/Weave/Properties/launchSettings.json
@@ -0,0 +1,13 @@
+{
+ "profiles": {
+ "Weave": {
+ "commandName": "Project",
+ "commandLineArgs": "Compiler\\Templates\\BodyElement.weave Compiler\\Templates\\Branch.weave Compiler\\Templates\\Code.weave Compiler\\Templates\\CodeElement.weave Compiler\\Templates\\EachElement.weave Compiler\\Templates\\EchoTag.weave Compiler\\Templates\\IfElement.weave Compiler\\Templates\\Indentation.weave Compiler\\Templates\\IndentationElement.weave Compiler\\Templates\\NewLineElement.weave Compiler\\Templates\\RenderElement.weave Compiler\\Templates\\Template.weave Compiler\\Templates\\TextElement.weave Compiler\\Templates\\WrapIfElement.weave",
+ "workingDirectory": "."
+ },
+ "Weave (source generator)": {
+ "commandName": "DebugRoslynComponent",
+ "targetProject": "..\\Weave.Tests.Generated\\Weave.Tests.Generated.csproj"
+ }
+ }
+}
diff --git a/Weave/Weave.csproj b/Weave/Weave.csproj
index 291fffe..90cac3b 100644
--- a/Weave/Weave.csproj
+++ b/Weave/Weave.csproj
@@ -3,9 +3,11 @@
Exe
+ true
..\Weave.ico
true
Weave.ruleset
+ true
true
Full
TRACE
@@ -16,18 +18,15 @@
true
false
2.5
- net46;netcoreapp2.0
+ net46;netcoreapp2.0;netstandard2.0
+ Latest
+
+ false
Weave is a text templating engine that is all about attention to detail. Weave handles the tricky work of making your rendered text beautiful.
https://raw.github.com/otac0n/Weave/master/license.md
https://github.com/otac0n/Weave
https://raw.github.com/otac0n/Weave/master/Weave.ico
-
- $(DefineConstants);NETFULL
-
-
- $(DefineConstants);NETCORE;NETCOREAPP2_0
-
BodyElement.weave
@@ -86,18 +85,32 @@
-
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
@@ -109,14 +122,23 @@
+
true
-
+
+ true
+ build\net46\
+
+
+ true
+ build\netcoreapp2.0\
+
+
true
- build\
+ analyzers\dotnet\cs
diff --git a/Weave/Weave.targets b/Weave/Weave.targets
index b5814e9..ccbfc10 100644
--- a/Weave/Weave.targets
+++ b/Weave/Weave.targets
@@ -1,7 +1,11 @@
-
+
+
+
+
+
$(MSBuildThisFileDirectory)netcoreapp2.0\Weave.dll
@@ -11,29 +15,59 @@
-
+
+
-
+
-
+
+
-
+
+ true
+
+
+ false
+
+
+ true
+
+
+ false
+
+
$(IntermediateOutputPath)%(WeaveTemplate.Link).cs
-
+
$(IntermediateOutputPath)%(WeaveTemplate.Identity).cs
+
+
+
+ %(WeaveTemplate.OutputPath)
+
+
+ %(WeaveTemplate.UseSourceGeneration)
+ %(WeaveTemplate.ConfigFileExists)
+
+
+ false
+ true
+
+
+
+
-
+
-
-
-
+
+
+
diff --git a/appveyor.yml b/appveyor.yml
index dcc1173..6b99691 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,28 +1,28 @@
-os: Visual Studio 2017
+os: Visual Studio 2022
configuration: Release
install:
- "SET PATH=C:\\ProgramData\\chocolatey\\bin;%PATH%"
- - choco install gitversion.portable -y
+ - choco install gitversion.portable -y --version 5.12.0
- gitversion /l console /output buildserver
- choco install GitReleaseNotes.Portable
- choco install opencover.portable
- - pip install codecov
+ - choco install codecov
before_build:
- - nuget restore
- - GitReleaseNotes . /AllTags /C breaking /O ReleaseNotes.md
+ - dotnet restore
+ - GitReleaseNotes . /AllTags /C breaking /O ReleaseNotes.md || exit 0
build:
project: Weave.sln
test_script:
- OpenCover.Console.exe -target:dotnet.exe -targetargs:"test --configuration %CONFIGURATION% --no-build" -register:user -filter:"+[*]* -[*.Tests]* -[xunit*]*" -output:coverage.xml -oldStyle
after_test:
- - codecov -X gcov -f "coverage.xml"
+ - codecov -f "coverage.xml"
artifacts:
- path: 'ReleaseNotes.md'
- path: '**\*.nupkg'
deploy:
provider: NuGet
api_key:
- secure: 2tZ8tu75MkmhyIcFGzFZsukJx9WAfV94mMtIAnSlurGlGqKaUhG6n6fTimXiIQiB
+ secure: TVpGH+UM7lK2qC2RiNlBY2kLk5MfE228uzlXb1JSaSW05USy6rjkTW+4CksCOu8H
skip_symbols: false
artifact: /.*\.nupkg/
skip_commits:
diff --git a/license.md b/license.md
index 52292a5..f665a67 100644
--- a/license.md
+++ b/license.md
@@ -1,4 +1,4 @@
-Copyright © 2018 John Gietzen
+Copyright © 2023 John Gietzen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the