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

chore: add migration guide for v5 #257

Merged
merged 10 commits into from
Nov 6, 2024
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
[![NuGet](https://img.shields.io/nuget/v/Unleash.Client.svg)](https://www.nuget.org/packages/Unleash.Client/)


> **Migrating to v5**
>
> If you use [bootstrapping](#bootstrapping), [custom strategies](#custom-strategies), or a custom JSON serializer, read the complete [migration guide](./v5_MIGRATION_GUIDE.md) before upgrading to v5.


## Introduction

Unleash Client SDK for .Net. It is compatible with the
Expand Down
46 changes: 46 additions & 0 deletions v5_MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Migrating to Unleash-Client-Dotnet 5.0.0

This guide highlights the key changes you should be aware of when upgrading to v5.0.0 of the Unleash client.

## Custom strategy changes

Custom strategies no longer provide the option to access the constraints in their interface. The method `bool IsEnabled(Dictionary<string, string> parameters, UnleashContext context, IEnumerable<Constraint> constraints)` no longer exists. Other than that, custom strategies remain unchanged.

## Direct access to feature toggles
sighphyre marked this conversation as resolved.
Show resolved Hide resolved

Direct access to the feature toggle objects through `UnleashClient.FeatureToggles` has been removed. All classes related to the internal representation of feature toggles are no longer publicly accessible in the SDK.

The SDK now provides a `UnleashClient.ListKnownToggles` method, which returns a list of feature toggle names, their type, and the project they're bound to.

The client also no longer provides access to listing the variants bound to a feature flag through `UnleashClient.GetVariants`. We determined that this was exposing internal abstractions that should remain within the SDK. However, if you have a strong use case for this, please open an issue.

## Bootstrapping changes

Due to the changes in the previous section, bootstrapping classes are now required to return a `String` instead of a `FeatureToggleCollection`. The string should be a JSON string representing the response returned from your Unleash instance's `api/client/features` endpoint. In practice, that means if you previously had a `Read` method in your bootstrapping class like so:

``` dotnet

public ToggleCollection Read()
{
var json = settings.FileSystem.ReadAllText(filePath);
return settings.JsonSerializer.Deserialize<ToggleCollection>(json);
}

```

You can simplify it to:

``` dotnet

public string Read()
{
return settings.FileSystem.ReadAllText(filePath);
}

```

## Custom serializers

In v4.x and before, the SDK provided the option of mounting a custom JSON serializer. This option has been removed in v5.x; the SDK now relies on `System.Text.Json` with no option to override it. If you previously provided a custom serializer to access `System.Text.Json`, it's now safe to remove it.

If you use NewtonSoft you don't have to make any changes.
Loading