Skip to content

Commit

Permalink
Convert public fields to properties (#814)
Browse files Browse the repository at this point in the history
* Convert public fields to properties

* Run dotnet format

* Don't include fields in JSON serialization anymore

* Make Runner.Online a nullable bool

* Delete script
  • Loading branch information
louis-z authored Dec 16, 2024
1 parent 8bf473e commit 69e81d3
Show file tree
Hide file tree
Showing 125 changed files with 2,230 additions and 1,502 deletions.
2 changes: 1 addition & 1 deletion NGitLab.Mock.Tests/GroupsMockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public void Test_create_update_delete_group_hooks()
var groupId = 1;

using var server = new GitLabConfig()
.WithUser("user1", isAdmin: true)
.WithUser("user1", isAdmin: true)
.WithGroup("group1", groupId)
.BuildServer();

Expand Down
2 changes: 1 addition & 1 deletion NGitLab.Mock.Tests/UsingVerify/RepositoryMockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using NGitLab.Mock.Clients;
using NGitLab.Mock.Config;
using NUnit.Framework;
using static VerifyNUnit.Verifier;
using RepositoryGetTreeOptions = NGitLab.Models.RepositoryGetTreeOptions;
using Throws = NUnit.Framework.Throws;
using static VerifyNUnit.Verifier;

namespace NGitLab.Mock.Tests.UsingVerify;

Expand Down
2 changes: 1 addition & 1 deletion NGitLab.Mock/Change.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Change : GitLabObject

public Models.Change ToChange()
{
return new ()
return new()
{
Diff = Diff,
AMode = AMode,
Expand Down
2 changes: 1 addition & 1 deletion NGitLab.Mock/Clients/MergeRequestChangeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NGitLab.Mock.Clients;

internal sealed class MergeRequestChangeClient : ClientBase, IMergeRequestChangeClient
internal sealed class MergeRequestChangeClient : ClientBase, IMergeRequestChangeClient
{
private readonly long _projectId;
private readonly long _mergeRequestIid;
Expand Down
2 changes: 1 addition & 1 deletion NGitLab.Mock/PipelineSchedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public PipelineScheduleBasic ToPipelineScheduleBasicClient()
public Models.PipelineSchedule ToPipelineScheduleClient()
=> new()
{
Id = Id,
Id = Id,
Active = Active,
CreatedAt = CreatedAt,
Cron = Cron,
Expand Down
2 changes: 1 addition & 1 deletion NGitLab.Tests/AsyncApiValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void ValidateAsyncMethodSignature()

if (parameterInfo.ParameterType != typeof(CancellationToken))
{
Assert.Fail($"The last parameter of method '{method}' must be of type 'CancellationToken' and named 'cancellationToken'");
Assert.Fail($"The last parameter of method '{method}' must be of type 'CancellationToken' and named 'cancellationToken'");
}

if (!string.Equals(parameterInfo.Name, "cancellationToken", StringComparison.Ordinal))
Expand Down
3 changes: 2 additions & 1 deletion NGitLab.Tests/PipelineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public async Task Test_can_list_jobs_from_pipeline()

var pipelineJobQuery = new PipelineJobQuery
{
PipelineId = pipeline.Id, Scope = new[] { "success", "pending" },
PipelineId = pipeline.Id,
Scope = new[] { "success", "pending" },
};
var allJobs = await GitLabTestContext.RetryUntilAsync(() => pipelineClient.GetJobsAsync(pipelineJobQuery).ToList(), p => p.Count != 0, TimeSpan.FromSeconds(120));
Assert.That(allJobs.Count != 0);
Expand Down
2 changes: 1 addition & 1 deletion NGitLab.Tests/RunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ private static RetryPolicy GetRetryPolicy()
{
return Policy
.Handle<GitLabException>(ex => ex.StatusCode is HttpStatusCode.Forbidden)
.WaitAndRetry(3, sleepDurationProvider: attempt => TimeSpan.FromSeconds(2 * attempt));
.WaitAndRetry(3, sleepDurationProvider: attempt => TimeSpan.FromSeconds(2 * attempt));
}
}
1 change: 0 additions & 1 deletion NGitLab/Impl/Json/Serializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ internal static class Serializer
{
private static readonly JsonSerializerOptions _options = new()
{
IncludeFields = true,
Converters =
{
new BooleanConverter(),
Expand Down
2 changes: 1 addition & 1 deletion NGitLab/Models/AccessControl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace NGitLab.Models;

Expand Down
14 changes: 7 additions & 7 deletions NGitLab/Models/Assignee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ namespace NGitLab.Models;
public class Assignee
{
[JsonPropertyName("id")]
public long Id;
public long Id { get; set; }

[JsonPropertyName("username")]
public string Username;
public string Username { get; set; }

[JsonPropertyName("email")]
public string Email;
public string Email { get; set; }

[JsonPropertyName("name")]
public string Name;
public string Name { get; set; }

[JsonPropertyName("state")]
public string State;
public string State { get; set; }

[JsonPropertyName("created_at")]
public DateTime CreatedAt;
public DateTime CreatedAt { get; set; }

[JsonPropertyName("avatar_url")]
public string AvatarURL;
public string AvatarURL { get; set; }
}
16 changes: 8 additions & 8 deletions NGitLab/Models/Author.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ namespace NGitLab.Models;
public class Author
{
[JsonPropertyName("id")]
public long Id;
public long Id { get; set; }

[JsonPropertyName("username")]
public string Username;
public string Username { get; set; }

[JsonPropertyName("email")]
public string Email;
public string Email { get; set; }

[JsonPropertyName("name")]
public string Name;
public string Name { get; set; }

[JsonPropertyName("state")]
public string State;
public string State { get; set; }

[JsonPropertyName("created_at")]
public DateTime CreatedAt;
public DateTime CreatedAt { get; set; }

[JsonPropertyName("avatar_url")]
public string AvatarUrl;
public string AvatarUrl { get; set; }

[JsonPropertyName("web_url")]
public string WebUrl;
public string WebUrl { get; set; }
}
12 changes: 6 additions & 6 deletions NGitLab/Models/Badge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ namespace NGitLab.Models;
public class Badge
{
[JsonPropertyName("id")]
public long Id;
public long Id { get; set; }

[JsonPropertyName("link_url")]
public string LinkUrl;
public string LinkUrl { get; set; }

[JsonPropertyName("image_url")]
public string ImageUrl;
public string ImageUrl { get; set; }

[JsonPropertyName("rendered_link_url")]
public string RenderedLinkUrl;
public string RenderedLinkUrl { get; set; }

[JsonPropertyName("rendered_image_url")]
public string RenderedImageUrl;
public string RenderedImageUrl { get; set; }

[JsonPropertyName("kind")]
public BadgeKind Kind;
public BadgeKind Kind { get; set; }
}
4 changes: 2 additions & 2 deletions NGitLab/Models/BadgeCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace NGitLab.Models;
public class BadgeCreate
{
[JsonPropertyName("link_url")]
public string LinkUrl;
public string LinkUrl { get; set; }

[JsonPropertyName("image_url")]
public string ImageUrl;
public string ImageUrl { get; set; }
}
4 changes: 2 additions & 2 deletions NGitLab/Models/BadgeUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace NGitLab.Models;
public class BadgeUpdate
{
[JsonPropertyName("link_url")]
public string LinkUrl;
public string LinkUrl { get; set; }

[JsonPropertyName("image_url")]
public string ImageUrl;
public string ImageUrl { get; set; }
}
8 changes: 4 additions & 4 deletions NGitLab/Models/Blob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace NGitLab.Models;
public class Blob
{
[JsonPropertyName("size")]
public int Size;
public int Size { get; set; }

[JsonPropertyName("encoding")]
public string Encoding;
public string Encoding { get; set; }

[JsonPropertyName("content")]
public string Content;
public string Content { get; set; }

[JsonPropertyName("sha")]
public Sha1 Sha;
public Sha1 Sha { get; set; }
}
16 changes: 8 additions & 8 deletions NGitLab/Models/Branch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ namespace NGitLab.Models;
public class Branch
{
[JsonPropertyName("name")]
public string Name;
public string Name { get; set; }

[JsonPropertyName("merged")]
public bool Merged;
public bool Merged { get; set; }

[JsonPropertyName("protected")]
public bool Protected;
public bool Protected { get; set; }

[JsonPropertyName("default")]
public bool Default;
public bool Default { get; set; }

[JsonPropertyName("developers_can_push")]
public bool DevelopersCanPush;
public bool DevelopersCanPush { get; set; }

[JsonPropertyName("developers_can_merge")]
public bool DevelopersCanMerge;
public bool DevelopersCanMerge { get; set; }

[JsonPropertyName("can_push")]
public bool CanPush;
public bool CanPush { get; set; }

[JsonPropertyName("commit")]
public CommitInfo Commit;
public CommitInfo Commit { get; set; }
}
4 changes: 2 additions & 2 deletions NGitLab/Models/BranchCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace NGitLab.Models;
public class BranchCreate
{
[JsonPropertyName("branch")]
public string Name;
public string Name { get; set; }

[JsonPropertyName("ref")]
public string Ref;
public string Ref { get; set; }
}
2 changes: 1 addition & 1 deletion NGitLab/Models/Change.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace NGitLab.Models;

Expand Down
8 changes: 4 additions & 4 deletions NGitLab/Models/ClusterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace NGitLab.Models;
public class ClusterInfo
{
[JsonPropertyName("id")]
public long Id;
public long Id { get; set; }

[JsonPropertyName("name")]
public string Name;
public string Name { get; set; }

[JsonPropertyName("platform_type")]
public string PlatformType;
public string PlatformType { get; set; }

[JsonPropertyName("environment_scope")]
public string EnvionmentScope;
public string EnvionmentScope { get; set; }
}
32 changes: 16 additions & 16 deletions NGitLab/Models/Commit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,50 @@ public class Commit
public const string Url = "/commits";

[JsonPropertyName("id")]
public Sha1 Id;
public Sha1 Id { get; set; }

[JsonPropertyName("title")]
public string Title;
public string Title { get; set; }

[JsonPropertyName("short_id")]
public string ShortId;
public string ShortId { get; set; }

[JsonPropertyName("author_name")]
public string AuthorName;
public string AuthorName { get; set; }

[JsonPropertyName("author_email")]
public string AuthorEmail;
public string AuthorEmail { get; set; }

[JsonPropertyName("authored_date")]
public DateTime AuthoredDate;
public DateTime AuthoredDate { get; set; }

[JsonPropertyName("committer_name")]
public string CommitterName;
public string CommitterName { get; set; }

[JsonPropertyName("committer_email")]
public string CommitterEmail;
public string CommitterEmail { get; set; }

[JsonPropertyName("committed_date")]
public DateTime CommittedDate;
public DateTime CommittedDate { get; set; }

[JsonPropertyName("created_at")]
public DateTime CreatedAt;
public DateTime CreatedAt { get; set; }

[JsonPropertyName("message")]
public string Message;
public string Message { get; set; }

[JsonPropertyName("parent_ids")]
public Sha1[] Parents;
public Sha1[] Parents { get; set; }

[JsonPropertyName("status")]
public string Status;
public string Status { get; set; }

[JsonPropertyName("stats")]
public CommitStats Stats;
public CommitStats Stats { get; set; }

[JsonPropertyName("web_url")]
public string WebUrl;
public string WebUrl { get; set; }

[JsonPropertyName("last_pipeline")]
public Pipeline LastPipeline;
public Pipeline LastPipeline { get; set; }
}
2 changes: 1 addition & 1 deletion NGitLab/Models/CommitCherryPick.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace NGitLab.Models;
Expand Down
Loading

0 comments on commit 69e81d3

Please sign in to comment.