Skip to content

Commit

Permalink
Fixed local unit test compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
sungaila committed Aug 24, 2021
1 parent 8693452 commit b678a16
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
3 changes: 3 additions & 0 deletions Cdelta.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "src\Core\Core.csproj", "{14017185-C15A-4A26-BB6C-BE59C740CA5D}"
ProjectSection(ProjectDependencies) = postProject
{F87087C1-AD14-400F-A87C-01B5B80A9237} = {F87087C1-AD14-400F-A87C-01B5B80A9237}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "src\Tests\Tests.csproj", "{B4188C3C-08D4-4A83-86A3-42E84304D46B}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ jobs:
displayName: 'Run tests'
inputs:
command: 'test'
arguments: '$(Pipeline.Workspace)\**\net50\Cdelta.Tests.dll'
arguments: '$(Pipeline.Workspace)\**\net5.0\Cdelta.Tests.dll'
testRunTitle: '.NET 5.0 ($(agent.os))'
16 changes: 8 additions & 8 deletions src/Core/CdeltaGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public void Execute(GeneratorExecutionContext context)

var inputStream = new AntlrInputStream(input);

CdeltaLexer lexer = new CdeltaLexer(inputStream);
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
CdeltaParser parser = new CdeltaParser(tokenStream);
var lexer = new CdeltaLexer(inputStream);
var tokenStream = new CommonTokenStream(lexer);
var parser = new CdeltaParser(tokenStream);

CdeltaParser.CodeFileContext parsed = parser.codeFile();
var visitor = new CdeltaGrammarVisitor();
Expand All @@ -48,20 +48,20 @@ public void Execute(GeneratorExecutionContext context)
context.AddSource($"{Path.GetFileName(file.Path)}.cs", code);
}

using Stream stream = typeof(CdeltaGenerator).Assembly.GetManifestResourceStream("Cdelta.IAutomaton.cs");
using StreamReader reader = new StreamReader(stream);
using var stream = typeof(CdeltaGenerator).Assembly.GetManifestResourceStream("Cdelta.IAutomaton.cs");
using var reader = new StreamReader(stream);
context.AddSource("IAutomaton.cs", reader.ReadToEnd());
}

/// <inheritdoc/>
public void Initialize(GeneratorInitializationContext context)
{
#if FALSE && DEBUG
if (!Debugger.IsAttached)
if (!System.Diagnostics.Debugger.IsAttached)
{
Debugger.Launch();
System.Diagnostics.Debugger.Launch();
}
#endif
}
}
}
}
19 changes: 15 additions & 4 deletions src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
<!-- NuGet -->
<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>preview2</VersionSuffix>
<VersionSuffix></VersionSuffix>
<Authors>David Sungaila</Authors>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Icon_128.png</PackageIcon>
<PackageProjectUrl>https://github.com/sungaila/Cdelta</PackageProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/sungaila/Cdelta/master/etc/Icon_128.png</PackageIconUrl>
<Description>A C# source generator for finite-state machines ‐ easily referenced as a Roslyn analyzer.</Description>
<PackageReleaseNotes>Initial preview release</PackageReleaseNotes>
<PackageReleaseNotes>Initial release</PackageReleaseNotes>
<PackageTags>Roslyn CodeAnalysis Compiler Transpiler CSharp C# Analyzers DotNetAnalyzers StateMachine Cdelta Cδ SourceGenerator ISourceGenerator state-machine StateMachine Automaton Automata NFA DFA</PackageTags>
<RepositoryUrl>https://github.com/sungaila/Cdelta.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand All @@ -36,6 +36,7 @@
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<Features>strict</Features>
<NoWarn>1701;1702;3021;NU5128</NoWarn>
<WarningsAsErrors>nullable</WarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
Expand All @@ -45,14 +46,12 @@
<!-- Debug builds -->
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<VersionSuffix>debug</VersionSuffix>
<NoWarn>1701;1702;3021;NU5128</NoWarn>
</PropertyGroup>

<!-- Release builds -->
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<SignAssembly>true</SignAssembly>
<Optimize>true</Optimize>
<NoWarn>1701;1702;3021;NU5128</NoWarn>
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand All @@ -76,4 +75,16 @@
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" PrivateAssets="all" />
<PackageReference Include="Antlr4.Runtime" Version="4.6.6" PrivateAssets="all" />
</ItemGroup>

<!-- the following block is needed for the compilation of the unit tests -->
<!-- otherwise the Antlr4.Runtime.dll cannot be resolved and the source generation fails -->
<PropertyGroup>
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
</PropertyGroup>

<Target Name="GetDependencyTargetPaths" AfterTargets="ResolvePackageDependenciesForBuild">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="@(ResolvedCompileFileDefinitions)" IncludeRuntimeDependency="false" />
</ItemGroup>
</Target>
</Project>
17 changes: 8 additions & 9 deletions src/Grammar/Grammar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,31 @@
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<Features>strict</Features>
<WarningsAsErrors>nullable;NU1605</WarningsAsErrors>
<NoWarn>1701;1702;3021;1584;1658</NoWarn>
<WarningsAsErrors>nullable</WarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>

<!-- Debug builds -->
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<VersionSuffix>debug</VersionSuffix>
<NoWarn>1701;1702;3021;1584;1658</NoWarn>
</PropertyGroup>

<!-- Release builds -->
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<Optimize>true</Optimize>
<NoWarn>1701;1702;3021;1584;1658</NoWarn>
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<None Include="obj\$(Configuration)\netstandard2.0\CdeltaLexer.cs" />
<None Include="obj\$(Configuration)\netstandard2.0\CdeltaParser.cs" />
<None Include="obj\$(Configuration)\netstandard2.0\CdeltaParserBaseListener.cs" />
<None Include="obj\$(Configuration)\netstandard2.0\CdeltaParserBaseVisitor.cs" />
<None Include="obj\$(Configuration)\netstandard2.0\CdeltaParserListener.cs" />
<None Include="obj\$(Configuration)\netstandard2.0\CdeltaParserVisitor.cs" />
<None Include="obj\$(Configuration)\$(TargetFramework)\CdeltaLexer.cs" />
<None Include="obj\$(Configuration)\$(TargetFramework)\CdeltaParser.cs" />
<None Include="obj\$(Configuration)\$(TargetFramework)\CdeltaParserBaseListener.cs" />
<None Include="obj\$(Configuration)\$(TargetFramework)\CdeltaParserBaseVisitor.cs" />
<None Include="obj\$(Configuration)\$(TargetFramework)\CdeltaParserListener.cs" />
<None Include="obj\$(Configuration)\$(TargetFramework)\CdeltaParserVisitor.cs" />
</ItemGroup>

<!-- SourceLink build steps -->
Expand Down
1 change: 1 addition & 0 deletions src/Tests/LowerCamelCaseTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma warning disable IDE1006
using Microsoft.VisualStudio.TestTools.UnitTesting;
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]

namespace Cdelta.Tests
{
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Assembly -->
<PropertyGroup>
<TargetFramework>net50</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<AssemblyName>Cdelta.Tests</AssemblyName>
<RootNamespace>Cdelta.Tests</RootNamespace>
<IsPackable>false</IsPackable>
Expand All @@ -12,7 +12,7 @@
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<Features>strict</Features>
<WarningsAsErrors>nullable;NU1605</WarningsAsErrors>
<WarningsAsErrors>nullable</WarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
Expand Down

0 comments on commit b678a16

Please sign in to comment.