Skip to content

Commit 452151f

Browse files
authored
Merge pull request #71 from delegateas/patches/12187-diverse
Patches/12187 diverse
2 parents 2db3593 + 3d01192 commit 452151f

File tree

12 files changed

+894
-49
lines changed

12 files changed

+894
-49
lines changed

.claude/settings.local.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(npm run dev:*)",
5+
"Bash(dotnet build:*)",
6+
"Bash(npm run build:*)"
7+
],
8+
"deny": [],
9+
"ask": []
10+
}
11+
}

Generator/DTO/Attributes/Attribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public abstract class Attribute
77
public bool IsStandardFieldModified { get; set; }
88
public bool IsCustomAttribute { get; set; }
99
public bool IsPrimaryId { get; set; }
10+
public bool IsPrimaryName { get; set; }
1011
public List<AttributeUsage> AttributeUsages { get; set; } = new List<AttributeUsage>();
1112
public string DisplayName { get; }
1213
public string SchemaName { get; }
@@ -20,6 +21,7 @@ public abstract class Attribute
2021
protected Attribute(AttributeMetadata metadata)
2122
{
2223
IsPrimaryId = metadata.IsPrimaryId ?? false;
24+
IsPrimaryName = metadata.IsPrimaryName ?? false;
2325
IsCustomAttribute = metadata.IsCustomAttribute ?? false;
2426
DisplayName = metadata.DisplayName.UserLocalizedLabel?.Label ?? string.Empty;
2527
SchemaName = metadata.SchemaName;

Generator/DataverseService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private static Record MakeRecord(
339339
.Select(metadata =>
340340
{
341341
var attr = GetAttribute(metadata, entity, logicalToSchema, attributeUsages, logger);
342-
attr.IsStandardFieldModified = MetadataExtensions.StandardFieldHasChanged(metadata, entity.DisplayName.UserLocalizedLabel?.Label ?? string.Empty);
342+
attr.IsStandardFieldModified = MetadataExtensions.StandardFieldHasChanged(metadata, entity.DisplayName.UserLocalizedLabel?.Label ?? string.Empty, entity.IsCustomEntity ?? false);
343343
return attr;
344344
})
345345
.Where(x => !string.IsNullOrEmpty(x.DisplayName))

Generator/MetadataExtensions.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@ internal static string PrettyDescription(this string description) =>
2020
.Replace("\"", @"”")
2121
.Replace("\n", " ");
2222

23-
public static bool StandardFieldHasChanged(this AttributeMetadata attribute, string entityDisplayName)
23+
public static bool StandardFieldHasChanged(this AttributeMetadata attribute, string entityDisplayName, bool isCustomEntity)
2424
{
2525
if (attribute.IsCustomAttribute ?? false) return false;
2626

2727
var languagecode = attribute.DisplayName.UserLocalizedLabel?.LanguageCode;
2828

2929
var fields = GetDefaultFields(entityDisplayName, languagecode);
30-
return fields.StandardDescriptionHasChanged(attribute.LogicalName, attribute.Description.UserLocalizedLabel?.Label ?? string.Empty)
30+
var hasTextChanged = fields.StandardDescriptionHasChanged(attribute.LogicalName, attribute.Description.UserLocalizedLabel?.Label ?? string.Empty)
3131
|| fields.StandardDisplayNameHasChanged(attribute.LogicalName, attribute.DisplayName.UserLocalizedLabel?.Label ?? string.Empty);
32+
33+
// Check if options have been added to statecode or statuscode
34+
var hasOptionsChanged = attribute switch
35+
{
36+
StateAttributeMetadata state => StateCodeOptionsHaveChanged(state),
37+
StatusAttributeMetadata status => StatusCodeOptionsHaveChanged(status),
38+
_ => false
39+
};
40+
41+
return hasTextChanged || hasOptionsChanged;
3242
}
3343

3444
private static bool StandardDisplayNameHasChanged(this IEnumerable<(string LogicalName, string DisplayName, string Description)> fields, string logicalName, string displayName)
@@ -45,6 +55,16 @@ private static bool StandardDescriptionHasChanged(this IEnumerable<(string Logic
4555
.Any(f => description.Equals(f.Description));
4656
}
4757

58+
private static bool StateCodeOptionsHaveChanged(StateAttributeMetadata state)
59+
{
60+
return state.OptionSet?.Options?.Count > 2;
61+
}
62+
63+
private static bool StatusCodeOptionsHaveChanged(StatusAttributeMetadata status)
64+
{
65+
return status.OptionSet?.Options?.Count > 2;
66+
}
67+
4868
private static IEnumerable<(string LogicalName, string DisplayName, string Description)> GetDefaultFields(string entityDisplayName, int? languageCode)
4969
{
5070
switch (languageCode)

0 commit comments

Comments
 (0)