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

New field AltinnNugetVersion in applicationMetadata.cs #333

Merged
merged 1 commit into from
Nov 13, 2023
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
9 changes: 8 additions & 1 deletion src/Altinn.App.Core/Models/ApplicationMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reflection;
using Altinn.Platform.Storage.Interface.Models;
using Newtonsoft.Json;

Expand Down Expand Up @@ -57,7 +58,13 @@ public ApplicationMetadata(string id)
/// </summary>
[JsonProperty(PropertyName = "logo")]
public Logo? Logo { get; set; }


/// <summary>
/// Frontend sometimes need to have knowledge of the nuget package version for backwards compatibility
/// </summary>
[JsonProperty(PropertyName = "altinnNugetVersion")]
public string AltinnNugetVersion { get; set; } = typeof(ApplicationMetadata).Assembly!.GetName().Version!.ToString();

/// <summary>
/// Holds properties that are not mapped to other properties
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reflection;
using System.Text.Json;
using Altinn.App.Core.Configuration;
using Altinn.App.Core.Internal.App;
Expand Down Expand Up @@ -482,8 +483,9 @@ public async Task GetApplicationMetadata_deserialize_serialize_unmapped_properti
AppSettings appSettings = GetAppSettings("AppMetadata", "unmapped-properties.applicationmetadata.json");
IAppMetadata appMetadata = SetupAppMedata(Options.Create(appSettings));
var appMetadataObj = await appMetadata.GetApplicationMetadata();
string serialized = JsonSerializer.Serialize(appMetadataObj, new JsonSerializerOptions { WriteIndented = true });
string serialized = JsonSerializer.Serialize(appMetadataObj, new JsonSerializerOptions { WriteIndented = true, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping });
string expected = File.ReadAllText(Path.Join(appBasePath, "AppMetadata", "unmapped-properties.applicationmetadata.expected.json"));
expected = expected.Replace("--AltinnNugetVersion--", typeof(ApplicationMetadata).Assembly!.GetName().Version!.ToString());
serialized.Should().Be(expected);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"Show": "select-instance"
},
"Logo": null,
"AltinnNugetVersion": "--AltinnNugetVersion--",
"VersionId": null,
"Org": "tdd",
"Title": {
Expand Down
Loading