Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
486 changes: 247 additions & 239 deletions .azure-pipelines/ci-build.yml

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Build and Test
on:
workflow_dispatch:
push:
branches: ["main", "dev", "feature/*"]
branches: [ "main", "dev", "feature/*" ]
pull_request:
branches: ["main", "dev"]
branches: [ "main", "dev" ]

permissions:
contents: read #those permissions are required to run the codeql analysis
Expand All @@ -19,10 +19,13 @@ jobs:
solutionName: Microsoft.Kiota.slnx
steps:
- uses: actions/checkout@v6
- name: Setup .NET

- name: Setup .NET 8 and 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
dotnet-version: |
8.x
10.x
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
Expand All @@ -32,10 +35,14 @@ jobs:
- name: Check formatting
run: dotnet format ${{ env.solutionName }} --verify-no-changes
- name: Build
run: dotnet build ${{ env.solutionName }} --no-restore /p:UseSharedCompilation=false
run: dotnet build ${{ env.solutionName }} --no-restore
/p:UseSharedCompilation=false
- name: Test for net472
run: dotnet test --solution ${{ env.solutionName }} --no-build --verbosity normal --framework net472
run: dotnet test --solution ${{ env.solutionName }} --no-build --verbosity
normal --framework net472
- name: Test for net10.0 and collect coverage
run: dotnet test --solution ${{ env.solutionName }} --no-build --verbosity normal --framework net10.0 -- --coverlet --coverlet-output-format opencover
run: dotnet test --solution ${{ env.solutionName }} --no-build --verbosity
normal --framework net10.0 -- --coverlet --coverlet-output-format
opencover
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: pwsh
run: |
dotnet tool run dotnet-sonarscanner begin /k:"microsoft_kiota-abstractions-dotnet" /o:"microsoft" /d:sonar.token="$env:SONAR_TOKEN" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/abstractions/bin/Debug/net10.0/TestResults/coverage.opencover.xml,tests/authentication/azure/bin/Debug/net10.0/TestResults/coverage.opencover.xml,tests/http/httpClient/bin/Debug/net10.0/TestResults/coverage.opencover.xml,tests/serialization/json/bin/Debug/net10.0/TestResults/coverage.opencover.xml,tests/serialization/text/bin/Debug/net10.0/TestResults/coverage.opencover.xml,tests/serialization/form/bin/Debug/net10.0/TestResults/coverage.opencover.xml,tests/serialization/multipart/bin/Debug/net10.0/TestResults/coverage.opencover.xml,tests/bundle/bin/Debug/net10.0/TestResults/coverage.opencover.xml"
dotnet tool run dotnet-sonarscanner begin /k:"microsoft_kiota-abstractions-dotnet" /o:"microsoft" /d:sonar.token="$env:SONAR_TOKEN" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/**/TestResults/coverage.opencover.*.xml"
dotnet workload restore
dotnet build
dotnet test --solution Microsoft.Kiota.slnx --no-build --verbosity normal --framework net10.0 -- --coverlet --coverlet-output-format opencover
Expand Down
26 changes: 26 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- Source packages -->
<PackageVersion Include="Azure.Core" Version="1.50.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="4.14.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="[8.0,)" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.14.15" />
<PackageVersion Include="Std.UriTemplate" Version="2.0.8" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="[8.0.1,)" />
<PackageVersion Include="System.Net.Http.WinHttpHandler" Version="[10.0,)" />
<PackageVersion Include="System.Text.Json" Version="[8.0,)" />
<!-- Test packages -->
<PackageVersion Include="coverlet.MTP" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.7" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="10.0.7" />
<PackageVersion Include="Microsoft.Testing.Platform" Version="2.2.2" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.2" />
</ItemGroup>
</Project>
7 changes: 5 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net10.0</TargetFrameworks>
</PropertyGroup>
<!-- Common project properties for PACKAGED projects TO BE RELEASED-->
<PropertyGroup Condition="('$(IsTestProject)' != 'true') and ('$(IsAnalyzerProject)' != 'true')">
<Authors>Microsoft</Authors>
Expand All @@ -19,7 +22,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);NU5048;NETSDK1138;</NoWarn>
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net5.0'))">true</IsTrimmable>
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net8.0'))">true</IsTrimmable>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net8.0'))">true</IsAotCompatible>
<ContinuousIntegrationBuild Condition="'$(TF_BUILD)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand All @@ -30,7 +33,7 @@
<PackagePath>
</PackagePath>
</None>
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="4.14.0" Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net8.0'))">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Condition="'$(TargetFramework)' == 'net8.0'">
Comment thread
gavinbarron marked this conversation as resolved.
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
15 changes: 6 additions & 9 deletions src/abstractions/Microsoft.Kiota.Abstractions.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Abstractions library for the Kiota generated SDKs in dotnet.</Description>
<AssemblyTitle>Kiota Abstractions Library for dotnet</AssemblyTitle>
<!-- NET 5 target to be removed on next major version-->
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<EnablePackageValidation>true</EnablePackageValidation>
<GenerateCompatibilitySuppressionFile>false</GenerateCompatibilitySuppressionFile>
Expand All @@ -16,15 +14,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.14.15">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Std.UriTemplate" Version="2.0.8" />
<PackageReference Include="Std.UriTemplate" />
</ItemGroup>

