-
-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (TfsGitRepositoryTool): add validation and logging for TfsGitReposi…
…toryTool options Add a check to ensure the TfsGitRepositoryEnricher is enabled before proceeding, logging a warning if it is not. This prevents unnecessary operations when the feature is disabled. Introduce a default initialization for the Mappings dictionary to avoid null references. Implement a new options validator class, TfsGitRepositoryToolOptionsValidator, to ensure that Mappings is always initialized, enhancing robustness and preventing runtime errors. These changes improve the reliability and maintainability of the tool by ensuring proper configuration and logging.
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/MigrationTools.Clients.TfsObjectModel/Tools/TfsGitRepositoryToolOptionsValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace MigrationTools.Tools | ||
{ | ||
internal class TfsGitRepositoryToolOptionsValidator : IValidateOptions<TfsGitRepositoryToolOptions> | ||
{ | ||
public ValidateOptionsResult Validate(string name, TfsGitRepositoryToolOptions options) | ||
{ | ||
if (options.Mappings == null) | ||
{ | ||
return ValidateOptionsResult.Fail("Mappings must be set to at least an empty array"); | ||
} | ||
return ValidateOptionsResult.Success; | ||
} | ||
} | ||
} |