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
10 changes: 2 additions & 8 deletions appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,8 @@
},
"TfsWorkItemTypeValidatorTool": {
"Enabled": true,
"ExcludeWorkItemtypes": [
"Code Review Request",
"Code Review Response",
"Feedback Request",
"Feedback Response",
"Shared Parameter",
"Shared Steps"
],
"ExcludeWorkItemtypes": [],
"ExcludeDefaultWorkItemTypes": true,
"SourceFieldMappings": [],
"FixedTargetFields": []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ configurationSamples:
"CommonTools": {
"TfsWorkItemTypeValidatorTool": {
"Enabled": "True",
"ExcludeWorkItemtypes": [
"Code Review Request",
"Code Review Response",
"Feedback Request",
"Feedback Response",
"Shared Parameter",
"Shared Steps"
],
"ExcludeDefaultWorkItemTypes": "True",
"ExcludeWorkItemtypes": null,
"FixedTargetFields": null,
"SourceFieldMappings": null
}
Expand Down Expand Up @@ -60,14 +54,8 @@ configurationSamples:
"$type": "TfsWorkItemTypeValidatorToolOptions",
"Enabled": true,
"IncludeWorkItemtypes": [],
"ExcludeWorkItemtypes": [
"Code Review Request",
"Code Review Response",
"Feedback Request",
"Feedback Response",
"Shared Parameter",
"Shared Steps"
],
"ExcludeWorkItemtypes": [],
"ExcludeDefaultWorkItemTypes": true,
"SourceFieldMappings": {
"User Story": {
"Microsoft.VSTS.Common.Prirucka": "Custom.Prirucka"
Expand All @@ -92,6 +80,15 @@ options:
defaultValue: true
isRequired: false
dotNetType: System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
- parameterName: ExcludeDefaultWorkItemTypes
type: Boolean
description: >-
If `true`, some work item types will be automatically added to `ExcludeWorkItemtypes` list.
Work item types excluded by default are: Code Review Request, Code Review Response, Feedback Request,
Feedback Response, Shared Parameter, Shared Steps.
defaultValue: missing XML code comments
isRequired: false
dotNetType: System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
- parameterName: ExcludeWorkItemtypes
type: List
description: List of work item types which will be excluded from validation.
Expand Down
4 changes: 4 additions & 0 deletions docs/static/schema/configuration.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2468,6 +2468,10 @@
"type": "boolean",
"default": "true"
},
"ExcludeDefaultWorkItemTypes": {
"description": "If `true`, some work item types will be automatically added to `ExcludeWorkItemtypes` list.\r\n Work item types excluded by default are: Code Review Request, Code Review Response, Feedback Request,\r\n Feedback Response, Shared Parameter, Shared Steps.",
"type": "boolean"
},
"ExcludeWorkItemtypes": {
"description": "List of work item types which will be excluded from validation.",
"type": "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"type": "boolean",
"default": "true"
},
"ExcludeDefaultWorkItemTypes": {
"description": "If `true`, some work item types will be automatically added to `ExcludeWorkItemtypes` list.\r\n Work item types excluded by default are: Code Review Request, Code Review Response, Feedback Request,\r\n Feedback Response, Shared Parameter, Shared Steps.",
"type": "boolean"
},
"ExcludeWorkItemtypes": {
"description": "List of work item types which will be excluded from validation.",
"type": "array"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static void AddMigrationToolServicesForClientTfs_Tools(this IServiceColle
context.AddSingleton<TfsTeamSettingsTool>().AddMigrationToolsOptions<TfsTeamSettingsToolOptions>(configuration);
context.AddSingleton<TfsChangeSetMappingTool>().AddMigrationToolsOptions<TfsChangeSetMappingToolOptions>(configuration);
context.AddSingleton<TfsWorkItemTypeValidatorTool>().AddMigrationToolsOptions<TfsWorkItemTypeValidatorToolOptions, TfsWorkItemTypeValidatorToolOptionsValidator>(configuration);
context.PostConfigure<TfsWorkItemTypeValidatorToolOptions>(options => options.Normalize());
}

public static void AddMigrationToolServicesForClientTfs_Processors(this IServiceCollection context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public TfsWorkItemTypeValidatorTool(
: base(options, services, logger, telemetry)
{
_witMappingTool = witMappingTool ?? throw new ArgumentNullException(nameof(witMappingTool));
Options.Normalize();
}

public bool ValidateReflectedWorkItemIdField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public class TfsWorkItemTypeValidatorToolOptions : ToolOptions

private static readonly StringComparer _normalizedComparer = StringComparer.OrdinalIgnoreCase;
private bool _isNormalized = false;
private static string[] _defaultExcludedWorkItemTypes = [
"Code Review Request",
"Code Review Response",
"Feedback Request",
"Feedback Response",
"Shared Parameter",
"Shared Steps"
];

/// <summary>
/// List of work item types which will be validated. If this list is empty, all work item types will be validated.
Expand All @@ -26,6 +34,13 @@ public class TfsWorkItemTypeValidatorToolOptions : ToolOptions
/// </summary>
public List<string> ExcludeWorkItemtypes { get; set; } = [];

/// <summary>
/// If <see langword="true"/>, some work item types will be automatically added to <see cref="ExcludeWorkItemtypes"/> list.
/// Work item types excluded by default are: Code Review Request, Code Review Response, Feedback Request,
/// Feedback Response, Shared Parameter, Shared Steps.
/// </summary>
public bool ExcludeDefaultWorkItemTypes { get; set; } = true;

/// <summary>
/// Field reference name mappings. Key is work item type name, value is dictionary of mapping source filed name to
/// target field name. Target field name can be empty string to indicate that this field will not be validated in target.
Expand Down Expand Up @@ -90,6 +105,17 @@ public void Normalize()

IncludeWorkItemtypes ??= [];
ExcludeWorkItemtypes ??= [];
if (ExcludeDefaultWorkItemTypes)
{
foreach (string defaultExcludedWit in _defaultExcludedWorkItemTypes)
{
if (!ExcludeWorkItemtypes.Contains(defaultExcludedWit, _normalizedComparer))
{
ExcludeWorkItemtypes.Add(defaultExcludedWit);
}
}
}

FixedTargetFields = newFixedFields;
SourceFieldMappings = newMappings;
_isNormalized = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public ValidateOptionsResult Validate(string name, TfsWorkItemTypeValidatorToolO
if ((includedCount > 0) && (excludedCount > 0))
{
const string msg = $"'{nameof(options.IncludeWorkItemtypes)}' and '{nameof(options.ExcludeWorkItemtypes)}'"
+ $" cannot be set both at the same time.";
+ $" cannot be set both at the same time."
+ $" If '{nameof(options.IncludeWorkItemtypes)}' list is not empty,"
+ $" '{nameof(options.ExcludeDefaultWorkItemTypes)}' must be set to 'false'.";
return ValidateOptionsResult.Fail(msg);
}
return ValidateOptionsResult.Success;
Expand Down
Loading