Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/dom export flat #5085

Merged
merged 42 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
26a7183
chore: adds a task to reset sample locks when generating
baywet Jul 10, 2024
51cd7f0
fix: missing parent for code type
baywet Jul 10, 2024
9ac2339
feat: base infrastructure for dom export
baywet Jul 10, 2024
bea1c09
fix: adds interface for accessibility elements
baywet Jul 12, 2024
f7226c0
feat: early prortotype of linear export
baywet Jul 12, 2024
3b7257e
fix: property custom types
baywet Jul 12, 2024
7a3d261
feat: adds indexer support
baywet Jul 12, 2024
8d9816b
feat: adds support for enums
baywet Jul 12, 2024
7b10f85
feat: adds support for inheritance and implement
baywet Jul 12, 2024
bae6835
feat: adds support for optional and defaulted parameters
baywet Jul 12, 2024
45397fe
fix: parameters separation to support generic types parsing
baywet Jul 18, 2024
570b508
feat: enables public API export service behind a flag
baywet Jul 23, 2024
3720261
chore: comment removal
baywet Jul 23, 2024
e209e3f
chore: formatting
baywet Aug 2, 2024
486e521
Merge branch 'main' into feature/dom-export-flat
baywet Aug 16, 2024
4a1635c
Resolve PR comment
Aug 19, 2024
4186211
golang: ensure elements in code files have the namespace element extr…
Aug 19, 2024
1a61fc9
Merge remote-tracking branch 'origin/main' into feature/dom-export-flat
Aug 19, 2024
4dcf5e6
fix: TS does not generate getters and setters.
Aug 19, 2024
a6b0bb7
Merge branch 'main' into feature/dom-export-flat
andrueastman Aug 19, 2024
a9d9778
fixes PHP generation due to broken tree.
Aug 20, 2024
339fd36
Merge remote-tracking branch 'origin/main' into feature/dom-export-flat
Aug 20, 2024
0121012
adds validation tests.
Aug 20, 2024
8d55991
Add changelog entry
Aug 20, 2024
467df9b
Merge remote-tracking branch 'origin/main' into feature/dom-export-flat
Aug 21, 2024
8695f33
Merge remote-tracking branch 'origin/main' into feature/dom-export-flat
Aug 21, 2024
2f1aa47
Merge branch 'main' into feature/dom-export-flat
andrueastman Aug 21, 2024
c42e67b
more language specific improvements on type information
Aug 21, 2024
9afcb9b
Get the entry so that its cleaned up.
Aug 21, 2024
c9132d7
Merge branch 'main' into feature/dom-export-flat
andrueastman Aug 22, 2024
cf69785
Merge branch 'main' into feature/dom-export-flat
andrueastman Aug 23, 2024
a778e9f
Update src/Kiota.Builder/KiotaBuilder.cs
andrueastman Aug 23, 2024
05543a4
Merge branch 'main' into feature/dom-export-flat
andrueastman Aug 23, 2024
dbd584d
Merge branch 'main' into feature/dom-export-flat
andrueastman Aug 27, 2024
18d9900
Merge remote-tracking branch 'origin/main' into feature/dom-export-flat
Aug 28, 2024
1e47fad
fix: pr review feedback
Aug 28, 2024
a8a09ec
fix: pr review feedback
Aug 28, 2024
432ac31
format
Aug 28, 2024
59c1ea0
cleanup
Aug 28, 2024
722cda0
Merge branch 'main' into feature/dom-export-flat
andrueastman Aug 28, 2024
9c9eb74
Update src/Kiota.Builder/Export/PublicAPIExportService.cs
andrueastman Aug 28, 2024
be33c1b
Merge branch 'main' into feature/dom-export-flat
andrueastman Aug 28, 2024
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
40 changes: 8 additions & 32 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,7 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/kiota/bin/Debug/net8.0/kiota.dll",
"args": [
"search",
"microsoft"
],
"args": ["search", "microsoft"],
"cwd": "${workspaceFolder}/src/kiota",
"console": "internalConsole",
"stopAtEntry": false
Expand All @@ -210,10 +207,7 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/kiota/bin/Debug/net8.0/kiota.dll",
"args": [
"search",
"test"
],
"args": ["search", "test"],
"cwd": "${workspaceFolder}/src/kiota",
"console": "internalConsole",
"stopAtEntry": false
Expand Down Expand Up @@ -255,11 +249,7 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/kiota/bin/Debug/net8.0/kiota.dll",
"args": [
"info",
"-l",
"CSharp"
],
"args": ["info", "-l", "CSharp"],
"cwd": "${workspaceFolder}/src/kiota",
"console": "internalConsole",
"stopAtEntry": false
Expand All @@ -270,11 +260,7 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/kiota/bin/Debug/net8.0/kiota.dll",
"args": [
"update",
"-o",
"${workspaceFolder}/samples"
],
"args": ["update", "-o", "${workspaceFolder}/samples"],
"cwd": "${workspaceFolder}/src/kiota",
"console": "internalConsole",
"stopAtEntry": false
Expand All @@ -285,10 +271,7 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/kiota/bin/Debug/net8.0/kiota.dll",
"args": [
"workspace",
"migrate"
],
"args": ["workspace", "migrate"],
"cwd": "${workspaceFolder}/samples/msgraph-mail/dotnet",
"console": "internalConsole",
"stopAtEntry": false,
Expand All @@ -302,10 +285,7 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/kiota/bin/Debug/net8.0/kiota.dll",
"args": [
"client",
"generate"
],
"args": ["client", "generate"],
"cwd": "${workspaceFolder}/samples/msgraph-mail/dotnet",
"console": "internalConsole",
"stopAtEntry": false,
Expand Down Expand Up @@ -369,11 +349,7 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/kiota/bin/Debug/net8.0/kiota.dll",
"args": [
"login",
"github",
"device"
],
"args": ["login", "github", "device"],
"cwd": "${workspaceFolder}/src/kiota",
"console": "internalConsole",
"stopAtEntry": false
Expand All @@ -385,4 +361,4 @@
"processId": "${command:pickProcess}"
}
]
}
}
12 changes: 11 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
"problemMatcher": "$msCompile",
"dependsOn": ["checkout:sample:locks"]
},
{
"label": "checkout:sample:locks",
"type": "process",
"command": "git",
"args": ["checkout", "**/kiota-lock.json"],
"options": {
"cwd": "${workspaceFolder}/samples"
}
},
{
"label": "test",
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added the ability to export the CodeDom to a file showing the public APIs to be generated in a given language [#4627](https://github.com/microsoft/kiota/issues/4627)

### Changed

- Fixed shorthand for refresh option in workspace experience. [#5240](https://github.com/microsoft/kiota/issues/5240)
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/CodeDOM/CodeMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public object Clone()
}
}

public class CodeMethod : CodeTerminalWithKind<CodeMethodKind>, ICloneable, IDocumentedElement, IDeprecableElement
public class CodeMethod : CodeTerminalWithKind<CodeMethodKind>, ICloneable, IDocumentedElement, IDeprecableElement, IAccessibleElement
{
public static readonly CodeParameterKind ParameterKindForConvertedIndexers = CodeParameterKind.Custom;
public static CodeMethod FromIndexer(CodeIndexer originalIndexer, Func<string, string> methodNameCallback, Func<string, string> parameterNameCallback, bool parameterNullable, bool typeSpecificOverload = false)
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/CodeDOM/CodeProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum CodePropertyKind
ErrorMessageOverride
}

public class CodeProperty : CodeTerminalWithKind<CodePropertyKind>, IDocumentedElement, IAlternativeName, ICloneable, IDeprecableElement
public class CodeProperty : CodeTerminalWithKind<CodePropertyKind>, IDocumentedElement, IAlternativeName, ICloneable, IDeprecableElement, IAccessibleElement
{
public bool ReadOnly
{
Expand Down
17 changes: 15 additions & 2 deletions src/Kiota.Builder/CodeDOM/CodeType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

Expand Down Expand Up @@ -33,10 +34,22 @@
TypeDefinition = TypeDefinition, // not cloning the type definition as it's a code element that lives in the tree and we don't want to fork the tree
IsExternal = IsExternal,
// Clone the list so that modifications on cloned objects' property are localized
// e.g. var y = x.Clone(); var z = y.Clone(); y.GenericTypeParameterValues.Add(value);

Check warning on line 37 in src/Kiota.Builder/CodeDOM/CodeType.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
// shouldn't modify x.GenericTypeParameterValues or z.GenericTypeParameterValues
GenericTypeParameterValues = new(GenericTypeParameterValues.ToList()),
genericTypeParameterValues = [.. genericTypeParameterValues],
}.BaseClone<CodeType>(this, TypeDefinition is null || IsExternal);
}
public Collection<CodeType> GenericTypeParameterValues { get; init; } = new();
public IEnumerable<CodeType> GenericTypeParameterValues
{
get => genericTypeParameterValues;
init => AddGenericTypeParameterValue([.. value]);
}
private Collection<CodeType> genericTypeParameterValues = [];
public void AddGenericTypeParameterValue(params CodeType[] types)
{
if (types is null) return;
EnsureElementsAreChildren(types);
foreach (var type in types)
genericTypeParameterValues.Add(type);
}
}
12 changes: 12 additions & 0 deletions src/Kiota.Builder/CodeDOM/IAccessibleElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Kiota.Builder.CodeDOM;

