Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
prepare 3.0.0 release (#49)
Browse files Browse the repository at this point in the history
* configure Android HTTP client to do timeouts correctly.

* typo

* version 1.0.0-beta24

* changelog update

* version 1.0.0

* use CommonSdk 4.1.0

* fix dependency

* update test data because User.Anonymous was fixed to default to null instead of false

* linefeeds

* use CommonSDK 4.2.0 (adds log helper)

* version 1.1.0

* set default background polling interval

* fix csproj reference to MSBuild.Sdk.Extras

* need to keep PackageReference?

* try to fix test build

* fix MSBuild.Sdk.Extras again (https://github.com/onovotny/MSBuildSdkExtras/blob/master/README.md)

* try another project file format change

* more project config fixes

* brew cask is built-in now

* explicit TargetFramework

* set OutputPath

* rm redundant assembly info

* more project fixes

* misc project fixes

* add SDK version config

* changelog update

* changelog update

* use CommonSdk 4.2.1

* fix tests (user JSON no longer includes pointless "custom":{})

* version 1.1.1

* add EnumVariation extension methods

* update CommonSdk, don't use deprecated reason types

* use transformed user, not original user, when requesting flags after Identify

* fix some more deprecated usages

* fix some more deprecated usages

* fix test logic for detecting generated user key

* use CommonSdk 4.3.0

* update CommonSdk to 4.3.1 for event payload ID fix

* version 1.2.0

* project file cleanup

* revert project file change

* try setting CodesignKey

* build in debug mode

* set platform explicitly to simulator in CI

* use Xcode 11.3 in CI

* fix brew install of Xamarin tools

* fix iOS build path

* add comment, rm unnecessary property

* execute Xamarin SDK releases via Releaser (#98)

* fix Android CI build (#99)

* Removed the guides link

* don't drop base paths from custom base URIs

* Update base64 encoding of user JSON to be URL safe. (#102)

* make the Android CI build work (#103)

* Removed redundant dependencies on android support libraries. This allows to use the package with mono droid 10 and Jetpack. (#104)

Co-authored-by: Vladimir-Mischenchuk <uniqueidentificator@gmail.com>

* better install logic for CI and release (#105)

* prevent spurious dependencies in package build

* Set up mysterious ibtool fix. (#108)

This is a rather unexplained workaround for the iOS CI job being non-functional. I unfortunately do not have any good explanation for _why_ this works. There's some sort of 👻 statefulness going on that I can't explain. Regardless, this does allow the `msbuild` to complete successfully and tests to run. There's still some sort of issue when actually running the tests related to `System.IO.Pipelines`, but I haven't looked into that.

* use EmbedIO instead of WireMock.Net for embedded HTTP server in tests

* support ping message used by Relay stream endpoint

* add lower-level test coverage

* (2.0 - #1) minimum changes to migrate to newer common packages that are used by .NET SDK 6.0 (#100)

* (2.0 - #2) remove Newtonsoft.Json (#106)

* improve EnumVariation with type constraint, fix tests

* use LaunchDarkly.TestHelpers for HTTP tests

* fix project files

* fix project files

* update to latest InternalSdk, misc cleanup, better test code sharing (#114)

* better workaround for iOS storyboard build problem (#115)

* update dependencies to latest releases

* drop support for Android 7.1 and 8.0

* (#1) code reorganization, standardize namespaces (#117)

* (#2) rename SDK in the readme and project names (#118)

* (#3) rename Xamarin to Client in namespaces & assemblies (#119)

* (#4) add logging configuration and per-platform default loggers (#120)

* implement Alias method and auto-aliasing

* misc test fixes

* remove IConfigurationBuilder interface

* doc comment fixes + add files for new doc generator

* rm obsolete file

* Apply suggestions from code review

Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>

* clarify CommonSdk documentation

* (#4) add IDataSource interface & more component infrastructure similar to dotnet-server-sdk (#124)

* (#5) scoped configuration & public interface for events (#125)

* (#6) scoped configuration for HTTP (#126)

* (#1) reimplement data store components for cleaner abstraction of persistence, make it configurable (#127)

* (#2) misc tedious code cleanup of property/method naming (#128)

* (#3) revise flag notification mechanism to look more like the server-side SDK (#129)

* (#4) implement test data source (#130)

* (#5) use new concurrency helpers in dotnet-sdk-internal (#131)

* data source status API

* comments

* make build fail if XML comments are missing or invalid

* doc comment fixes

* doc comment fix

* set default flush interval to 30 seconds on mobile platforms

* simpler way of configuring service base URIs (#134)

* add DoubleVariation and DoubleVariationDetail

* enable REPORT mode, except on Android

* configure TaskExecutor to call event handlers on main thread in Android/iOS

* add guard on writing to Xunit test output

* implement diagnostic events (#137)

* fix HttpMessageHandler + proxy configuration, add test coverage (#141)

* fix HttpMessageHandler + proxy configuration, add test coverage

* fix test package dependencies

* re-fix dependencies

* update MSBuild.Sdk.Extras to prevent spurious build warnings from .NET 5 tools

* new persistent storage implementation + max users limit (#143)

* better data source test coverage + misc bugfixes (#144)

* use Releaser v2 configuration (#135)

* add Authenticode signing in release builds; remove obsolete scripts (#145)

* add prerelease notice

* add strong naming in release build

* revise local storage usage to only use base64url-safe characters in namespaces/keys

* fix test package build script

* remove ReadTimeout setting which only worked in Android but not in a useful way

* refactor ConnectionManager state management to handle diagnostic events correctly

* fix init logic, add tests

* remove prerelease notice from readme for GA release

* update CommonSdk & InternalSdk to latest releases + delete obsolete project file

* Use CircleCI macOS Gen2 resource class. (#152)

* fix unset timestamp in alias events

* contract test service implementation (#154)

* Change master to main. (#155)

* remove obsolete Alias, AutoAliasingOptOut, InlineUsersInEvents

* update contract tests

* use U2C alpha packages, replace user with context

* fix tests

* fix more tests

* use correct context key for flag store + clean up context decorator implementation

* add test for flag storage with single/multi-kind contexts

* remove automatic "device" and "os" attributes

* simplify usage of LdClientContext in client initialization

* move component API types into Subsystems

* rm unused

* update to latest alpha packages

* never use device ID, always UUID for generated keys

* actually in .NET it's a GUID, not a UUID

* generate & cache randomized keys per context kind

* add new config option for auto-generating keys

* fix Android & iOS CI builds

* typo

* add contract tests for contexts + update prerelease CommonSdk

* don't use .NET Core 3.1 or .NET 5.0 for testing

* downgrade MSBuild.Sdk.Extras to work in .NET Core 3.1

* fix test framework & dependencies

* actually let's use .NET 6.0

* fix script permissions

* (#4) use System.Text.Json directly instead of LaunchDarkly.JsonStream (#170)

* use new polling endpoints with "context" in path

* use latest prerelease packages where Secondary is removed

* use more correct path for release credential parameter

* replace various factory interfaces with a generic interface

* bump LaunchDarkly.Logging to v1.0.2 for sc-177921

* fix release build to use newer osslsigncode (for 2.x)

* doc comment

* allow User to be used interchangeably with Context (#177)

* allow User to be used interchangeably with Context

* support User type in contract tests

* make context nullable in test service commands

* use latest package versions

* add FlushAndWait method

* update release metadata

* add FlushAndWaitAsync

* finish revising TestData API to use contexts (#182)

* finish revising TestData API to use contexts

* comment typos

Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Vladimir-Mischenchuk <uniqueidentificator@gmail.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
  • Loading branch information
8 people authored Dec 21, 2022
1 parent fb8295f commit df71983
Show file tree
Hide file tree
Showing 121 changed files with 2,313 additions and 2,019 deletions.
19 changes: 10 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ jobs:
# from build_android_and_ios. However, setting up the Linux build is so much faster than the Mac host that
# it's better to let this one run independently so we can get quick CI feedback for any basic problems.
docker:
- image: ldcircleci/dotnet5-release:1
# This image is based on mcr.microsoft.com/dotnet/sdk:5.0-focal but is in a
# slightly better state for us to install the make tool (apt-get update has
# already been done). See: https://github.com/launchdarkly/sdks-ci-docker
- image: mcr.microsoft.com/dotnet/sdk:6.0-focal
environment:
ASPNETCORE_SUPPRESSSTATUSMESSAGES: "true" # suppresses annoying debug output from embedded HTTP servers in tests
TEST_HARNESS_PARAMS: -junit /tmp/circle-reports/contract-tests-junit.xml
TESTFRAMEWORK: net5.0
TESTFRAMEWORK: net6.0
steps:
- checkout
- run: apt install -y make
- run: mkdir -p /tmp/circle-reports
- run: dotnet restore src/LaunchDarkly.ClientSdk
- run: dotnet build src/LaunchDarkly.ClientSdk -f netstandard2.0
Expand All @@ -43,11 +39,16 @@ jobs:
--logger:"junit;LogFilePath=/tmp/circle-reports/unit-tests.xml" \
tests/LaunchDarkly.ClientSdk.Tests/LaunchDarkly.ClientSdk.Tests.csproj
- run: make build-contract-tests
- run:
command: make start-contract-test-service
name: build contract tests
command: ./scripts/build-contract-tests.sh
- run:
name: run contract test service
command: ./scripts/start-contract-test-service.sh
background: true
- run: make run-contract-tests
- run:
name: run contract tests
command: ./scripts/run-contract-tests.sh

- store_test_results:
path: /tmp/circle-reports
Expand Down
5 changes: 3 additions & 2 deletions .ldrelease/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ repo:

branches:
- name: main
description: 2.x
description: 3.x
- name: 2.x
- name: 1.x

jobs:
Expand All @@ -23,7 +24,7 @@ jobs:

# Documentation is built in a Linux container
- template:
name: dotnet-linux
name: dotnet6-linux
skip:
- test
- publish
Expand Down
2 changes: 1 addition & 1 deletion .ldrelease/mac-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -eu

# Run the .NET Standard 2.0 unit tests. (Android and iOS tests are run by regular CI jobs)

dotnet test tests/LaunchDarkly.ClientSdk.Tests/LaunchDarkly.ClientSdk.Tests.csproj -f net5.0
TESTFRAMEWORK=net6.0 dotnet test tests/LaunchDarkly.ClientSdk.Tests/LaunchDarkly.ClientSdk.Tests.csproj -f net6.0
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ clean:
dotnet clean

TEMP_TEST_OUTPUT=/tmp/sdk-contract-test-service.log
BUILDFRAMEWORKS ?= netcoreapp2.1
TESTFRAMEWORK ?= netcoreapp2.1

build-contract-tests:
@cd contract-tests && dotnet build TestService.csproj
@./scripts/build-contract-tests.sh

start-contract-test-service:
@cd contract-tests && dotnet bin/Debug/${TESTFRAMEWORK}/ContractTestService.dll
@./scripts/start-contract-test-service.sh

start-contract-test-service-bg:
@echo "Test service output will be captured in $(TEMP_TEST_OUTPUT)"
@make start-contract-test-service >$(TEMP_TEST_OUTPUT) 2>&1 &
@./scripts/start-contract-test-service.sh >$(TEMP_TEST_OUTPUT) 2>&1 &

run-contract-tests:
@curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/main/downloader/run.sh \
| VERSION=v1 PARAMS="-url http://localhost:8000 -debug -stop-service-at-end $(TEST_HARNESS_PARAMS)" sh
@./scripts/run-contract-tests.sh

contract-tests: build-contract-tests start-contract-test-service-bg run-contract-tests

Expand Down
38 changes: 32 additions & 6 deletions contract-tests/Representations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
using System.Collections.Generic;
using LaunchDarkly.Sdk;

// Note, in order for System.Text.Json serialization/deserialization to work correctly, the members of
// this class must be properties with get/set, rather than fields. The property names are automatically
// camelCased by System.Text.Json.

namespace TestService
{
public class Status
Expand Down Expand Up @@ -49,7 +53,6 @@ public class SdkConfigEventParams
public bool EnableDiagnostics { get; set; }
public string[] GlobalPrivateAttributes { get; set; }
public long? FlushIntervalMs { get; set; }
public bool InlineUsers { get; set; }
}

public class SdkConfigServiceEndpointsParams
Expand All @@ -61,8 +64,8 @@ public class SdkConfigServiceEndpointsParams

public class SdkClientSideParams
{
public bool? AutoAliasingOptOut { get; set; }
public bool? EvaluationReasons { get; set; }
public Context? InitialContext { get; set; }
public User InitialUser { get; set; }
public bool? UseReport { get; set; }
}
Expand All @@ -74,7 +77,8 @@ public class CommandParams
public EvaluateAllFlagsParams EvaluateAll { get; set; }
public IdentifyEventParams IdentifyEvent { get; set; }
public CustomEventParams CustomEvent { get; set; }
public AliasEventParams AliasEvent { get; set; }
public ContextBuildParams ContextBuild { get; set; }
public ContextConvertParams ContextConvert { get; set; }
}

public class EvaluateFlagParams
Expand Down Expand Up @@ -104,6 +108,7 @@ public class EvaluateAllFlagsResponse

public class IdentifyEventParams
{
public Context? Context { get; set; }
public User User { get; set; }
}

Expand All @@ -115,9 +120,30 @@ public class CustomEventParams
public double? MetricValue { get; set; }
}

public class AliasEventParams
public class ContextBuildParams
{
public User User { get; set; }
public User PreviousUser { get; set; }
public ContextBuildSingleParams Single { get; set; }
public ContextBuildSingleParams[] Multi { get; set; }
}

public class ContextBuildSingleParams
{
public string Kind { get; set; }
public string Key { get; set; }
public string Name { get; set; }
public bool Anonymous { get; set; }
public string[] Private { get; set; }
public Dictionary<string, LdValue> Custom { get; set; }
}

public class ContextBuildResponse
{
public string Output { get; set; }
public string Error { get; set; }
}

public class ContextConvertParams
{
public string Input { get; set; }
}
}
99 changes: 85 additions & 14 deletions contract-tests/SdkClientEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using LaunchDarkly.Logging;
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Client;
using LaunchDarkly.Sdk.Json;

namespace TestService
{
Expand Down Expand Up @@ -37,7 +38,14 @@ string tag
startWaitTime = TimeSpan.FromMilliseconds(sdkParams.StartWaitTimeMs.Value);
}

_client = LdClient.Init(config, sdkParams.ClientSide.InitialUser, startWaitTime);
if (sdkParams.ClientSide.InitialContext != null)
{
_client = LdClient.Init(config, sdkParams.ClientSide.InitialContext.Value, startWaitTime);
}
else
{
_client = LdClient.Init(config, sdkParams.ClientSide.InitialUser, startWaitTime);
}
if (!_client.Initialized && !sdkParams.InitCanFail)
{
_client.Dispose();
Expand All @@ -63,7 +71,14 @@ public void Close()
return (true, DoEvaluateAll(command.EvaluateAll));

case "identifyEvent":
await _client.IdentifyAsync(command.IdentifyEvent.User);
if (command.IdentifyEvent.Context != null)
{
await _client.IdentifyAsync(command.IdentifyEvent.Context.Value);
}
else
{
await _client.IdentifyAsync(command.IdentifyEvent.User);
}
return (true, null);

case "customEvent":
Expand All @@ -82,14 +97,16 @@ public void Close()
}
return (true, null);

case "aliasEvent":
_client.Alias(command.AliasEvent.User, command.AliasEvent.PreviousUser);
return (true, null);

case "flushEvents":
_client.Flush();
return (true, null);

case "contextBuild":
return (true, DoContextBuild(command.ContextBuild));

case "contextConvert":
return (true, DoContextConvert(command.ContextConvert));

default:
return (false, null);
}
Expand Down Expand Up @@ -187,6 +204,66 @@ private object DoEvaluateAll(EvaluateAllFlagsParams p)
};
}

private ContextBuildResponse DoContextBuild(ContextBuildParams p)
{
Context c;
if (p.Multi is null)
{
c = DoContextBuildSingle(p.Single);
}
else
{
var b = Context.MultiBuilder();
foreach (var s in p.Multi)
{
b.Add(DoContextBuildSingle(s));
}
c = b.Build();
}
if (c.Valid)
{
return new ContextBuildResponse { Output = LdJsonSerialization.SerializeObject(c) };
}
return new ContextBuildResponse { Error = c.Error };
}

private Context DoContextBuildSingle(ContextBuildSingleParams s)
{
var b = Context.Builder(s.Key)
.Kind(s.Kind)
.Name(s.Name)
.Anonymous(s.Anonymous);
if (!(s.Private is null))
{
b.Private(s.Private);
}
if (!(s.Custom is null))
{
foreach (var kv in s.Custom)
{
b.Set(kv.Key, kv.Value);
}
}
return b.Build();
}

private ContextBuildResponse DoContextConvert(ContextConvertParams p)
{
try
{
var c = LdJsonSerialization.DeserializeObject<Context>(p.Input);
if (c.Valid)
{
return new ContextBuildResponse { Output = LdJsonSerialization.SerializeObject(c) };
}
return new ContextBuildResponse { Error = c.Error };
}
catch (Exception e)
{
return new ContextBuildResponse { Error = e.ToString() };
}
}

private static Configuration BuildSdkConfig(SdkConfigParams sdkParams, ILogAdapter logAdapter, string tag)
{
var builder = Configuration.Builder(sdkParams.Credential);
Expand Down Expand Up @@ -251,8 +328,7 @@ private static Configuration BuildSdkConfig(SdkConfigParams sdkParams, ILogAdapt
{
endpoints.Events(eventParams.BaseUri);
var events = Components.SendEvents()
.AllAttributesPrivate(eventParams.AllAttributesPrivate)
.InlineUsersInEvents(eventParams.InlineUsers);
.AllAttributesPrivate(eventParams.AllAttributesPrivate);
if (eventParams.Capacity.HasValue && eventParams.Capacity.Value > 0)
{
events.Capacity(eventParams.Capacity.Value);
Expand All @@ -263,7 +339,7 @@ private static Configuration BuildSdkConfig(SdkConfigParams sdkParams, ILogAdapt
}
if (eventParams.GlobalPrivateAttributes != null)
{
events.PrivateAttributeNames(eventParams.GlobalPrivateAttributes);
events.PrivateAttributes(eventParams.GlobalPrivateAttributes);
}
builder.Events(events);
builder.DiagnosticOptOut(!eventParams.EnableDiagnostics);
Expand All @@ -276,11 +352,6 @@ private static Configuration BuildSdkConfig(SdkConfigParams sdkParams, ILogAdapt
}
builder.Http(http);

if (sdkParams.ClientSide.AutoAliasingOptOut.HasValue)
{
builder.AutoAliasingOptOut(sdkParams.ClientSide.AutoAliasingOptOut.Value);
}

if (sdkParams.ClientSide.EvaluationReasons.HasValue)
{
builder.EvaluationReasons(sdkParams.ClientSide.EvaluationReasons.Value);
Expand Down
7 changes: 3 additions & 4 deletions contract-tests/TestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ public class Webapp
{
private static readonly string[] Capabilities = {
"client-side",
"context-type",
"mobile",
"service-endpoints",
"singleton",
"strongly-typed"
"strongly-typed",
"user-type"
};

public readonly Handler Handler;
Expand All @@ -55,9 +57,6 @@ public Webapp(EventWaitHandle quitSignal)
var service = new SimpleJsonService();
Handler = service.Handler;

// Tell the service about the custom JSON conversions for LaunchDarkly SDK types like User
service.SetJsonConverters(LaunchDarkly.Sdk.Json.LdJsonNet.Converter);

service.Route(HttpMethod.Get, "/", GetStatus);
service.Route(HttpMethod.Delete, "/", ForceQuit);
service.Route<CreateInstanceParams>(HttpMethod.Post, "/", PostCreateClient);
Expand Down
15 changes: 3 additions & 12 deletions contract-tests/TestService.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TestFramework Condition="'$(TESTFRAMEWORK)' == ''">netcoreapp2.1</TestFramework>
<TestFramework Condition="'$(TESTFRAMEWORK)' == ''">net6.0</TestFramework>
<TargetFrameworks>$(TESTFRAMEWORK)</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>ContractTestService</AssemblyName>
Expand All @@ -16,20 +16,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LaunchDarkly.TestHelpers" Version="1.5.0" />
<PackageReference Include="LaunchDarkly.CommonSdk.JsonNet" Version="5.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="LaunchDarkly.TestHelpers" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\LaunchDarkly.ClientSdk\LaunchDarkly.ClientSdk.csproj" />
</ItemGroup>

<ItemGroup>
<Content Update="Properties\launchSettings.json">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>

</Project>
8 changes: 5 additions & 3 deletions docs-src/namespaces/LaunchDarkly.Sdk.Client.Interfaces.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Interfaces that provide advanced SDK features or allow customization of LaunchDarkly components.
Interfaces and types that are part of the public API, but not needed for basic use of the SDK.

Most applications will not need to refer to these types. You will use them if you are creating a plug-in component, such as a data store integration, or if you use advanced features such as <xref:LaunchDarkly.Sdk.Client.LdClient.FlagTracker>.
Types in this namespace include:

The namespace also includes concrete types that are used as parameters within these interfaces.
* <xref:LaunchDarkly.Sdk.Client.Interfaces.ILdClient>, which allows the SDK client to be referenced via an interface rather than the concrete type <xref:LaunchDarkly.Sdk.Client.LdClient> (if for instance you want to create a mock implementation for testing).
* Types like <xref:LaunchDarkly.Sdk.Client.Interfaces.IFlagTracker> that provide a facade for some part of the SDK API; these are returned by properties like <xref:LaunchDarkly.Sdk.Client.Interfaces.ILdClient.FlagTracker>.
* Concrete types that are used as parameters within these interfaces, like <xref:LaunchDarkly.Sdk.Client.Interfaces.FlagValueChangeEvent>.
Loading

0 comments on commit df71983

Please sign in to comment.