Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ on:
branches:
- main
- master
tags:
- "*"
pull_request:

jobs:
build-test:
runs-on: ubuntu-latest
permissions:
contents: read
env:
DOTNET_NOLOGO: true

steps:
- name: Check out repository
Expand All @@ -20,11 +26,31 @@ jobs:
with:
global-json-file: global.json

- name: Compute package version
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
version="${GITHUB_REF_NAME#v}"
else
version="1.0.0-ci.${GITHUB_RUN_NUMBER}"
fi
echo "PACKAGE_VERSION=${version}" >> "${GITHUB_ENV}"

- name: Restore
run: dotnet restore Pixie.sln

- name: Build
run: dotnet build Pixie.sln --configuration Release --no-restore
run: dotnet build Pixie.sln --configuration Release --no-restore -p:Version=${{ env.PACKAGE_VERSION }}

- name: Run examples
shell: bash
run: |
dotnet ./Examples/CaretDiagnostics/bin/Release/net10.0/CaretDiagnostics.dll
dotnet ./Examples/FormattedList/bin/Release/net10.0/FormattedList.dll
dotnet ./Examples/LoycInterop/bin/Release/net10.0/LoycInterop.dll
dotnet ./Examples/ParseOptions/bin/Release/net10.0/ParseOptions.dll a.txt -fno-syntax-only --files -O1 -Ofast b.txt --files=c.txt - -- -v
dotnet ./Examples/PrintHelp/bin/Release/net10.0/PrintHelp.dll
dotnet ./Examples/SimpleErrorMessage/bin/Release/net10.0/SimpleErrorMessage.dll

- name: Run tests
run: dotnet test Tests/Tests.csproj --configuration Release --no-build --logger "trx;LogFileName=TestResults.trx" --collect:"XPlat Code Coverage"
Expand All @@ -37,3 +63,31 @@ jobs:
path: |
Tests/TestResults/**/*.trx
Tests/TestResults/**/coverage.cobertura.xml

- name: Pack NuGet packages
if: startsWith(github.ref, 'refs/tags/')
run: |
dotnet pack Pixie/Pixie.csproj --configuration Release --no-build --output ./artifacts/packages -p:PackageVersion=${{ env.PACKAGE_VERSION }}
dotnet pack Pixie.Loyc/Pixie.Loyc.csproj --configuration Release --no-build --output ./artifacts/packages -p:PackageVersion=${{ env.PACKAGE_VERSION }}

