Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Omondi committed Aug 20, 2024
2 parents 8e544fe + c198508 commit 6d347b1
Show file tree
Hide file tree
Showing 80 changed files with 739 additions and 286 deletions.
36 changes: 30 additions & 6 deletions .azure-pipelines/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,15 @@ extends:
projects: '$(Build.SourcesDirectory)\Microsoft.Kiota.sln'
arguments: '--configuration $(BuildConfiguration) --no-build --framework net8.0'

- task: EsrpCodeSigning@3
- task: EsrpCodeSigning@5
displayName: 'ESRP DLL Strong Name'
inputs:
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
ConnectedServiceName: 'Federated DevX ESRP Managed Identity Connection'
AppRegistrationClientId: '65035b7f-7357-4f29-bf25-c5ee5c3949f8'
AppRegistrationTenantId: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2'
AuthAKVName: 'akv-prod-eastus'
AuthCertName: 'ReferenceLibraryPrivateCert'
AuthSignCertName: 'ReferencePackagePublisherCertificate'
FolderPath: src # This path should already omit test dlls as they exist in the `tests` folder
Pattern: '**\*Microsoft.Kiota.*.dll'
signConfigType: inlineSignParams
Expand All @@ -112,11 +117,19 @@ extends:
}
]
SessionTimeout: 20
MaxConcurrency: 50
MaxRetryAttempts: 5
PendingAnalysisWaitTimeoutMinutes: 5

- task: EsrpCodeSigning@3
- task: EsrpCodeSigning@5
displayName: 'ESRP DLL CodeSigning'
inputs:
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
ConnectedServiceName: 'Federated DevX ESRP Managed Identity Connection'
AppRegistrationClientId: '65035b7f-7357-4f29-bf25-c5ee5c3949f8'
AppRegistrationTenantId: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2'
AuthAKVName: 'akv-prod-eastus'
AuthCertName: 'ReferenceLibraryPrivateCert'
AuthSignCertName: 'ReferencePackagePublisherCertificate'
FolderPath: src # This path should already omit test dlls as they exist in the `tests` folder
signConfigType: inlineSignParams
UseMinimatch: true
Expand Down Expand Up @@ -160,17 +173,25 @@ extends:
}
]
SessionTimeout: 20
MaxConcurrency: 50
MaxRetryAttempts: 5
PendingAnalysisWaitTimeoutMinutes: 5

# arguments are not parsed in DotNetCoreCLI@2 task for `pack` command, that's why we have a custom pack command here
- pwsh: dotnet pack /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg --no-build --output $env:BUILD_ARTIFACTSTAGINGDIRECTORY --configuration $env:BUILD_CONFIGURATION
env:
BUILD_CONFIGURATION: $(BuildConfiguration)
displayName: Dotnet pack

- task: EsrpCodeSigning@3
- task: EsrpCodeSigning@5
displayName: 'ESRP CodeSigning Nuget Packages'
inputs:
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
ConnectedServiceName: 'Federated DevX ESRP Managed Identity Connection'
AppRegistrationClientId: '65035b7f-7357-4f29-bf25-c5ee5c3949f8'
AppRegistrationTenantId: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2'
AuthAKVName: 'akv-prod-eastus'
AuthCertName: 'ReferenceLibraryPrivateCert'
AuthSignCertName: 'ReferencePackagePublisherCertificate'
FolderPath: '$(Build.ArtifactStagingDirectory)'
Pattern: '*.nupkg'
signConfigType: inlineSignParams
Expand All @@ -193,6 +214,9 @@ extends:
}
]
SessionTimeout: 20
MaxConcurrency: 50
MaxRetryAttempts: 5
PendingAnalysisWaitTimeoutMinutes: 5

- task: CopyFiles@2
displayName: 'Copy release scripts to artifact staging directory'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
CoverletOutputFormat: "opencover" # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682
shell: pwsh
run: |
dotnet tool run dotnet-sonarscanner begin /k:"microsoft_kiota-abstractions-dotnet" /o:"microsoft" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/abstractions/coverage.net8.0.opencover.xml,tests/authentication/azure/coverage.net8.0.opencover.xml,tests/http/httpClient/coverage.net8.0.opencover.xml,tests/serialization/json/coverage.net8.0.opencover.xml,tests/serialization/text/coverage.net8.0.opencover.xml,tests/serialization/form/coverage.net8.0.opencover.xml,tests/serialization/multipart/coverage.net8.0.opencover.xml"
dotnet tool run dotnet-sonarscanner begin /k:"microsoft_kiota-abstractions-dotnet" /o:"microsoft" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/abstractions/coverage.net8.0.opencover.xml,tests/authentication/azure/coverage.net8.0.opencover.xml,tests/http/httpClient/coverage.net8.0.opencover.xml,tests/serialization/json/coverage.net8.0.opencover.xml,tests/serialization/text/coverage.net8.0.opencover.xml,tests/serialization/form/coverage.net8.0.opencover.xml,tests/serialization/multipart/coverage.net8.0.opencover.xml,tests/bundle/coverage.net8.0.opencover.xml"
dotnet workload restore
dotnet build
dotnet test Microsoft.Kiota.sln --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --framework net8.0
Expand Down
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.11.3] - 2024-08-16

