From 9d63c9c51dbb5bdcf2fbd6222d0f5d666b5b352d Mon Sep 17 00:00:00 2001
From: Scott Kearney <=>
Date: Wed, 7 Aug 2024 19:52:36 -0400
Subject: [PATCH 1/2] test: Check whether updating the Description and
DisplayName properties actually works.
This test fails without the fix in place. Once the fix is applied, it passes. Checks by attempting to update the Description and DisplayName properties, which should create the appropriate traits automatically.
---
.../CdmEntityAttributePersistenceTests.cs | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/objectModel/CSharp/Microsoft.CommonDataModel.ObjectModel.Tests/Persistence/CdmFolder/EntityAttribute/CdmEntityAttributePersistenceTests.cs b/objectModel/CSharp/Microsoft.CommonDataModel.ObjectModel.Tests/Persistence/CdmFolder/EntityAttribute/CdmEntityAttributePersistenceTests.cs
index 1c92a1dcc9..71ba6a759e 100644
--- a/objectModel/CSharp/Microsoft.CommonDataModel.ObjectModel.Tests/Persistence/CdmFolder/EntityAttribute/CdmEntityAttributePersistenceTests.cs
+++ b/objectModel/CSharp/Microsoft.CommonDataModel.ObjectModel.Tests/Persistence/CdmFolder/EntityAttribute/CdmEntityAttributePersistenceTests.cs
@@ -41,5 +41,35 @@ public void TestDescriptionAndDisplayName()
// Checks if there is no residue of the transformation of the properties into traits.
Assert.IsNull(data.AppliedTraits);
}
+
+ ///
+ /// Tests if updating the properties description and displayName will persist
+ ///
+ [TestMethod]
+ public void TestUpdatingDescriptionAndDisplayName()
+ {
+ var corpus = new CdmCorpusDefinition();
+ var entityName = "TheEntity";
+ var description = "entityAttributeDescription";
+ var displayName = "whatABeutifulDisplayName";
+ var inputData = new JObject()
+ {
+ ["name"] = entityName,
+ ["displayName"] = displayName,
+ ["description"] = description
+ };
+
+ var instance = EntityAttributePersistence.FromData(corpus.Ctx, inputData);
+
+ var newDescription = "newEntityAttributeDescription";
+ var newDisplayName = "anotherBeautifulDisplanyName";
+
+ instance.Description = newDescription;
+ instance.DisplayName = newDisplayName;
+
+ // Make sure the properties got updated on the instance correctly
+ Assert.AreEqual(newDescription, instance.Description);
+ Assert.AreEqual(newDisplayName, instance.DisplayName);
+ }
}
}
From 8189e901748673eb6f996e2e9eb70f7ad021631c Mon Sep 17 00:00:00 2001
From: Scott Kearney <=>
Date: Wed, 7 Aug 2024 19:55:15 -0400
Subject: [PATCH 2/2] fix: Set the attribute to the provided newValue for a
localizedTraitTable.
As referenced in the comment, the attReturn positioned value should be set to the newValue which was passed in. Instead, it was just re-writing the existing value. This change fixes that glitch.
---
.../Cdm/CdmConstantEntityDefinition.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/objectModel/CSharp/Microsoft.CommonDataModel.ObjectModel/Cdm/CdmConstantEntityDefinition.cs b/objectModel/CSharp/Microsoft.CommonDataModel.ObjectModel/Cdm/CdmConstantEntityDefinition.cs
index 943c9260ff..b60ce37daf 100644
--- a/objectModel/CSharp/Microsoft.CommonDataModel.ObjectModel/Cdm/CdmConstantEntityDefinition.cs
+++ b/objectModel/CSharp/Microsoft.CommonDataModel.ObjectModel/Cdm/CdmConstantEntityDefinition.cs
@@ -141,7 +141,7 @@ internal string FetchConstantValue(ResolveOptions resOpt, dynamic attReturn, dyn
internal string UpdateConstantValue(ResolveOptions resOpt, dynamic attReturn, string newValue, dynamic attSearch, string valueSearch, int order)
{
string result = null;
- Func action = found => { result = found; return found; };
+ Func action = found => { result = newValue; return newValue; };
this.FindValue(resOpt, attReturn, attSearch, valueSearch, order, action);
return result;
}