From b67c6b04a2748ea502ec920a05b194bdc5767563 Mon Sep 17 00:00:00 2001 From: Ahmad Sattar Atta Date: Sun, 19 Jan 2020 11:47:20 +0100 Subject: [PATCH 1/2] Fix deprecation state decision making --- .../CustomControls/CheckBoxListView.cs | 6 +++--- DeprecationTool/DeprecateControl.cs | 2 +- Lib/Deprecate.fs | 19 ++++++++----------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/DeprecationTool/CustomControls/CheckBoxListView.cs b/DeprecationTool/CustomControls/CheckBoxListView.cs index 9aed485..48ad186 100644 --- a/DeprecationTool/CustomControls/CheckBoxListView.cs +++ b/DeprecationTool/CustomControls/CheckBoxListView.cs @@ -22,8 +22,8 @@ public enum CheckState { public CheckBoxListView() { - Bitmap intermediatestate = new Bitmap(16, 16); - CheckBoxRenderer.DrawCheckBox(Graphics.FromImage(intermediatestate), new Point(0, 3), System.Windows.Forms.VisualStyles.CheckBoxState.MixedNormal); + Bitmap indeterminate = new Bitmap(16, 16); + CheckBoxRenderer.DrawCheckBox(Graphics.FromImage(indeterminate), new Point(0, 3), System.Windows.Forms.VisualStyles.CheckBoxState.MixedNormal); Bitmap uncheckedstate = new Bitmap(16, 16); CheckBoxRenderer.DrawCheckBox(Graphics.FromImage(uncheckedstate), new Point(0, 3), System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal); @@ -33,7 +33,7 @@ public CheckBoxListView() CheckStates.Images.Add(Deprecate.UNCHECKED, uncheckedstate); CheckStates.Images.Add(Deprecate.CHECKED, checkedstate); - CheckStates.Images.Add(Deprecate.INDETERMINATE, intermediatestate); + CheckStates.Images.Add(Deprecate.INDETERMINATE, indeterminate); SmallImageList = CheckStates; } diff --git a/DeprecationTool/DeprecateControl.cs b/DeprecationTool/DeprecateControl.cs index 62c914f..542b719 100644 --- a/DeprecationTool/DeprecateControl.cs +++ b/DeprecationTool/DeprecateControl.cs @@ -353,7 +353,7 @@ private Deprecate.MetaDataWithCheck[] FieldsWithCheckedState() .Select((item, i) => new Deprecate.MetaDataWithCheck( (Deprecate.MetaData) item.Tag, - (Deprecate.DeprecationState) item.ImageIndex) + Deprecate.CheckBoxLiteralToDeprecationState(item.ImageKey)) ) .ToArray(); return attrWithCheckedState; diff --git a/Lib/Deprecate.fs b/Lib/Deprecate.fs index 876588b..ec71a50 100644 --- a/Lib/Deprecate.fs +++ b/Lib/Deprecate.fs @@ -28,7 +28,14 @@ module Deprecate = | DeprecationState.Favored -> UNCHECKED | DeprecationState.Deprecated -> CHECKED | DeprecationState.Partial -> INDETERMINATE - + | _ -> failwith "unexpected state" + + let CheckBoxLiteralToDeprecationState = function + | x when x = UNCHECKED -> DeprecationState.Favored + | x when x = CHECKED -> DeprecationState.Deprecated + | x when x = INDETERMINATE -> DeprecationState.Partial + | _ -> failwith "unexpected literal" + type LogicalName = string let labelToString (label: Label) = @@ -70,21 +77,16 @@ module Deprecate = deprecationState: DeprecationState } -// type ResDict = IDictionary> - type EntityMetaDataMap = Map type SolutionMetaDataMap = Map - type Action = Deprecate of Data: MetaData | Favor of Data : MetaData - let deprecationStampPattern = @"\n(\(Deprecated:)\s(?\d{2,}\/\d{2,}\/\d{4,}\s\d{2,}.\d{2,}.\d{2,})(,\ssearch:\s(?1|0))?(\))" - let startsWithPrefix (text: string) prefix = text.StartsWith(prefix, true, CultureInfo.InvariantCulture) @@ -118,7 +120,6 @@ module Deprecate = | x when (isPartiallyDeprecated x prefix) -> DeprecationState.Partial | _ -> DeprecationState.Favored - let getResponse<'T when 'T :> OrganizationResponse> (proxy:IOrganizationService) request = (proxy.Execute(request)) :?> 'T @@ -158,7 +159,6 @@ module Deprecate = (resp.EntityMetadata.LogicalName, filteredMetaData) - let internal retrieveMultiple proxy logicalName (query:QueryExpression) = query.PageInfo <- PagingInfo() @@ -176,7 +176,6 @@ module Deprecate = } retrieveMultiple' proxy query 1 null - let internal getEntitiesFilter proxy (logicalName:string) (cols:string list) (filter:Map) = @@ -262,7 +261,6 @@ module Deprecate = then displayName.[prefixLength..] else displayName - let executeRequests (proxy: IOrganizationService) (reqs: OrganizationRequest[]) = let req = ExecuteMultipleRequest() req.Requests <- OrganizationRequestCollection() @@ -280,7 +278,6 @@ module Deprecate = resp - (* An attribute is deprecated when 1. The display name has been prepended with a deprecation prefix, such as "zz_" 2. Searchable is set to no (IsValidForAdvancedFind) From 9724f841a10b3dc7b033cf9712656b65d5cca469 Mon Sep 17 00:00:00 2001 From: Ahmad Sattar Atta Date: Sun, 19 Jan 2020 11:47:39 +0100 Subject: [PATCH 2/2] Fix fsharp code --- Lib/deprecate.fs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Lib/deprecate.fs b/Lib/deprecate.fs index 876588b..ec71a50 100644 --- a/Lib/deprecate.fs +++ b/Lib/deprecate.fs @@ -28,7 +28,14 @@ module Deprecate = | DeprecationState.Favored -> UNCHECKED | DeprecationState.Deprecated -> CHECKED | DeprecationState.Partial -> INDETERMINATE - + | _ -> failwith "unexpected state" + + let CheckBoxLiteralToDeprecationState = function + | x when x = UNCHECKED -> DeprecationState.Favored + | x when x = CHECKED -> DeprecationState.Deprecated + | x when x = INDETERMINATE -> DeprecationState.Partial + | _ -> failwith "unexpected literal" + type LogicalName = string let labelToString (label: Label) = @@ -70,21 +77,16 @@ module Deprecate = deprecationState: DeprecationState } -// type ResDict = IDictionary> - type EntityMetaDataMap = Map type SolutionMetaDataMap = Map - type Action = Deprecate of Data: MetaData | Favor of Data : MetaData - let deprecationStampPattern = @"\n(\(Deprecated:)\s(?\d{2,}\/\d{2,}\/\d{4,}\s\d{2,}.\d{2,}.\d{2,})(,\ssearch:\s(?1|0))?(\))" - let startsWithPrefix (text: string) prefix = text.StartsWith(prefix, true, CultureInfo.InvariantCulture) @@ -118,7 +120,6 @@ module Deprecate = | x when (isPartiallyDeprecated x prefix) -> DeprecationState.Partial | _ -> DeprecationState.Favored - let getResponse<'T when 'T :> OrganizationResponse> (proxy:IOrganizationService) request = (proxy.Execute(request)) :?> 'T @@ -158,7 +159,6 @@ module Deprecate = (resp.EntityMetadata.LogicalName, filteredMetaData) - let internal retrieveMultiple proxy logicalName (query:QueryExpression) = query.PageInfo <- PagingInfo() @@ -176,7 +176,6 @@ module Deprecate = } retrieveMultiple' proxy query 1 null - let internal getEntitiesFilter proxy (logicalName:string) (cols:string list) (filter:Map) = @@ -262,7 +261,6 @@ module Deprecate = then displayName.[prefixLength..] else displayName - let executeRequests (proxy: IOrganizationService) (reqs: OrganizationRequest[]) = let req = ExecuteMultipleRequest() req.Requests <- OrganizationRequestCollection() @@ -280,7 +278,6 @@ module Deprecate = resp - (* An attribute is deprecated when 1. The display name has been prepended with a deprecation prefix, such as "zz_" 2. Searchable is set to no (IsValidForAdvancedFind)