### Changed

- Replaced Convert.FromBase64 by System.Text.Json GetBytesFromBase64 to improve performance (10x improvement).

## [1.11.2] - 2024-08-14

### Changed

- Fixed an additional performance regression with the backing store introduced in version 1.9.2 by #243

## [1.11.1] - 2024-08-12

### Changed

- Fixed a performance regression with the backing store introduced in version 1.9.2 by #243

## [1.11.0] - 2024-08-08

- Enabled Continuous Access evaluation by default.

## [1.10.1] - 2024-08-01

- Cleans up enum serialization to read from attributes for form and text serialization [#284](https://github.com/microsoft/kiota-dotnet/issues/284)
- Pass relevant `JsonWriterOptions` from the `KiotaJsonSerializationContext.Options` to the `Utf8JsonWriter` when writing json to enable customization. [#281](https://github.com/microsoft/kiota-dotnet/issues/281)

## [1.10.0] - 2024-07-17

- Adds Kiota bundle package to provide default adapter with registrations setup. [#290](https://github.com/microsoft/kiota-dotnet/issues/290)

## [1.9.12] - 2024-07-30

- Fix non IParasable object serialization.
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<!-- Common default project properties for ALL projects-->
<PropertyGroup>
<VersionPrefix>1.9.12</VersionPrefix>
<VersionPrefix>1.11.3</VersionPrefix>
<VersionSuffix></VersionSuffix>
<!-- This is overidden in test projects by setting to true-->
<IsTestProject>false</IsTestProject>
Expand Down
14 changes: 13 additions & 1 deletion Microsoft.Kiota.sln
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Kiota.Serializati
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Kiota.Serialization.Text.Tests", "tests\serialization\text\Microsoft.Kiota.Serialization.Text.Tests.csproj", "{5F6AC278-C4A4-4EED-A7D3-1750A4D6FD15}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Kiota.Trimming.Validation", "tests\trimming\Microsoft.Kiota.Trimming.Validation\Microsoft.Kiota.Trimming.Validation.csproj", "{13992912-662D-4A3B-9354-DD49DB1AC2D5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Kiota.Trimming.Validation", "tests\trimming\Microsoft.Kiota.Trimming.Validation\Microsoft.Kiota.Trimming.Validation.csproj", "{13992912-662D-4A3B-9354-DD49DB1AC2D5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Kiota.Bundle", "src\bundle\Microsoft.Kiota.Bundle.csproj", "{3F1F2EF2-8C57-4FC2-9722-68FAE551D19E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Kiota.Bundle.Tests", "tests\bundle\Microsoft.Kiota.Bundle.Tests.csproj", "{A1155A75-88FB-4C21-AA96-240A0E69FF1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -116,6 +120,14 @@ Global
{13992912-662D-4A3B-9354-DD49DB1AC2D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13992912-662D-4A3B-9354-DD49DB1AC2D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13992912-662D-4A3B-9354-DD49DB1AC2D5}.Release|Any CPU.Build.0 = Release|Any CPU
{3F1F2EF2-8C57-4FC2-9722-68FAE551D19E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F1F2EF2-8C57-4FC2-9722-68FAE551D19E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F1F2EF2-8C57-4FC2-9722-68FAE551D19E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F1F2EF2-8C57-4FC2-9722-68FAE551D19E}.Release|Any CPU.Build.0 = Release|Any CPU
{A1155A75-88FB-4C21-AA96-240A0E69FF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1155A75-88FB-4C21-AA96-240A0E69FF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1155A75-88FB-4C21-AA96-240A0E69FF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1155A75-88FB-4C21-AA96-240A0E69FF1A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ Read more about Kiota [here](https://github.com/microsoft/kiota/blob/main/README

## Libraries

| Library | Nuget Release |
| ------ | ------ |
| [Abstractions](./src/abstractions/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Abstractions?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Abstractions/) |
| [Authentication - Azure](./src/authentication/azure/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Authentication.Azure?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Authentication.Azure/) |
| [Http - HttpClientLibrary](./src/http/httpClient/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Http.HttpClientLibrary?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Http.HttpClientLibrary/) |
| [Serialization - JSON](./src/serialization/json/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Serialization.Json?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Json/) |
| [Serialization - FORM](./src/serialization/form/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Serialization.Form?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Form/) |
| [Serialization - TEXT](./src/serialization/text/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Serialization.Text?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Text/) |
| Library | Nuget Release |
|----------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Abstractions](./src/abstractions/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Abstractions?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Abstractions/) |
| [Authentication - Azure](./src/authentication/azure/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Authentication.Azure?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Authentication.Azure/) |
| [Http - HttpClientLibrary](./src/http/httpClient/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Http.HttpClientLibrary?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Http.HttpClientLibrary/) |
| [Serialization - JSON](./src/serialization/json/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Serialization.Json?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Json/) |
| [Serialization - FORM](./src/serialization/form/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Serialization.Form?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Form/) |
| [Serialization - TEXT](./src/serialization/text/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Serialization.Text?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Text/) |
| [Serialization - MULTIPART](./src/serialization/multipart/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Serialization.Multipart?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Multipart/) |
| [Bundle](./src/bundle/README.md) | [![NuGet Version](https://buildstats.info/nuget/Microsoft.Kiota.Bundle?includePreReleases=true)](https://www.nuget.org/packages/Microsoft.Kiota.Bundle/) |

## Release notes

Expand Down
25 changes: 25 additions & 0 deletions src/abstractions/Helpers/EnumHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Reflection;
using System.Runtime.Serialization;
using Microsoft.Kiota.Abstractions.Extensions;

#if NET5_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -154,5 +155,29 @@ private static bool TryGetFieldValueName(Type type, string rawValue, out string
}
return false;
}

/// <summary>
/// Gets the enum string representation of the given value. Looks up if there is an <see cref="EnumMemberAttribute"/> and returns the value if found, otherwise returns the enum name in camel case.
/// </summary>
/// <typeparam name="T">The Enum type</typeparam>
/// <param name="value">The enum value</param>
/// <returns></returns>
/// <exception cref="ArgumentException">If value is null</exception>
#if NET5_0_OR_GREATER
public static string? GetEnumStringValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(T value) where T : struct, Enum
#else
public static string? GetEnumStringValue<T>(T value) where T : struct, Enum
#endif
{
var type = typeof(T);

if(Enum.GetName(type, value) is not { } name)
throw new ArgumentException($"Invalid Enum value {value} for enum of type {type}");

if(type.GetField(name)?.GetCustomAttribute<EnumMemberAttribute>() is { } attribute)
return attribute.Value;

return name;
}
}
}
23 changes: 11 additions & 12 deletions src/abstractions/store/InMemoryBackingStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@ public void Set<T>(string key, T? value)
// All the list items are dirty as the model has been touched.
foreach(var item in collectionValues)
{
if(item is IBackedModel model)
// we don't support heterogeneous collections, so we can break if the first item is not a IBackedModel
if(item is not IBackedModel model) break;
model.BackingStore.InitializationCompleted = false;
model.BackingStore.Subscribe((keyString, oldObject, newObject) =>
{
model.BackingStore.InitializationCompleted = false;
model.BackingStore.Subscribe((keyString, oldObject, newObject) =>
{
Set(key, value);
}, key); // use property name(key) as subscriptionId to prevent excess subscription creation in the event this is called again
}
Set(key, value);
}, key); // use property name(key) as subscriptionId to prevent excess subscription creation in the event this is called again
}
}

Expand Down Expand Up @@ -206,12 +205,12 @@ private void EnsureCollectionPropertyIsConsistent(string key, object? storeItem)
// Call Get<>() on nested properties so that this method may be called recursively to ensure collections are consistent
foreach(var item in collectionTuple.Item1)
{
if(item is IBackedModel store)
if(item is not IBackedModel backedModel) break;
// there are no mixed collections if the first element is not a IBackedModel, not need to iterate over the collection

foreach(var innerItem in backedModel.BackingStore.Enumerate())
{
foreach(var innerItem in store.BackingStore.Enumerate())
{
store.BackingStore.Get<object>(innerItem.Key);
}
backedModel.BackingStore.Get<object>(innerItem.Key);
}
}

Expand Down
Loading

0 comments on commit 6d347b1

Please sign in to comment.