Comments (5)
Thank you @erandjo for raising this. We'll have a look! Interesting though, I'd have thought providing Naming policy camel case through JsonSerializerOptions would have sorted this
from unleash-client-dotnet.
where I found that dependencies was optional and defaulting to an empty lists of dependencies (similar to the issue you shared). Is this the reason why dependent features wont work when using System.Text.Json, and will this also be true for variants?
Hello @erandjo! No, it's inside dependency implementation. Spec requires enabled
to default to true
if not set in the JSON payload, and we didn't want to expose a nullable boolean on the dependency itself, leading to System.Text.Json not being able to resolve the type/property/parameter since once is a bool?
and the other a regular bool
. Ends up with runtime deserialization errors. (dotnet/runtime#44428)
Docs on dependent features is here by the way: https://docs.getunleash.io/reference/dependent-features
from unleash-client-dotnet.
Couple of things here
- For serialization use also camel case options
- Setting stream position to 0 in the end of serialization
Although, this will eventually not work with Dependent Features, because of an issue in .NET runtime dotnet/runtime#44428
class TextJsonSerializer : IJsonSerializer
{
private readonly JsonSerializerOptions options;
public TextJsonSerializer()
{
options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
}
T IJsonSerializer.Deserialize<T>(Stream stream)
{
var instance = JsonSerializer.Deserialize<T>(stream, options);
if (instance == null)
{
throw new Exception("The result of serializing feature toggle is null");
}
return instance;
}
void IJsonSerializer.Serialize<T>(Stream stream, T instance)
{
JsonSerializer.Serialize(stream, instance, options);
stream.Position = 0;
}
}
from unleash-client-dotnet.
Wow. thank you. This seems to be a blunder on my part, forgetting to pass in options; I am sorry about that. I will close the the issue. Interesting side note about dependent features. Thanks again.
from unleash-client-dotnet.
I searched for dependent features on unleash and unleash dotnet sdk out of curiosity for what you meant with the comment about dependent features not working in the future. I couldnt find an exact reference to dependent features (with exception of some tests).
These tests lead me to the FeatureToggle constructor:
public FeatureToggle(string name, string type, bool enabled, bool impressionData, List<ActivationStrategy> strategies, List<VariantDefinition> variants = null, List<Dependency> dependencies = null)
{
Name = name;
Type = type;
Enabled = enabled;
ImpressionData = impressionData;
Strategies = strategies ?? new List<ActivationStrategy>();
Variants = variants ?? new List<VariantDefinition>();
Dependencies = dependencies ?? new List<Dependency>();
}
where I found that dependencies was optional and defaulting to an empty lists of dependencies (similar to the issue you shared). Is this the reason why dependent features wont work when using System.Text.Json, and will this also be true for variants?
from unleash-client-dotnet.
Related Issues (20)
- Have Strategies also Implement Microsoft Feature management HOT 2
- Does the Context Need to be Cloned? HOT 4
- Reducation in target frameworks HOT 1
- Replacement of LibLog with Microsoft.Extensions.Logging.Abstractions HOT 1
- Record metrics using System.Diagnostics.Metrics HOT 2
- Split of nuget package HOT 2
- Negate operator not work in dot net sdk HOT 3
- Feature toggles are fetched in a chron manner instead of when a feature flag is actually needed HOT 9
- Removal of Microsoft.CSharp package dependency HOT 4
- Update licence inclusion in Nuget HOT 2
- Platform specific test suite for .NET Framework to run in CI HOT 2
- Receiving Json Parsing error when receiving 304 status when ETag in response header is null. HOT 1
- We see a lot "The `appName` property is required. It was not present on the data you sent." HOT 2
- Unhandled exceptions in Unleash's background process HOT 2
- synchronousInitialization: true should throw exception if exception happens in the init flow (network, authorization, etc) HOT 3
- InvalidOperationException being thrown from Unleash.Scheduling.SystemTimerScheduledTaskManager.ConfigureTask HOT 2
- Empty userId breaks gradual rollout 100% expected behavior. HOT 3
- Built-in JSON serialization without reflection HOT 3
- Avoid subtle errors and improve DX when setting a custom serializer HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unleash-client-dotnet.