forked from OpenRA/OpenRA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
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,28 @@ | ||
using System; | ||
Check failure on line 1 in OpenRA.SourceGenerators/Class1.cs GitHub Actions / Windows (.NET 6.0)
|
||
using System.Text; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace OpenRA.SourceGenerators | ||
{ | ||
[Generator] | ||
public class HelloWorldGenerator : ISourceGenerator | ||
{ | ||
public void Execute(GeneratorExecutionContext context) | ||
{ | ||
// begin creating the source we'll inject into the users compilation | ||
var sourceCode = SourceText.From(@"namespace OpenRA { | ||
public static class GeneratedCode | ||
{ | ||
public static string GeneratedMessage = ""Hello from Generated Code""; | ||
}}", Encoding.UTF8); | ||
|
||
context.AddSource("GeneratedCode.g.cs", sourceCode); | ||
} | ||
|
||
public void Initialize(GeneratorInitializationContext context) | ||
{ | ||
} | ||
} | ||
} |
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,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" /> | ||
</ItemGroup> | ||
|
||
</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
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 |
---|---|---|
|
@@ -52,6 +52,7 @@ static void Main(string[] args) | |
|
||
static void Run(string[] args) | ||
{ | ||
Console.WriteLine(GeneratedCode.GeneratedMessage); | ||
var engineDir = Environment.GetEnvironmentVariable("ENGINE_DIR"); | ||
Check failure on line 56 in OpenRA.Utility/Program.cs GitHub Actions / Windows (.NET 6.0)
Check failure on line 56 in OpenRA.Utility/Program.cs GitHub Actions / Linux (.NET 6.0)
|
||
if (!string.IsNullOrEmpty(engineDir)) | ||
Check failure on line 57 in OpenRA.Utility/Program.cs GitHub Actions / Windows (.NET 6.0)
Check failure on line 57 in OpenRA.Utility/Program.cs GitHub Actions / Linux (.NET 6.0)
|
||
Platform.OverrideEngineDir(engineDir); | ||
|
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