Skip to content

Commit

Permalink
Merge branch 'main' into netstandard20-dateonly
Browse files Browse the repository at this point in the history
  • Loading branch information
thom0707 committed Aug 22, 2024
2 parents 1059199 + 75f03bf commit e406166
Show file tree
Hide file tree
Showing 50 changed files with 2,391 additions and 796 deletions.
14 changes: 7 additions & 7 deletions it/csharp/dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.11.3" />
<PackageReference Include="Microsoft.kiota.Serialization.Multipart" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.12.0" />
<PackageReference Include="Microsoft.kiota.Serialization.Multipart" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.12.0" />

<Compile Remove="basic\**" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions it/python/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pylint==3.2.6

pytest==8.3.2

pytest-asyncio==0.23.8
pytest-asyncio==0.24.0

requests==2.32.3 ; python_version >= '3.7'

Expand Down Expand Up @@ -100,15 +100,15 @@ hyperframe==6.0.1 ; python_full_version >= '3.6.1'

microsoft-kiota-abstractions==1.3.3

microsoft-kiota-authentication-azure==1.0.0
microsoft-kiota-authentication-azure==1.1.0

microsoft-kiota-http==1.3.3

microsoft-kiota-serialization-json==1.3.0

microsoft-kiota-serialization-text==1.0.0

microsoft-kiota-serialization-form==0.1.0
microsoft-kiota-serialization-form==0.1.1

microsoft-kiota-serialization-multipart==0.1.0

