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
11 changes: 11 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"permissions": {
"allow": [
"Bash(npm run dev:*)",
"Bash(dotnet build:*)",
"Bash(npm run build:*)"
],
"deny": [],
"ask": []
}
}
2 changes: 2 additions & 0 deletions Generator/DTO/Attributes/Attribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public abstract class Attribute
public bool IsStandardFieldModified { get; set; }
public bool IsCustomAttribute { get; set; }
public bool IsPrimaryId { get; set; }
public bool IsPrimaryName { get; set; }
public List<AttributeUsage> AttributeUsages { get; set; } = new List<AttributeUsage>();
public string DisplayName { get; }
public string SchemaName { get; }
Expand All @@ -20,6 +21,7 @@ public abstract class Attribute
protected Attribute(AttributeMetadata metadata)
{
IsPrimaryId = metadata.IsPrimaryId ?? false;
IsPrimaryName = metadata.IsPrimaryName ?? false;
IsCustomAttribute = metadata.IsCustomAttribute ?? false;
DisplayName = metadata.DisplayName.UserLocalizedLabel?.Label ?? string.Empty;
SchemaName = metadata.SchemaName;
Expand Down
2 changes: 1 addition & 1 deletion Generator/DataverseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private static Record MakeRecord(
.Select(metadata =>
{
var attr = GetAttribute(metadata, entity, logicalToSchema, attributeUsages, logger);
attr.IsStandardFieldModified = MetadataExtensions.StandardFieldHasChanged(metadata, entity.DisplayName.UserLocalizedLabel?.Label ?? string.Empty);
attr.IsStandardFieldModified = MetadataExtensions.StandardFieldHasChanged(metadata, entity.DisplayName.UserLocalizedLabel?.Label ?? string.Empty, entity.IsCustomEntity ?? false);
return attr;
})
.Where(x => !string.IsNullOrEmpty(x.DisplayName))
Expand Down
24 changes: 22 additions & 2 deletions Generator/MetadataExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,25 @@ internal static string PrettyDescription(this string description) =>
.Replace("\"", @"”")
.Replace("\n", " ");

public static bool StandardFieldHasChanged(this AttributeMetadata attribute, string entityDisplayName)
public static bool StandardFieldHasChanged(this AttributeMetadata attribute, string entityDisplayName, bool isCustomEntity)
{
if (attribute.IsCustomAttribute ?? false) return false;

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

var fields = GetDefaultFields(entityDisplayName, languagecode);
return fields.StandardDescriptionHasChanged(attribute.LogicalName, attribute.Description.UserLocalizedLabel?.Label ?? string.Empty)
var hasTextChanged = fields.StandardDescriptionHasChanged(attribute.LogicalName, attribute.Description.UserLocalizedLabel?.Label ?? string.Empty)
|| fields.StandardDisplayNameHasChanged(attribute.LogicalName, attribute.DisplayName.UserLocalizedLabel?.Label ?? string.Empty);

// Check if options have been added to statecode or statuscode
var hasOptionsChanged = attribute switch
{
StateAttributeMetadata state => StateCodeOptionsHaveChanged(state),
StatusAttributeMetadata status => StatusCodeOptionsHaveChanged(status),
_ => false
};

return hasTextChanged || hasOptionsChanged;
}

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

private static bool StateCodeOptionsHaveChanged(StateAttributeMetadata state)
{
return state.OptionSet?.Options?.Count > 2;
}

private static bool StatusCodeOptionsHaveChanged(StatusAttributeMetadata status)
{
return status.OptionSet?.Options?.Count > 2;
}

private static IEnumerable<(string LogicalName, string DisplayName, string Description)> GetDefaultFields(string entityDisplayName, int? languageCode)
{
switch (languageCode)
Expand Down
Loading
Loading