Skip to content

Commit 1424909

Browse files
committed
chore: adds experimental attribute for new deep copy apis
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent 532765a commit 1424909

47 files changed

Lines changed: 137 additions & 46 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
#if !NET8_0_OR_GREATER
5+
namespace System.Diagnostics.CodeAnalysis
6+
{
7+
/// <summary>
8+
/// Indicates that an API is experimental and may change in the future.
9+
/// </summary>
10+
[AttributeUsage(
11+
AttributeTargets.Assembly |
12+
AttributeTargets.Module |
13+
AttributeTargets.Class |
14+
AttributeTargets.Struct |
15+
AttributeTargets.Enum |
16+
AttributeTargets.Constructor |
17+
AttributeTargets.Method |
18+
AttributeTargets.Property |
19+
AttributeTargets.Field |
20+
AttributeTargets.Event |
21+
AttributeTargets.Interface |
22+
AttributeTargets.Delegate,
23+
Inherited = false)]
24+
internal sealed class ExperimentalAttribute : Attribute
25+
{
26+
/// <summary>
27+
/// Initializes a new instance of the <see cref="ExperimentalAttribute"/> class.
28+
/// </summary>
29+
/// <param name="diagnosticId">The diagnostic ID reported when the API is used.</param>
30+
public ExperimentalAttribute(string diagnosticId)
31+
{
32+
DiagnosticId = diagnosticId;
33+
}
34+
35+
/// <summary>
36+
/// Gets the diagnostic ID reported when the API is used.
37+
/// </summary>
38+
public string DiagnosticId { get; }
39+
40+
/// <summary>
41+
/// Gets or sets the URL format used by the diagnostic.
42+
/// </summary>
43+
public string? UrlFormat { get; set; }
44+
}
45+
}
46+
#endif

src/Microsoft.OpenApi/Interfaces/IDeepCopyable.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ namespace Microsoft.OpenApi;
66
/// Interface for deep copyable objects.
77
/// </summary>
88
/// <typeparam name="T">The type of the resulting object.</typeparam>
9+
[System.Diagnostics.CodeAnalysis.Experimental("OPENAPI001")]
910
public interface IDeepCopyable<out T>
1011
{
1112
/// <summary>
1213
/// Create a deep copy of the current instance.
1314
/// </summary>
15+
[System.Diagnostics.CodeAnalysis.Experimental("OPENAPI001")]
1416
T CreateDeepCopy();
1517
}
16-

src/Microsoft.OpenApi/Microsoft.OpenApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net8.0'))">true</IsAotCompatible>
1010
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
1111
<EmbedUntrackedSources>true</EmbedUntrackedSources>
12-
<NoWarn>NU5048</NoWarn>
12+
<NoWarn>$(NoWarn);NU5048;OPENAPI001</NoWarn>
1313
<Nullable>enable</Nullable>
1414
<PackageReadmeFile>README.md</PackageReadmeFile>
1515
</PropertyGroup>

src/Microsoft.OpenApi/Models/OpenApiCallback.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public IOpenApiCallback CreateShallowCopy()
114114
return new OpenApiCallback(this);
115115
}
116116
/// <inheritdoc/>
117+
[System.Diagnostics.CodeAnalysis.Experimental("OPENAPI001")]
117118
public IOpenApiCallback CreateDeepCopy()
118119
{
119120
return new OpenApiDeepCopyContext().Copy(this);

src/Microsoft.OpenApi/Models/OpenApiComponents.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public OpenApiComponents(OpenApiComponents? components)
9797
}
9898

9999
/// <inheritdoc/>
100+
[System.Diagnostics.CodeAnalysis.Experimental("OPENAPI001")]
100101
public OpenApiComponents CreateDeepCopy()
101102
{
102103
return new OpenApiDeepCopyContext().Copy(this);

src/Microsoft.OpenApi/Models/OpenApiContact.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public OpenApiContact(OpenApiContact contact)
4848
Extensions = contact?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(contact.Extensions) : null;
4949
}
5050
/// <inheritdoc/>
51+
[System.Diagnostics.CodeAnalysis.Experimental("OPENAPI001")]
5152
public OpenApiContact CreateDeepCopy()
5253
{
5354
return new OpenApiDeepCopyContext().Copy(this);

src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public OpenApiDiscriminator(OpenApiDiscriminator discriminator)
4747
}
4848

4949
/// <inheritdoc/>
50+
[System.Diagnostics.CodeAnalysis.Experimental("OPENAPI001")]
5051
public OpenApiDiscriminator CreateDeepCopy()
5152
{
5253
return new OpenApiDeepCopyContext().Copy(this);

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public OpenApiDocument(OpenApiDocument? document)
155155
}
156156

157157
/// <inheritdoc/>
158+
[System.Diagnostics.CodeAnalysis.Experimental("OPENAPI001")]
158159
public OpenApiDocument CreateDeepCopy()
159160
{
160161
return new OpenApiDeepCopyContext().Copy(this);

src/Microsoft.OpenApi/Models/OpenApiEncoding.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public OpenApiEncoding(OpenApiEncoding encoding)
9797
}
9898

9999
/// <inheritdoc/>
100+
[System.Diagnostics.CodeAnalysis.Experimental("OPENAPI001")]
100101
public OpenApiEncoding CreateDeepCopy()
101102
{
102103
return new OpenApiDeepCopyContext().Copy(this);

src/Microsoft.OpenApi/Models/OpenApiExample.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public IOpenApiExample CreateShallowCopy()
136136
return new OpenApiExample(this);
137137
}
138138
/// <inheritdoc/>
139+
[System.Diagnostics.CodeAnalysis.Experimental("OPENAPI001")]
139140
public IOpenApiExample CreateDeepCopy()
140141
{
141142
return new OpenApiDeepCopyContext().Copy(this);

0 commit comments

Comments
 (0)