Skip to content

Commit 6d81072

Browse files
committed
fix spacing, add back s3 integ test and precompile regex for sanitization
1 parent 77202ab commit 6d81072

File tree

6 files changed

+6
-25
lines changed

6 files changed

+6
-25
lines changed

sdk/src/Core/Amazon.Runtime/Internal/Transform/JsonUnmarshallerContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public string ReadText(ref StreamingUtf8JsonReader reader)
281281
// overload which accepts a ReadOnlySpan<byte> is only available in netstandard2.1 and netcore2.1+
282282
text = Encoding.UTF8.GetString(reader.Reader.ValueSpan.ToArray());
283283
#else
284-
text = Encoding.UTF8.GetString(reader.Reader.ValueSpan);
284+
text = Encoding.UTF8.GetString(reader.Reader.ValueSpan);
285285
#endif
286286
break;
287287
default:

sdk/src/Core/Amazon.Util/Internal/JsonSerializerHelper.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text;
4+
using System.Text.RegularExpressions;
45
using System.Text.Json;
56

67
#if NET8_0_OR_GREATER
@@ -16,6 +17,9 @@ public static class JsonSerializerHelper
1617
{
1718
AllowTrailingCommas = true,
1819
};
20+
21+
// compile regex once to avoid re-parsing every time
22+
private static readonly System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"(""[^""]*""|\d+)(\s*""[^""]*""\s*:)", System.Text.RegularExpressions.RegexOptions.Compiled);
1923
#if NET8_0_OR_GREATER
2024
public static T Deserialize<T>(string json, JsonSerializerContext context)
2125
{
@@ -46,7 +50,7 @@ public static string Serialize<T>(object obj, JsonSerializerContext typeInfo)
4650
public static string SanitizeJson(string rawJson)
4751
{
4852
// Add a comma after numbers or strings if they're not followed by a closing brace/bracket or comma.
49-
rawJson = System.Text.RegularExpressions.Regex.Replace(rawJson, @"(""[^""]*""|\d+)(\s*""[^""]*""\s*:)", "$1,$2");
53+
rawJson = regex.Replace(rawJson, "$1,$2");
5054
return rawJson;
5155
}
5256
}

sdk/test/Services/S3/IntegrationTests/S3ExpressTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ public void Test_CopyObject_BetweenS3ExpressBuckets()
212212

213213
[TestMethod]
214214
[TestCategory("S3")]
215-
[Ignore]
216215
public void Test_CopyObject_BetweenRegularBucket_And_S3ExpressBucket()
217216
{
218217
var oldObjectKey = "Test Object 123";

sdk/test/UnitTests/Custom/Runtime/EC2InstanceMetadataServlet.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,10 @@ public EC2InstanceMetadataServlet()
3030
new DisposableSwitch(
3131
onStart: () => SetEC2InstanceMetadataEndpoint(ServiceURL),
3232
onEnd: () => SetEC2InstanceMetadataEndpoint(currentEndpointUrl));
33-
34-
// JsonMapper.ToJson's DateTime writing exporter will output any date as a string formatted
35-
// as a local or unspecified time. This changes it so the data is mocked as IMDS would
36-
// actually return it which is "yyyy-MM-ddTHH:mm:ssZ" ending in a Z specified as UTC.
37-
//JsonMapper.RegisterExporter<DateTime>(
38-
// (DateTime date, JsonWriter writer) => {
39-
// if(date == DateTime.MinValue && date.Kind != DateTimeKind.Utc)
40-
// {
41-
// //Do not use .ToUniversalTime on a min datetime as it will adjust the hours.
42-
// DateTime.SpecifyKind(date, DateTimeKind.Utc);
43-
// }
44-
// else if(date.Kind != DateTimeKind.Utc)
45-
// {
46-
// date = date.ToUniversalTime();
47-
// }
48-
49-
// writer.Write(date.ToString("yyyy-MM-ddTHH:mm:ssZ"));
50-
// }
51-
//);
5233
}
5334

5435
public override void Dispose()
5536
{
56-
//JsonMapper.UnregisterExporters();
5737
_metadataServiceEndpointSwitch.Dispose();
5838

5939
ResetUseNullToken();

sdk/test/UnitTests/Custom/Runtime/_bcl/Tokens/SSOTokenManagerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public void ValidateTokenCacheLocation(string startUrl, string expectedCacheFile
6060
accessToken = "cachedToken",
6161
expiresAt = "3000-12-25T21:30:00Z",
6262
};
63-
6463
mockFileSystem.WriteAllText(
6564
Path.Combine(testCacheFolder, expectedCacheFile),
6665
JsonSerializer.Serialize(cachedSsoToken));

sdk/test/UnitTests/Custom/TestTools/SpecMarkdownTestDataHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace AWSSDK.UnitTests
66
{
77
public static class SpecMarkdownTestDataHelper
8-
98
{
109
public static string StandardDataClean(this string s)
1110
{

0 commit comments

Comments
 (0)