Skip to content

Commit 1ceb48d

Browse files
fix the issue in customization code in redis SDK (Azure#36347)
* fix the issue * fix build issue
1 parent e0b9819 commit 1ceb48d

File tree

5 files changed

+87
-57
lines changed

5 files changed

+87
-57
lines changed

sdk/redis/Azure.ResourceManager.Redis/Azure.ResourceManager.Redis.sln

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30309.148
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33530.505
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{6D52B45B-1766-409C-BCDA-AE78A291A000}") = "Azure.ResourceManager.Redis", "src\Azure.ResourceManager.Redis.csproj", "{76FB489A-8C0B-4712-B789-829BD1396817}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Redis", "src\Azure.ResourceManager.Redis.csproj", "{76FB489A-8C0B-4712-B789-829BD1396817}"
77
EndProject
8-
Project("{6D52B45B-1766-409C-BCDA-AE78A291A000}") = "Azure.ResourceManager.Redis.Tests", "tests\Azure.ResourceManager.Redis.Tests.csproj", "{BFB2FA06-3DAA-4845-A20F-8FB60F3438E2}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Redis.Tests", "tests\Azure.ResourceManager.Redis.Tests.csproj", "{BFB2FA06-3DAA-4845-A20F-8FB60F3438E2}"
99
EndProject
10-
Project("{6D52B45B-1766-409C-BCDA-AE78A291A000}") = "Azure.ResourceManager.Redis.Samples", "samples\Azure.ResourceManager.Redis.Samples.csproj", "{4579FB37-CAD4-4B6D-B123-A4049492C33B}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Redis.Samples", "samples\Azure.ResourceManager.Redis.Samples.csproj", "{4579FB37-CAD4-4B6D-B123-A4049492C33B}"
1111
EndProject
1212
Global
13-
GlobalSection(SolutionProperties) = preSolution
14-
HideSolutionNode = FALSE
15-
EndGlobalSection
16-
GlobalSection(ExtensibilityGlobals) = postSolution
17-
SolutionGuid = {7DCB7558-E377-4DBC-B689-A44766D3D723}
18-
EndGlobalSection
1913
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2014
Debug|Any CPU = Debug|Any CPU
2115
Debug|x64 = Debug|x64
@@ -49,5 +43,23 @@ Global
4943
{BFB2FA06-3DAA-4845-A20F-8FB60F3438E2}.Release|x64.Build.0 = Release|Any CPU
5044
{BFB2FA06-3DAA-4845-A20F-8FB60F3438E2}.Release|x86.ActiveCfg = Release|Any CPU
5145
{BFB2FA06-3DAA-4845-A20F-8FB60F3438E2}.Release|x86.Build.0 = Release|Any CPU
46+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Debug|x64.ActiveCfg = Debug|Any CPU
49+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Debug|x64.Build.0 = Debug|Any CPU
50+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Debug|x86.ActiveCfg = Debug|Any CPU
51+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Debug|x86.Build.0 = Debug|Any CPU
52+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Release|Any CPU.ActiveCfg = Release|Any CPU
53+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Release|Any CPU.Build.0 = Release|Any CPU
54+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Release|x64.ActiveCfg = Release|Any CPU
55+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Release|x64.Build.0 = Release|Any CPU
56+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Release|x86.ActiveCfg = Release|Any CPU
57+
{4579FB37-CAD4-4B6D-B123-A4049492C33B}.Release|x86.Build.0 = Release|Any CPU
58+
EndGlobalSection
59+
GlobalSection(SolutionProperties) = preSolution
60+
HideSolutionNode = FALSE
61+
EndGlobalSection
62+
GlobalSection(ExtensibilityGlobals) = postSolution
63+
SolutionGuid = {7DCB7558-E377-4DBC-B689-A44766D3D723}
5264
EndGlobalSection
5365
EndGlobal

sdk/redis/Azure.ResourceManager.Redis/api/Azure.ResourceManager.Redis.netstandard2.0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public RedisCommonConfiguration() { }
294294
public string MaxMemoryPolicy { get { throw null; } set { } }
295295
public string MaxMemoryReserved { get { throw null; } set { } }
296296
public string PreferredDataArchiveAuthMethod { get { throw null; } }
297-
public string PreferredDataPersistenceAuthMethod { get { throw null; } }
297+
public string PreferredDataPersistenceAuthMethod { get { throw null; } set { } }
298298
public string RdbBackupFrequency { get { throw null; } set { } }
299299
public int? RdbBackupMaxSnapshotCount { get { throw null; } set { } }
300300
public string RdbStorageConnectionString { get { throw null; } set { } }

sdk/redis/Azure.ResourceManager.Redis/src/Customization/Models/RedisCommonConfiguration.Serialization.cs

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
// <auto-generated/>
5-
64
#nullable disable
75

86
using System;
9-
using System.Globalization;
107
using System.Collections.Generic;
8+
using System.Globalization;
119
using System.Text.Json;
1210
using Azure.Core;
1311

14-
// This customization can be removed after fix https://github.com/Azure/autorest.csharp/issues/2745
15-
[assembly: CodeGenSuppressType("RedisCommonConfiguration")]
16-
1712
namespace Azure.ResourceManager.Redis.Models
1813
{
1914
public partial class RedisCommonConfiguration : IUtf8JsonSerializable
2015
{
21-
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
16+
void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
2217
{
2318
writer.WriteStartObject();
2419
if (Optional.IsDefined(IsRdbBackupEnabled))
2520
{
26-
writer.WritePropertyName("rdb-backup-enabled");
21+
writer.WritePropertyName("rdb-backup-enabled"u8);
2722
writer.WriteBooleanValue(IsRdbBackupEnabled.Value);
2823
}
2924
if (Optional.IsDefined(RdbBackupFrequency))
3025
{
31-
writer.WritePropertyName("rdb-backup-frequency");
26+
writer.WritePropertyName("rdb-backup-frequency"u8);
3227
writer.WriteStringValue(RdbBackupFrequency);
3328
}
3429
if (Optional.IsDefined(RdbBackupMaxSnapshotCount))
3530
{
36-
writer.WritePropertyName("rdb-backup-max-snapshot-count");
31+
writer.WritePropertyName("rdb-backup-max-snapshot-count"u8);
3732
writer.WriteStringValue(RdbBackupMaxSnapshotCount.Value.ToString(CultureInfo.InvariantCulture));
3833
}
3934
if (Optional.IsDefined(RdbStorageConnectionString))
4035
{
41-
writer.WritePropertyName("rdb-storage-connection-string");
36+
writer.WritePropertyName("rdb-storage-connection-string"u8);
4237
writer.WriteStringValue(RdbStorageConnectionString);
4338
}
4439
if (Optional.IsDefined(IsAofBackupEnabled))
4540
{
46-
writer.WritePropertyName("aof-backup-enabled");
41+
writer.WritePropertyName("aof-backup-enabled"u8);
4742
writer.WriteBooleanValue(IsAofBackupEnabled.Value);
4843
}
4944
if (Optional.IsDefined(AofStorageConnectionString0))
5045
{
51-
writer.WritePropertyName("aof-storage-connection-string-0");
46+
writer.WritePropertyName("aof-storage-connection-string-0"u8);
5247
writer.WriteStringValue(AofStorageConnectionString0);
5348
}
5449
if (Optional.IsDefined(AofStorageConnectionString1))
5550
{
56-
writer.WritePropertyName("aof-storage-connection-string-1");
51+
writer.WritePropertyName("aof-storage-connection-string-1"u8);
5752
writer.WriteStringValue(AofStorageConnectionString1);
5853
}
5954
if (Optional.IsDefined(MaxFragmentationMemoryReserved))
6055
{
61-
writer.WritePropertyName("maxfragmentationmemory-reserved");
56+
writer.WritePropertyName("maxfragmentationmemory-reserved"u8);
6257
writer.WriteStringValue(MaxFragmentationMemoryReserved);
6358
}
6459
if (Optional.IsDefined(MaxMemoryPolicy))
6560
{
66-
writer.WritePropertyName("maxmemory-policy");
61+
writer.WritePropertyName("maxmemory-policy"u8);
6762
writer.WriteStringValue(MaxMemoryPolicy);
6863
}
6964
if (Optional.IsDefined(MaxMemoryReserved))
7065
{
71-
writer.WritePropertyName("maxmemory-reserved");
66+
writer.WritePropertyName("maxmemory-reserved"u8);
7267
writer.WriteStringValue(MaxMemoryReserved);
7368
}
7469
if (Optional.IsDefined(MaxMemoryDelta))
7570
{
76-
writer.WritePropertyName("maxmemory-delta");
71+
writer.WritePropertyName("maxmemory-delta"u8);
7772
writer.WriteStringValue(MaxMemoryDelta);
7873
}
74+
if (Optional.IsDefined(PreferredDataPersistenceAuthMethod))
75+
{
76+
writer.WritePropertyName("preferred-data-persistence-auth-method"u8);
77+
writer.WriteStringValue(PreferredDataPersistenceAuthMethod);
78+
}
7979
if (Optional.IsDefined(AuthNotRequired))
8080
{
81-
writer.WritePropertyName("authnotrequired");
81+
writer.WritePropertyName("authnotrequired"u8);
8282
writer.WriteStringValue(AuthNotRequired);
8383
}
8484
foreach (var item in AdditionalProperties)
@@ -95,6 +95,10 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
9595

9696
internal static RedisCommonConfiguration DeserializeRedisCommonConfiguration(JsonElement element)
9797
{
98+
if (element.ValueKind == JsonValueKind.Null)
99+
{
100+
return null;
101+
}
98102
Optional<bool> rdbBackupEnabled = default;
99103
Optional<string> rdbBackupFrequency = default;
100104
Optional<int> rdbBackupMaxSnapshotCount = default;
@@ -115,11 +119,10 @@ internal static RedisCommonConfiguration DeserializeRedisCommonConfiguration(Jso
115119
Dictionary<string, BinaryData> additionalPropertiesDictionary = new Dictionary<string, BinaryData>();
116120
foreach (var property in element.EnumerateObject())
117121
{
118-
if (property.NameEquals("rdb-backup-enabled"))
122+
if (property.NameEquals("rdb-backup-enabled"u8))
119123
{
120124
if (property.Value.ValueKind == JsonValueKind.Null)
121125
{
122-
property.ThrowNonNullablePropertyIsNull();
123126
continue;
124127
}
125128

@@ -129,35 +132,33 @@ internal static RedisCommonConfiguration DeserializeRedisCommonConfiguration(Jso
129132

130133
continue;
131134
}
132-
if (property.NameEquals("rdb-backup-frequency"))
135+
if (property.NameEquals("rdb-backup-frequency"u8))
133136
{
134137
rdbBackupFrequency = property.Value.GetString();
135138
continue;
136139
}
137-
if (property.NameEquals("rdb-backup-max-snapshot-count"))
140+
if (property.NameEquals("rdb-backup-max-snapshot-count"u8))
138141
{
139142
if (property.Value.ValueKind == JsonValueKind.Null)
140143
{
141-
property.ThrowNonNullablePropertyIsNull();
142144
continue;
143145
}
144146
if (!int.TryParse(property.Value.GetString(), out int rdbBackupMaxSnapshotCountValue))
145147
{
146-
throw new FormatException();
148+
throw new FormatException($"cannot parse {property.Value.GetString()} into an int for property {property.Name}");
147149
}
148150
rdbBackupMaxSnapshotCount = rdbBackupMaxSnapshotCountValue;
149151
continue;
150152
}
151-
if (property.NameEquals("rdb-storage-connection-string"))
153+
if (property.NameEquals("rdb-storage-connection-string"u8))
152154
{
153155
rdbStorageConnectionString = property.Value.GetString();
154156
continue;
155157
}
156-
if (property.NameEquals("aof-backup-enabled"))
158+
if (property.NameEquals("aof-backup-enabled"u8))
157159
{
158160
if (property.Value.ValueKind == JsonValueKind.Null)
159161
{
160-
property.ThrowNonNullablePropertyIsNull();
161162
continue;
162163
}
163164

@@ -167,57 +168,57 @@ internal static RedisCommonConfiguration DeserializeRedisCommonConfiguration(Jso
167168

168169
continue;
169170
}
170-
if (property.NameEquals("aof-storage-connection-string-0"))
171+
if (property.NameEquals("aof-storage-connection-string-0"u8))
171172
{
172173
aofStorageConnectionString0 = property.Value.GetString();
173174
continue;
174175
}
175-
if (property.NameEquals("aof-storage-connection-string-1"))
176+
if (property.NameEquals("aof-storage-connection-string-1"u8))
176177
{
177178
aofStorageConnectionString1 = property.Value.GetString();
178179
continue;
179180
}
180-
if (property.NameEquals("maxfragmentationmemory-reserved"))
181+
if (property.NameEquals("maxfragmentationmemory-reserved"u8))
181182
{
182183
maxfragmentationmemoryReserved = property.Value.GetString();
183184
continue;
184185
}
185-
if (property.NameEquals("maxmemory-policy"))
186+
if (property.NameEquals("maxmemory-policy"u8))
186187
{
187188
maxmemoryPolicy = property.Value.GetString();
188189
continue;
189190
}
190-
if (property.NameEquals("maxmemory-reserved"))
191+
if (property.NameEquals("maxmemory-reserved"u8))
191192
{
192193
maxmemoryReserved = property.Value.GetString();
193194
continue;
194195
}
195-
if (property.NameEquals("maxmemory-delta"))
196+
if (property.NameEquals("maxmemory-delta"u8))
196197
{
197198
maxmemoryDelta = property.Value.GetString();
198199
continue;
199200
}
200-
if (property.NameEquals("maxclients"))
201+
if (property.NameEquals("maxclients"u8))
201202
{
202203
maxclients = property.Value.GetString();
203204
continue;
204205
}
205-
if (property.NameEquals("preferred-data-archive-auth-method"))
206+
if (property.NameEquals("preferred-data-archive-auth-method"u8))
206207
{
207208
preferredDataArchiveAuthMethod = property.Value.GetString();
208209
continue;
209210
}
210-
if (property.NameEquals("preferred-data-persistence-auth-method"))
211+
if (property.NameEquals("preferred-data-persistence-auth-method"u8))
211212
{
212213
preferredDataPersistenceAuthMethod = property.Value.GetString();
213214
continue;
214215
}
215-
if (property.NameEquals("zonal-configuration"))
216+
if (property.NameEquals("zonal-configuration"u8))
216217
{
217218
zonalConfiguration = property.Value.GetString();
218219
continue;
219220
}
220-
if (property.NameEquals("authnotrequired"))
221+
if (property.NameEquals("authnotrequired"u8))
221222
{
222223
authnotrequired = property.Value.GetString();
223224
continue;

sdk/redis/Azure.ResourceManager.Redis/src/Generated/Models/RedisCommonConfiguration.Serialization.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/redis/Azure.ResourceManager.Redis/src/Customization/Models/RedisCommonConfiguration.cs renamed to sdk/redis/Azure.ResourceManager.Redis/src/Generated/Models/RedisCommonConfiguration.cs

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)