/// <summary>
/// Defines a contract for elements that can have configurable access to them using <see cref="AccessModifier"/>
/// </summary>
public interface IAccessibleElement
andrueastman marked this conversation as resolved.
Show resolved Hide resolved
{
AccessModifier Access
{
get; set;
}
}
5 changes: 5 additions & 0 deletions src/Kiota.Builder/Configuration/GenerationConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public ConsumerOperation? Operation
public string ClientClassName { get; set; } = "ApiClient";
public string ClientNamespaceName { get; set; } = "ApiSdk";
public string NamespaceNameSeparator { get; set; } = ".";
public bool ExportPublicApi
{
get; set;
}
internal const string ModelsNamespaceSegmentName = "models";
public string ModelsNamespaceName
{
Expand Down Expand Up @@ -152,6 +156,7 @@ public object Clone()
PatternsOverride = new(PatternsOverride ?? Enumerable.Empty<string>(), StringComparer.OrdinalIgnoreCase),
PluginTypes = new(PluginTypes ?? Enumerable.Empty<PluginType>()),
DisableSSLValidation = DisableSSLValidation,
ExportPublicApi = ExportPublicApi,
};
}
private static readonly StringIEnumerableDeepComparer comparer = new();
Expand Down
130 changes: 130 additions & 0 deletions src/Kiota.Builder/Export/PublicAPIExportService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Kiota.Builder.CodeDOM;
using Kiota.Builder.Configuration;
using Kiota.Builder.Writers;
using Kiota.Builder.Writers.CSharp;
using Kiota.Builder.Writers.Go;
using Kiota.Builder.Writers.Java;
using Kiota.Builder.Writers.Php;
using Kiota.Builder.Writers.Python;
using Kiota.Builder.Writers.Ruby;
using Kiota.Builder.Writers.Swift;
using Kiota.Builder.Writers.TypeScript;

