Skip to content

Commit 02b94ba

Browse files
authored
Remove setters from ISource/Source (#97)
1 parent a6a4f1c commit 02b94ba

File tree

12 files changed

+65
-39
lines changed

12 files changed

+65
-39
lines changed

.github/labeler.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
"test":
1+
test:
22
- src/GraphQLParser.ApiTests/**/*
33
- src/GraphQLParser.Tests/**/*
44

5-
"CI":
5+
CI:
66
- .github/workflows/**/*
77

8-
"code style":
8+
code style:
99
- .editorconfig
1010

11-
"documentation":
11+
documentation:
1212
- README.md
1313

14-
"performance":
14+
performance:
1515
- src/GraphQLParser.Benchmarks/**/*

.github/workflows/label.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
label:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/labeler@v2
15+
- uses: actions/labeler@v3
1616
with:
17+
sync-labels: ""
1718
repo-token: "${{ secrets.GITHUB_TOKEN }}"
19+
continue-on-error: true

.github/workflows/publish-release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,21 @@ jobs:
5151
- name: Publish Nuget packages to Nuget registry
5252
working-directory: src
5353
run: dotnet nuget push "out/*" -k ${{secrets.NUGET_AUTH_TOKEN}}
54+
- name: Upload Nuget packages as release artifacts
55+
uses: actions/github-script@v2
56+
with:
57+
github-token: ${{secrets.GITHUB_TOKEN}}
58+
script: |
59+
console.log('environment', process.versions);
60+
const fs = require('fs').promises;
61+
const { repo: { owner, repo }, sha } = context;
62+
for (let file of await fs.readdir('src/out')) {
63+
console.log('uploading', file);
64+
await github.repos.uploadReleaseAsset({
65+
owner,
66+
repo,
67+
release_id: ${{ github.event.release.id }},
68+
name: file,
69+
data: await fs.readFile(`src/out/${file}`)
70+
});
71+
}

src/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22

33
<PropertyGroup>
4-
<VersionPrefix>5.3.4-preview</VersionPrefix>
4+
<VersionPrefix>6.0.0-preview</VersionPrefix>
55
<LangVersion>latest</LangVersion>
66
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -18,6 +18,7 @@
1818
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1919
<!-- https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables -->
2020
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">True</ContinuousIntegrationBuild>
21+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
2122
<NoWarn>$(NoWarn);1591</NoWarn>
2223
<Nullable>enable</Nullable>
2324
</PropertyGroup>

src/GraphQLParser.ApiTests/ApiApprovalTests.Public_Api_Should_Not_Change_Inadvertently.approved.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,8 @@ namespace GraphQLParser
390390
}
391391
public interface ISource
392392
{
393-
string Body { get; set; }
394-
string Name { get; set; }
393+
string Body { get; }
394+
string Name { get; }
395395
}
396396
public class Lexer : GraphQLParser.ILexer
397397
{
@@ -403,6 +403,7 @@ namespace GraphQLParser
403403
public readonly struct Location
404404
{
405405
public Location(GraphQLParser.ISource source, int position) { }
406+
public Location(string source, int position) { }
406407
public int Column { get; }
407408
public int Line { get; }
408409
}
@@ -423,8 +424,8 @@ namespace GraphQLParser
423424
{
424425
public Source(string body) { }
425426
public Source(string body, string name) { }
426-
public string Body { get; set; }
427-
public string Name { get; set; }
427+
public string Body { get; }
428+
public string Name { get; }
428429
}
429430
public readonly struct Token
430431
{

src/GraphQLParser.Tests/LexerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using Shouldly;
32
using Xunit;
43

src/GraphQLParser.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1616
Directory.Build.props = Directory.Build.props
1717
..\LICENSE.md = ..\LICENSE.md
1818
..\assets\logo.64x64.png = ..\assets\logo.64x64.png
19-
NuGet.config = NuGet.config
2019
..\README.md = ..\README.md
2120
EndProjectSection
2221
EndProject

src/GraphQLParser/AST/GraphQLLocation.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ public GraphQLLocation(int start, int end)
3030
/// </summary>
3131
public int End { get; }
3232

33-
34-
3533
public bool Equals(GraphQLLocation other) => Start == other.Start && End == other.End;
3634

37-
public override bool Equals(object obj) => obj is GraphQLLocation l ? Equals(l) : false;
35+
public override bool Equals(object obj) => obj is GraphQLLocation l && Equals(l);
3836

3937
public override int GetHashCode() => (Start, End).GetHashCode();
4038

src/GraphQLParser/ISource.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
namespace GraphQLParser
1+
namespace GraphQLParser
22
{
33
public interface ISource
44
{
5-
string Body { get; set; }
5+
string Body { get; }
66

7-
string Name { get; set; }
7+
string Name { get; }
88
}
9-
}
9+
}

src/GraphQLParser/Location.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,27 @@ public readonly struct Location
77
private static readonly Regex _lineRegex = new Regex("\r\n|[\n\r]", RegexOptions.ECMAScript);
88

99
public Location(ISource source, int position)
10+
: this(source.Body, position)
11+
{
12+
13+
}
14+
15+
public Location(string source, int position)
1016
{
1117
Line = 1;
1218
Column = position + 1;
1319

14-
var matches = _lineRegex.Matches(source.Body);
15-
foreach (Match match in matches)
20+
if (position > 0)
1621
{
17-
if (match.Index >= position)
18-
break;
22+
var matches = _lineRegex.Matches(source);
23+
foreach (Match match in matches)
24+
{
25+
if (match.Index >= position)
26+
break;
1927

20-
Line++;
21-
Column = position + 1 - (match.Index + matches[0].Length);
28+
Line++;
29+
Column = position + 1 - (match.Index + matches[0].Length);
30+
}
2231
}
2332
}
2433

0 commit comments

Comments
 (0)