From eb613f135f500c4d17181a33b12c538e3d85da94 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 22 Jun 2023 14:55:20 -0400 Subject: [PATCH 01/10] - removes unused property for serialization of composed types --- src/Kiota.Builder/CodeDOM/CodeProperty.cs | 4 ---- .../Refiners/CommonLanguageRefiner.cs | 15 --------------- .../Writers/CSharp/CodePropertyWriter.cs | 3 +-- 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/Kiota.Builder/CodeDOM/CodeProperty.cs b/src/Kiota.Builder/CodeDOM/CodeProperty.cs index 5b9ff266fc..deb6b2716f 100644 --- a/src/Kiota.Builder/CodeDOM/CodeProperty.cs +++ b/src/Kiota.Builder/CodeDOM/CodeProperty.cs @@ -34,10 +34,6 @@ public enum CodePropertyKind /// The request middleware options. Used when request parameters are wrapped in a class. /// Options, - /// - /// Serialization hint for composed type wrappers. - /// - SerializationHint, } public class CodeProperty : CodeTerminalWithKind, IDocumentedElement, IAlternativeName, ICloneable, IDeprecableElement diff --git a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs index bc6775f615..28d1a3cbee 100644 --- a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs +++ b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs @@ -628,21 +628,6 @@ private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, Co x.TypeDefinition is CodeEnum || x.TypeDefinition is null)) { KiotaBuilder.AddSerializationMembers(newClass, true, usesBackingStore); - newClass.AddProperty(new CodeProperty - { - Name = "serializationHint", - Type = new CodeType - { - Name = "string", - IsExternal = true, - }, - Documentation = new() - { - Description = "Serialization hint for the current wrapper.", - }, - Access = AccessModifier.Public, - Kind = CodePropertyKind.SerializationHint, - }); newClass.Kind = CodeClassKind.Model; } newClass.OriginalComposedType = codeComposedType; diff --git a/src/Kiota.Builder/Writers/CSharp/CodePropertyWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodePropertyWriter.cs index da74dc859d..d30e1f2403 100644 --- a/src/Kiota.Builder/Writers/CSharp/CodePropertyWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CodePropertyWriter.cs @@ -15,8 +15,7 @@ public override void WriteCodeElement(CodeProperty codeElement, LanguageWriter w var isNullableReferenceType = !propertyType.EndsWith("?", StringComparison.OrdinalIgnoreCase) && codeElement.IsOfKind( CodePropertyKind.Custom, - CodePropertyKind.QueryParameter, - CodePropertyKind.SerializationHint);// Other property types are appropriately constructor initialized + CodePropertyKind.QueryParameter);// Other property types are appropriately constructor initialized conventions.WriteShortDescription(codeElement.Documentation.Description, writer); conventions.WriteDeprecationAttribute(codeElement, writer); if (isNullableReferenceType) From 4f10757f00b54fcc5753e3bf3f4870dcf6cfa5a7 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 22 Jun 2023 14:57:29 -0400 Subject: [PATCH 02/10] - removes additional properties from wrappers as each member type should have it depending on description Signed-off-by: Vincent Biret --- src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs index 28d1a3cbee..3a055bc5ad 100644 --- a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs +++ b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs @@ -627,7 +627,7 @@ private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, Co if (codeComposedType.Types.All(static x => x.TypeDefinition is CodeClass targetClass && targetClass.IsOfKind(CodeClassKind.Model) || x.TypeDefinition is CodeEnum || x.TypeDefinition is null)) { - KiotaBuilder.AddSerializationMembers(newClass, true, usesBackingStore); + KiotaBuilder.AddSerializationMembers(newClass, false, usesBackingStore); newClass.Kind = CodeClassKind.Model; } newClass.OriginalComposedType = codeComposedType; From c81f6d02f4936db169af28e4edc3b9b6397ebf14 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 27 Jun 2023 10:20:29 -0400 Subject: [PATCH 03/10] - adds marker interface to CSharp composed type wrappers Signed-off-by: Vincent Biret --- src/Kiota.Builder/Refiners/CSharpRefiner.cs | 48 +++++++++++-------- .../Refiners/CommonLanguageRefiner.cs | 34 +++++++++---- .../Refiners/CSharpLanguageRefinerTests.cs | 1 + 3 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/Kiota.Builder/Refiners/CSharpRefiner.cs b/src/Kiota.Builder/Refiners/CSharpRefiner.cs index c32a40ea7a..30fe646fc5 100644 --- a/src/Kiota.Builder/Refiners/CSharpRefiner.cs +++ b/src/Kiota.Builder/Refiners/CSharpRefiner.cs @@ -22,7 +22,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance Name = "BaseRequestBuilder", Declaration = new CodeType { - Name = "Microsoft.Kiota.Abstractions", + Name = AbstractionsNamespaceName, IsExternal = true } }); @@ -33,7 +33,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance // Name = "RequestConfiguration", // Declaration = new CodeType // { - // Name = "Microsoft.Kiota.Abstractions", + // Name = AbstractionsNamespaceName, // IsExternal = true // } // }, @@ -45,7 +45,11 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance AddDefaultImports(generatedCode, defaultUsingEvaluators); MoveClassesWithNamespaceNamesUnderNamespace(generatedCode); ConvertUnionTypesToWrapper(generatedCode, - _configuration.UsesBackingStore + _configuration.UsesBackingStore, + true, + AbstractionsNamespaceName, + "IComposedTypeWrapper", + false ); cancellationToken.ThrowIfCancellationRequested(); AddRawUrlConstructorOverload(generatedCode); @@ -91,7 +95,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance AddParentClassToErrorClasses( generatedCode, "ApiException", - "Microsoft.Kiota.Abstractions" + AbstractionsNamespaceName ); AddConstructorsForDefaultValues(generatedCode, false); AddDiscriminatorMappingsUsingsToParentClasses( @@ -127,26 +131,30 @@ protected static void MakeEnumPropertiesNullable(CodeElement currentElement) .ForEach(x => x.Type.IsNullable = true); CrawlTree(currentElement, MakeEnumPropertiesNullable); } + private const string AbstractionsNamespaceName = "Microsoft.Kiota.Abstractions"; + private const string SerializationNamespaceName = $"{AbstractionsNamespaceName}.Serialization"; + private const string StoreNamespaceName = $"{AbstractionsNamespaceName}.Store"; + private const string ExtensionsNamespaceName = $"{AbstractionsNamespaceName}.Extensions"; protected static readonly AdditionalUsingEvaluator[] defaultUsingEvaluators = { new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.RequestAdapter), - "Microsoft.Kiota.Abstractions", "IRequestAdapter"), + AbstractionsNamespaceName, "IRequestAdapter"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), - "Microsoft.Kiota.Abstractions", "Method", "RequestInformation", "IRequestOption"), + AbstractionsNamespaceName, "Method", "RequestInformation", "IRequestOption"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor), - "Microsoft.Kiota.Abstractions", "IResponseHandler"), + AbstractionsNamespaceName, "IResponseHandler"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Serializer), - "Microsoft.Kiota.Abstractions.Serialization", "ISerializationWriter"), + SerializationNamespaceName, "ISerializationWriter"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Deserializer), - "Microsoft.Kiota.Abstractions.Serialization", "IParseNode"), + SerializationNamespaceName, "IParseNode"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.ClientConstructor), - "Microsoft.Kiota.Abstractions.Extensions", "Dictionary"), + ExtensionsNamespaceName, "Dictionary"), new (static x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.Model), - "Microsoft.Kiota.Abstractions.Serialization", "IParsable"), + SerializationNamespaceName, "IParsable"), new (static x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.Model) && @class.Properties.Any(x => x.IsOfKind(CodePropertyKind.AdditionalData)), - "Microsoft.Kiota.Abstractions.Serialization", "IAdditionalDataHolder"), + SerializationNamespaceName, "IAdditionalDataHolder"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor), - "Microsoft.Kiota.Abstractions.Serialization", "IParsable"), + SerializationNamespaceName, "IParsable"), new (static x => x is CodeClass || x is CodeEnum, "System", "String"), new (static x => x is CodeClass, @@ -161,15 +169,15 @@ protected static void MakeEnumPropertiesNullable(CodeElement currentElement) "System.Linq", "Enumerable"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.ClientConstructor) && method.Parameters.Any(y => y.IsOfKind(CodeParameterKind.BackingStore)), - "Microsoft.Kiota.Abstractions.Store", "IBackingStoreFactory", "IBackingStoreFactorySingleton"), + StoreNamespaceName, "IBackingStoreFactory", "IBackingStoreFactorySingleton"), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.BackingStore), - "Microsoft.Kiota.Abstractions.Store", "IBackingStore", "IBackedModel", "BackingStoreFactorySingleton" ), + StoreNamespaceName, "IBackingStore", "IBackedModel", "BackingStoreFactorySingleton" ), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.QueryParameter) && !string.IsNullOrEmpty(prop.SerializationName), - "Microsoft.Kiota.Abstractions", "QueryParameterAttribute"), + AbstractionsNamespaceName, "QueryParameterAttribute"), new (static x => x is CodeClass @class && @class.OriginalComposedType is CodeIntersectionType intersectionType && intersectionType.Types.Any(static y => !y.IsExternal), - "Microsoft.Kiota.Abstractions.Serialization", "ParseNodeHelper"), + SerializationNamespaceName, "ParseNodeHelper"), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.Headers), - "Microsoft.Kiota.Abstractions", "RequestHeaders"), + AbstractionsNamespaceName, "RequestHeaders"), new (static x => x is CodeEnum prop && prop.Options.Any(x => x.IsNameEscaped), "System.Runtime.Serialization", "EnumMemberAttribute"), new (static x => x is IDeprecableElement element && element.Deprecation is not null && element.Deprecation.IsDeprecated, @@ -213,7 +221,7 @@ protected static void CorrectMethodType(CodeMethod currentMethod) Name = "Date", Declaration = new CodeType { - Name = "Microsoft.Kiota.Abstractions", + Name = AbstractionsNamespaceName, IsExternal = true, }, }) @@ -224,7 +232,7 @@ protected static void CorrectMethodType(CodeMethod currentMethod) Name = "Time", Declaration = new CodeType { - Name = "Microsoft.Kiota.Abstractions", + Name = AbstractionsNamespaceName, IsExternal = true, }, }) diff --git a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs index 3a055bc5ad..7c80e80a02 100644 --- a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs +++ b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs @@ -539,7 +539,7 @@ protected static void ReplaceBinaryByNativeType(CodeElement currentElement, stri } CrawlTree(currentElement, c => ReplaceBinaryByNativeType(c, symbol, ns, addDeclaration, isNullable)); } - protected static void ConvertUnionTypesToWrapper(CodeElement currentElement, bool usesBackingStore, bool supportInnerClasses = true) + protected static void ConvertUnionTypesToWrapper(CodeElement currentElement, bool usesBackingStore, bool supportInnerClasses = true, string markerInterfaceNamespace = "", string markerInterfaceName = "", bool addMarkerProperty = true) { ArgumentNullException.ThrowIfNull(currentElement); if (currentElement.Parent is CodeClass parentClass) @@ -547,22 +547,22 @@ protected static void ConvertUnionTypesToWrapper(CodeElement currentElement, boo if (currentElement is CodeMethod currentMethod) { if (currentMethod.ReturnType is CodeComposedTypeBase currentUnionType) - currentMethod.ReturnType = ConvertComposedTypeToWrapper(parentClass, currentUnionType, usesBackingStore, supportInnerClasses); + currentMethod.ReturnType = ConvertComposedTypeToWrapper(parentClass, currentUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty); if (currentMethod.Parameters.Any(static x => x.Type is CodeComposedTypeBase)) foreach (var currentParameter in currentMethod.Parameters.Where(static x => x.Type is CodeComposedTypeBase)) - currentParameter.Type = ConvertComposedTypeToWrapper(parentClass, (CodeComposedTypeBase)currentParameter.Type, usesBackingStore, supportInnerClasses); + currentParameter.Type = ConvertComposedTypeToWrapper(parentClass, (CodeComposedTypeBase)currentParameter.Type, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty); if (currentMethod.ErrorMappings.Select(static x => x.Value).OfType().Any()) foreach (var errorUnionType in currentMethod.ErrorMappings.Select(static x => x.Value).OfType()) - currentMethod.ReplaceErrorMapping(errorUnionType, ConvertComposedTypeToWrapper(parentClass, errorUnionType, usesBackingStore, supportInnerClasses)); + currentMethod.ReplaceErrorMapping(errorUnionType, ConvertComposedTypeToWrapper(parentClass, errorUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty)); } else if (currentElement is CodeIndexer currentIndexer && currentIndexer.ReturnType is CodeComposedTypeBase currentUnionType) - currentIndexer.ReturnType = ConvertComposedTypeToWrapper(parentClass, currentUnionType, usesBackingStore); + currentIndexer.ReturnType = ConvertComposedTypeToWrapper(parentClass, currentUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty); else if (currentElement is CodeProperty currentProperty && currentProperty.Type is CodeComposedTypeBase currentPropUnionType) - currentProperty.Type = ConvertComposedTypeToWrapper(parentClass, currentPropUnionType, usesBackingStore, supportInnerClasses); + currentProperty.Type = ConvertComposedTypeToWrapper(parentClass, currentPropUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty); } - CrawlTree(currentElement, x => ConvertUnionTypesToWrapper(x, usesBackingStore, supportInnerClasses)); + CrawlTree(currentElement, x => ConvertUnionTypesToWrapper(x, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty)); } - private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, CodeComposedTypeBase codeComposedType, bool usesBackingStore, bool supportsInnerClasses = true) + private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, CodeComposedTypeBase codeComposedType, bool usesBackingStore, bool supportsInnerClasses, string markerInterfaceNamespace, string markerInterfaceName, bool addMarkerProperty) { ArgumentNullException.ThrowIfNull(codeClass); ArgumentNullException.ThrowIfNull(codeComposedType); @@ -591,7 +591,7 @@ private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, Co Description = description }, }) - .First(); + .First(); newClass.AddUsing(codeComposedType.AllTypes .SelectMany(static c => (c.TypeDefinition as CodeClass)?.Usings ?? Enumerable.Empty()) @@ -631,6 +631,22 @@ private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, Co newClass.Kind = CodeClassKind.Model; } newClass.OriginalComposedType = codeComposedType; + if (!string.IsNullOrEmpty(markerInterfaceName) && !string.IsNullOrEmpty(markerInterfaceNamespace)) + { + newClass.StartBlock.AddImplements(new CodeType + { + Name = markerInterfaceName + }); + newClass.AddUsing(new CodeUsing + { + Name = markerInterfaceName, + Declaration = new() + { + Name = markerInterfaceNamespace, + IsExternal = true, + } + }); + } // Add the discriminator function to the wrapper as it will be referenced. KiotaBuilder.AddDiscriminatorMethod(newClass, codeComposedType.DiscriminatorInformation.DiscriminatorPropertyName, codeComposedType.DiscriminatorInformation.DiscriminatorMappings); return new CodeType diff --git a/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs index 70f94f88a9..bcf20e4964 100644 --- a/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs @@ -310,6 +310,7 @@ public async Task ConvertsUnionTypesToWrapper() var resultingWrapper = root.FindChildByName("union"); Assert.NotNull(resultingWrapper); Assert.NotNull(resultingWrapper.OriginalComposedType); + Assert.Contains("IComposedTypeWrapper", resultingWrapper.StartBlock.Implements.Select(static x => x.Name)); } [Fact] public async Task MovesClassesWithNamespaceNamesUnderNamespace() From 740a101dff9188be7f80c1b8cd2ec0c3ba2a9ab1 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 27 Jun 2023 10:42:00 -0400 Subject: [PATCH 04/10] - adds marker interface to java composed types Signed-off-by: Vincent Biret --- src/Kiota.Builder/Refiners/JavaRefiner.cs | 50 +++++++++++++---------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/Kiota.Builder/Refiners/JavaRefiner.cs b/src/Kiota.Builder/Refiners/JavaRefiner.cs index 4632c3f741..3a62c462f2 100644 --- a/src/Kiota.Builder/Refiners/JavaRefiner.cs +++ b/src/Kiota.Builder/Refiners/JavaRefiner.cs @@ -23,7 +23,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance Name = "BaseRequestBuilder", Declaration = new CodeType { - Name = "com.microsoft.kiota", + Name = AbstractionsNamespaceName, IsExternal = true } }); @@ -33,7 +33,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance Name = "BaseRequestConfiguration", Declaration = new CodeType { - Name = "com.microsoft.kiota", + Name = AbstractionsNamespaceName, IsExternal = true } }); @@ -57,7 +57,11 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance cancellationToken.ThrowIfCancellationRequested(); RemoveCancellationParameter(generatedCode); ConvertUnionTypesToWrapper(generatedCode, - _configuration.UsesBackingStore + _configuration.UsesBackingStore, + true, + SerializationNamespaceName, + "ComposedTypeWrapper", + false ); AddRawUrlConstructorOverload(generatedCode); CorrectCoreType(generatedCode, CorrectMethodType, CorrectPropertyType, CorrectImplements); @@ -99,29 +103,29 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance generatedCode, defaultConfiguration.Serializers, new(StringComparer.OrdinalIgnoreCase) { - "com.microsoft.kiota.serialization.JsonSerializationWriterFactory", - "com.microsoft.kiota.serialization.TextSerializationWriterFactory", - "com.microsoft.kiota.serialization.FormSerializationWriterFactory", + $"{SerializationNamespaceName}.JsonSerializationWriterFactory", + $"{SerializationNamespaceName}.TextSerializationWriterFactory", + $"{SerializationNamespaceName}.FormSerializationWriterFactory", } ); ReplaceDefaultDeserializationModules( generatedCode, defaultConfiguration.Deserializers, new(StringComparer.OrdinalIgnoreCase) { - "com.microsoft.kiota.serialization.JsonParseNodeFactory", - "com.microsoft.kiota.serialization.FormParseNodeFactory", - "com.microsoft.kiota.serialization.TextParseNodeFactory" + $"{SerializationNamespaceName}.JsonParseNodeFactory", + $"{SerializationNamespaceName}.FormParseNodeFactory", + $"{SerializationNamespaceName}.TextParseNodeFactory" } ); AddSerializationModulesImport(generatedCode, - new[] { "com.microsoft.kiota.ApiClientBuilder", - "com.microsoft.kiota.serialization.SerializationWriterFactoryRegistry" }, - new[] { "com.microsoft.kiota.serialization.ParseNodeFactoryRegistry" }); + new[] { $"{AbstractionsNamespaceName}.ApiClientBuilder", + $"{SerializationNamespaceName}.SerializationWriterFactoryRegistry" }, + new[] { $"{SerializationNamespaceName}.ParseNodeFactoryRegistry" }); cancellationToken.ThrowIfCancellationRequested(); AddParentClassToErrorClasses( generatedCode, "ApiException", - "com.microsoft.kiota" + AbstractionsNamespaceName ); AddDiscriminatorMappingsUsingsToParentClasses( generatedCode, @@ -195,21 +199,23 @@ private static void AddEnumSetImport(CodeElement currentElement) CrawlTree(currentElement, AddEnumSetImport); } private static readonly JavaConventionService conventionService = new(); + private const string AbstractionsNamespaceName = "com.microsoft.kiota"; + private const string SerializationNamespaceName = "com.microsoft.kiota.serialization"; private static readonly AdditionalUsingEvaluator[] defaultUsingEvaluators = { new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.RequestAdapter), - "com.microsoft.kiota", "RequestAdapter"), + AbstractionsNamespaceName, "RequestAdapter"), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.PathParameters), "java.util", "HashMap"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), - "com.microsoft.kiota", "RequestInformation", "RequestOption", "HttpMethod"), + AbstractionsNamespaceName, "RequestInformation", "RequestOption", "HttpMethod"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), "java.net", "URISyntaxException"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), "java.util", "Collection", "Map"), new (static x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.Model), - "com.microsoft.kiota.serialization", "Parsable"), + SerializationNamespaceName, "Parsable"), new (static x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.Model) && @class.Properties.Any(x => x.IsOfKind(CodePropertyKind.AdditionalData)), - "com.microsoft.kiota.serialization", "AdditionalDataHolder"), + SerializationNamespaceName, "AdditionalDataHolder"), new (static x => x is CodeMethod method && method.Parameters.Any(x => !x.Optional), "java.util", "Objects"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor) && @@ -217,11 +223,11 @@ private static void AddEnumSetImport(CodeElement currentElement) x.Type.Name.Equals(conventionService.StreamTypeName, StringComparison.OrdinalIgnoreCase)), "java.io", "InputStream"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Serializer), - "com.microsoft.kiota.serialization", "SerializationWriter"), + SerializationNamespaceName, "SerializationWriter"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Deserializer), - "com.microsoft.kiota.serialization", "ParseNode"), + SerializationNamespaceName, "ParseNode"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor), - "com.microsoft.kiota.serialization", "Parsable", "ParsableFactory"), + SerializationNamespaceName, "Parsable", "ParsableFactory"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Deserializer), "java.util", "HashMap", "Map"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.ClientConstructor) && @@ -234,9 +240,9 @@ private static void AddEnumSetImport(CodeElement currentElement) x is CodeParameter para && "decimal".Equals(para.Type.Name, StringComparison.OrdinalIgnoreCase), "java.math", "BigDecimal"), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.QueryParameter) && !string.IsNullOrEmpty(prop.SerializationName), - "com.microsoft.kiota", "QueryParameter"), + AbstractionsNamespaceName, "QueryParameter"), new (static x => x is CodeClass @class && @class.OriginalComposedType is CodeIntersectionType intersectionType && intersectionType.Types.Any(static y => !y.IsExternal), - "com.microsoft.kiota.serialization", "ParseNodeHelper"), + SerializationNamespaceName, "ParseNodeHelper"), }; private static void CorrectPropertyType(CodeProperty currentProperty) { From d19edc6d7b983e0cebb3ca3b4061a031c29be0d8 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 28 Jun 2023 12:57:51 -0400 Subject: [PATCH 05/10] - adds support for go composed types scalar serialization --- src/Kiota.Builder/CodeDOM/CodeMethod.cs | 4 +++ src/Kiota.Builder/Refiners/CSharpRefiner.cs | 3 +- .../Refiners/CommonLanguageRefiner.cs | 36 ++++++++++++++----- src/Kiota.Builder/Refiners/GoRefiner.cs | 6 +++- src/Kiota.Builder/Refiners/JavaRefiner.cs | 3 +- .../Writers/CSharp/CodeMethodWriter.cs | 2 ++ .../Writers/Go/CodeMethodWriter.cs | 10 +++++- .../Writers/Java/CodeMethodWriter.cs | 2 ++ .../Writers/Go/CodeMethodWriterTests.cs | 11 ++++++ 9 files changed, 63 insertions(+), 14 deletions(-) diff --git a/src/Kiota.Builder/CodeDOM/CodeMethod.cs b/src/Kiota.Builder/CodeDOM/CodeMethod.cs index 50c99976e2..49b8fbc692 100644 --- a/src/Kiota.Builder/CodeDOM/CodeMethod.cs +++ b/src/Kiota.Builder/CodeDOM/CodeMethod.cs @@ -29,6 +29,10 @@ public enum CodeMethodKind /// The method to be used during query parameters serialization to get the proper uri template parameter name. /// QueryParametersMapper, + /// + /// Method used to distinguish between regular and composed type wrapper models during serialization for loosely-typed languages. + /// + ComposedTypeMarker, } public enum HttpMethod { diff --git a/src/Kiota.Builder/Refiners/CSharpRefiner.cs b/src/Kiota.Builder/Refiners/CSharpRefiner.cs index 30fe646fc5..5175b4b95d 100644 --- a/src/Kiota.Builder/Refiners/CSharpRefiner.cs +++ b/src/Kiota.Builder/Refiners/CSharpRefiner.cs @@ -48,8 +48,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance _configuration.UsesBackingStore, true, AbstractionsNamespaceName, - "IComposedTypeWrapper", - false + "IComposedTypeWrapper" ); cancellationToken.ThrowIfCancellationRequested(); AddRawUrlConstructorOverload(generatedCode); diff --git a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs index 7c80e80a02..ce31f618d4 100644 --- a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs +++ b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs @@ -539,7 +539,7 @@ protected static void ReplaceBinaryByNativeType(CodeElement currentElement, stri } CrawlTree(currentElement, c => ReplaceBinaryByNativeType(c, symbol, ns, addDeclaration, isNullable)); } - protected static void ConvertUnionTypesToWrapper(CodeElement currentElement, bool usesBackingStore, bool supportInnerClasses = true, string markerInterfaceNamespace = "", string markerInterfaceName = "", bool addMarkerProperty = true) + protected static void ConvertUnionTypesToWrapper(CodeElement currentElement, bool usesBackingStore, bool supportInnerClasses = true, string markerInterfaceNamespace = "", string markerInterfaceName = "", string markerMethodName = "") { ArgumentNullException.ThrowIfNull(currentElement); if (currentElement.Parent is CodeClass parentClass) @@ -547,22 +547,22 @@ protected static void ConvertUnionTypesToWrapper(CodeElement currentElement, boo if (currentElement is CodeMethod currentMethod) { if (currentMethod.ReturnType is CodeComposedTypeBase currentUnionType) - currentMethod.ReturnType = ConvertComposedTypeToWrapper(parentClass, currentUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty); + currentMethod.ReturnType = ConvertComposedTypeToWrapper(parentClass, currentUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, markerMethodName); if (currentMethod.Parameters.Any(static x => x.Type is CodeComposedTypeBase)) foreach (var currentParameter in currentMethod.Parameters.Where(static x => x.Type is CodeComposedTypeBase)) - currentParameter.Type = ConvertComposedTypeToWrapper(parentClass, (CodeComposedTypeBase)currentParameter.Type, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty); + currentParameter.Type = ConvertComposedTypeToWrapper(parentClass, (CodeComposedTypeBase)currentParameter.Type, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, markerMethodName); if (currentMethod.ErrorMappings.Select(static x => x.Value).OfType().Any()) foreach (var errorUnionType in currentMethod.ErrorMappings.Select(static x => x.Value).OfType()) - currentMethod.ReplaceErrorMapping(errorUnionType, ConvertComposedTypeToWrapper(parentClass, errorUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty)); + currentMethod.ReplaceErrorMapping(errorUnionType, ConvertComposedTypeToWrapper(parentClass, errorUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, markerMethodName)); } else if (currentElement is CodeIndexer currentIndexer && currentIndexer.ReturnType is CodeComposedTypeBase currentUnionType) - currentIndexer.ReturnType = ConvertComposedTypeToWrapper(parentClass, currentUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty); + currentIndexer.ReturnType = ConvertComposedTypeToWrapper(parentClass, currentUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, markerMethodName); else if (currentElement is CodeProperty currentProperty && currentProperty.Type is CodeComposedTypeBase currentPropUnionType) - currentProperty.Type = ConvertComposedTypeToWrapper(parentClass, currentPropUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty); + currentProperty.Type = ConvertComposedTypeToWrapper(parentClass, currentPropUnionType, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, markerMethodName); } - CrawlTree(currentElement, x => ConvertUnionTypesToWrapper(x, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, addMarkerProperty)); + CrawlTree(currentElement, x => ConvertUnionTypesToWrapper(x, usesBackingStore, supportInnerClasses, markerInterfaceNamespace, markerInterfaceName, markerMethodName)); } - private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, CodeComposedTypeBase codeComposedType, bool usesBackingStore, bool supportsInnerClasses, string markerInterfaceNamespace, string markerInterfaceName, bool addMarkerProperty) + private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, CodeComposedTypeBase codeComposedType, bool usesBackingStore, bool supportsInnerClasses, string markerInterfaceNamespace, string markerInterfaceName, string markerMethodName) { ArgumentNullException.ThrowIfNull(codeClass); ArgumentNullException.ThrowIfNull(codeComposedType); @@ -647,6 +647,26 @@ private static CodeTypeBase ConvertComposedTypeToWrapper(CodeClass codeClass, Co } }); } + if (!string.IsNullOrEmpty(markerMethodName)) + { + newClass.AddMethod(new CodeMethod + { + Name = markerMethodName, + ReturnType = new CodeType + { + Name = "boolean", + IsNullable = false, + }, + Kind = CodeMethodKind.ComposedTypeMarker, + Access = AccessModifier.Public, + IsAsync = false, + IsStatic = false, + Documentation = new() + { + Description = "Determines if the current object is a wrapper around a composed type", + }, + }); + } // Add the discriminator function to the wrapper as it will be referenced. KiotaBuilder.AddDiscriminatorMethod(newClass, codeComposedType.DiscriminatorInformation.DiscriminatorPropertyName, codeComposedType.DiscriminatorInformation.DiscriminatorMappings); return new CodeType diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs index a8e9caea38..66184214da 100644 --- a/src/Kiota.Builder/Refiners/GoRefiner.cs +++ b/src/Kiota.Builder/Refiners/GoRefiner.cs @@ -51,7 +51,11 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance ); ConvertUnionTypesToWrapper( generatedCode, - _configuration.UsesBackingStore + _configuration.UsesBackingStore, + true, + string.Empty, + string.Empty, + "GetIsComposedType" ); AddRawUrlConstructorOverload( generatedCode diff --git a/src/Kiota.Builder/Refiners/JavaRefiner.cs b/src/Kiota.Builder/Refiners/JavaRefiner.cs index 3a62c462f2..72a77e1c75 100644 --- a/src/Kiota.Builder/Refiners/JavaRefiner.cs +++ b/src/Kiota.Builder/Refiners/JavaRefiner.cs @@ -60,8 +60,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance _configuration.UsesBackingStore, true, SerializationNamespaceName, - "ComposedTypeWrapper", - false + "ComposedTypeWrapper" ); AddRawUrlConstructorOverload(generatedCode); CorrectCoreType(generatedCode, CorrectMethodType, CorrectPropertyType, CorrectImplements); diff --git a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs index 7e08d3d932..b6dab1d292 100644 --- a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs @@ -90,6 +90,8 @@ protected virtual void HandleMethodKind(CodeMethod codeElement, LanguageWriter w case CodeMethodKind.Factory: WriteFactoryMethodBody(codeElement, parentClass, writer); break; + case CodeMethodKind.ComposedTypeMarker: + throw new InvalidOperationException("ComposedTypeMarker is not required as interface is explicitly implemented."); default: writer.WriteLine("return null;"); break; diff --git a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs index 4148df3edb..26bd6a6720 100644 --- a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs @@ -72,12 +72,19 @@ public override void WriteCodeElement(CodeMethod codeElement, LanguageWriter wri case CodeMethodKind.Factory: WriteFactoryMethodBody(codeElement, parentClass, writer); break; + case CodeMethodKind.ComposedTypeMarker: + WriteComposedTypeMarkerBody(writer); + break; default: writer.WriteLine("return nil"); break; } writer.CloseBlock(); } + private void WriteComposedTypeMarkerBody(LanguageWriter writer) + { + writer.WriteLine("return true"); + } private void WriteFactoryMethodBody(CodeMethod codeElement, CodeClass parentClass, LanguageWriter writer) { var parseNodeParameter = codeElement.Parameters.OfKind(CodeParameterKind.ParseNode) ?? throw new InvalidOperationException("Factory method should have a ParseNode parameter"); @@ -404,7 +411,8 @@ private void WriteMethodPrototype(CodeMethod code, CodeElement parentBlock, Lang CodeMethodKind.Deserializer, CodeMethodKind.RequestBuilderWithParameters, CodeMethodKind.RequestBuilderBackwardCompatibility, - CodeMethodKind.RawUrlConstructor) || code.IsAsync ? + CodeMethodKind.RawUrlConstructor, + CodeMethodKind.ComposedTypeMarker) || code.IsAsync ? string.Empty : "error"; if (!string.IsNullOrEmpty(finalReturnType) && !string.IsNullOrEmpty(errorDeclaration)) diff --git a/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs index 59342a4664..e63f4a165f 100644 --- a/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs @@ -78,6 +78,8 @@ public override void WriteCodeElement(CodeMethod codeElement, LanguageWriter wri case CodeMethodKind.Factory when codeElement.IsOverload: WriteFactoryOverloadMethod(codeElement, parentClass, writer); break; + case CodeMethodKind.ComposedTypeMarker: + throw new InvalidOperationException("ComposedTypeMarker is not required as interface is explicitly implemented."); default: writer.WriteLine("return null;"); break; diff --git a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs index 8b6c7f75c0..fd2c68b91e 100644 --- a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs @@ -1917,4 +1917,15 @@ public void WritesDeprecationInformation() Assert.Contains("v2.0", result); Assert.Contains("// Deprecated:", result); } + [Fact] + public void WritesComposedMarker() + { + method.Kind = CodeMethodKind.ComposedTypeMarker; + method.ReturnType = new CodeType { Name = "boolean", IsNullable = false }; + method.IsAsync = false; + writer.Write(method); + var result = tw.ToString(); + Assert.Contains("return true", result, StringComparison.OrdinalIgnoreCase); + Assert.DoesNotContain("error", result, StringComparison.OrdinalIgnoreCase); + } } From bcaee35c9ef4fa006f9eefd6ef7ea9b7e34d938c Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 28 Jun 2023 12:59:18 -0400 Subject: [PATCH 06/10] - adds changelog entry for composed types serialization fix --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30e5e905a7..753d7ae74f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,9 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Fixed an issue with query parameter name normalization in Ruby and Python. [#2825](https://github.com/microsoft/kiota/issues/2825) +- Fixed serialization of scalar members in union types for C#, Go, Java. [#2462](https://github.com/microsoft/kiota/issues/2462) - Deprecated Visual Studio OpenAPI reference packages. -- Fixes a bug where a stackoverflow exception occurs when inlined schemas have self-references [2656](https://github.com/microsoft/kiota/issues/2656) -- Fixes nil safety while type casting values in collections in Go +- Fixed a bug where a stackoverflow exception occurs when inlined schemas have self-references [2656](https://github.com/microsoft/kiota/issues/2656) +- Fixed nil safety while type casting values in collections in Go - Moved common RequestBuilder ((request_adapter, url_template and path_parameters)) and RequestConfiguration(headers, options) properties to respective base classes in Python.[2440](https://github.com/microsoft/kiota/issues/2440) - Fixed a bug where escaped package names would not be lowercased in Java. From 20820e60cb34cab70accf2417e41811c6ff6fea0 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 28 Jun 2023 15:01:36 -0400 Subject: [PATCH 07/10] - increases code coverage Signed-off-by: Vincent Biret --- .../Refiners/CSharpLanguageRefinerTests.cs | 1 + .../Refiners/GoLanguageRefinerTests.cs | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs index bcf20e4964..712a84116b 100644 --- a/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs @@ -311,6 +311,7 @@ public async Task ConvertsUnionTypesToWrapper() Assert.NotNull(resultingWrapper); Assert.NotNull(resultingWrapper.OriginalComposedType); Assert.Contains("IComposedTypeWrapper", resultingWrapper.StartBlock.Implements.Select(static x => x.Name)); + Assert.Null(resultingWrapper.Methods.SingleOrDefault(static x => x.IsOfKind(CodeMethodKind.ComposedTypeMarker))); } [Fact] public async Task MovesClassesWithNamespaceNamesUnderNamespace() diff --git a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs index b463dd7fda..af661178f3 100644 --- a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs @@ -256,6 +256,63 @@ public async Task ReplacesModelsByInnerInterfaces() Assert.NotNull(responseInter); } [Fact] + public async Task ConvertsUnionTypesToWrapper() + { + var model = root.AddClass(new CodeClass + { + Name = "model", + Kind = CodeClassKind.Model + }).First(); + var union = new CodeUnionType + { + Name = "union", + }; + union.AddType(new() + { + Name = "type1", + }, new() + { + Name = "type2" + }); + var property = model.AddProperty(new CodeProperty + { + Name = "deserialize", + Kind = CodePropertyKind.Custom, + Type = union.Clone() as CodeTypeBase, + }).First(); + var method = model.AddMethod(new CodeMethod + { + Name = "method", + ReturnType = union.Clone() as CodeTypeBase + }).First(); + var parameter = new CodeParameter + { + Name = "param1", + Type = union.Clone() as CodeTypeBase + }; + var indexer = new CodeIndexer + { + Name = "idx", + ReturnType = union.Clone() as CodeTypeBase, + IndexType = new CodeType + { + Name = "string" + }, + IndexParameterName = "id", + }; + model.Indexer = indexer; + method.AddParameter(parameter); + await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Go }, root); //using CSharp so the indexer doesn't get removed + Assert.True(property.Type is CodeType); + Assert.True(parameter.Type is CodeType); + Assert.True(method.ReturnType is CodeType); + var resultingWrapper = root.FindChildByName("union"); + Assert.NotNull(resultingWrapper); + Assert.NotNull(resultingWrapper.OriginalComposedType); + Assert.DoesNotContain("IComposedTypeWrapper", resultingWrapper.StartBlock.Implements.Select(static x => x.Name)); + Assert.NotNull(resultingWrapper.Methods.Single(static x => x.IsOfKind(CodeMethodKind.ComposedTypeMarker))); + } + [Fact] public async Task AddsExceptionInheritanceOnErrorClasses() { var model = root.AddClass(new CodeClass From faf56ac7c54ea4d7a5fc4e0d10acb1adb9c2060e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 29 Jun 2023 08:47:05 -0400 Subject: [PATCH 08/10] - updates dotnet packades --- src/Kiota.Builder/Kiota.Builder.csproj | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Kiota.Builder/Kiota.Builder.csproj b/src/Kiota.Builder/Kiota.Builder.csproj index 9581ff64f5..65c362596a 100644 --- a/src/Kiota.Builder/Kiota.Builder.csproj +++ b/src/Kiota.Builder/Kiota.Builder.csproj @@ -44,20 +44,21 @@ - + - + - + - + \ No newline at end of file From dc833f517ab1ce57818cad1c19e63fb4d46361fd Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 29 Jun 2023 08:51:00 -0400 Subject: [PATCH 09/10] - udpates java dependencies --- it/java/basic/pom.xml | 2 +- it/java/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/it/java/basic/pom.xml b/it/java/basic/pom.xml index 75925101ad..825609a306 100644 --- a/it/java/basic/pom.xml +++ b/it/java/basic/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.4.1 + 0.4.5 diff --git a/it/java/pom.xml b/it/java/pom.xml index 80123d1c25..cb82333deb 100644 --- a/it/java/pom.xml +++ b/it/java/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.4.1 + 0.4.5 From 382bdfba7dba0d49f35e1a971c70ded7b8c3505e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 29 Jun 2023 09:23:24 -0400 Subject: [PATCH 10/10] - udpates go dependencies --- it/go/go.mod | 33 +++++++++++++++++---------------- it/go/go.sum | 46 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/it/go/go.mod b/it/go/go.mod index 859e4e1e18..69bda3e53f 100644 --- a/it/go/go.mod +++ b/it/go/go.mod @@ -4,34 +4,35 @@ go 1.20 require ( github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 - github.com/microsoft/kiota-abstractions-go v0.19.0 - github.com/microsoft/kiota-authentication-azure-go v0.6.0 - github.com/microsoft/kiota-http-go v0.16.1 - github.com/microsoft/kiota-serialization-form-go v0.9.0 - github.com/microsoft/kiota-serialization-json-go v0.9.0 - github.com/microsoft/kiota-serialization-text-go v0.7.0 + github.com/microsoft/kiota-abstractions-go v1.1.0 + github.com/microsoft/kiota-authentication-azure-go v1.0.0 + github.com/microsoft/kiota-http-go v1.0.0 + github.com/microsoft/kiota-serialization-form-go v1.0.0 + github.com/microsoft/kiota-serialization-json-go v1.0.3 + github.com/microsoft/kiota-serialization-text-go v1.0.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect github.com/cjlapao/common-go v0.0.39 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.8.2 // indirect + github.com/stretchr/testify v1.8.4 // indirect github.com/yosida95/uritemplate/v3 v3.0.2 // indirect - go.opentelemetry.io/otel v1.14.0 // indirect - go.opentelemetry.io/otel/trace v1.14.0 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + go.opentelemetry.io/otel v1.16.0 // indirect + go.opentelemetry.io/otel/metric v1.16.0 // indirect + go.opentelemetry.io/otel/trace v1.16.0 // indirect + golang.org/x/crypto v0.10.0 // indirect + golang.org/x/net v0.11.0 // indirect + golang.org/x/sys v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/it/go/go.sum b/it/go/go.sum index 6ab4b54e62..839c4f016a 100644 --- a/it/go/go.sum +++ b/it/go/go.sum @@ -1,9 +1,13 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/cjlapao/common-go v0.0.39 h1:bAAUrj2B9v0kMzbAOhzjSmiyDy+rd56r2sy7oEiQLlA= @@ -15,6 +19,8 @@ github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= @@ -26,18 +32,18 @@ github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/microsoft/kiota-abstractions-go v0.19.0 h1:R57UbZaIMdouccDpBMTNiwXljN/sOkeRSpXLtBAl2wg= -github.com/microsoft/kiota-abstractions-go v0.19.0/go.mod h1:0lbPErVO6Rj3HHpntNYW/OFmHhJJ1ewPdsi1xPxYIMc= -github.com/microsoft/kiota-authentication-azure-go v0.6.0 h1:Il9bLO34J6D8DY89xYAXoGh9muvlphayqG4eihyT6B8= -github.com/microsoft/kiota-authentication-azure-go v0.6.0/go.mod h1:EJCHiLWLXW1/mSgX7lYReAhVO37MzRT5Xi2mcPTwCRQ= -github.com/microsoft/kiota-http-go v0.16.1 h1:5SZbSwHs14Xve5VMQHHz00lwL/kEg3H9rgESAUrXnvw= -github.com/microsoft/kiota-http-go v0.16.1/go.mod h1:pKSaeSaBwh3Zadbnzw3kALEZbCZA1gq7A5PuxwVd/aU= -github.com/microsoft/kiota-serialization-form-go v0.9.0 h1:ZMyvuxg7z1LmRWJOXr5QuJlwnD/tuNatb+k1KPURBFQ= -github.com/microsoft/kiota-serialization-form-go v0.9.0/go.mod h1:FQqYzIrGX6KUoDOlg+DhDWoGaZoB8AicBYGOsBq0Dw4= -github.com/microsoft/kiota-serialization-json-go v0.9.0 h1:Em/YJb3eQGxcjNIPqKuaKrcuD0ib7tWXfaWccJrtIcc= -github.com/microsoft/kiota-serialization-json-go v0.9.0/go.mod h1:S7Ltu0/5hQjfeWmV9vQT5KYdFOsqHGdfMoP4Zo9Ctlw= -github.com/microsoft/kiota-serialization-text-go v0.7.0 h1:uayeq8fpDcZgL0zDyLkYZsH6zNnEXKgp+bRWfR5LcxA= -github.com/microsoft/kiota-serialization-text-go v0.7.0/go.mod h1:2su1PTllHCMNkHugmvpYad+AKBXUUGoiNP3xOAJUL7w= +github.com/microsoft/kiota-abstractions-go v1.1.0 h1:X1aKlsYCRs/0RSChr/fbq4j/+kxRzbSY5GeWhtHQNYI= +github.com/microsoft/kiota-abstractions-go v1.1.0/go.mod h1:RkxyZ5x87Njik7iVeQY9M2wtrrL1MJZcXiI/BxD/82g= +github.com/microsoft/kiota-authentication-azure-go v1.0.0 h1:29FNZZ/4nnCOwFcGWlB/sxPvWz487HA2bXH8jR5k2Rk= +github.com/microsoft/kiota-authentication-azure-go v1.0.0/go.mod h1:rnx3PRlkGdXDcA/0lZQTbBwyYGmc+3POt7HpE/e4jGw= +github.com/microsoft/kiota-http-go v1.0.0 h1:F1hd6gMlLeEgH2CkRB7z13ow7LxMKMWEmms/t0VfS+k= +github.com/microsoft/kiota-http-go v1.0.0/go.mod h1:eujxJliqodotsYepIc6ihhK+vXMMt5Q8YiSNL7+7M7U= +github.com/microsoft/kiota-serialization-form-go v1.0.0 h1:UNdrkMnLFqUCccQZerKjblsyVgifS11b3WCx+eFEsAI= +github.com/microsoft/kiota-serialization-form-go v1.0.0/go.mod h1:h4mQOO6KVTNciMF6azi1J9QB19ujSw3ULKcSNyXXOMA= +github.com/microsoft/kiota-serialization-json-go v1.0.3 h1:U0VR3IPP8an9BHunuKykqpCIvM3FJzjMQy8tiit+FTk= +github.com/microsoft/kiota-serialization-json-go v1.0.3/go.mod h1:rM4+FsAY+9AEpBsBzkFFis+b/LZLlNKKewuLwK9Q6Mg= +github.com/microsoft/kiota-serialization-text-go v1.0.0 h1:XOaRhAXy+g8ZVpcq7x7a0jlETWnWrEum0RhmbYrTFnA= +github.com/microsoft/kiota-serialization-text-go v1.0.0/go.mod h1:sM1/C6ecnQ7IquQOGUrUldaO5wj+9+v7G2W3sQ3fy6M= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -49,21 +55,37 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= +go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= +go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= +go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= +go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= +go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= +go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=