Skip to content

Commit

Permalink
feat!: rename OpenFeature class to API and ns to OpenFeature (#82)
Browse files Browse the repository at this point in the history
To make it easier to reuse the OpenFeature namespace, we need to ensure
no classes/structs are named OpenFeature.
  • Loading branch information
benjiro authored Oct 16, 2022
1 parent 8b738da commit 6090bd9
Show file tree
Hide file tree
Showing 45 changed files with 174 additions and 178 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ jobs:
- name: Pack
if: ${{ steps.release.outputs.releases_created }}
run: |
dotnet pack OpenFeatureSDK.proj --configuration Release --no-build -p:PackageID=OpenFeature
dotnet pack OpenFeature.proj --configuration Release --no-build -p:PackageID=OpenFeature
- name: Publish to Nuget
if: ${{ steps.release.outputs.releases_created }}
run: |
dotnet nuget push src/OpenFeatureSDK/bin/Release/OpenFeature.${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}.nupkg `
dotnet nuget push src/OpenFeature/bin/Release/OpenFeature.${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}.nupkg `
--api-key ${{secrets.NUGET_TOKEN}} `
--source https://api.nuget.org/v3/index.json
File renamed without changes.
4 changes: 2 additions & 2 deletions OpenFeatureSDK.sln → OpenFeature.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFeatureSDK", "src\OpenFeatureSDK\OpenFeatureSDK.csproj", "{07A6E6BD-FB7E-4B3B-9CBE-65AE9D0EB223}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFeature", "src\OpenFeature\OpenFeature.csproj", "{07A6E6BD-FB7E-4B3B-9CBE-65AE9D0EB223}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{72005F60-C2E8-40BF-AE95-893635134D7D}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -29,7 +29,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{65FBA159-2
test\Directory.Build.props = test\Directory.Build.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFeatureSDK.Tests", "test\OpenFeatureSDK.Tests\OpenFeatureSDK.Tests.csproj", "{49BB42BA-10A6-4DA3-A7D5-38C968D57837}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFeature.Tests", "test\OpenFeature.Tests\OpenFeature.Tests.csproj", "{49BB42BA-10A6-4DA3-A7D5-38C968D57837}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ The packages will aim to support all current .NET versions. Refer to the current
### Basic Usage

```csharp
using OpenFeatureSDK;
using OpenFeature;

// Sets the provider used by the client
OpenFeature.Instance.SetProvider(new NoOpProvider());
Api.Instance.SetProvider(new NoOpProvider());
// Gets a instance of the feature flag client
var client = OpenFeature.Instance.GetClient();
// Evaluation the `my-feature` feature flag
Expand All @@ -42,8 +42,8 @@ To develop a provider, you need to create a new project and include the OpenFeat
Example of implementing a feature flag provider

```csharp
using OpenFeatureSDK;
using OpenFeatureSDK.Model;
using OpenFeature;
using OpenFeature.Model;

public class MyFeatureProvider : FeatureProvider
{
Expand Down Expand Up @@ -94,10 +94,10 @@ Example of adding a hook

```csharp
// add a hook globally, to run on all evaluations
openFeature.AddHooks(new ExampleGlobalHook());
Api.Instance.AddHooks(new ExampleGlobalHook());

// add a hook on this client, to run on all evaluations made by this client
var client = OpenFeature.Instance.GetClient();
var client = Api.Instance.GetClient();
client.AddHooks(new ExampleClientHook());

// add a hook for this evaluation only
Expand Down
2 changes: 1 addition & 1 deletion build/Common.tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">
<Content Include="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenFeatureSDK.sln'))\build\xunit.runner.json">
<Content Include="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenFeature.sln'))\build\xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenFeatureSDK.sln'))\build\Common.prod.props" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenFeature.sln'))\build\Common.prod.props" />
</Project>
21 changes: 10 additions & 11 deletions src/OpenFeatureSDK/OpenFeature.cs → src/OpenFeature/Api.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Microsoft.Extensions.Logging;
using OpenFeatureSDK.Model;
using OpenFeature.Model;

namespace OpenFeatureSDK
namespace OpenFeature
{
/// <summary>
/// The evaluation API allows for the evaluation of feature flag values, independent of any flag control plane or vendor.
/// In the absence of a provider the evaluation API uses the "No-op provider", which simply returns the supplied default flag value.
/// </summary>
/// <seealso href="https://github.com/open-feature/spec/blob/main/specification/flag-evaluation.md#flag-evaluation-api"/>
public sealed class OpenFeature
public sealed class Api
{
private EvaluationContext _evaluationContext = EvaluationContext.Empty;
private FeatureProvider _featureProvider = new NoOpFeatureProvider();
Expand All @@ -24,15 +23,15 @@ public sealed class OpenFeature
private readonly ReaderWriterLockSlim _featureProviderLock = new ReaderWriterLockSlim();

/// <summary>
/// Singleton instance of OpenFeature
/// Singleton instance of Api
/// </summary>
public static OpenFeature Instance { get; } = new OpenFeature();
public static Api Instance { get; } = new Api();

// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit
// IE Lazy way of ensuring this is thread safe without using locks
static OpenFeature() { }
private OpenFeature() { }
static Api() { }
private Api() { }

/// <summary>
/// Sets the feature provider
Expand All @@ -58,7 +57,7 @@ public void SetProvider(FeatureProvider featureProvider)
/// it should be accessed once for an operation, and then that reference should be used for all dependent
/// operations. For instance, during an evaluation the flag resolution method, and the provider hooks
/// should be accessed from the same reference, not two independent calls to
/// <see cref="OpenFeature.GetProvider"/>.
/// <see cref="GetProvider"/>.
/// </para>
/// </summary>
/// <returns><see cref="FeatureProvider"/></returns>
Expand All @@ -80,7 +79,7 @@ public FeatureProvider GetProvider()
/// <para>
/// This method is not guaranteed to return the same provider instance that may be used during an evaluation
/// in the case where the provider may be changed from another thread.
/// For multiple dependent provider operations see <see cref="OpenFeature.GetProvider"/>.
/// For multiple dependent provider operations see <see cref="GetProvider"/>.
/// </para>
/// </summary>
/// <returns><see cref="ClientMetadata"/></returns>
Expand Down Expand Up @@ -111,7 +110,7 @@ public FeatureClient GetClient(string name = null, string version = null, ILogge
/// Adds a hook to global hooks list
/// <para>
/// Hooks which are dependent on each other should be provided in a collection
/// using the <see cref="AddHooks(System.Collections.Generic.IEnumerable{OpenFeatureSDK.Hook})"/>.
/// using the <see cref="AddHooks(IEnumerable{Hook})"/>.
/// </para>
/// </summary>
/// <param name="hook">Hook that implements the <see cref="Hook"/> interface</param>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace OpenFeatureSDK.Constant
namespace OpenFeature.Constant
{
/// <summary>
/// These errors are used to indicate abnormal execution when evaluation a flag
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OpenFeatureSDK.Constant
namespace OpenFeature.Constant
{
/// <summary>
/// Used to identity what object type of flag being evaluated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OpenFeatureSDK.Constant
namespace OpenFeature.Constant
{
internal static class NoOpProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OpenFeatureSDK.Constant
namespace OpenFeature.Constant
{
/// <summary>
/// Common reasons used during flag resolution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using OpenFeatureSDK.Constant;
using OpenFeature.Constant;

namespace OpenFeatureSDK.Error
namespace OpenFeature.Error
{
/// <summary>
/// Used to represent an abnormal error when evaluating a flag. This exception should be thrown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.ComponentModel;
using System.Linq;

namespace OpenFeatureSDK.Extension
namespace OpenFeature.Extension
{
internal static class EnumExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenFeatureSDK.Model;
using OpenFeature.Model;

namespace OpenFeatureSDK.Extension
namespace OpenFeature.Extension
{
internal static class ResolutionDetailsExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Collections.Immutable;
using System.Threading.Tasks;
using OpenFeatureSDK.Model;
using OpenFeature.Model;

namespace OpenFeatureSDK
namespace OpenFeature
{
/// <summary>
/// The provider interface describes the abstraction layer for a feature flag provider.
Expand Down
4 changes: 2 additions & 2 deletions src/OpenFeatureSDK/Hook.cs → src/OpenFeature/Hook.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenFeatureSDK.Model;
using OpenFeature.Model;

namespace OpenFeatureSDK
namespace OpenFeature
{
/// <summary>
/// The Hook abstract class describes the default implementation for a hook.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenFeatureSDK.Model;
using OpenFeature.Model;

namespace OpenFeatureSDK
namespace OpenFeature
{
internal interface IFeatureClient
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// Represents the client metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;

namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// A KeyValuePair with a string key and object value that is used to apply user defined properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// A builder which allows the specification of attributes for an <see cref="EvaluationContext"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenFeatureSDK.Constant;
using OpenFeature.Constant;

namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// The contract returned to the caller that describes the result of the flag evaluation process.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Immutable;

namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// A structure containing the one or more hooks and hook hints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using OpenFeatureSDK.Constant;
using OpenFeature.Constant;

namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// Context provided to hook execution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// <see cref="OpenFeature"/> metadata
/// <see cref="Api"/> metadata
/// </summary>
public class Metadata
{
/// <summary>
/// Gets name of <see cref="OpenFeature"/> instance
/// Gets name of <see cref="Api"/> instance
/// </summary>
public string Name { get; }

/// <summary>
/// Initializes a new instance of the <see cref="Metadata"/> class.
/// </summary>
/// <param name="name">Name of <see cref="OpenFeature"/> instance</param>
/// <param name="name">Name of <see cref="Api"/> instance</param>
public Metadata(string name)
{
this.Name = name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenFeatureSDK.Constant;
using OpenFeature.Constant;

namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// Defines the contract that the <see cref="FeatureProvider"/> is required to return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;

namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// Structure represents a map of Values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;

namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// A builder which allows the specification of attributes for a <see cref="Structure"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;

namespace OpenFeatureSDK.Model
namespace OpenFeature.Model
{
/// <summary>
/// Values serve as a return type for provider objects. Providers may deal in JSON, protobuf, XML or some other data-interchange format.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Threading.Tasks;
using OpenFeatureSDK.Constant;
using OpenFeatureSDK.Model;
using OpenFeature.Constant;
using OpenFeature.Model;

namespace OpenFeatureSDK
namespace OpenFeature
{
internal class NoOpFeatureProvider : FeatureProvider
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<RootNamespace>OpenFeatureSDK</RootNamespace>
<RootNamespace>OpenFeature</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand All @@ -11,7 +11,7 @@

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>OpenFeatureSDK.Tests</_Parameter1>
<_Parameter1>OpenFeature.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

Expand Down
Loading

0 comments on commit 6090bd9

Please sign in to comment.