Skip to content

Commit 9435295

Browse files
authored
Revert sealed Attributes (#1734)
Revert sealed Attributes
1 parent 2bf78ca commit 9435295

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

Refit/Attributes.cs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public abstract class HttpMethodAttribute(string path) : Attribute
3737
/// </remarks>
3838
/// <param name="path">The path.</param>
3939
[AttributeUsage(AttributeTargets.Method)]
40-
public sealed class GetAttribute(string path) : HttpMethodAttribute(path)
40+
#pragma warning disable CA1813 // Avoid unsealed attributes
41+
public class GetAttribute(string path) : HttpMethodAttribute(path)
4142
{
4243
/// <summary>
4344
/// Gets the method.
@@ -56,7 +57,7 @@ public sealed class GetAttribute(string path) : HttpMethodAttribute(path)
5657
/// </remarks>
5758
/// <param name="path">The path.</param>
5859
[AttributeUsage(AttributeTargets.Method)]
59-
public sealed class PostAttribute(string path) : HttpMethodAttribute(path)
60+
public class PostAttribute(string path) : HttpMethodAttribute(path)
6061
{
6162
/// <summary>
6263
/// Gets the method.
@@ -75,7 +76,7 @@ public sealed class PostAttribute(string path) : HttpMethodAttribute(path)
7576
/// </remarks>
7677
/// <param name="path">The path.</param>
7778
[AttributeUsage(AttributeTargets.Method)]
78-
public sealed class PutAttribute(string path) : HttpMethodAttribute(path)
79+
public class PutAttribute(string path) : HttpMethodAttribute(path)
7980
{
8081
/// <summary>
8182
/// Gets the method.
@@ -94,7 +95,7 @@ public sealed class PutAttribute(string path) : HttpMethodAttribute(path)
9495
/// </remarks>
9596
/// <param name="path">The path.</param>
9697
[AttributeUsage(AttributeTargets.Method)]
97-
public sealed class DeleteAttribute(string path) : HttpMethodAttribute(path)
98+
public class DeleteAttribute(string path) : HttpMethodAttribute(path)
9899
{
99100
/// <summary>
100101
/// Gets the method.
@@ -113,15 +114,15 @@ public sealed class DeleteAttribute(string path) : HttpMethodAttribute(path)
113114
/// </remarks>
114115
/// <param name="path">The path.</param>
115116
[AttributeUsage(AttributeTargets.Method)]
116-
public sealed class PatchAttribute(string path) : HttpMethodAttribute(path)
117+
public class PatchAttribute(string path) : HttpMethodAttribute(path)
117118
{
118119
/// <summary>
119120
/// Gets the method.
120121
/// </summary>
121122
/// <value>
122123
/// The method.
123124
/// </value>
124-
public override HttpMethod Method => new HttpMethod("PATCH");
125+
public override HttpMethod Method => new("PATCH");
125126
}
126127

127128
/// <summary>
@@ -132,15 +133,15 @@ public sealed class PatchAttribute(string path) : HttpMethodAttribute(path)
132133
/// </remarks>
133134
/// <param name="path">The path.</param>
134135
[AttributeUsage(AttributeTargets.Method)]
135-
public sealed class OptionsAttribute(string path) : HttpMethodAttribute(path)
136+
public class OptionsAttribute(string path) : HttpMethodAttribute(path)
136137
{
137138
/// <summary>
138139
/// Gets the method.
139140
/// </summary>
140141
/// <value>
141142
/// The method.
142143
/// </value>
143-
public override HttpMethod Method => new HttpMethod("OPTIONS");
144+
public override HttpMethod Method => new("OPTIONS");
144145
}
145146

146147
/// <summary>
@@ -151,7 +152,7 @@ public sealed class OptionsAttribute(string path) : HttpMethodAttribute(path)
151152
/// </remarks>
152153
/// <param name="path">The path.</param>
153154
[AttributeUsage(AttributeTargets.Method)]
154-
public sealed class HeadAttribute(string path) : HttpMethodAttribute(path)
155+
public class HeadAttribute(string path) : HttpMethodAttribute(path)
155156
{
156157
/// <summary>
157158
/// Gets the method.
@@ -173,7 +174,7 @@ public sealed class HeadAttribute(string path) : HttpMethodAttribute(path)
173174
/// </remarks>
174175
/// <param name="boundaryText">The boundary text.</param>
175176
[AttributeUsage(AttributeTargets.Method)]
176-
public sealed class MultipartAttribute(string boundaryText = "----MyGreatBoundary") : Attribute
177+
public class MultipartAttribute(string boundaryText = "----MyGreatBoundary") : Attribute
177178
{
178179
/// <summary>
179180
/// Gets the boundary text.
@@ -223,7 +224,7 @@ public enum BodySerializationMethod
223224
/// - For all other types, the object will be serialized using the content serializer specified in the request's <see cref="RefitSettings"/>.
224225
/// </remarks>
225226
[AttributeUsage(AttributeTargets.Parameter)]
226-
public sealed class BodyAttribute : Attribute
227+
public class BodyAttribute : Attribute
227228
{
228229
/// <summary>
229230
/// Initializes a new instance of the <see cref="BodyAttribute"/> class.
@@ -284,7 +285,7 @@ public BodyAttribute(
284285
/// </remarks>
285286
/// <param name="name">The name.</param>
286287
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
287-
public sealed class AliasAsAttribute(string name) : Attribute
288+
public class AliasAsAttribute(string name) : Attribute
288289
{
289290
/// <summary>
290291
/// Gets or sets the name.
@@ -304,7 +305,7 @@ public sealed class AliasAsAttribute(string name) : Attribute
304305
"Use Refit.StreamPart, Refit.ByteArrayPart, Refit.FileInfoPart or if necessary, inherit from Refit.MultipartItem",
305306
false
306307
)]
307-
public sealed class AttachmentNameAttribute(string name) : Attribute
308+
public class AttachmentNameAttribute(string name) : Attribute
308309
{
309310
/// <summary>
310311
/// Gets or sets the name.
@@ -319,7 +320,7 @@ public sealed class AttachmentNameAttribute(string name) : Attribute
319320
/// Allows you to provide a Dictionary of headers to be added to the request.
320321
/// </summary>
321322
[AttributeUsage(AttributeTargets.Parameter)]
322-
public sealed class HeaderCollectionAttribute : Attribute { }
323+
public class HeaderCollectionAttribute : Attribute { }
323324

324325
/// <summary>
325326
/// Add multiple headers to the request.
@@ -329,15 +330,15 @@ public sealed class HeaderCollectionAttribute : Attribute { }
329330
/// </remarks>
330331
/// <param name="headers">The headers.</param>
331332
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method)]
332-
public sealed class HeadersAttribute(params string[] headers) : Attribute
333+
public class HeadersAttribute(params string[] headers) : Attribute
333334
{
334335
/// <summary>
335336
/// Gets the headers.
336337
/// </summary>
337338
/// <value>
338339
/// The headers.
339340
/// </value>
340-
public string[] Headers { get; } = headers ?? Array.Empty<string>();
341+
public string[] Headers { get; } = headers ?? [];
341342
}
342343

343344
/// <summary>
@@ -348,7 +349,7 @@ public sealed class HeadersAttribute(params string[] headers) : Attribute
348349
/// </remarks>
349350
/// <param name="header">The header.</param>
350351
[AttributeUsage(AttributeTargets.Parameter)]
351-
public sealed class HeaderAttribute(string header) : Attribute
352+
public class HeaderAttribute(string header) : Attribute
352353
{
353354
/// <summary>
354355
/// Gets the header.
@@ -365,7 +366,7 @@ public sealed class HeaderAttribute(string header) : Attribute
365366
/// If no key is specified then the key will be defaulted to the name of the parameter.
366367
/// </summary>
367368
[AttributeUsage(AttributeTargets.Parameter)]
368-
public sealed class PropertyAttribute : Attribute
369+
public class PropertyAttribute : Attribute
369370
{
370371
/// <summary>
371372
/// Initializes a new instance of the <see cref="PropertyAttribute"/> class.
@@ -398,7 +399,7 @@ public PropertyAttribute(string key)
398399
/// </remarks>
399400
/// <param name="scheme">The scheme.</param>
400401
[AttributeUsage(AttributeTargets.Parameter)]
401-
public sealed class AuthorizeAttribute(string scheme = "Bearer") : Attribute
402+
public class AuthorizeAttribute(string scheme = "Bearer") : Attribute
402403
{
403404
/// <summary>
404405
/// Gets the scheme.
@@ -413,7 +414,7 @@ public sealed class AuthorizeAttribute(string scheme = "Bearer") : Attribute
413414
/// Associated value will be added to the request Uri as query-string, using a delimiter to split the values. (default: '.')
414415
/// </summary>
415416
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] // Property is to allow for form url encoded data
416-
public sealed class QueryAttribute : Attribute
417+
public class QueryAttribute : Attribute
417418
{
418419
CollectionFormat? collectionFormat;
419420

@@ -489,6 +490,8 @@ public QueryAttribute(CollectionFormat collectionFormat)
489490
/// </example>
490491
public string? Prefix { get; protected set; }
491492

493+
#pragma warning disable CA1019 // Define accessors for attribute arguments
494+
492495
/// <summary>
493496
/// Used to customize the formatting of the encoded value.
494497
/// </summary>
@@ -514,6 +517,8 @@ public CollectionFormat CollectionFormat
514517
set => collectionFormat = value;
515518
}
516519

520+
#pragma warning restore CA1019 // Define accessors for attribute arguments
521+
517522
/// <summary>
518523
/// Gets a value indicating whether this instance is collection format specified.
519524
/// </summary>
@@ -532,11 +537,12 @@ public CollectionFormat CollectionFormat
532537
/// </remarks>
533538
/// <param name="uriFormat">The URI format.</param>
534539
[AttributeUsage(AttributeTargets.Method)]
535-
public sealed class QueryUriFormatAttribute(UriFormat uriFormat) : Attribute
540+
public class QueryUriFormatAttribute(UriFormat uriFormat) : Attribute
536541
{
537542
/// <summary>
538543
/// Specifies how the Query Params should be encoded.
539544
/// </summary>
540545
public UriFormat UriFormat { get; } = uriFormat;
541546
}
547+
#pragma warning restore CA1813 // Avoid unsealed attributes
542548
}

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "7.1.0",
2+
"version": "7.1.1",
33
"publicReleaseRefSpec": [
44
"^refs/heads/main$", // we release out of main
55
"^refs/heads/rel/v\\d+\\.\\d+" // we also release branches starting with vN.N

0 commit comments

Comments
 (0)