Skip to content

Commit c6ee75d

Browse files
Fixing code generation for scalar values
1 parent 04d8c76 commit c6ee75d

File tree

15 files changed

+27
-27
lines changed

15 files changed

+27
-27
lines changed

Octokit.GraphQL.Core.Generation.UnitTests/EntityGenerationTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ public void Generates_Method_For_List_Field_With_Nullable_Enum_List_Arg()
10551055
[Fact]
10561056
public void Generates_Method_For_String_Field()
10571057
{
1058-
var expected = FormatMemberTemplate("public int? Foo(Arg<string>? bar = null) => null;");
1058+
var expected = FormatMemberTemplate("public int? Foo(Arg<string>? bar = null) => default;");
10591059

10601060
var model = new TypeModel
10611061
{
@@ -1087,7 +1087,7 @@ public void Generates_Method_For_String_Field()
10871087
[Fact]
10881088
public void Generates_Method_For_NonNull_String_Field()
10891089
{
1090-
var expected = FormatMemberTemplate("public int? Foo(Arg<string> bar) => null;");
1090+
var expected = FormatMemberTemplate("public int? Foo(Arg<string> bar) => default;");
10911091

10921092
var model = new TypeModel
10931093
{
@@ -1119,7 +1119,7 @@ public void Generates_Method_For_NonNull_String_Field()
11191119
[Fact]
11201120
public void Generates_Method_For_Scalar_Field()
11211121
{
1122-
var expected = FormatMemberTemplate("public int? Foo(Arg<int>? bar = null) => null;");
1122+
var expected = FormatMemberTemplate("public int? Foo(Arg<int>? bar = null) => default;");
11231123

11241124
var model = new TypeModel
11251125
{
@@ -1151,7 +1151,7 @@ public void Generates_Method_For_Scalar_Field()
11511151
[Fact]
11521152
public void Generates_Method_For_Deprecated_WithoutReason_Scalar_Field()
11531153
{
1154-
var expected = FormatMemberTemplate($@"[Obsolete(@""Old and unused"")]{Environment.NewLine} public int? Foo(Arg<int>? bar = null) => null;");
1154+
var expected = FormatMemberTemplate($@"[Obsolete(@""Old and unused"")]{Environment.NewLine} public int? Foo(Arg<int>? bar = null) => default;");
11551155

11561156
var model = new TypeModel
11571157
{
@@ -1185,7 +1185,7 @@ public void Generates_Method_For_Deprecated_WithoutReason_Scalar_Field()
11851185
[Fact]
11861186
public void Generates_Method_For_Deprecated_Scalar_Field()
11871187
{
1188-
var expected = FormatMemberTemplate($@"[Obsolete]{Environment.NewLine} public int? Foo(Arg<int>? bar = null) => null;");
1188+
var expected = FormatMemberTemplate($@"[Obsolete]{Environment.NewLine} public int? Foo(Arg<int>? bar = null) => default;");
11891189

11901190
var model = new TypeModel
11911191
{
@@ -1218,7 +1218,7 @@ public void Generates_Method_For_Deprecated_Scalar_Field()
12181218
[Fact]
12191219
public void Generates_Method_For_NonNull_Scalar_Field()
12201220
{
1221-
var expected = FormatMemberTemplate("public int Foo(Arg<int>? bar = null) => null;");
1221+
var expected = FormatMemberTemplate("public int Foo(Arg<int>? bar = null) => default;");
12221222

12231223
var model = new TypeModel
12241224
{
@@ -1250,7 +1250,7 @@ public void Generates_Method_For_NonNull_Scalar_Field()
12501250
[Fact]
12511251
public void Generates_Method_For_ID_Field()
12521252
{
1253-
var expected = FormatMemberTemplate("public ID? Foo(Arg<int>? bar = null) => null;");
1253+
var expected = FormatMemberTemplate("public ID? Foo(Arg<int>? bar = null) => default;");
12541254

12551255
var model = new TypeModel
12561256
{
@@ -1282,7 +1282,7 @@ public void Generates_Method_For_ID_Field()
12821282
[Fact]
12831283
public void Generates_Method_For_NonNull_ID_Field()
12841284
{
1285-
var expected = FormatMemberTemplate("public ID Foo(Arg<int>? bar = null) => null;");
1285+
var expected = FormatMemberTemplate("public ID Foo(Arg<int>? bar = null) => default;");
12861286

12871287
var model = new TypeModel
12881288
{

Octokit.GraphQL.Core.Generation.UnitTests/InterfaceGenerationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ public void Generates_Method_For_Scalar()
512512
{
513513
var expected = FormatMemberTemplate(
514514
"int? Foo(Arg<int>? bar = null);",
515-
"public int? Foo(Arg<int>? bar = null) => null;");
515+
"public int? Foo(Arg<int>? bar = null) => default;");
516516

517517
var model = new TypeModel
518518
{
@@ -546,7 +546,7 @@ public void Generates_Method_For_NonNull_Scalar()
546546
{
547547
var expected = FormatMemberTemplate(
548548
"int Foo(Arg<int>? bar = null);",
549-
"public int Foo(Arg<int>? bar = null) => null;");
549+
"public int Foo(Arg<int>? bar = null) => default;");
550550

551551
var model = new TypeModel
552552
{

Octokit.GraphQL.Core.Generation/EntityGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ private static string GenerateScalarMethod(FieldModel field, TypeModel type)
229229

230230
GenerateArguments(field, out string arguments, out string parameters);
231231

232-
return $"{obsoleteAttribute} public {csharpType} {name}({arguments}) => null;";
232+
return $"{obsoleteAttribute} public {csharpType} {name}({arguments}) => default;";
233233
}
234234

235235
private static string GenerateObjectMethod(FieldModel field, TypeModel type, string entityNamespace)

Octokit.GraphQL/Model/Actor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public StubIActor(Expression expression) : base(expression)
5050
{
5151
}
5252

53-
public string AvatarUrl(Arg<int>? size = null) => null;
53+
public string AvatarUrl(Arg<int>? size = null) => default;
5454

5555
public string Login { get; }
5656

Octokit.GraphQL/Model/App.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public App(Expression expression) : base(expression)
4141
/// A URL pointing to the app's logo.
4242
/// </summary>
4343
/// <param name="size">The size of the resulting image.</param>
44-
public string LogoUrl(Arg<int>? size = null) => null;
44+
public string LogoUrl(Arg<int>? size = null) => default;
4545

4646
/// <summary>
4747
/// The name of the app.

Octokit.GraphQL/Model/Bot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Bot(Expression expression) : base(expression)
1919
/// A URL pointing to the GitHub App's public avatar.
2020
/// </summary>
2121
/// <param name="size">The size of the resulting square image.</param>
22-
public string AvatarUrl(Arg<int>? size = null) => null;
22+
public string AvatarUrl(Arg<int>? size = null) => default;
2323

2424
/// <summary>
2525
/// Identifies the date and time when the object was created.

Octokit.GraphQL/Model/ContributionsCollection.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ public ContributionsCollection(Expression expression) : base(expression)
8181
/// </summary>
8282
/// <param name="excludeFirst">Should the user's first issue ever be excluded from this count.</param>
8383
/// <param name="excludePopular">Should the user's most commented issue be excluded from this count.</param>
84-
public int TotalIssueContributions(Arg<bool>? excludeFirst = null, Arg<bool>? excludePopular = null) => null;
84+
public int TotalIssueContributions(Arg<bool>? excludeFirst = null, Arg<bool>? excludePopular = null) => default;
8585

8686
/// <summary>
8787
/// How many pull requests the user opened.
8888
/// </summary>
8989
/// <param name="excludeFirst">Should the user's first pull request ever be excluded from this count.</param>
9090
/// <param name="excludePopular">Should the user's most commented pull request be excluded from this count.</param>
91-
public int TotalPullRequestContributions(Arg<bool>? excludeFirst = null, Arg<bool>? excludePopular = null) => null;
91+
public int TotalPullRequestContributions(Arg<bool>? excludeFirst = null, Arg<bool>? excludePopular = null) => default;
9292

9393
/// <summary>
9494
/// How many pull request reviews the user left.
@@ -105,7 +105,7 @@ public ContributionsCollection(Expression expression) : base(expression)
105105
/// </summary>
106106
/// <param name="excludeFirst">Should the user's first issue ever be excluded from this count.</param>
107107
/// <param name="excludePopular">Should the user's most commented issue be excluded from this count.</param>
108-
public int TotalRepositoriesWithContributedIssues(Arg<bool>? excludeFirst = null, Arg<bool>? excludePopular = null) => null;
108+
public int TotalRepositoriesWithContributedIssues(Arg<bool>? excludeFirst = null, Arg<bool>? excludePopular = null) => default;
109109

110110
/// <summary>
111111
/// How many different repositories the user left pull request reviews in.
@@ -117,13 +117,13 @@ public ContributionsCollection(Expression expression) : base(expression)
117117
/// </summary>
118118
/// <param name="excludeFirst">Should the user's first pull request ever be excluded from this count.</param>
119119
/// <param name="excludePopular">Should the user's most commented pull request be excluded from this count.</param>
120-
public int TotalRepositoriesWithContributedPullRequests(Arg<bool>? excludeFirst = null, Arg<bool>? excludePopular = null) => null;
120+
public int TotalRepositoriesWithContributedPullRequests(Arg<bool>? excludeFirst = null, Arg<bool>? excludePopular = null) => default;
121121

122122
/// <summary>
123123
/// How many repositories the user created.
124124
/// </summary>
125125
/// <param name="excludeFirst">Should the user's first repository ever be excluded from this count.</param>
126-
public int TotalRepositoryContributions(Arg<bool>? excludeFirst = null) => null;
126+
public int TotalRepositoryContributions(Arg<bool>? excludeFirst = null) => default;
127127

128128
/// <summary>
129129
/// The user who made the contributions in this collection.

Octokit.GraphQL/Model/GitActor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public GitActor(Expression expression) : base(expression)
1919
/// A URL pointing to the author's public avatar.
2020
/// </summary>
2121
/// <param name="size">The size of the resulting square image.</param>
22-
public string AvatarUrl(Arg<int>? size = null) => null;
22+
public string AvatarUrl(Arg<int>? size = null) => default;
2323

2424
/// <summary>
2525
/// The timestamp of the Git action (authoring or committing).

Octokit.GraphQL/Model/MarketplaceListing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public MarketplaceListing(Expression expression) : base(expression)
131131
/// URL for the listing's logo image.
132132
/// </summary>
133133
/// <param name="size">The size in pixels of the resulting square image.</param>
134-
public string LogoUrl(Arg<int>? size = null) => null;
134+
public string LogoUrl(Arg<int>? size = null) => default;
135135

136136
/// <summary>
137137
/// The listing's full name.

Octokit.GraphQL/Model/Organization.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Organization(Expression expression) : base(expression)
1919
/// A URL pointing to the organization's public avatar.
2020
/// </summary>
2121
/// <param name="size">The size of the resulting square image.</param>
22-
public string AvatarUrl(Arg<int>? size = null) => null;
22+
public string AvatarUrl(Arg<int>? size = null) => default;
2323

2424
/// <summary>
2525
/// Identifies the primary key from the database.

0 commit comments

Comments
 (0)