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

feat: Initial Proposal for Diagnostic Feature Codes in OpenFeature #3

Merged
Show file tree
Hide file tree
Changes from 2 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
39 changes: 39 additions & 0 deletions src/OpenFeature.DependencyInjection/Diagnostics/FeatureCodes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace OpenFeature.DependencyInjection.Diagnostics;

/// <summary>
/// Contains identifiers for experimental features and diagnostics in the OpenFeature framework.
/// </summary>
/// <remarks>
/// <c>Experimental</c> - This class includes identifiers that allow developers to track and conditionally enable
/// experimental features. Each identifier follows a structured code format to indicate the feature domain,
/// maturity level, and unique identifier. Note that experimental features are subject to change or removal
/// in future releases.
/// <para>
/// <strong>Basic Information</strong><br/>
/// These identifiers conform to OpenFeature’s Diagnostics Specifications, allowing developers to recognize
/// and manage experimental features effectively. For more details, refer to the
/// <a href="https://github.com/open-feature/dotnet-sdk/docs/diagnostics/README.md">Diagnostics Specifications</a>.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to add this readme or a new section could be added to the root readme.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, I’ve placed it here as an example for now. If the team decides it’s a good idea and we move forward with documenting it, I’ll update the path to the correct location (e.g., adding it to the root README or a new section). Otherwise, I’ll simply remove it. For now, I’m waiting on some feedback and approval to ensure my changes align with what the team wanted, so I can finalize everything accordingly.

And thanks for the quick response!

/// </para>
/// </remarks>
/// <example>
/// <code>
/// Code Structure:
/// - "OF" - Represents the OpenFeature library.
/// - "DI" - Indicates the Dependency Injection domain.
/// - "001" - Unique identifier for a specific feature.
/// </code>
/// </example>
internal static class FeatureCodes
{
/// <summary>
/// Identifier for the experimental Dependency Injection features within the OpenFeature framework.
/// </summary>
/// <remarks>
/// <c>OFDI001</c> identifier marks experimental features in the Dependency Injection (DI) domain.
///
/// Usage:
/// Developers can use this identifier to conditionally enable or test experimental DI features.
/// It is part of the OpenFeature diagnostics system to help track experimental functionality.
/// </remarks>
public const string NewDi = "OFDI001";
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace OpenFeature.DependencyInjection;
/// This factory interface enables custom configuration and initialization of feature providers
/// to support domain-specific or application-specific feature flag management.
/// </summary>
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.Experimental(Diagnostics.FeatureCodes.NewDi)]
#endif
public interface IFeatureProviderFactory
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace OpenFeature;
/// <summary>
/// Contains extension methods for the <see cref="OpenFeatureBuilder"/> class.
/// </summary>
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.Experimental(DependencyInjection.Diagnostics.FeatureCodes.NewDi)]
#endif
public static partial class OpenFeatureBuilderExtensions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace OpenFeature.DependencyInjection.Providers.Memory;
/// <summary>
/// Extension methods for configuring feature providers with <see cref="OpenFeatureBuilder"/>.
/// </summary>
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.Experimental(Diagnostics.FeatureCodes.NewDi)]
#endif
public static partial class FeatureBuilderExtensions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace OpenFeature.DependencyInjection.Providers.Memory;
/// This factory allows for the customization of feature flags to facilitate
/// testing and lightweight feature flag management without external dependencies.
/// </summary>
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.Experimental(Diagnostics.FeatureCodes.NewDi)]
#endif
public class InMemoryProviderFactory : IFeatureProviderFactory
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace OpenFeature.DependencyInjection.Tests;

#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.Experimental(Diagnostics.FeatureCodes.NewDi)]
#endif
public class NoOpFeatureProviderFactory : IFeatureProviderFactory
{
public FeatureProvider Create() => new NoOpFeatureProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public void AddContext_Delegate_ShouldCorrectlyHandles(bool useServiceProviderDe
delegateCalled.Should().BeTrue("The delegate should be invoked.");
}

#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.Experimental(Diagnostics.FeatureCodes.NewDi)]
#endif
[Fact]
public void AddProvider_ShouldAddProviderToCollection()
{
Expand All @@ -73,6 +76,9 @@ public void AddProvider_ShouldAddProviderToCollection()
"A singleton service of type FeatureProvider should be added.");
}

#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.Experimental(Diagnostics.FeatureCodes.NewDi)]
#endif
[Fact]
public void AddProvider_ShouldResolveCorrectProvider()
{
Expand Down