Skip to content

Commit aa3753c

Browse files
authored
[Az.Resources] change version commparator from double to version (#13559)
* change version commparator from double to version * Add missing files
1 parent 0e6d853 commit aa3753c

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/Resources/Resources.sln

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Global
5252
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
5353
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
5454
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.Build.0 = Release|Any CPU
55+
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56+
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.Build.0 = Debug|Any CPU
57+
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.ActiveCfg = Release|Any CPU
58+
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.Build.0 = Release|Any CPU
5559
{6BD4D521-DAFB-472B-A803-81F053AB1396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5660
{6BD4D521-DAFB-472B-A803-81F053AB1396}.Debug|Any CPU.Build.0 = Debug|Any CPU
5761
{6BD4D521-DAFB-472B-A803-81F053AB1396}.Release|Any CPU.ActiveCfg = Release|Any CPU

src/Resources/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* Fixed an issue where What-If shows two resource group scopes with different casing
2424
* Updated `Export-AzResourceGroup` to use the SDK.
2525
* Added culture info to parse methods
26+
* Changed Double parser for version parser
2627

2728
## Version 3.0.0
2829
* Fixed parsing bug

src/Resources/Resources/RoleAssignments/NewAzureRoleAssignmentCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ public override void ExecuteCmdlet()
274274
}
275275
// ensure that if ConditionVersion is empty in any way, it becomes null
276276
ConditionVersion = string.IsNullOrEmpty(ConditionVersion) ? null : string.IsNullOrWhiteSpace(ConditionVersion) ? null : ConditionVersion;
277-
double _conditionVersion = double.Parse(ConditionVersion ?? "2.0", CultureInfo.InvariantCulture);
278-
if (_conditionVersion < 2.0)
277+
var _conditionVersion = Version.Parse(ConditionVersion ?? "2.0");
278+
if (_conditionVersion.Major < 2)
279279
{
280280
WriteExceptionError(new ArgumentException("Argument -ConditionVersion must be greater or equal than 2.0"));
281281
return;

src/Resources/Resources/RoleAssignments/SetAzureRoleAssignmentCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ public override void ExecuteCmdlet()
112112
}
113113

114114
// If ConditionVersion is changed, validate it's in the allowed values
115-
var oldConditionVersion = double.Parse(InputObject.ConditionVersion ?? "0.0");
116-
var newConditionVersion = double.Parse(fetchedRole.ConditionVersion ?? "2.0");
115+
var oldConditionVersion = Version.Parse(InputObject.ConditionVersion ?? "0.0");
116+
var newConditionVersion = Version.Parse(fetchedRole.ConditionVersion ?? "2.0");
117117

118118
// A condition version can change but currently we don't support downgrading to 1.0
119119
// we only verify the change if it's a downgrade
120-
if ((oldConditionVersion > newConditionVersion) && (newConditionVersion < 2.0))
120+
if ((oldConditionVersion > newConditionVersion) && (newConditionVersion.Major < 2))
121121
{
122122
throw new ArgumentException("Condition version different than '2.0' is not supported for update operations");
123123
}

0 commit comments

Comments
 (0)