- name: Upload packages
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
artifacts/packages/*.nupkg

- name: Publish to NuGet
if: startsWith(github.ref, 'refs/tags/')
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
if [[ -z "${NUGET_API_KEY}" ]]; then
echo "NUGET_API_KEY secret is not configured." >&2
exit 1
fi
dotnet nuget push "artifacts/packages/*.nupkg" \
--api-key "${NUGET_API_KEY}" \
--source "https://api.nuget.org/v3/index.json" \
--skip-duplicate
8 changes: 4 additions & 4 deletions Examples/LoycInterop/LoycInterop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<ProjectReference Include="..\..\Pixie\Pixie.csproj" />
<ProjectReference Include="..\..\Pixie.Terminal\Pixie.Terminal.csproj" />
<ProjectReference Include="..\..\Pixie.Loyc\Pixie.Loyc.csproj" />
<PackageReference Include="Loyc.Collections" Version="26.8.1" />
<PackageReference Include="Loyc.Ecs" Version="26.8.1" />
<PackageReference Include="Loyc.Essentials" Version="26.8.1" />
<PackageReference Include="Loyc.Syntax" Version="26.8.1" />
<PackageReference Include="Loyc.Collections" Version="30.1.3" />
<PackageReference Include="Loyc.Ecs" Version="30.1.3" />
<PackageReference Include="Loyc.Essentials" Version="30.1.3" />
<PackageReference Include="Loyc.Syntax" Version="30.1.3" />
</ItemGroup>
</Project>
36 changes: 0 additions & 36 deletions Pixie.Loyc.nuspec

This file was deleted.

3 changes: 1 addition & 2 deletions Pixie.Loyc/LoycSourceDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private int ComputeLineCount()
public override GridPosition GetGridPosition(int offset)
{
var linePos = source.IndexToLine(offset);
return new GridPosition(linePos.Line - 1, linePos.PosInLine - 1);
return new GridPosition(linePos.Line - 1, linePos.Column - 1);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -67,4 +67,3 @@ public override TextReader Open(int offset)
}
}
}

21 changes: 18 additions & 3 deletions Pixie.Loyc/Pixie.Loyc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
<AssemblyName>Pixie.Loyc</AssemblyName>
<Version>1.0</Version>
<TargetFrameworks>netstandard2.0;net10.0</TargetFrameworks>
<PackageId>Pixie.Loyc</PackageId>
<Authors>Jonathan Van der Cruysse</Authors>
<PackageProjectUrl>https://github.com/jonathanvdc/Pixie</PackageProjectUrl>
<RepositoryUrl>https://github.com/jonathanvdc/Pixie</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Description>Pixie is a C# library that prints beautifully formatted output to the console. This package contains Pixie.Loyc, a library that translates Loyc diagnostics to Pixie markup nodes.</Description>
<PackageTags>terminal;console;output;formatting;loyc;ecsharp</PackageTags>
<NoPackageAnalysis>true</NoPackageAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -29,8 +40,12 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Pixie\Pixie.csproj" />
<PackageReference Include="Loyc.Collections" Version="26.8.1" />
<PackageReference Include="Loyc.Essentials" Version="26.8.1" />
<PackageReference Include="Loyc.Syntax" Version="26.8.1" />
<PackageReference Include="Loyc.Collections" Version="30.1.3" />
<PackageReference Include="Loyc.Essentials" Version="30.1.3" />
<PackageReference Include="Loyc.Syntax" Version="30.1.3" />
</ItemGroup>
<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
<None Include="..\LICENSE" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions Pixie.Loyc/PixieMessageSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@
{
return FormatContext(((LNode)context).Range);
}
else if (context is IHasLocation)
else if (context is ILocation)
{
return FormatContext(((IHasLocation)context).Location);
return FormatContext(((ILocation)context).Location);
}
else if (context is SourcePos)

Check warning on line 117 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'

Check warning on line 117 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'

Check warning on line 117 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'
{
// Source positions are actually pretty tough to create
// caret diagnostics for. We'll just try to index the source
// document cache.
var pos = (SourcePos)context;

Check warning on line 122 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'

Check warning on line 122 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'

Check warning on line 122 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'
SourceRegion region;
if (TryIndexSourceDocumentCache(pos, out region))
{
Expand All @@ -134,7 +134,7 @@
// OTOH, we're not even use if the message we're
// generating is a diagnostic.
return "At " + pos.FileName + ":" + pos.Line +
":" + pos.PosInLine + ".";
":" + pos.Column + ".";
}
}
else if (context == null)
Expand All @@ -154,13 +154,13 @@
}
}

private bool TryIndexSourceDocumentCache(SourcePos pos, out SourceRegion result)

Check warning on line 157 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'

Check warning on line 157 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'

Check warning on line 157 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'

Check warning on line 157 in Pixie.Loyc/PixieMessageSink.cs

View workflow job for this annotation

GitHub Actions / build-test

'SourcePos' is obsolete: 'Please use the new name of this class: LineColumnFile'
{
SourceDocument document;
if (DocumentCache.TryGetDocument(pos.FileName, out document))
{
int lineOffset = document.GetLineOffset(pos.Line - 1);
int offset = lineOffset + pos.PosInLine - 1;
int offset = lineOffset + pos.Column - 1;
result = new SourceRegion(new SourceSpan(document, offset, 1));
return true;
}
Expand Down Expand Up @@ -188,4 +188,4 @@
return Severity.Info;
}
}
}
}
1 change: 1 addition & 0 deletions Pixie.Terminal/Pixie.Terminal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<AssemblyName>Pixie.Terminal</AssemblyName>
<Version>1.0</Version>
<TargetFrameworks>netstandard2.0;net10.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
32 changes: 0 additions & 32 deletions Pixie.nuspec

This file was deleted.

27 changes: 27 additions & 0 deletions Pixie/Pixie.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<AssemblyName>Pixie</AssemblyName>
<Version>1.0</Version>
<TargetFrameworks>netstandard2.0;net10.0</TargetFrameworks>
<PackageId>Pixie</PackageId>
<Authors>Jonathan Van der Cruysse</Authors>
<PackageProjectUrl>https://github.com/jonathanvdc/Pixie</PackageProjectUrl>
<RepositoryUrl>https://github.com/jonathanvdc/Pixie</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Description>Pixie is a C# library that prints beautifully formatted output to the console. You describe your layout using a high-level API and Pixie turns it into neatly-formatted text.</Description>
<PackageTags>terminal;console;output;formatting</PackageTags>
<NoPackageAnalysis>true</NoPackageAnalysis>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeTerminalAssembly</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -27,4 +39,19 @@
<ConsolePause>false</ConsolePause>
<DocumentationFile>bin\Release\Pixie.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
<None Include="..\LICENSE" Pack="true" PackagePath="\" />
</ItemGroup>
<Target Name="IncludeTerminalAssembly">
<ItemGroup>
<BuildOutputInPackage Include="$(MSBuildThisFileDirectory)..\Pixie.Terminal\bin\$(Configuration)\$(TargetFramework)\Pixie.Terminal.dll">
<TargetPath>Pixie.Terminal.dll</TargetPath>
</BuildOutputInPackage>
<BuildOutputInPackage Include="$(MSBuildThisFileDirectory)..\Pixie.Terminal\bin\$(Configuration)\$(TargetFramework)\Pixie.Terminal.xml"
Condition="Exists('$(MSBuildThisFileDirectory)..\Pixie.Terminal\bin\$(Configuration)\$(TargetFramework)\Pixie.Terminal.xml')">
<TargetPath>Pixie.Terminal.xml</TargetPath>
</BuildOutputInPackage>
</ItemGroup>
</Target>
</Project>
30 changes: 30 additions & 0 deletions Tests/NUnitCompatibilityAsserts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Collections;

namespace NUnit.Framework
{
internal static class StringAssert
{
public static void Contains(string expected, string actual)
{
Assert.That(actual, Does.Contain(expected));
}

public static void StartsWith(string expected, string actual)
{
Assert.That(actual, Does.StartWith(expected));
}

public static void EndsWith(string expected, string actual)
{
Assert.That(actual, Does.EndWith(expected));
}
}

internal static class CollectionAssert
{
public static void AreEqual(IEnumerable expected, IEnumerable actual)
{
Assert.That(actual, Is.EqualTo(expected));
}
}
}
14 changes: 7 additions & 7 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<ProjectReference Include="..\Pixie\Pixie.csproj" />
<ProjectReference Include="..\Pixie.Terminal\Pixie.Terminal.csproj" />
<ProjectReference Include="..\Pixie.Loyc\Pixie.Loyc.csproj" />
<PackageReference Include="Loyc.Essentials" Version="26.8.1" />
<PackageReference Include="Loyc.Collections" Version="26.8.1" />
<PackageReference Include="Loyc.Syntax" Version="26.8.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PackageReference Include="Loyc.Essentials" Version="30.1.3" />
<PackageReference Include="Loyc.Collections" Version="30.1.3" />
<PackageReference Include="Loyc.Syntax" Version="30.1.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="NUnit" Version="4.5.1" />
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0" />
<PackageReference Include="coverlet.collector" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading
Loading