-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an examples solution and more documentation.
- Loading branch information
1 parent
46950ce
commit b170d30
Showing
36 changed files
with
534 additions
and
100 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,64 @@ | ||
name: Build | ||
description: "Builds a C# solution." | ||
inputs: | ||
name: | ||
description: "Name of the solution." | ||
required: true | ||
directory: | ||
description: "Directory containing the solution." | ||
required: true | ||
assembly-filter: | ||
description: "Optional code coverage assembly filter." | ||
required: false | ||
default: "+*" | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Restore Dependencies | ||
shell: bash | ||
working-directory: ${{ inputs.directory }} | ||
run: dotnet restore | ||
|
||
- name: Build | ||
shell: bash | ||
working-directory: ${{ inputs.directory }} | ||
run: dotnet build --no-restore --configuration Release | ||
|
||
- name: Test | ||
shell: bash | ||
working-directory: ${{ inputs.directory }} | ||
run: dotnet test --no-restore --no-build --configuration Release --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage" | ||
|
||
- name: Test Report | ||
uses: dorny/test-reporter@v1.6.0 | ||
if: success() || failure() | ||
with: | ||
name: ${{ inputs.name }} Test Results | ||
path: "${{ inputs.directory }}/**/TestResults/test-results.trx" | ||
reporter: dotnet-trx | ||
|
||
- name: Aggregate Coverage Reports | ||
shell: bash | ||
working-directory: ${{ inputs.directory }} | ||
run: | | ||
dotnet new tool-manifest | ||
dotnet tool install dotnet-reportgenerator-globaltool | ||
dotnet tool run reportgenerator "-reports:**/TestResults/**/coverage.cobertura.xml" "-targetdir:." "-reportTypes:Cobertura" "-assemblyfilters:${{ inputs.assembly-filter }}" | ||
- name: Generate Coverage Report | ||
uses: irongut/CodeCoverageSummary@v1.3.0 | ||
with: | ||
filename: ${{ inputs.directory }}/Cobertura.xml | ||
format: markdown | ||
indicators: true | ||
output: file | ||
thresholds: '95 100' | ||
|
||
- name: Attach Coverage Report to Build | ||
uses: dtinth/markdown-report-action@v1 | ||
with: | ||
name: ${{ inputs.name }} Test Coverage | ||
title: ${{ inputs.name }} Test Coverage | ||
body-file: code-coverage-results.md |
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,17 @@ | ||
name: Documentation | ||
description: "Deploys the documentation." | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v3 | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v1 | ||
with: | ||
path: './doc/_site' | ||
|
||
- name: Deploy to GitHub Pages | ||
uses: actions/deploy-pages@v2 |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Listeners | ||
|
||
Listeners are an alternative lightweight method to [processing](processing.md) for visiting nodes in a tree and performing | ||
some functionality. Listeners walk all the nodes and a tree and have events that can be hooked into when nodes are reached. | ||
Processing is best for mutating a tree, listeners are more suitable for building something new from a tree. | ||
|
||
## Creating a Listener | ||
|
||
There are four base listener classes that can be inherited from to create a listener: | ||
|
||
* [Listener\<TNode\>](xref:MrKWatkins.Ast.Listening.Listener\`1) - Listens to all nodes in a tree. | ||
* [Listener\<TBaseNode, TNode\>](xref:MrKWatkins.Ast.Listening.Listener\`2) - Listens to all nodes of a specific type in a tree. | ||
* [ListenerWithContext\<TContext, TNode\>](xref:MrKWatkins.Ast.Listening.ListenerWithContext\`2) - Listens to all nodes in a tree with access to a context object. | ||
* [ListenerWithContext\<TContext, TBaseNode, TNode\>](xref:MrKWatkins.Ast.Listening.ListenerWithContext\`3) - Listens to all nodes of a specific type in a tree with access to a context object. | ||
|
||
The listeners have three methods that can be overridden to get access to the nodes: | ||
|
||
* [BeforeListenToNode](xref:MrKWatkins.Ast.Listening.Listener\`1.BeforeListenToNode(\`0)) - Called immediately before a node and its children are visited. | ||
* [ListenToNode](xref:MrKWatkins.Ast.Listening.Listener\`1.ListenToNode(\`0)) - Called when node is visited. | ||
* [AfterListenToNode](xref:MrKWatkins.Ast.Listening.Listener\`1.AfterListenToNode(\`0)) - Called immediately after a node and its children have been visited. | ||
|
||
To start the listening process call the [Listen](xref:MrKWatkins.Ast.Listening.Listener\`1.Listen(\`0)) method. | ||
|
||
## Composite Listeners | ||
|
||
Often you will want to visit a tree performing different actions for specific types of node in the tree. Rather than have all the code in one class with | ||
switch statements on the node type you can instead build a composite listener from multiple other listeners. A composite listener can be built using a fluent | ||
interface from the [Build](xref:MrKWatkins.Ast.Listening.CompositeListener\`1.Build) or [BuildWithContext](xref:MrKWatkins.Ast.Listening.CompositeListener\`1.BuildWithContext\`\`1) | ||
methods. | ||
|
||
Only one listener for a given type can be registered. However listeners can be registered for base types too, and the listener with the most specific type | ||
will be chosen to listen to a node. This is useful for fallback behaviour. Listeners can also have base classes to share implementation between different node | ||
types. | ||
|
||
## Example | ||
|
||
Find an example of using listeners to produce a string representation of a tree at <https://github.com/MrKWatkins/Ast/tree/main/examples/Listeners>. |
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,2 @@ | ||
# Processing | ||
|
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
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
- name: Home | ||
href: home.md | ||
|
||
- name: Processing | ||
href: processing.md | ||
|
||
- name: Listeners | ||
href: listeners.md | ||
|
||
- name: API | ||
href: api/ |
Oops, something went wrong.