Skip to content

Commit

Permalink
Migrate NGitLab from net461 to net462 + bump up LangVersion to 11.0 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-z authored Oct 4, 2023
1 parent c8b1b52 commit 705e880
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 16 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
10 changes: 5 additions & 5 deletions NGitLab/DynamicEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ 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);
}

public override bool Equals(object obj)
public override readonly 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
3 changes: 1 addition & 2 deletions NGitLab/Impl/Json/EnumConverterFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
using NGitLab.Models;
Expand Down Expand Up @@ -38,7 +37,7 @@ public EnumConverter()
foreach (var mapping in _enumType.GetEnumMappings())
{
enumValues.Add((TEnum)mapping.EnumValue);
stringValues.Add(mapping.StringValue ?? mapping.EnumValue.ToString(CultureInfo.InvariantCulture));
stringValues.Add(mapping.StringValue ?? mapping.EnumValue.ToString());
}

_stringToEnumValues = new Dictionary<string, TEnum>(stringValues.Count, StringComparer.OrdinalIgnoreCase);
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>net462;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)' == 'net462'">
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Net.Http" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.202",
"rollForward": "major"
"version": "7.0.100",
"rollForward": "latestFeature"
}
}

0 comments on commit 705e880

Please sign in to comment.