-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ODataClientDuplicateEdmTypeRaceCondition experiment
- Loading branch information
Showing
10 changed files
with
3,509 additions
and
1 deletion.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
ODataClientDuplicateEdmTypeRaceCondition/ODataClientDuplicateEdmTypeRaceCondition.sln
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,43 @@ | ||
| ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.3.32901.215 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ODataClientDuplicateEdmTypeRaceCondition", "ODataClientDuplicateEdmTypeRaceCondition\ODataClientDuplicateEdmTypeRaceCondition.csproj", "{9A5021A4-A1C4-43A5-B14E-0FA54AECB0C6}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OData.Client", "..\..\..\..\..\odata.net\src\Microsoft.OData.Client\Microsoft.OData.Client.csproj", "{C4E72E08-3FAD-45DA-8545-1ED21694A84A}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OData.Core", "..\..\..\..\..\odata.net\src\Microsoft.OData.Core\Microsoft.OData.Core.csproj", "{E0789CEA-CE83-4A80-9F14-CC32F453DA3F}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OData.Edm", "..\..\..\..\..\odata.net\src\Microsoft.OData.Edm\Microsoft.OData.Edm.csproj", "{77B2B77B-A4CA-4B80-9719-F29356F8BF29}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9A5021A4-A1C4-43A5-B14E-0FA54AECB0C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9A5021A4-A1C4-43A5-B14E-0FA54AECB0C6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9A5021A4-A1C4-43A5-B14E-0FA54AECB0C6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9A5021A4-A1C4-43A5-B14E-0FA54AECB0C6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{C4E72E08-3FAD-45DA-8545-1ED21694A84A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C4E72E08-3FAD-45DA-8545-1ED21694A84A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C4E72E08-3FAD-45DA-8545-1ED21694A84A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C4E72E08-3FAD-45DA-8545-1ED21694A84A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{E0789CEA-CE83-4A80-9F14-CC32F453DA3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E0789CEA-CE83-4A80-9F14-CC32F453DA3F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E0789CEA-CE83-4A80-9F14-CC32F453DA3F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E0789CEA-CE83-4A80-9F14-CC32F453DA3F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{77B2B77B-A4CA-4B80-9719-F29356F8BF29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{77B2B77B-A4CA-4B80-9719-F29356F8BF29}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{77B2B77B-A4CA-4B80-9719-F29356F8BF29}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{77B2B77B-A4CA-4B80-9719-F29356F8BF29}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {FFB1CA92-2E4A-4617-9A51-C6054114C048} | ||
EndGlobalSection | ||
EndGlobal |
42 changes: 42 additions & 0 deletions
42
...lientDuplicateEdmTypeRaceCondition/Connected Services/OData Service/ConnectedService.json
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,42 @@ | ||
{ | ||
"ProviderId": "Microsoft.OData.ConnectedService", | ||
"Version": "1.0.0.0", | ||
"GettingStartedDocument": { | ||
"Uri": "http://odata.github.io/odata.net/" | ||
}, | ||
"ExtendedData": { | ||
"EnableNamingAlias": true, | ||
"IgnoreUnexpectedElementsAndAttributes": true, | ||
"IncludeT4File": false, | ||
"ExcludedOperationImports": [], | ||
"ExcludedBoundOperations": [], | ||
"ServiceName": "OData Service", | ||
"Endpoint": "https://services.odata.org/V4/(S(3jjpqgfjmnsmsy4twnnqedz3))/TripPinServiceRW/$metadata", | ||
"EdmxVersion": { | ||
"Major": 4, | ||
"Minor": 0, | ||
"Build": 0, | ||
"Revision": 0, | ||
"MajorRevision": 0, | ||
"MinorRevision": 0 | ||
}, | ||
"GeneratedFileNamePrefix": "Reference", | ||
"UseNamespacePrefix": false, | ||
"NamespacePrefix": null, | ||
"UseDataServiceCollection": true, | ||
"MakeTypesInternal": false, | ||
"OpenGeneratedFilesInIDE": false, | ||
"GenerateMultipleFiles": false, | ||
"CustomHttpHeaders": null, | ||
"IncludeWebProxy": false, | ||
"WebProxyHost": null, | ||
"IncludeWebProxyNetworkCredentials": false, | ||
"StoreWebProxyNetworkCredentials": false, | ||
"WebProxyNetworkCredentialsUsername": null, | ||
"WebProxyNetworkCredentialsPassword": null, | ||
"WebProxyNetworkCredentialsDomain": null, | ||
"IncludeCustomHeaders": false, | ||
"StoreCustomHttpHeaders": false, | ||
"ExcludedSchemaTypes": [] | ||
} | ||
} |
334 changes: 334 additions & 0 deletions
334
...lientDuplicateEdmTypeRaceCondition/Connected Services/OData Service/OData ServiceCsdl.xml
Large diffs are not rendered by default.
Oops, something went wrong.
2,761 changes: 2,761 additions & 0 deletions
2,761
...on/ODataClientDuplicateEdmTypeRaceCondition/Connected Services/OData Service/Reference.cs
Large diffs are not rendered by default.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
.../ODataClientDuplicateEdmTypeRaceCondition/ODataClientDuplicateEdmTypeRaceCondition.csproj
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,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="Connected Services\OData Service\OData ServiceCsdl.xml" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="Connected Services\OData Service\OData ServiceCsdl.xml" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.OData.Client" Version="7.12.4" /> | ||
<PackageReference Include="Microsoft.OData.Core" Version="7.12.4" /> | ||
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.4" /> | ||
<PackageReference Include="Microsoft.Spatial" Version="7.12.4" /> | ||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> | ||
<PackageReference Include="System.Text.Json" Version="6.0.6" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<!--<ProjectReference Include="..\..\..\..\..\..\odata.net\src\Microsoft.OData.Client\Microsoft.OData.Client.csproj" />--> | ||
</ItemGroup> | ||
|
||
</Project> |
141 changes: 141 additions & 0 deletions
141
ODataClientDuplicateEdmTypeRaceCondition/ODataClientDuplicateEdmTypeRaceCondition/Program.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,141 @@ | ||
using Microsoft.OData.Client; | ||
using Microsoft.OData.SampleService.Models.TripPin; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace ODataClientExample | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
//Console.WriteLine("Press enter key to start"); | ||
//Console.ReadLine(); | ||
//ConcurrentCreateRequestsWithIndividualContexts().Wait(); | ||
//ConcurrentFetchRequestsWithIndividualContexts().Wait(); | ||
ConcurrentMixedRequests().Wait(); | ||
} | ||
|
||
static async Task Test() | ||
{ | ||
var uri = new Uri("https://services.odata.org/V4/(S(3jjpqgfjmnsmsy4twnnqedz3))/TripPinServiceRW"); | ||
var context = new DefaultContainer(uri); | ||
//await GetPerson(context); | ||
//await GetPeople(context); | ||
await CreatePerson(context); | ||
} | ||
|
||
static async Task GetPerson(DefaultContainer context) | ||
{ | ||
var personRequest = context.People.ByKey("russellwhyte"); | ||
var person = await personRequest.GetValueAsync(); | ||
Console.WriteLine(person.FirstName); | ||
} | ||
|
||
static async Task GetPeople(DefaultContainer context) | ||
{ | ||
var people = await context.People.ExecuteAsync(); | ||
foreach (var person in people) | ||
{ | ||
Console.WriteLine(person.FirstName); | ||
} | ||
} | ||
|
||
static async Task CreatePerson(DefaultContainer context, string username = "johndoe") | ||
{ | ||
var person = new Person() | ||
{ | ||
UserName = username, | ||
FirstName = "John", | ||
LastName = "Doe", | ||
}; | ||
|
||
person.AddressInfo.Add(new Location() | ||
{ | ||
Address = "Addr1", | ||
City = new City | ||
{ | ||
Name = "City1", | ||
Region = "Region1", | ||
CountryRegion = "CR1" | ||
} | ||
}); | ||
|
||
person.AddressInfo.Add(new Location() | ||
{ | ||
Address = "Addr2", | ||
City = new City | ||
{ | ||
Name = "City2", | ||
Region = "Region2", | ||
CountryRegion = "CR2" | ||
} | ||
}); | ||
|
||
context.AddObject("People", person); | ||
await context.SaveChangesAsync(); | ||
Console.WriteLine(person.UserName); | ||
} | ||
|
||
static async Task GetProperty(DefaultContainer context) | ||
{ | ||
var locations = await context.ExecuteAsync<Location>(new Uri("People('russellwhyte')/AddressInfo", UriKind.Relative)); | ||
foreach (var location in locations) | ||
{ | ||
Console.WriteLine(location.Address); | ||
} | ||
} | ||
static async Task ConcurrentRequestsWithSharedContext() | ||
{ | ||
var uri = new Uri("https://services.odata.org/V4/(S(3jjpqgfjmnsmsy4twnnqedz3))/TripPinServiceRW"); | ||
var context = new DefaultContainer(uri); | ||
await Task.WhenAll(CreatePerson(context), GetPerson(context)); | ||
} | ||
|
||
static async Task ConcurrentCreateRequestsWithIndividualContexts() | ||
{ | ||
var uri = new Uri("https://services.odata.org/V4/(S(3jjpqgfjmnsmsy4twnnqedz3))/TripPinServiceRW"); | ||
var ctx1 = new DefaultContainer(uri); | ||
var ctx2 = new DefaultContainer(uri); | ||
Task createPersonTask = Task.Run(() => CreatePerson(ctx1)); | ||
Task createPerson2Task = Task.Run(() => CreatePerson(ctx2, "foobar")); | ||
|
||
await Task.WhenAll(createPersonTask, createPerson2Task); ; | ||
} | ||
|
||
static async Task ConcurrentFetchRequestsWithIndividualContexts() | ||
{ | ||
var uri = new Uri("https://services.odata.org/V4/(S(3jjpqgfjmnsmsy4twnnqedz3))/TripPinServiceRW"); | ||
var ctx1 = new DefaultContainer(uri); | ||
var ctx2 = new DefaultContainer(uri); | ||
Task task1 = Task.Run(() => GetPeople(ctx1)); | ||
Task task2 = Task.Run(() => GetPeople(ctx2)); | ||
|
||
await Task.WhenAll(task1, task2); ; | ||
} | ||
|
||
static async Task ConcurrentMixedRequests() | ||
{ | ||
var uri = new Uri("https://services.odata.org/V4/(S(3jjpqgfjmnsmsy4twnnqedz3))/TripPinServiceRW"); | ||
var ctx1 = new DefaultContainer(uri); | ||
var ctx2 = new DefaultContainer(uri); | ||
|
||
Task task1 = Task.Run(() => GetPeople(ctx2)); | ||
Task task2 = Task.Run(() => GetProperty(ctx1)); | ||
|
||
await Task.WhenAll(task1, task2); ; | ||
await CreatePerson(new DefaultContainer(uri)); | ||
} | ||
|
||
static async Task RepeatExperiment(Func<Task> experiment, int count) | ||
{ | ||
for (int i = 0; i < count; i++) | ||
{ | ||
await experiment(); | ||
} | ||
} | ||
|
||
} | ||
} |
Binary file added
BIN
+174 KB
ODataClientDuplicateEdmTypeRaceCondition/ODataClientDuplicateEdmTypeRaceCondition/log.txt
Binary file not shown.
Oops, something went wrong.