<!-- NET 5 target to be removed on next major version-->
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' or '$(TargetFramework)'== 'netStandard2.0' or '$(TargetFramework)' == 'netStandard2.1'">
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="[6.0,)" />
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
</ItemGroup>
</Project>
</Project>
50 changes: 0 additions & 50 deletions src/abstractions/MultipartBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{
throw new ArgumentNullException(nameof(contentType));
}
if(partValue == null)

Check warning on line 46 in src/abstractions/MultipartBody.cs

View workflow job for this annotation

GitHub Actions / Build

Use a comparison to 'default(T)' instead or add a constraint to 'T' so that it can't be a value type.

Check warning on line 46 in src/abstractions/MultipartBody.cs

View workflow job for this annotation

GitHub Actions / Build

Use a comparison to 'default(T)' instead or add a constraint to 'T' so that it can't be a value type.

Check warning on line 46 in src/abstractions/MultipartBody.cs

View workflow job for this annotation

GitHub Actions / Build

Use a comparison to 'default(T)' instead or add a constraint to 'T' so that it can't be a value type.
{
throw new ArgumentNullException(nameof(partValue));
}
Expand All @@ -54,31 +54,6 @@
_parts[key] = value;
}
}
// TODO: Remove with next major release
/// <summary>
/// Gets the value of a part from the multipart body.
/// </summary>
/// <typeparam name="T">The type of the part value.</typeparam>
/// <param name="partName">The name of the part.</param>
/// <returns>The value of the part.</returns>
public T? GetPartValue<T>(string partName)
{
var value = GetPartValue<T>(partName, null);

if(EqualityComparer<T?>.Default.Equals(value, default))
{
foreach(var key in _parts.Keys)
{
if(key.Item1 == partName)
{
value = GetPartValue<T>(partName, key.Item2);
break;
}
}
}

return value;
}
/// <summary>
/// Gets the value of a part from the multipart body.
/// </summary>
Expand All @@ -101,31 +76,6 @@
}
return default;
}
// TODO: Remove with next major release
/// <summary>
/// Removes a part from the multipart body.
/// </summary>
/// <param name="partName">The name of the part.</param>
/// <returns>True if the part was removed, false otherwise.</returns>
public bool RemovePart(string partName)
{
bool success = RemovePart(partName, null);

if(!success)
{
foreach(var key in _parts.Keys)
{
if(key.Item1 == partName)
{
success = RemovePart(partName, key.Item2);
break;
}
}
}

return success;
}

/// <summary>
/// Removes a part from the multipart body.
/// </summary>
Expand All @@ -146,7 +96,7 @@
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() => throw new NotImplementedException();
private const char DoubleQuote = '"';
/// <inheritdoc />
public void Serialize(ISerializationWriter writer)

Check warning on line 99 in src/abstractions/MultipartBody.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed.

Check warning on line 99 in src/abstractions/MultipartBody.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed.
{
if(writer == null)
{
Expand Down
Loading
Loading