Skip to content

Commit

Permalink
Do not create request builder classes in parallel
Browse files Browse the repository at this point in the history
This causes quite severe corruption of the CodeModel. Many threads
concurrently start creating the same models and start adding properties.
The result is undefined for larger models and will be different on every
run.

This probably fixes (or at least improves the situation for) microsoft#2442.
  • Loading branch information
papegaaij committed Jul 5, 2023
1 parent 30cfa13 commit 463a70e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Kiota.Builder/KiotaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,15 @@ private void CreateRequestBuilderClass(CodeNamespace currentNamespace, OpenApiUr
CreateUrlManagement(codeClass, currentNode, isApiClientClass);

if (rootNamespace != null)
Parallel.ForEach(currentNode.Children.Values, childNode =>
foreach (var childNode in currentNode.Children.Values)
{
if (childNode.GetNodeNamespaceFromPath(config.ClientNamespaceName) is string targetNamespaceName &&
!string.IsNullOrEmpty(targetNamespaceName))
{
var targetNamespace = rootNamespace.FindOrAddNamespace(targetNamespaceName);
CreateRequestBuilderClass(targetNamespace, childNode, rootNode);
}
});
};
}
private static void CreateMethod(string propIdentifier, string propType, CodeClass codeClass, OpenApiUrlTreeNode currentNode)
{
Expand Down

0 comments on commit 463a70e

Please sign in to comment.