Skip to content

Commit 8c629b7

Browse files
authored
Remove a lot of Jetbrains.Annotations (#2787)
1 parent 8b08c43 commit 8c629b7

38 files changed

+75
-223
lines changed
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,51 @@
11
using System.ComponentModel.DataAnnotations;
2-
using JetBrains.Annotations;
32

43
namespace JoinRpg.CommonUI.Models;
54

65
public enum CommentExtraAction
76
{
87
[Display(Name = "Финансовая операция подтверждена", ShortName = "отмечено")]
9-
[UsedImplicitly]
108
ApproveFinance,
119

1210
[Display(Name = "Финансовая операция отклонена", ShortName = "отмечено")]
13-
[UsedImplicitly]
1411
RejectFinance,
1512

1613
[Display(Name = "Заявка одобрена мастером", ShortName = "одобрена")]
17-
[UsedImplicitly]
1814
ApproveByMaster,
1915

2016
[Display(Name = "Заявка отклонена мастером", ShortName = "отклонена")]
21-
[UsedImplicitly]
2217
DeclineByMaster,
2318

2419
[Display(Name = "Заявка восстановлена мастером", ShortName = "восстановлена")]
25-
[UsedImplicitly]
2620
RestoreByMaster,
2721

2822
[Display(Name = "Заявка перемещена мастером", ShortName = "изменена")]
29-
[UsedImplicitly]
3023
MoveByMaster,
3124

3225
[Display(Name = "Заявка отозвана игроком", ShortName = "отозвана")]
33-
[UsedImplicitly]
3426
DeclineByPlayer,
3527

3628
[Display(Name = "Ответственный мастер изменен", ShortName = "изменена")]
37-
[UsedImplicitly]
3829
ChangeResponsible,
3930

4031
[Display(Name = "Новая заявка", ShortName = "подана")]
41-
[UsedImplicitly]
4232
NewClaim,
4333

4434
[Display(Name = "Заявка поставлена в лист ожидания", ShortName = "изменена")]
45-
[UsedImplicitly]
4635
OnHoldByMaster,
4736

4837
[Display(Name = "Сумма взноса установлена вручную", ShortName = "изменена")]
49-
[UsedImplicitly]
5038
FeeChanged,
5139

5240
[Display(Name = "Пройдена регистрация на полигоне", ShortName = "изменена")]
53-
[UsedImplicitly]
5441
CheckedIn,
5542

5643
[Display(Name = "Выпущен второй ролью", ShortName = "изменена")]
57-
[UsedImplicitly]
5844
SecondRole,
5945

6046
[Display(Name = "Игрок вышел из игры", ShortName = "изменена")]
61-
[UsedImplicitly]
6247
OutOfGame,
6348

6449
[Display(Name = "Запрос льготного взноса", ShortName = "изменена")]
65-
[UsedImplicitly]
6650
RequestPreferential,
6751
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
using JetBrains.Annotations;
21
using JoinRpg.DataModel;
32

43
namespace JoinRpg.Domain.CharacterFields;
54

65
public interface IFieldDefaultValueGenerator
76
{
8-
string? CreateDefaultValue([CanBeNull] Claim? claim, [NotNull] FieldWithValue field);
9-
string? CreateDefaultValue([CanBeNull] Character? character, [NotNull] FieldWithValue field);
7+
string? CreateDefaultValue(Claim? claim, FieldWithValue field);
8+
string? CreateDefaultValue(Character? character, FieldWithValue field);
109
}

src/JoinRpg.Domain/ClaimAcccessExtensions.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Linq.Expressions;
2-
using JetBrains.Annotations;
32
using JoinRpg.DataModel;
43

54
namespace JoinRpg.Domain;
@@ -16,8 +15,7 @@ public enum ExtraAccessReason
1615

1716
public static class ClaimAcccessExtensions
1817
{
19-
[NotNull]
20-
public static Claim RequestAccess([CanBeNull]
18+
public static Claim RequestAccess(
2119
this Claim claim,
2220
int currentUserId,
2321
Expression<Func<ProjectAcl, bool>> access,
@@ -36,27 +34,19 @@ public static Claim RequestAccess([CanBeNull]
3634
return claim;
3735
}
3836

39-
[NotNull]
40-
public static Claim RequestAccess([CanBeNull]
37+
public static Claim RequestAccess(
4138
this Claim claim,
4239
int currentUserId,
4340
ExtraAccessReason reasons = ExtraAccessReason.None) => claim.RequestAccess(currentUserId, acl => true, reasons);
4441

45-
public static bool HasAccess([NotNull] this Claim claim,
42+
public static bool HasAccess(this Claim claim,
4643
int? userId,
47-
[NotNull]
4844
Expression<Func<ProjectAcl, bool>> permission,
4945
ExtraAccessReason reasons = ExtraAccessReason.None)
5046
{
51-
if (claim == null)
52-
{
53-
throw new ArgumentNullException(nameof(claim));
54-
}
47+
ArgumentNullException.ThrowIfNull(claim);
5548

56-
if (permission == null)
57-
{
58-
throw new ArgumentNullException(nameof(permission));
59-
}
49+
ArgumentNullException.ThrowIfNull(permission);
6050

6151
if (userId == null)
6252
{
@@ -76,7 +66,7 @@ public static bool HasAccess([NotNull] this Claim claim,
7666
return claim.HasMasterAccess(userId, permission);
7767
}
7868

79-
public static bool HasAccess([NotNull] this Claim claim,
69+
public static bool HasAccess(this Claim claim,
8070
int? userId,
8171
ExtraAccessReason reasons = ExtraAccessReason.None) => claim.HasAccess(userId, acl => true, reasons);
8272
}

src/JoinRpg.Domain/ClaimExtensions.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using JetBrains.Annotations;
1+
using System.Diagnostics.Contracts;
22
using JoinRpg.DataModel;
33
using JoinRpg.Helpers;
44

@@ -25,8 +25,7 @@ public static bool HasOtherClaimsForThisCharacter(this Claim claim)
2525
return claim.Character?.Claims?.Where(c => c.PlayerUserId != claim.PlayerUserId && c.ClaimStatus.IsActive())?.Any() ?? false;
2626
}
2727

28-
[NotNull]
29-
public static IClaimSource GetTarget([NotNull] this Claim claim)
28+
public static IClaimSource GetTarget(this Claim claim)
3029
{
3130
if (claim == null)
3231
{
@@ -38,7 +37,7 @@ public static IClaimSource GetTarget([NotNull] this Claim claim)
3837
?? throw new InvalidOperationException("Claim not bound neither to character nor character group. That shouldn't happen"); ;
3938
}
4039

41-
[NotNull, ItemNotNull, MustUseReturnValue]
40+
[Pure]
4241
public static IEnumerable<CharacterGroup> GetGroupsPartOf(this IClaimSource? claimSource)
4342
{
4443
return claimSource
@@ -125,13 +124,10 @@ public static void ChangeStatusWithCheck(this Claim claim, Claim.Status targetSt
125124
claim.ClaimStatus = targetStatus;
126125
}
127126

128-
[CanBeNull, MustUseReturnValue]
129-
public static Claim? TrySelectSingleClaim([NotNull, ItemNotNull] this IReadOnlyCollection<Claim> claims)
127+
[Pure]
128+
public static Claim? TrySelectSingleClaim(this IReadOnlyCollection<Claim> claims)
130129
{
131-
if (claims == null)
132-
{
133-
throw new ArgumentNullException(nameof(claims));
134-
}
130+
ArgumentNullException.ThrowIfNull(claims);
135131

136132
if (claims.Count(c => c.IsApproved) == 1)
137133
{
@@ -148,9 +144,8 @@ public static void ChangeStatusWithCheck(this Claim claim, Claim.Status targetSt
148144
return null;
149145
}
150146

151-
[CanBeNull, MustUseReturnValue]
147+
[Pure]
152148
public static Claim? TrySelectSingleClaim(
153-
[NotNull, ItemNotNull]
154149
this IEnumerable<Claim> claims)
155150
=> claims.ToList().TrySelectSingleClaim();
156151
//That's not optimal way to do it, but in practice, claims.Length will be 1 or 2.

src/JoinRpg.Domain/Exceptions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Linq.Expressions;
2-
using JetBrains.Annotations;
32
using JoinRpg.DataModel;
43
using JoinRpg.Helpers;
54

@@ -28,7 +27,6 @@ public class MustBeAdminException : JoinRpgInvalidUserException
2827

2928
public class JoinRpgProjectException : JoinRpgBaseException
3029
{
31-
[PublicAPI]
3230
public Project Project { get; }
3331

3432
public JoinRpgProjectException(Project project, string message) : base(message) => Project = project;
@@ -223,7 +221,6 @@ public RoomIsOccupiedException(ProjectAccommodation entity) : base(entity, "Cann
223221

224222
public class NoAccessToProjectException : JoinRpgProjectEntityException
225223
{
226-
[PublicAPI]
227224
public int? UserId { get; }
228225

229226
public NoAccessToProjectException(Project project, int? userId, Expression<Func<ProjectAcl, bool>> accessExpression)

src/JoinRpg.Domain/FinanceExtensions.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using JetBrains.Annotations;
21
using JoinRpg.DataModel;
32
using JoinRpg.DataModel.Finances;
43
using JoinRpg.PrimitiveTypes.ProjectMetadata;
@@ -209,8 +208,7 @@ public static void UpdateClaimFeeIfRequired(this Claim claim, DateTime operation
209208
}
210209
}
211210

212-
[CanBeNull]
213-
public static PaymentType? GetCashPaymentType([NotNull]
211+
public static PaymentType? GetCashPaymentType(
214212
this Project project,
215213
int userId)
216214
{
@@ -222,9 +220,8 @@ public static void UpdateClaimFeeIfRequired(this Claim claim, DateTime operation
222220
return project.PaymentTypes.SingleOrDefault(pt => pt.UserId == userId && pt.TypeKind == PaymentTypeKind.Cash);
223221
}
224222

225-
public static bool CanAcceptCash([NotNull]
223+
public static bool CanAcceptCash(
226224
this Project project,
227-
[NotNull]
228225
User user)
229226
{
230227
if (project == null)

src/JoinRpg.Domain/JoinRpg.Domain.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
</ItemGroup>
1212
<ItemGroup>
1313
<PackageReference Include="Autofac" Version="8.1.0" />
14-
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />
1514
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
1615
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1716
</ItemGroup>
Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,21 @@
1-
using JetBrains.Annotations;
21
using JoinRpg.DataModel;
32

43
namespace JoinRpg.Domain;
54

65
public static class PlotExtensions
76
{
8-
public static IEnumerable<IWorldObject> GetTargets([NotNull] this PlotElement element)
7+
public static IEnumerable<IWorldObject> GetTargets(this PlotElement element)
98
{
10-
if (element == null)
11-
{
12-
throw new ArgumentNullException(nameof(element));
13-
}
9+
ArgumentNullException.ThrowIfNull(element);
1410

1511
return element.TargetCharacters.Cast<IWorldObject>().Union(element.TargetGroups);
1612
}
1713

18-
[NotNull, ItemNotNull]
19-
public static PlotElement[] SelectPlots([NotNull] this Character character, [NotNull] IEnumerable<PlotElement> selectMany)
14+
public static PlotElement[] SelectPlots(this Character character, IEnumerable<PlotElement> selectMany)
2015
{
21-
if (character == null)
22-
{
23-
throw new ArgumentNullException(nameof(character));
24-
}
16+
ArgumentNullException.ThrowIfNull(character);
2517

26-
if (selectMany == null)
27-
{
28-
throw new ArgumentNullException(nameof(selectMany));
29-
}
18+
ArgumentNullException.ThrowIfNull(selectMany);
3019

3120
var groups = character.GetParentGroupsToTop().Select(g => g.CharacterGroupId);
3221
return selectMany
@@ -35,18 +24,11 @@ public static PlotElement[] SelectPlots([NotNull] this Character character, [Not
3524
p.TargetGroups.Any(g => groups.Contains(g.CharacterGroupId))).ToArray();
3625
}
3726

38-
public static int CountCharacters([NotNull] this PlotElement element,
39-
[NotNull, ItemNotNull] IReadOnlyCollection<Character> characters)
27+
public static int CountCharacters(this PlotElement element, IReadOnlyCollection<Character> characters)
4028
{
41-
if (element == null)
42-
{
43-
throw new ArgumentNullException(nameof(element));
44-
}
29+
ArgumentNullException.ThrowIfNull(element);
4530

46-
if (characters == null)
47-
{
48-
throw new ArgumentNullException(nameof(characters));
49-
}
31+
ArgumentNullException.ThrowIfNull(characters);
5032

5133
return characters.Count(character =>
5234
{
@@ -63,13 +45,12 @@ public static int CountCharacters([NotNull] this PlotElement element,
6345
});
6446
}
6547

66-
[NotNull]
67-
public static PlotElementTexts LastVersion([NotNull] this PlotElement e) => e.Texts.OrderByDescending(text => text.Version).First();
48+
public static PlotElementTexts LastVersion(this PlotElement e) => e.Texts.OrderByDescending(text => text.Version).First();
6849

69-
public static PlotElementTexts? SpecificVersion([NotNull] this PlotElement e, int version) => e.Texts.SingleOrDefault(text => text.Version == version);
50+
public static PlotElementTexts? SpecificVersion(this PlotElement e, int version) => e.Texts.SingleOrDefault(text => text.Version == version);
7051

7152
//TODO consider return NUll if deleted
72-
public static PlotElementTexts? PublishedVersion([NotNull] this PlotElement e) => e.Published != null ? e.SpecificVersion((int)e.Published) : null;
53+
public static PlotElementTexts? PublishedVersion(this PlotElement e) => e.Published != null ? e.SpecificVersion((int)e.Published) : null;
7354

7455
public static PlotElementTexts? PrevVersion(this PlotElement e) => e.Texts.OrderByDescending(text => text.Version).Skip(1).FirstOrDefault();
7556
}

src/JoinRpg.Domain/Problems/ClaimProblem.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
using JetBrains.Annotations;
2-
31
namespace JoinRpg.Domain.Problems;
42

53
public class ClaimProblem
64
{
75
public ClaimProblemType ProblemType { get; }
86

97
public DateTime? ProblemTime { get; }
10-
[CanBeNull]
118
public string? ExtraInfo { get; }
129

1310
public ProblemSeverity Severity { get; }

src/JoinRpg.Domain/Problems/ClaimProblemType.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using JetBrains.Annotations;
2-
31
namespace JoinRpg.Domain.Problems;
42

53
public enum ClaimProblemType
@@ -17,7 +15,7 @@ public enum ClaimProblemType
1715
UnApprovedClaimPayment,
1816
ClaimWorkStopped,
1917
ClaimDontHaveTarget,
20-
[Obsolete, UsedImplicitly]
18+
[Obsolete]
2119
DeletedFieldHasValue,
2220
FieldIsEmpty,
2321
FieldShouldNotHaveValue,

0 commit comments

Comments
 (0)