namespace Kiota.Builder.Export;

internal class PublicApiExportService
{
internal PublicApiExportService(GenerationConfiguration generationConfiguration)
{
ArgumentNullException.ThrowIfNull(generationConfiguration);
_conventionService = GetLanguageConventionServiceFromConfiguration(generationConfiguration);
}
private readonly ILanguageConventionService _conventionService;
internal const string DomExportFileName = "kiota-dom-export.txt";
private const string InheritsSymbol = "-->";
private const string ImplementsSymbol = "~~>";
private const string OptionalSymbol = "?";
private const string ParentElementAndChildSeparator = "::";

internal async Task SerializeDomAsync(Stream outputStream, CodeNamespace rootNamespace, CancellationToken cancellationToken = default)
{
var streamWriter = new StreamWriter(outputStream, leaveOpen: true);
await using (streamWriter.ConfigureAwait(false))
{
var entries = GetEntriesFromDom(rootNamespace).Order(StringComparer.OrdinalIgnoreCase).ToArray();
foreach (var entry in entries)
{
await streamWriter.WriteLineAsync(entry.AsMemory(), cancellationToken).ConfigureAwait(false);
}
await streamWriter.FlushAsync(cancellationToken).ConfigureAwait(false);
}
}
private IEnumerable<string> GetEntriesFromDom(CodeElement currentElement)
{
foreach (var currentElementEntry in GetEntry(currentElement).Where(static x => !string.IsNullOrEmpty(x)))
yield return currentElementEntry;
foreach (var childElement in currentElement.GetChildElements())
foreach (var childElementEntry in GetEntriesFromDom(childElement))
yield return childElementEntry;
}

private IEnumerable<string> GetEntry(CodeElement codeElement, bool includeDefinitions = false)
{
string accessModifierValue = string.Empty;
if (codeElement is IAccessibleElement accessibleElement)
{
if (accessibleElement.Access is AccessModifier.Private)
return []; // we are not interested in private props as they are not used externally

accessModifierValue = $"|{accessibleElement.Access.ToString().ToLowerInvariant()}|";
}

return codeElement switch
{
CodeProperty property when property.Parent is not null =>
[$"{GetEntryPath(property.Parent)}{ParentElementAndChildSeparator}{accessModifierValue}{property.Name}:{GetEntryType(property.Type, property)}"],
CodeMethod method when method.Parent is not null =>
[$"{GetEntryPath(method.Parent)}{ParentElementAndChildSeparator}{(method.IsStatic ? "|static" : string.Empty)}{accessModifierValue}{method.Name}({GetParameters(method.Parameters)}):{((GetEntryType(method.ReturnType, method) is { } stringValue && !string.IsNullOrEmpty(stringValue)) ? stringValue : method.ReturnType.Name)}"],
CodeFunction function when function.Parent is not null =>
[$"{GetEntryPath(function.Parent)}{ParentElementAndChildSeparator}{function.Name}({GetParameters(function.OriginalLocalMethod.Parameters)}):{GetEntryType(function.OriginalLocalMethod.ReturnType, function)}"],
CodeIndexer codeIndexer when codeIndexer.Parent is not null =>
[$"{GetEntryPath(codeIndexer.Parent)}{ParentElementAndChildSeparator}[{GetParameters([codeIndexer.IndexParameter])}]:{GetEntryType(codeIndexer.ReturnType, codeIndexer)}"],
CodeEnum codeEnum1 when !includeDefinitions =>
codeEnum1.Options.Select((x, y) => $"{GetEntryPath(codeEnum1)}::{y:D4}-{x.Name}"),
CodeClass codeClass1 when !includeDefinitions && codeClass1.StartBlock.Inherits is not null =>
[$"{GetEntryPath(codeClass1)}{InheritsSymbol}{GetEntryType(codeClass1.StartBlock.Inherits, codeClass1)}"],
CodeClass codeClass2 when !includeDefinitions && codeClass2.StartBlock.Implements.Any() =>
[$"{GetEntryPath(codeClass2)}{ImplementsSymbol}{string.Join("; ", codeClass2.StartBlock.Implements.Select(x => GetEntryType(x, codeClass2)))}"],
CodeInterface codeInterface1 when !includeDefinitions && codeInterface1.StartBlock.Implements.Any() =>
[$"{GetEntryPath(codeInterface1)}{ImplementsSymbol}{string.Join("; ", codeInterface1.StartBlock.Implements.Select(x => GetEntryType(x, codeInterface1)))}"],
CodeClass codeClass when includeDefinitions => [GetEntryPath(codeClass)],
CodeEnum codeEnum when includeDefinitions => [GetEntryPath(codeEnum)],
CodeInterface codeInterface when includeDefinitions => [GetEntryPath(codeInterface)],
CodeConstant codeConstant => [GetEntryPath(codeConstant)],
_ => [],
};
}
private string GetParameters(IEnumerable<CodeParameter> parameters)
{
return string.Join("; ", parameters.Select(x => $"{x.Name}{(x.Optional ? OptionalSymbol : string.Empty)}:{GetEntryType(x.Type, x)}{(string.IsNullOrEmpty(x.DefaultValue) ? string.Empty : $"={x.DefaultValue}")}"));
}

private string GetEntryType(CodeTypeBase codeElementTypeBase, CodeElement targetElement) => _conventionService.GetTypeString(codeElementTypeBase, targetElement)
.Replace(ParentElementAndChildSeparator, ".", StringComparison.OrdinalIgnoreCase);//ensure language specific stuff doesn't break things like global:: in dotnet

private static string GetEntryPath(CodeElement codeElement)
{
return codeElement switch
{
CodeClass x when x.Parent is not null => $"{GetEntryPath(x.Parent)}.{codeElement.Name}",
CodeEnum x when x.Parent is not null => $"{GetEntryPath(x.Parent)}.{codeElement.Name}",
CodeInterface x when x.Parent is not null => $"{GetEntryPath(x.Parent)}.{codeElement.Name}",
CodeConstant x when x.Parent is not null => $"{GetEntryPath(x.Parent)}.{codeElement.Name}",
CodeFile x when x.Parent is not null => GetEntryPath(x.Parent),
CodeNamespace x => x.Name,
_ => string.Empty,
};
}
private static ILanguageConventionService GetLanguageConventionServiceFromConfiguration(GenerationConfiguration generationConfiguration)
{
return generationConfiguration.Language switch
{
GenerationLanguage.CSharp => new CSharpConventionService(),
GenerationLanguage.Java => new JavaConventionService(),
GenerationLanguage.TypeScript => new TypeScriptConventionService(),
GenerationLanguage.PHP => new PhpConventionService(),
GenerationLanguage.Python => new PythonConventionService(),
GenerationLanguage.Go => new GoConventionService(),
GenerationLanguage.Swift => new SwiftConventionService(generationConfiguration.ClientNamespaceName),
GenerationLanguage.Ruby => new RubyConventionService(),
GenerationLanguage.CLI => new CSharpConventionService(),
_ => throw new ArgumentOutOfRangeException(nameof(generationConfiguration), generationConfiguration.Language, null)
};
}
}
13 changes: 13 additions & 0 deletions src/Kiota.Builder/KiotaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Kiota.Builder.Configuration;
using Kiota.Builder.EqualityComparers;
using Kiota.Builder.Exceptions;
using Kiota.Builder.Export;
using Kiota.Builder.Extensions;
using Kiota.Builder.Logging;
using Kiota.Builder.Manifest;
Expand Down Expand Up @@ -268,6 +269,18 @@
await ApplyLanguageRefinement(config, generatedCode, cancellationToken).ConfigureAwait(false);
StopLogAndReset(sw, $"step {++stepId} - refine by language - took");