Expand Down
8 changes: 4 additions & 4 deletions it/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion it/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"devDependencies": {
"@es-exec/esbuild-plugin-start": "^0.0.5",
"@stylistic/eslint-plugin-ts": "^2.6.4",
"@types/node": "^22.4.1",
"@types/node": "^22.5.0",
"@typescript-eslint/eslint-plugin": "^8.2.0",
"@typescript-eslint/parser": "^8.2.0",
"esbuild": "^0.23.1",
Expand Down
37 changes: 37 additions & 0 deletions scripts/execute-vscode-sideload.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
param (
[string]
[Parameter(Mandatory = $false)]
$Platform = "win-x64",
[switch]
$WSL
)


Push-Location ./vscode/microsoft-kiota

# Install all dependencies
npm i

# Package the VS Code extension
npx @vscode/vsce package

# Getting package for its version
$PackageJson = Get-Content "package.json" -Raw | ConvertFrom-Json

# Install the extension
code --install-extension "./kiota-$($PackageJson.version).vsix"

if ($WSL) {
$Platform = "linux-x64"
$VsCodeRootPath = (Resolve-Path "~/.vscode-server").Path
}
else {
$VsCodeRootPath = (Resolve-Path "~/.vscode").Path
}

$KiotaBin = "$VsCodeRootPath/extensions/ms-graph.kiota-$($PackageJson.version)/.kiotabin/$($PackageJson.kiotaVersion)/$Platform"

Pop-Location

# Building Kiota
dotnet publish ./src/kiota/kiota.csproj -p:PublishSingleFile=true -p:PublishReadyToRun=true --self-contained -c Release -r $platform -o $KiotaBin
12 changes: 6 additions & 6 deletions src/Kiota.Builder/Kiota.Builder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
<PackageReference Include="AsyncKeyedLock" Version="7.0.1" />
<PackageReference Include="DotNet.Glob" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.11.3" />
<PackageReference Include="Microsoft.kiota.Serialization.Multipart" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.12.0" />
<PackageReference Include="Microsoft.kiota.Serialization.Multipart" Version="1.12.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.17" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="0.5.5-preview" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.17" />
Expand Down
5 changes: 3 additions & 2 deletions src/kiota/Rpc/IServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ internal interface IServer
Task<SearchOperationResult> SearchAsync(string searchTerm, bool clearCache, CancellationToken cancellationToken);
Task<ShowResult> ShowAsync(string descriptionPath, string[] includeFilters, string[] excludeFilters, bool clearCache, CancellationToken cancellationToken);
Task<ManifestResult> GetManifestDetailsAsync(string manifestPath, string apiIdentifier, bool clearCache, CancellationToken cancellationToken);
Task<List<LogEntry>> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, CancellationToken cancellationToken);
Task<List<LogEntry>> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, ConsumerOperation operation, CancellationToken cancellationToken);
Task<LanguagesInformation> InfoForDescriptionAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken);
Task<List<LogEntry>> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, CancellationToken cancellationToken);
Task<List<LogEntry>> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, ConsumerOperation operation, CancellationToken cancellationToken);
Task<List<LogEntry>> MigrateFromLockFileAsync(string lockDirectoryPath, CancellationToken cancellationToken);
}
36 changes: 31 additions & 5 deletions src/kiota/Rpc/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Kiota.Builder.Extensions;
using Kiota.Builder.Lock;
using Kiota.Builder.Logging;
using Kiota.Builder.WorkspaceManagement;
using Kiota.Generated;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -137,7 +138,7 @@ private static string NormalizeOperationNodePath(OpenApiUrlTreeNode node, Operat
return indexingNormalizationRegex().Replace(name, "{}");
return name;
}
public async Task<List<LogEntry>> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, CancellationToken cancellationToken)
public async Task<List<LogEntry>> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, ConsumerOperation operation, CancellationToken cancellationToken)
{
var logger = new ForwardedLogger<KiotaBuilder>();
var configuration = Configuration.Generation;
Expand All @@ -151,7 +152,7 @@ public async Task<List<LogEntry>> GenerateAsync(string openAPIFilePath, string o
configuration.ClearCache = clearCache;
configuration.ExcludeBackwardCompatible = excludeBackwardCompatible;
configuration.IncludeAdditionalData = includeAdditionalData;
configuration.Operation = ConsumerOperation.Add; //TODO should be updated to edit in the edit scenario
configuration.Operation = operation;
if (disabledValidationRules is { Length: > 0 })
configuration.DisabledValidationRules = disabledValidationRules.ToHashSet(StringComparer.OrdinalIgnoreCase);
if (serializers is { Length: > 0 })
Expand Down Expand Up @@ -183,7 +184,7 @@ public async Task<List<LogEntry>> GenerateAsync(string openAPIFilePath, string o
}
return logger.LogEntries;
}
public async Task<List<LogEntry>> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, CancellationToken cancellationToken)
public async Task<List<LogEntry>> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, ConsumerOperation operation, CancellationToken cancellationToken)
{
var globalLogger = new ForwardedLogger<KiotaBuilder>();
var configuration = Configuration.Generation;
Expand All @@ -194,7 +195,7 @@ public async Task<List<LogEntry>> GeneratePluginAsync(string openAPIFilePath, st
configuration.ClientClassName = clientClassName;
configuration.CleanOutput = cleanOutput;
configuration.ClearCache = clearCache;
configuration.Operation = ConsumerOperation.Add; //TODO should be updated to edit in the edit scenario
configuration.Operation = operation;
if (disabledValidationRules is { Length: > 0 })
configuration.DisabledValidationRules = disabledValidationRules.ToHashSet(StringComparer.OrdinalIgnoreCase);
if (pluginTypes is { Length: > 0 })
Expand Down Expand Up @@ -230,6 +231,28 @@ public Task<LanguagesInformation> InfoForDescriptionAsync(string descriptionPath
ArgumentException.ThrowIfNullOrEmpty(descriptionPath);
return InfoInternalAsync(descriptionPath, clearCache, cancellationToken);
}

public async Task<List<LogEntry>> MigrateFromLockFileAsync(string lockDirectoryPath, CancellationToken cancellationToken)
{
ArgumentException.ThrowIfNullOrEmpty(lockDirectoryPath);
var logger = new ForwardedLogger<KiotaBuilder>();
try
{
var workspaceManagementService = new WorkspaceManagementService(logger, httpClient, IsConfigPreviewEnabled.Value);
var clientNames = await workspaceManagementService.MigrateFromLockFileAsync(string.Empty, lockDirectoryPath, cancellationToken).ConfigureAwait(false);
if (!clientNames.Any())
{
logger.LogWarning("no client configuration was migrated");
}
logger.LogInformation("Client configurations migrated successfully: {Clients}", string.Join(", ", clientNames));
}
catch (Exception ex)
{
logger.LogCritical(ex, "error migrating the lock file: {ExceptionMessage}", ex.Message);
}
return logger.LogEntries;
}

private async Task<LanguagesInformation> InfoInternalAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken)
{
var logger = new ForwardedLogger<KiotaBuilder>();
Expand Down Expand Up @@ -257,7 +280,10 @@ private static PathItem ConvertOpenApiUrlTreeNodeToPathItem(OpenApiUrlTreeNode n
.OrderByDescending(static x => x.isOperation)
.ThenBy(static x => x.segment, StringComparer.OrdinalIgnoreCase)
.ToArray();
return new PathItem(node.Path, node.DeduplicatedSegment(), children, filteredPaths.Count == 0 || Array.Exists(children, static x => x.isOperation) && children.Where(static x => x.isOperation).All(static x => x.selected));
bool isSelected = filteredPaths.Count == 0 || // There are no filtered paths
Array.Exists(children, static x => x.isOperation) && children.Where(static x => x.isOperation).All(static x => x.selected) || // All operations have been selected
!Array.Exists(children, static x => x.isOperation) && Array.TrueForAll(children, static x => x.selected); // All paths selected but no operations present
return new PathItem(node.Path, node.DeduplicatedSegment(), children, isSelected);
}
private static string GetAbsolutePath(string source)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.SDK" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.SDK" Version="17.11.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
Expand Down
2 changes: 1 addition & 1 deletion tests/Kiota.Builder.Tests/Kiota.Builder.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="DotNet.Glob" Version="3.1.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
Expand Down
2 changes: 1 addition & 1 deletion tests/Kiota.Tests/Kiota.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
26 changes: 25 additions & 1 deletion vscode/microsoft-kiota/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Context: you're most likely a program manager eager to demo the latest bits from
- GitHub CLI `winget install GitHub.CLI`
- dotnet 8 `winget install Microsoft.DotNet.SDK.8`
- node 20 `winget install CoreyButler.NVMforWindows && nvm install lts && nvm use lts`
- vsce & TypeScript `npm i -g TypeScript @vscode/vsce`
- vsce & TypeScript `npm i -g typescript @vscode/vsce`

### Steps

Expand Down Expand Up @@ -46,3 +46,27 @@ Where kiotaVersionInPackage is the kiotaVersion field and versionInPackage is th
> Note: the **.vscode** segment might change to **.vscode-server** if you're remoting to WSL.
> Note: alternatively to building executable yourself, you can download it from [the pipeline](https://github.com/microsoft/kiota/actions/workflows/dotnet.yml) by filtering the branch (top right corner) with the pull request branch, selecting the latest run, and downloading the right OS version from the artifacts. The only remaining work will be to move the downloaded files to the right path above.
#### Using the ready-made script

If you want to automate these steps, you can use the following script to automate the process:

```powershell
.\scripts\execute-vscode-sideload.ps1 -Platform "win-x64|linux-x64|osx-x64"
```

If you are using WSL, you can use the following:

```powershell
.\scripts\execute-vscode-sideload.ps1 -WSL
```

## FAQ

### VS Code keeps reinstalling from the marketplace

This is most likely caused by the fact that there's a newer released version. Run the following script replacing the version argument with the latest version of kiota.

```powershell
.\scripts\update-vscode-releases.ps1 -version "versionWithoutVPrefix" -online -filePath .\vscode\microsoft-kiota\package.json
```
Loading

0 comments on commit e406166

Please sign in to comment.