Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert sealed Attributes #1734

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions Refit/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public abstract class HttpMethodAttribute(string path) : Attribute
/// </remarks>
/// <param name="path">The path.</param>
[AttributeUsage(AttributeTargets.Method)]
public sealed class GetAttribute(string path) : HttpMethodAttribute(path)
#pragma warning disable CA1813 // Avoid unsealed attributes
public class GetAttribute(string path) : HttpMethodAttribute(path)
{
/// <summary>
/// Gets the method.
Expand All @@ -56,7 +57,7 @@ public sealed class GetAttribute(string path) : HttpMethodAttribute(path)
/// </remarks>
/// <param name="path">The path.</param>
[AttributeUsage(AttributeTargets.Method)]
public sealed class PostAttribute(string path) : HttpMethodAttribute(path)
public class PostAttribute(string path) : HttpMethodAttribute(path)
{
/// <summary>
/// Gets the method.
Expand All @@ -75,7 +76,7 @@ public sealed class PostAttribute(string path) : HttpMethodAttribute(path)
/// </remarks>
/// <param name="path">The path.</param>
[AttributeUsage(AttributeTargets.Method)]
public sealed class PutAttribute(string path) : HttpMethodAttribute(path)
public class PutAttribute(string path) : HttpMethodAttribute(path)
{
/// <summary>
/// Gets the method.
Expand All @@ -94,7 +95,7 @@ public sealed class PutAttribute(string path) : HttpMethodAttribute(path)
/// </remarks>
/// <param name="path">The path.</param>
[AttributeUsage(AttributeTargets.Method)]
public sealed class DeleteAttribute(string path) : HttpMethodAttribute(path)
public class DeleteAttribute(string path) : HttpMethodAttribute(path)
{
/// <summary>
/// Gets the method.
Expand All @@ -113,15 +114,15 @@ public sealed class DeleteAttribute(string path) : HttpMethodAttribute(path)
/// </remarks>
/// <param name="path">The path.</param>
[AttributeUsage(AttributeTargets.Method)]
public sealed class PatchAttribute(string path) : HttpMethodAttribute(path)
public class PatchAttribute(string path) : HttpMethodAttribute(path)
{
/// <summary>
/// Gets the method.
/// </summary>
/// <value>
/// The method.
/// </value>
public override HttpMethod Method => new HttpMethod("PATCH");
public override HttpMethod Method => new("PATCH");
}

/// <summary>
Expand All @@ -132,15 +133,15 @@ public sealed class PatchAttribute(string path) : HttpMethodAttribute(path)
/// </remarks>
/// <param name="path">The path.</param>
[AttributeUsage(AttributeTargets.Method)]
public sealed class OptionsAttribute(string path) : HttpMethodAttribute(path)
public class OptionsAttribute(string path) : HttpMethodAttribute(path)
{
/// <summary>
/// Gets the method.
/// </summary>
/// <value>
/// The method.
/// </value>
public override HttpMethod Method => new HttpMethod("OPTIONS");
public override HttpMethod Method => new("OPTIONS");
}

/// <summary>
Expand All @@ -151,7 +152,7 @@ public sealed class OptionsAttribute(string path) : HttpMethodAttribute(path)
/// </remarks>
/// <param name="path">The path.</param>
[AttributeUsage(AttributeTargets.Method)]
public sealed class HeadAttribute(string path) : HttpMethodAttribute(path)
public class HeadAttribute(string path) : HttpMethodAttribute(path)
{
/// <summary>
/// Gets the method.
Expand All @@ -173,7 +174,7 @@ public sealed class HeadAttribute(string path) : HttpMethodAttribute(path)
/// </remarks>
/// <param name="boundaryText">The boundary text.</param>
[AttributeUsage(AttributeTargets.Method)]
public sealed class MultipartAttribute(string boundaryText = "----MyGreatBoundary") : Attribute
public class MultipartAttribute(string boundaryText = "----MyGreatBoundary") : Attribute
{
/// <summary>
/// Gets the boundary text.
Expand Down Expand Up @@ -223,7 +224,7 @@ public enum BodySerializationMethod
/// - For all other types, the object will be serialized using the content serializer specified in the request's <see cref="RefitSettings"/>.
/// </remarks>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class BodyAttribute : Attribute
public class BodyAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="BodyAttribute"/> class.
Expand Down Expand Up @@ -284,7 +285,7 @@ public BodyAttribute(
/// </remarks>
/// <param name="name">The name.</param>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
public sealed class AliasAsAttribute(string name) : Attribute
public class AliasAsAttribute(string name) : Attribute
{
/// <summary>
/// Gets or sets the name.
Expand All @@ -304,7 +305,7 @@ public sealed class AliasAsAttribute(string name) : Attribute
"Use Refit.StreamPart, Refit.ByteArrayPart, Refit.FileInfoPart or if necessary, inherit from Refit.MultipartItem",
false
)]
public sealed class AttachmentNameAttribute(string name) : Attribute
public class AttachmentNameAttribute(string name) : Attribute
{
/// <summary>
/// Gets or sets the name.
Expand All @@ -319,7 +320,7 @@ public sealed class AttachmentNameAttribute(string name) : Attribute
/// Allows you to provide a Dictionary of headers to be added to the request.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class HeaderCollectionAttribute : Attribute { }
public class HeaderCollectionAttribute : Attribute { }

/// <summary>
/// Add multiple headers to the request.
Expand All @@ -329,15 +330,15 @@ public sealed class HeaderCollectionAttribute : Attribute { }
/// </remarks>
/// <param name="headers">The headers.</param>
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method)]
public sealed class HeadersAttribute(params string[] headers) : Attribute
public class HeadersAttribute(params string[] headers) : Attribute
{
/// <summary>
/// Gets the headers.
/// </summary>
/// <value>
/// The headers.
/// </value>
public string[] Headers { get; } = headers ?? Array.Empty<string>();
public string[] Headers { get; } = headers ?? [];
}

/// <summary>
Expand All @@ -348,7 +349,7 @@ public sealed class HeadersAttribute(params string[] headers) : Attribute
/// </remarks>
/// <param name="header">The header.</param>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class HeaderAttribute(string header) : Attribute
public class HeaderAttribute(string header) : Attribute
{
/// <summary>
/// Gets the header.
Expand All @@ -365,7 +366,7 @@ public sealed class HeaderAttribute(string header) : Attribute
/// If no key is specified then the key will be defaulted to the name of the parameter.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class PropertyAttribute : Attribute
public class PropertyAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="PropertyAttribute"/> class.
Expand Down Expand Up @@ -398,7 +399,7 @@ public PropertyAttribute(string key)
/// </remarks>
/// <param name="scheme">The scheme.</param>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AuthorizeAttribute(string scheme = "Bearer") : Attribute
public class AuthorizeAttribute(string scheme = "Bearer") : Attribute
{
/// <summary>
/// Gets the scheme.
Expand All @@ -413,7 +414,7 @@ public sealed class AuthorizeAttribute(string scheme = "Bearer") : Attribute
/// Associated value will be added to the request Uri as query-string, using a delimiter to split the values. (default: '.')
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] // Property is to allow for form url encoded data
public sealed class QueryAttribute : Attribute
public class QueryAttribute : Attribute
{
CollectionFormat? collectionFormat;

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

#pragma warning disable CA1019 // Define accessors for attribute arguments

/// <summary>
/// Used to customize the formatting of the encoded value.
/// </summary>
Expand All @@ -514,6 +517,8 @@ public CollectionFormat CollectionFormat
set => collectionFormat = value;
}

#pragma warning restore CA1019 // Define accessors for attribute arguments

/// <summary>
/// Gets a value indicating whether this instance is collection format specified.
/// </summary>
Expand All @@ -532,11 +537,12 @@ public CollectionFormat CollectionFormat
/// </remarks>
/// <param name="uriFormat">The URI format.</param>
[AttributeUsage(AttributeTargets.Method)]
public sealed class QueryUriFormatAttribute(UriFormat uriFormat) : Attribute
public class QueryUriFormatAttribute(UriFormat uriFormat) : Attribute
{
/// <summary>
/// Specifies how the Query Params should be encoded.
/// </summary>
public UriFormat UriFormat { get; } = uriFormat;
}
#pragma warning restore CA1813 // Avoid unsealed attributes
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "7.1.0",
"version": "7.1.1",
"publicReleaseRefSpec": [
"^refs/heads/main$", // we release out of main
"^refs/heads/rel/v\\d+\\.\\d+" // we also release branches starting with vN.N
Expand Down
Loading