if (config.ExportPublicApi)
{
// Generate public API export
sw.Start();
var fileStream = File.Create(Path.Combine(config.OutputPath, PublicApiExportService.DomExportFileName));
await using (fileStream.ConfigureAwait(false))
{
await new PublicApiExportService(config).SerializeDomAsync(fileStream, generatedCode, cancellationToken).ConfigureAwait(false);
}
StopLogAndReset(sw, $"step {++stepId} - generated public API export - took");
}

// Write language source
sw.Start();
await CreateLanguageSourceFilesAsync(config.Language, generatedCode, cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -695,7 +708,7 @@
methodToAdd.AddParameter(new CodeParameter
{
Name = "rawUrl",
Type = new CodeType { Name = "string", IsExternal = true },

Check warning on line 711 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'string' 18 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
Optional = false,
Documentation = new()
{
Expand Down Expand Up @@ -809,7 +822,7 @@
IsAsync = false,
IsStatic = false,
Documentation = new(new() {
{"TypeName", new CodeType {

Check warning on line 825 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'TypeName' 5 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
IsExternal = false,
TypeDefinition = currentClass,
}
Expand Down Expand Up @@ -1051,7 +1064,7 @@

if (!"string".Equals(parameter.Type.Name, StringComparison.OrdinalIgnoreCase) && config.IncludeBackwardCompatible)
{ // adding a second indexer for the string version of the parameter so we keep backward compatibility
//TODO remove for v2

Check warning on line 1067 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
var backCompatibleValue = (CodeIndexer)result[0].Clone();
backCompatibleValue.Name += "-string";
backCompatibleValue.IndexParameter.Type = DefaultIndexerParameterType;
Expand Down Expand Up @@ -1207,7 +1220,7 @@
var suffix = $"{operationType}Response";
var modelType = CreateModelDeclarations(currentNode, schema, operation, parentClass, suffix);
if (modelType is not null && config.IncludeBackwardCompatible && config.Language is GenerationLanguage.CSharp or GenerationLanguage.Go && modelType.Name.EndsWith(suffix, StringComparison.Ordinal))
{ //TODO remove for v2

Check warning on line 1223 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
var obsoleteTypeName = modelType.Name[..^suffix.Length] + "Response";
if (modelType is CodeType codeType &&
codeType.TypeDefinition is CodeClass codeClass)
Expand Down Expand Up @@ -1339,7 +1352,7 @@
executorMethod.AddParameter(cancellationParam);// Add cancellation token parameter

if (returnTypes.Item2 is not null && config.IncludeBackwardCompatible)
{ //TODO remove for v2

Check warning on line 1355 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
var additionalExecutorMethod = (CodeMethod)executorMethod.Clone();
additionalExecutorMethod.ReturnType = returnTypes.Item2;
additionalExecutorMethod.OriginalMethod = executorMethod;
Expand Down Expand Up @@ -2407,7 +2420,7 @@
if (!parameterClass.ContainsPropertyWithWireName(prop.WireName))
{
if (addBackwardCompatibleParameter && config.IncludeBackwardCompatible && config.Language is GenerationLanguage.CSharp or GenerationLanguage.Go)
{ //TODO remove for v2

Check warning on line 2423 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
var modernProp = (CodeProperty)prop.Clone();
modernProp.Name = $"{prop.Name}As{modernProp.Type.Name.ToFirstCharacterUpperCase()}";
modernProp.SerializationName = prop.WireName;
Expand Down
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Refiners/CliRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
}
private static void RemoveBackwardCompatibleIndexers(CodeElement currentElement)
{
//TODO remove for v2

Check warning on line 112 in src/Kiota.Builder/Refiners/CliRefiner.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
if (currentElement is CodeClass
{
Kind: CodeClassKind.RequestBuilder, Indexer: not null
Expand Down Expand Up @@ -327,10 +327,10 @@
{
Name = "Tuple",
IsExternal = true,
GenericTypeParameterValues = new() {
GenericTypeParameterValues = [
CreateCommandType(collectionKind),
CreateCommandType(collectionKind),
}
]
},
SimpleName = indexer.Name.CleanupSymbolName()
};
Expand Down
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,9 @@
if (currentElement is CodeIndexer currentIndexer &&
currentElement.Parent is CodeClass indexerParentClass)
{
if (indexerParentClass.ContainsMember(currentElement.Name)) // TODO remove condition for v2 necessary because of the second case of Go block

Check warning on line 626 in src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
indexerParentClass.RemoveChildElement(currentElement);
//TODO remove whole block except for last else if body for v2

Check warning on line 628 in src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
if (language == GenerationLanguage.Go)
{
if (currentIndexer.IsLegacyIndexer)
Expand Down Expand Up @@ -1411,7 +1411,7 @@
};
if (addCurrentTypeAsGenericTypeParameter)
{
currentClass.StartBlock.Inherits.GenericTypeParameterValues.Add(new CodeType
currentClass.StartBlock.Inherits.AddGenericTypeParameterValue(new CodeType
{
TypeDefinition = currentClass,
});
Expand Down Expand Up @@ -1502,7 +1502,7 @@
private static CodeType GetGenericTypeForRequestConfiguration(CodeType configurationParameterType, CodeType genericTypeParamValue)
{
var newType = (CodeType)configurationParameterType.Clone();
newType.GenericTypeParameterValues.Add(genericTypeParamValue);
newType.AddGenericTypeParameterValue(genericTypeParamValue);
return newType;
}

Expand Down
Loading
Loading