Skip to content

Commit

Permalink
Migrate NGitLab from net461 to net472 + bump up LangVersion to 11.0
Browse files Browse the repository at this point in the history
Plus fix some analyzer rules
  • Loading branch information
louis-z committed Oct 3, 2023
1 parent c8b1b52 commit 00dbfbc
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Authors>$(Company), NGitLab contributors</Authors>

<!-- Compile Options -->
<LangVersion>10.0</LangVersion>
<LangVersion>11.0</LangVersion>
<Deterministic>true</Deterministic>
<Features>strict</Features>
<TreatWarningsAsErrors Condition="'$(Configuration)' != 'Debug'">true</TreatWarningsAsErrors>
Expand Down
8 changes: 4 additions & 4 deletions NGitLab/DynamicEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public DynamicEnum(string stringValue)
StringValue = stringValue;
}

public bool Equals(TEnum other)
public readonly bool Equals(TEnum other)
{
return Equals(EnumValue, other);
}

public bool Equals(DynamicEnum<TEnum> other)
public readonly bool Equals(DynamicEnum<TEnum> other)
{
return EqualityComparer<TEnum?>.Default.Equals(EnumValue, other.EnumValue) &&
StringComparer.OrdinalIgnoreCase.Equals(StringValue, other.StringValue);
Expand All @@ -51,7 +51,7 @@ public override bool Equals(object obj)
return obj is DynamicEnum<TEnum> other && Equals(other);
}

public override int GetHashCode()
public override readonly int GetHashCode()
{
return EqualityComparer<TEnum?>.Default.GetHashCode(EnumValue);
}
Expand All @@ -64,7 +64,7 @@ public override int GetHashCode()

public static bool operator !=(DynamicEnum<TEnum> obj1, TEnum obj2) => !obj1.Equals(obj2);

public override string ToString()
public override readonly string ToString()
{
return StringValue ?? EnumValue?.ToString() ?? string.Empty;
}
Expand Down
2 changes: 1 addition & 1 deletion NGitLab/Impl/ProjectClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static string CreateGetUrl(ProjectQuery query)
// This is the default, it returns all visible projects.
break;
default:
throw new ArgumentOutOfRangeException();
throw new ArgumentOutOfRangeException(nameof(query), $"'{nameof(query.Scope)}' has unknown value '{query.Scope}'");
}

url = Utils.AddParameter(url, "archived", query.Archived);
Expand Down
2 changes: 0 additions & 2 deletions NGitLab/Impl/RepositoryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ public class RepositoryClient : IRepositoryClient
private readonly API _api;
private readonly string _repoPath;
private readonly string _projectPath;
private readonly int _projectId;

public RepositoryClient(API api, int projectId)
{
_api = api;
_projectId = projectId;
_projectPath = Project.Url + "/" + projectId.ToStringInvariant();
_repoPath = _projectPath + "/repository";
}
Expand Down
2 changes: 1 addition & 1 deletion NGitLab/Impl/SshKeyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class SshKeyClient : ISshKeyClient
public SshKeyClient(API api, int? userId)
{
_api = api;
_url = userId != null ? $"users/{userId}/keys" : "user/keys";
_url = userId != null ? $"users/{userId.Value.ToStringInvariant()}/keys" : "user/keys";
}

public IEnumerable<SshKey> All => _api.Get().GetAll<SshKey>(_url);
Expand Down
4 changes: 2 additions & 2 deletions NGitLab/NGitLab.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Net.Http" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
Expand Down

0 comments on commit 00dbfbc

Please sign in to comment.