Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
teinarss committed Aug 28, 2023
1 parent 7bd4b45 commit c1d1dc2
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
28 changes: 28 additions & 0 deletions OpenRA.SourceGenerators/Class1.cs
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

View workflow job for this annotation

GitHub Actions / Windows (.NET 6.0)

Using directive is unnecessary.

Check failure on line 1 in OpenRA.SourceGenerators/Class1.cs

View workflow job for this annotation

GitHub Actions / Linux (.NET 6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)
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)
{
}
}
}
16 changes: 16 additions & 0 deletions OpenRA.SourceGenerators/OpenRA.SourceGenerators.csproj
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>
2 changes: 1 addition & 1 deletion OpenRA.Utility/OpenRA.Utility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj" />
<ProjectReference Include="..\OpenRA.SourceGenerators\OpenRA.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<TrimmerRootAssembly Include="mscorlib" />
Expand Down
1 change: 1 addition & 0 deletions OpenRA.Utility/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static void Main(string[] args)

static void Run(string[] args)
{
Console.WriteLine(GeneratedCode.GeneratedMessage);

Check failure on line 55 in OpenRA.Utility/Program.cs

View workflow job for this annotation

GitHub Actions / Windows (.NET 6.0)

The name 'GeneratedCode' does not exist in the current context
var engineDir = Environment.GetEnvironmentVariable("ENGINE_DIR");

Check failure on line 56 in OpenRA.Utility/Program.cs

View workflow job for this annotation

GitHub Actions / Windows (.NET 6.0)

Elements should have the same indentation

Check failure on line 56 in OpenRA.Utility/Program.cs

View workflow job for this annotation

GitHub Actions / Linux (.NET 6.0)

if (!string.IsNullOrEmpty(engineDir))

Check failure on line 57 in OpenRA.Utility/Program.cs

View workflow job for this annotation

GitHub Actions / Windows (.NET 6.0)

Elements should have the same indentation

Check failure on line 57 in OpenRA.Utility/Program.cs

View workflow job for this annotation

GitHub Actions / Linux (.NET 6.0)

Platform.OverrideEngineDir(engineDir);
Expand Down
10 changes: 8 additions & 2 deletions OpenRA.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.352
# Visual Studio Version 17
VisualStudioVersion = 17.7.33913.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRA.Game", "OpenRA.Game\OpenRA.Game.csproj", "{0DFB103F-2962-400F-8C6D-E2C28CCBA633}"
EndProject
Expand All @@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRA.Launcher", "OpenRA.L
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRA.WindowsLauncher", "OpenRA.WindowsLauncher\OpenRA.WindowsLauncher.csproj", "{912B578E-0BC0-4987-807B-1E294A87DA37}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.SourceGenerators", "OpenRA.SourceGenerators\OpenRA.SourceGenerators.csproj", "{EA3C4A4C-661C-4456-AFB9-09251B003596}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -65,6 +67,10 @@ Global
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Release|Any CPU.Build.0 = Release|Any CPU
{912B578E-0BC0-4987-807B-1E294A87DA37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{912B578E-0BC0-4987-807B-1E294A87DA37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA3C4A4C-661C-4456-AFB9-09251B003596}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA3C4A4C-661C-4456-AFB9-09251B003596}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA3C4A4C-661C-4456-AFB9-09251B003596}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA3C4A4C-661C-4456-AFB9-09251B003596}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit c1d1dc2

Please sign in to comment.