Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks);net47</TargetFrameworks>
<NoWarn>$(NoWarn);CS8032</NoWarn>
<IncludeGeneratorSharedCode>true</IncludeGeneratorSharedCode>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions sdk/core/Azure.Core.TestFramework/src/TestRecording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ public TestRandom Random
#if NET6_0_OR_GREATER
var liveSeed = RandomNumberGenerator.GetInt32(int.MaxValue);
#else
#pragma warning disable SYSLIB0023

Choose a reason for hiding this comment

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

This is external code, I dont think we should be changing it

Copy link
Owner Author

Choose a reason for hiding this comment

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

Unfortunately, without this change, building will fail.

var csp = new RNGCryptoServiceProvider();
var bytes = new byte[4];
csp.GetBytes(bytes);
var liveSeed = BitConverter.ToInt32(bytes, 0);
#pragma warning restore SYSLIB0023
#endif
_random = new TestRandom(Mode, liveSeed);
break;
Expand Down
6 changes: 6 additions & 0 deletions sdk/personalizer/Azure.AI.Personalizer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{0F88C67F-34D2-4C68-B5BF-08A547D4CC2E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core", "..\core\Azure.Core\src\Azure.Core.csproj", "{CFB35402-69EB-448F-82B7-2D284730B0A6}"
Copy link
Owner Author

Choose a reason for hiding this comment

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

Have to add this project because Azure.Core.TestFramework depends on this.

EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -35,6 +37,10 @@ Global
{0F88C67F-34D2-4C68-B5BF-08A547D4CC2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F88C67F-34D2-4C68-B5BF-08A547D4CC2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F88C67F-34D2-4C68-B5BF-08A547D4CC2E}.Release|Any CPU.Build.0 = Release|Any CPU
{CFB35402-69EB-448F-82B7-2D284730B0A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CFB35402-69EB-448F-82B7-2D284730B0A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFB35402-69EB-448F-82B7-2D284730B0A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFB35402-69EB-448F-82B7-2D284730B0A6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>Microsoft Azure.AI.Personalizer client library</AssemblyTitle>
<Version>2.0.0-beta.2</Version>
Expand Down Expand Up @@ -33,6 +33,7 @@
<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="Microsoft.RL" VersionOverride="1.0.18120003-INTERNAL" />
Copy link
Owner Author

Choose a reason for hiding this comment

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

TODO: Need to take time to investigate whether we can remove VersionOverride in this file.

<PackageReference Include="System.Text.Json" VersionOverride="6.0.1" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is System.Text.Json necessary? I thought this was already included?

Copy link
Owner Author

Choose a reason for hiding this comment

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

The default is old 4.* version. But it won't support [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]. So I have to override the version to a higher one.

</ItemGroup>

</Project>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Text.Json;
using System.Text.Json.Serialization;
using System.Collections.Generic;
using System.Linq;

namespace Azure.AI.Personalizer
{
/// <summary> The Decision Context. </summary>
public class DecisionContext
{
/// <summary> The Decision Context used to serialize an object. </summary>
public DecisionContext()
{
}

/// <summary> Initializes a new instance of DecisionContext. </summary>
/// <param name="contextFeatures"> The context feature </param>
/// <param name="rankableActions"> Rankable actions </param>
public DecisionContext(IEnumerable<object> contextFeatures, List<PersonalizerRankableAction> rankableActions)
{
this.ContextFeatures = contextFeatures.Select(f => JsonSerializer.Serialize(f)).ToList();
this.Documents = rankableActions
.Select(action =>
{
List<string> actionFeatures = action.Features.Select(f => JsonSerializer.Serialize(f)).ToList();

return new DecisionContextDocument(action.Id, actionFeatures);
}).ToArray();
}

/// <summary> Properties from url </summary>
[JsonPropertyName("FromUrl")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonConverter(typeof(JsonRawStringListConverter))]
public List<string> ContextFeatures { get; }

/// <summary> Properties of documents </summary>
[JsonPropertyName("_multi")]
public DecisionContextDocument[] Documents { get; set; }
Copy link
Owner Author

Choose a reason for hiding this comment

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

Right.


/// <summary> Properties of slots </summary>
[JsonPropertyName("_slots")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DecisionContextDocument[] Slots { get; set; }
}
}
Loading