Skip to content

Commit b6fe3bd

Browse files
kirankumarkollikundadebdatta
authored andcommitted
Squashed Changes
VS 17.8 auto runs NuGetAudit and flagging 10.0.2, CosmosDB SDK already mitigated it by changing the MAXDEPATH (#4185) initial commit incremental changes assembly info changes bug fixes package share bug fixes resolve physical addresses, sort usings dependency usings
1 parent 4fee546 commit b6fe3bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3119
-9
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ClientOfficialVersion>3.36.0</ClientOfficialVersion>
44
<ClientPreviewVersion>3.36.0</ClientPreviewVersion>
55
<ClientPreviewSuffixVersion>preview</ClientPreviewSuffixVersion>
6-
<DirectVersion>3.31.5</DirectVersion>
6+
<DirectVersion>3.32.0</DirectVersion>
77
<EncryptionOfficialVersion>2.0.3</EncryptionOfficialVersion>
88
<EncryptionPreviewVersion>2.0.3</EncryptionPreviewVersion>
99
<EncryptionPreviewSuffixVersion>preview</EncryptionPreviewSuffixVersion>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
//------------------------------------------------------------
4+
5+
using System.Runtime.CompilerServices;
6+
7+
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyKeys.MoqPublicKey)]
8+
[assembly: InternalsVisibleTo("Microsoft.Azure.Cosmos" + AssemblyKeys.ProductPublicKey)]
9+
[assembly: InternalsVisibleTo("Microsoft.Azure.Cosmos" + AssemblyKeys.TestPublicKey)]
10+
[assembly: InternalsVisibleTo("Azure.Cosmos" + AssemblyKeys.ProductPublicKey)]
11+
[assembly: InternalsVisibleTo("Azure.Cosmos" + AssemblyKeys.TestPublicKey)]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Company>Microsoft Corporation</Company>
5+
<Product>Microsoft(R) Azure Cosmos</Product>
6+
<Description>This client library enables client applications to inject faults into Azure CosmosD DB applications.</Description>
7+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
8+
<NeutralLanguage>en-US</NeutralLanguage>
9+
<CurrentDate>$([System.DateTime]::Now.ToString(yyyyMMdd))</CurrentDate>
10+
<OutputType>Exe</OutputType>
11+
<TargetFramework>net6</TargetFramework>
12+
<RootNamespace>Microsoft.Azure.Cosmos.FaultInjection</RootNamespace>
13+
<AssemblyName>Microsoft.Azure.Cosmos.FaultInjection</AssemblyName>
14+
<ImplicitUsings>enable</ImplicitUsings>
15+
<Nullable>enable</Nullable>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Microsoft.Azure.Cosmos.Direct" Version="3.32.0" PrivateAssets="All" />
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<Reference Include="Microsoft.Azure.Cosmos.Client">
24+
<HintPath>..\..\..\Microsoft.Azure.Cosmos\src\bin\Release\netstandard2.0\Microsoft.Azure.Cosmos.Client.dll</HintPath>
25+
</Reference>
26+
</ItemGroup>
27+
<PropertyGroup>
28+
<SignAssembly>true</SignAssembly>
29+
<DelaySign>true</DelaySign>
30+
<AssemblyOriginatorKeyFile>..\..\..\testkey.snk</AssemblyOriginatorKeyFile>
31+
</PropertyGroup>
32+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33530.505
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaultInjection", "FaultInjection.csproj", "{35F312B5-93FF-45E5-BAD9-513697476B7C}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{35F312B5-93FF-45E5-BAD9-513697476B7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{35F312B5-93FF-45E5-BAD9-513697476B7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{35F312B5-93FF-45E5-BAD9-513697476B7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{35F312B5-93FF-45E5-BAD9-513697476B7C}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {9B003F88-147A-4B56-9BB3-EBCF53BA8D2A}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
//------------------------------------------------------------
4+
namespace Microsoft.Azure.Cosmos.FaultInjection
5+
{
6+
using System;
7+
8+
/// <summary>
9+
/// Fault Injection Condition
10+
/// </summary>
11+
public sealed class FaultInjectionCondition
12+
{
13+
private readonly FaultInjectionOperationType operationType;
14+
private readonly FaultInjectionConnectionType connectionType;
15+
private readonly string region;
16+
private readonly FaultInjectionEndpoint endpoint;
17+
private readonly string containerResourceId;
18+
19+
/// <summary>
20+
/// Creates a <see cref="FaultInjectionCondition"/>.
21+
/// </summary>
22+
/// <param name="operationType">Specifies which operation type rule will target.</param>
23+
/// <param name="connectionType">Specifies which connection type rule will target.</param>
24+
/// <param name="region">Specifies wich region the rule will target.</param>
25+
/// <param name="endpoint">Specifies which endpoint the rule will tareget.</param>
26+
/// <param name="containerResourceId">Specifies which container rid the rule will target.</param>
27+
public FaultInjectionCondition(
28+
FaultInjectionOperationType operationType,
29+
FaultInjectionConnectionType connectionType,
30+
string region,
31+
FaultInjectionEndpoint endpoint,
32+
string containerResourceId)
33+
{
34+
this.operationType = operationType;
35+
this.connectionType = connectionType;
36+
this.region = region;
37+
this.endpoint = endpoint;
38+
this.containerResourceId = containerResourceId;
39+
}
40+
41+
/// <summary>
42+
/// The operation type the rule will target.
43+
/// </summary>
44+
/// <returns>the <see cref="FaultInjectionOperationType"/>.</returns>
45+
public FaultInjectionOperationType GetOperationType()
46+
{
47+
return this.operationType;
48+
}
49+
50+
/// <summary>
51+
/// The connection type the rule will target.
52+
/// </summary>
53+
/// <returns>the <see cref="FaultInjectionConnectionType"/>.</returns>
54+
public FaultInjectionConnectionType GetConnectionType()
55+
{
56+
return this.connectionType;
57+
}
58+
59+
/// <summary>
60+
/// The region the rule will target.
61+
/// </summary>
62+
/// <returns>the region represented as a string.</returns>
63+
public string GetRegion()
64+
{
65+
return this.region;
66+
}
67+
68+
/// <summary>
69+
/// The endpoint the rule will target.
70+
/// </summary>
71+
/// <returns>the <see cref="FaultInjectionEndpoint"/>.</returns>
72+
public FaultInjectionEndpoint GetEndpoint()
73+
{
74+
return this.endpoint;
75+
}
76+
77+
/// <summary>
78+
/// The container resource id the rule will target.
79+
/// </summary>
80+
/// <returns></returns>
81+
public string GetContainerResourceId()
82+
{
83+
return this.containerResourceId;
84+
}
85+
86+
/// <summary>
87+
/// To String method
88+
/// </summary>
89+
/// <returns>A string represeting the <see cref="FaultInjectionCondition"/>.</returns>
90+
public override string ToString()
91+
{
92+
return String.Format(
93+
"FaultInjectionCondition{{ OperationType: {0}, ConnectionType: {1}, Region: {2}, Endpoint: {3}, ContainerResourceId: {4}",
94+
this.operationType,
95+
this.connectionType,
96+
this.region,
97+
this.endpoint.ToString(),
98+
this.containerResourceId);
99+
}
100+
}
101+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
//------------------------------------------------------------
4+
namespace Microsoft.Azure.Cosmos.FaultInjection
5+
{
6+
using System;
7+
using Microsoft.Azure.Cosmos;
8+
9+
/// <summary>
10+
/// This class is used to build a <see cref="FaultInjectionCondition"/>
11+
/// </summary>
12+
public sealed class FaultInjectionConditionBuilder
13+
{
14+
private FaultInjectionOperationType operationType;
15+
private FaultInjectionConnectionType connectionType;
16+
private string region = string.Empty;
17+
private FaultInjectionEndpoint? endpoint;
18+
private string containerResourceId = string.Empty;
19+
20+
/// <summary>
21+
/// Optional. Specifies which operation type rule will target. Once set, the rule will only target requests with this operation type.
22+
/// By default, the rule will target all operation types.
23+
/// </summary>
24+
/// <param name="operationType"></param>
25+
/// <returns>the <see cref="FaultInjectionCondition"/>.</returns>
26+
public FaultInjectionConditionBuilder WithOperationType(FaultInjectionOperationType operationType)
27+
{
28+
this.operationType = operationType;
29+
return this;
30+
}
31+
32+
/// <summary>
33+
/// Optional. Specifies which connection type rule will target. Once set, the rule will only target requests with this connection type.
34+
/// By default, the rule will target all connection types.
35+
/// </summary>
36+
/// <param name="connectionType"></param>
37+
/// <returns>the <see cref="FaultInjectionConditionBuilder"/>.</returns>
38+
public FaultInjectionConditionBuilder WithConnectionType(FaultInjectionConnectionType connectionType)
39+
{
40+
this.connectionType = connectionType;
41+
return this;
42+
}
43+
44+
/// <summary>
45+
/// Optional. Specifies which region the rule will target. Once set, the rule will only target requests targeting that region.
46+
/// By default, the rule will target all regions.
47+
/// </summary>
48+
/// <param name="region"></param>
49+
/// <returns>the <see cref="FaultInjectionConditionBuilder"/></returns>
50+
public FaultInjectionConditionBuilder WithRegion(string region)
51+
{
52+
RegionNameMapper mapper = new RegionNameMapper();
53+
string regionName = mapper.GetCosmosDBRegionName(region);
54+
this.region = string.IsNullOrEmpty(regionName)
55+
? throw new ArgumentNullException(nameof(region), "Argument 'region' cannot be null.")
56+
: regionName;
57+
58+
return this;
59+
}
60+
61+
/// <summary>
62+
/// Optional. Specifies which endpoint the rule will target. Once set, the rule will only target requests targeting that endpoint.
63+
/// Only applicable to direct mode.
64+
/// You must specify the conainter and partition key definition if you specify an endpoint.
65+
/// By default, the rule will target all endpoints
66+
/// </summary>
67+
/// <param name="endpoint"></param>
68+
/// <param name="containerResourceId">The container resource id</param>
69+
/// <returns> the <see cref="FaultInjectionConditionBuilder"/></returns>
70+
public FaultInjectionConditionBuilder WithEndpoint(FaultInjectionEndpoint endpoint, string containerResourceId)
71+
{
72+
this.endpoint = endpoint;
73+
this.containerResourceId = containerResourceId;
74+
return this;
75+
}
76+
77+
/// <summary>
78+
/// Creates the <see cref="FaultInjectionCondition"/>.
79+
/// </summary>
80+
/// <returns>the <see cref="FaultInjectionCondition"/>.</returns>
81+
public FaultInjectionCondition Build()
82+
{
83+
return new FaultInjectionCondition(
84+
this.operationType,
85+
this.connectionType,
86+
this.region,
87+
this.endpoint ?? FaultInjectionEndpoint.Empty,
88+
this.containerResourceId);
89+
}
90+
91+
}
92+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
//------------------------------------------------------------
4+
namespace Microsoft.Azure.Cosmos.FaultInjection
5+
{
6+
using System;
7+
8+
/// <summary>
9+
/// Fault Injection Connection Error Result.
10+
/// </summary>
11+
public sealed class FaultInjectionConnectionErrorResult : IFaultInjectionResult
12+
{
13+
private readonly FaultInjectionConnectionErrorType connectionErrorType;
14+
private readonly TimeSpan interval;
15+
private readonly double threshold;
16+
17+
/// <summary>
18+
/// Creates a new FaultInjectionConnectionErrorResult
19+
/// </summary>
20+
/// <param name="connectionErrorType">Specifies the connection error type.</param>
21+
/// <param name="interval">Timespan representing the ammount of time the SDK will wait before returning the error.</param>
22+
/// <param name="threshold">Percentage of the established connections that will be impaceted.</param>
23+
public FaultInjectionConnectionErrorResult(
24+
FaultInjectionConnectionErrorType connectionErrorType,
25+
TimeSpan interval,
26+
double threshold)
27+
{
28+
this.connectionErrorType = connectionErrorType;
29+
this.interval = interval;
30+
this.threshold = threshold;
31+
}
32+
33+
/// <summary>
34+
/// Gets the Connection Error Type.
35+
/// </summary>
36+
/// <returns>the <see cref="FaultInjectionConnectionErrorType"/>.</returns>
37+
public FaultInjectionConnectionErrorType GetConnectionErrorType()
38+
{
39+
return this.connectionErrorType;
40+
}
41+
42+
/// <summary>
43+
/// The ammount of time the SDK will wait before returning the error.
44+
/// </summary>
45+
/// <returns>the Timespan</returns>
46+
public TimeSpan GetTimespan()
47+
{
48+
return this.interval;
49+
}
50+
51+
/// <summary>
52+
/// Returns the percentage of the established connections that will be impacted. By default, the threshold is 1.
53+
/// </summary>
54+
/// <returns>the threshold represented as a double.</returns>
55+
public double GetThreshold()
56+
{
57+
return this.threshold;
58+
}
59+
60+
/// <summary>
61+
/// To String method
62+
/// </summary>
63+
/// <returns>A string represeting the <see cref="FaultInjectionConnectionErrorResult"/>.</returns>
64+
public override string ToString()
65+
{
66+
return String.Format(
67+
"FaultInjectionConnection{{ ConnectionErrorType: {0}, Interval: {1}, Threshold: {2}%}}",
68+
this.connectionErrorType,
69+
this.interval,
70+
this.threshold);
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)