Skip to content

Replace [Obsolete] with [Experimental] attributes #1487

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

Open
wants to merge 8 commits into
base: release-1.16
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ await foreach (var items in subscribeConfigurationResponse.Source.WithCancellati

```csharp
using System;
using System.Runtime.Versioning;
using Dapr.Client;
using Dapr.Common;

namespace LockService
{
class Program
{
[Obsolete("Distributed Lock API is in Alpha, this can be removed once it is stable.")]
[Experimental(DaprExperimentalConstants.LockIdentifier)]
static async Task Main(string[] args)
{
var daprLockName = "lockstore";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

using System.Buffers;
using Dapr.Client;
#pragma warning disable DAPR_CRYPTO_0001
#pragma warning disable CS0618 // Type or member is obsolete

namespace Cryptography.Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

using System.Text;
using Dapr.Client;
#pragma warning disable DAPR_CRYPTO_0001
#pragma warning disable CS0618 // Type or member is obsolete

namespace Cryptography.Examples
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using Dapr;
using Dapr.Client;
using Dapr.Common;
using DistributedLock.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
Expand All @@ -24,8 +26,7 @@ public BindingController(DaprClient client, ILogger<BindingController> logger)
this.appId = Environment.GetEnvironmentVariable("APP_ID");
}

[HttpPost("cronbinding")]
[Obsolete]
[Experimental(DaprExperimentalConstants.BindingIdentifier)]
public async Task<IActionResult> HandleBindingEvent()
{
logger.LogInformation($"Received binding event on {appId}, scanning for work.");
Expand All @@ -47,8 +48,7 @@ public async Task<IActionResult> HandleBindingEvent()
return Ok();
}


[Obsolete]
[Experimental(DaprExperimentalConstants.BindingIdentifier)]
private async Task AttemptToProcessFile(string fileName)
{
// Locks are Disposable and will automatically unlock at the end of a 'using' statement.
Expand Down
1 change: 1 addition & 0 deletions examples/Jobs/JobsSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Dapr.Jobs;
using Dapr.Jobs.Extensions;
using Dapr.Jobs.Models;
#pragma warning disable DAPR_JOBS_0001

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDaprJobsClient();
Expand Down
45 changes: 22 additions & 23 deletions src/Dapr.Client/DaprClient.cs

Large diffs are not rendered by default.

40 changes: 17 additions & 23 deletions src/Dapr.Client/DaprClientGrpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
// limitations under the License.
// ------------------------------------------------------------------------

using Dapr.Common.Extensions;
using Dapr.Common;

namespace Dapr.Client;

using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -1664,8 +1664,7 @@ public override async Task<UnsubscribeConfigurationResponse> UnsubscribeConfigur
#region Cryptography

/// <inheritdoc />
[Obsolete(
"The API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
public override async Task<ReadOnlyMemory<byte>> EncryptAsync(string vaultResourceName,
ReadOnlyMemory<byte> plaintextBytes, string keyName, EncryptionOptions encryptionOptions,
CancellationToken cancellationToken = default)
Expand All @@ -1685,8 +1684,7 @@ public override async Task<ReadOnlyMemory<byte>> EncryptAsync(string vaultResour
}

/// <inheritdoc />
[Obsolete(
"The API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
public override async Task<IAsyncEnumerable<ReadOnlyMemory<byte>>> EncryptAsync(string vaultResourceName,
Stream plaintextStream,
string keyName, EncryptionOptions encryptionOptions, CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -1787,8 +1785,7 @@ private async IAsyncEnumerable<ReadOnlyMemory<byte>> RetrieveEncryptedStreamAsyn
}

/// <inheritdoc />
[Obsolete(
"The API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
public override async Task<IAsyncEnumerable<ReadOnlyMemory<byte>>> DecryptAsync(string vaultResourceName,
Stream ciphertextStream, string keyName,
DecryptionOptions decryptionOptions, CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -1819,8 +1816,7 @@ public override async Task<IAsyncEnumerable<ReadOnlyMemory<byte>>> DecryptAsync(
}

/// <inheritdoc />
[Obsolete(
"The API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
public override Task<IAsyncEnumerable<ReadOnlyMemory<byte>>> DecryptAsync(string vaultResourceName,
Stream ciphertextStream, string keyName, CancellationToken cancellationToken = default) =>
DecryptAsync(vaultResourceName, ciphertextStream, keyName, new DecryptionOptions(),
Expand Down Expand Up @@ -1883,8 +1879,7 @@ private async IAsyncEnumerable<ReadOnlyMemory<byte>> RetrieveDecryptedStreamAsyn
}

/// <inheritdoc />
[Obsolete(
"The API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
public override async Task<ReadOnlyMemory<byte>> DecryptAsync(string vaultResourceName,
ReadOnlyMemory<byte> ciphertextBytes, string keyName, DecryptionOptions decryptionOptions,
CancellationToken cancellationToken = default)
Expand All @@ -1904,8 +1899,7 @@ public override async Task<ReadOnlyMemory<byte>> DecryptAsync(string vaultResour
}

/// <inheritdoc />
[Obsolete(
"The API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
public override async Task<ReadOnlyMemory<byte>> DecryptAsync(string vaultResourceName,
ReadOnlyMemory<byte> ciphertextBytes, string keyName, CancellationToken cancellationToken = default) =>
await DecryptAsync(vaultResourceName, ciphertextBytes, keyName,
Expand All @@ -1914,7 +1908,7 @@ await DecryptAsync(vaultResourceName, ciphertextBytes, keyName,
#region Subtle Crypto Implementation

///// <inheritdoc/>
//[Obsolete("This API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
//[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
//public override async Task<(string Name, string PublicKey)> GetKeyAsync(string vaultResourceName, string keyName, Autogenerated.SubtleGetKeyRequest.Types.KeyFormat keyFormat,
// CancellationToken cancellationToken = default)
//{
Expand Down Expand Up @@ -1943,7 +1937,7 @@ await DecryptAsync(vaultResourceName, ciphertextBytes, keyName,
//}

///// <inheritdoc/>
//[Obsolete("This API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
//[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
//public override async Task<(byte[] CipherTextBytes, byte[] AuthenticationTag)> EncryptAsync(string vaultResourceName, byte[] plainTextBytes, string algorithm,
// string keyName, byte[] nonce, byte[] associatedData, CancellationToken cancellationToken = default)
//{
Expand Down Expand Up @@ -1979,7 +1973,7 @@ await DecryptAsync(vaultResourceName, ciphertextBytes, keyName,
//}

///// <inheritdoc/>
//[Obsolete("This API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
//[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
//public override async Task<byte[]> DecryptAsync(string vaultResourceName, byte[] cipherTextBytes, string algorithm, string keyName, byte[] nonce, byte[] tag,
// byte[] associatedData, CancellationToken cancellationToken = default)
//{
Expand Down Expand Up @@ -2015,7 +2009,7 @@ await DecryptAsync(vaultResourceName, ciphertextBytes, keyName,
//}

///// <inheritdoc/>
//[Obsolete("This API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
//[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
//public override async Task<(byte[] WrappedKey, byte[] AuthenticationTag)> WrapKeyAsync(string vaultResourceName, byte[] plainTextKey, string keyName,
// string algorithm, byte[] nonce, byte[] associatedData, CancellationToken cancellationToken = default)
//{
Expand Down Expand Up @@ -2051,7 +2045,7 @@ await DecryptAsync(vaultResourceName, ciphertextBytes, keyName,
//}

///// <inheritdoc/>
//[Obsolete("This API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
//[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
//public override async Task<byte[]> UnwrapKeyAsync(string vaultResourceName, byte[] wrappedKey, string algorithm,
// string keyName, byte[] nonce, byte[] tag, byte[] associatedData, CancellationToken cancellationToken = default)
//{
Expand Down Expand Up @@ -2088,7 +2082,7 @@ await DecryptAsync(vaultResourceName, ciphertextBytes, keyName,
//}

///// <inheritdoc/>
//[Obsolete("This API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
//[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
//public override async Task<byte[]> SignAsync(string vaultResourceName, byte[] digest, string algorithm, string keyName, CancellationToken cancellationToken = default)
//{
// ArgumentVerifier.ThrowIfNullOrEmpty(vaultResourceName, nameof(vaultResourceName));
Expand Down Expand Up @@ -2121,7 +2115,7 @@ await DecryptAsync(vaultResourceName, ciphertextBytes, keyName,
//}

///// <inheritdoc/>
//[Obsolete("This API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
//[Experimental(DaprExperimentalConstants.CryptographyIdentifier)]
//public override async Task<bool> VerifyAsync(string vaultResourceName, byte[] digest, byte[] signature,
// string algorithm, string keyName, CancellationToken cancellationToken = default)
//{
Expand Down Expand Up @@ -2163,7 +2157,7 @@ await DecryptAsync(vaultResourceName, ciphertextBytes, keyName,
#region Distributed Lock API

/// <inheritdoc/>
[Obsolete]
[Experimental(DaprExperimentalConstants.LockIdentifier)]
public async override Task<TryLockResponse> Lock(
string storeName,
string resourceId,
Expand Down Expand Up @@ -2203,7 +2197,7 @@ public async override Task<TryLockResponse> Lock(
}

/// <inheritdoc/>
[Obsolete]
[Experimental(DaprExperimentalConstants.LockIdentifier)]
public async override Task<UnlockResponse> Unlock(
string storeName,
string resourceId,
Expand Down
4 changes: 3 additions & 1 deletion src/Dapr.Client/TryLockResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
// ------------------------------------------------------------------------

using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Dapr.Common;

namespace Dapr.Client
{
/// <summary>
/// Class representing the response from a Lock API call.
/// </summary>
[Obsolete("This API is currently not stable as it is in the Alpha stage. This attribute will be removed once it is stable.")]
[Experimental(DaprExperimentalConstants.LockIdentifier)]
public sealed class TryLockResponse : IAsyncDisposable
{
/// <summary>
Expand Down
83 changes: 83 additions & 0 deletions src/Dapr.Common/DaprExperimentalConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// ________________________________________________________________________
// Copyright 2025 The Dapr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE_2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ________________________________________________________________________

namespace Dapr.Common;

/// <summary>
/// Reflects constants available to use in the experimental attributes in various Dapr packages.
/// </summary>
public static class DaprExperimentalConstants
{
private const string DaprPrefix = "DAPR";

private const string MessagingPrefix = $"{DaprPrefix}_MESSAGING";
private const string WorkflowPrefix = $"{DaprPrefix}_WORKFLOW";
private const string BindingPrefix = $"{DaprPrefix}_BINDING";
private const string CryptoPrefix = $"{DaprPrefix}_CRYPTO";
private const string StatePrefix = $"{DaprPrefix}_STATE";
private const string AiPrefix = $"{DaprPrefix}_AI";
private const string InvocationPrefix = $"{DaprPrefix}_INVOCATION";
private const string ActorsPrefix = $"{DaprPrefix}_ACTORS";
private const string JobsPrefix = $"{DaprPrefix}_JOBS";
private const string LocksPrefix = $"{DaprPrefix}_LOCK";

/// <summary>
/// Identifier used for experimental flags in the Dapr.Messaging package.
/// </summary>
public const string MessagingIdentifier = $"{MessagingPrefix}_0001";

/// <summary>
/// Identifier used for experimental flags in the Dapr.Workflow package.
/// </summary>
public const string WorkflowIdentifier = $"{WorkflowPrefix}_0001";

/// <summary>
/// Identifier used for experimental flags in the Dapr.Binding package.
/// </summary>
public const string BindingIdentifier = $"{BindingPrefix}_0001";

/// <summary>
/// Identifier used for experimental flags in the Dapr.Cryptography package.
/// </summary>
public const string CryptographyIdentifier = $"{CryptoPrefix}_0001";

/// <summary>
/// Identifier used for experimental flags in the Dapr.State package.
/// </summary>
public const string StateIdentifier = $"{StatePrefix}_0001";

/// <summary>
/// Identifier used for experimental flags in the Dapr.AI package.
/// </summary>
public const string AiIdentifier = $"{AiPrefix}_0001";

/// <summary>
/// Identifier used for experimental flags in the Dapr.Invocation package.
/// </summary>
public const string InvocationIdentifier = $"{InvocationPrefix}_0001";

/// <summary>
/// Identifier used for experimental flags in the Dapr.Actors package.
/// </summary>
public const string ActorsIdentifier = $"{ActorsPrefix}_0001";

/// <summary>
/// Identifier used for experimental flags in the Dapr.Jobs package.
/// </summary>
public const string JobsIdentifier = $"{JobsPrefix}_0001";

/// <summary>
/// Identifier used for experimental flags in the Dapr.DistributedLock package.
/// </summary>
public const string LockIdentifier = $"{LocksPrefix}_0001";
}
27 changes: 27 additions & 0 deletions src/Dapr.Common/IDaprServiceBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ------------------------------------------------------------------------
// Copyright 2025 The Dapr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------

using Microsoft.Extensions.DependencyInjection;

namespace Dapr.Common;

/// <summary>
/// Responsible for registering Dapr service functionality.
/// </summary>
public interface IDaprServiceBuilder
{
/// <summary>
/// The registered services on the builder.
/// </summary>
public IServiceCollection Services { get; }
}
Loading