Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/AutoRest.CSharp/Mgmt/AutoRest/MgmtOutputLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,10 @@ public override TypeProvider FindTypeProviderForSchema(Schema schema)
public override CSharpType? FindTypeByName(string originalName)
{
_schemaOrNameToModels.TryGetValue(originalName, out TypeProvider? provider);
provider ??= ResourceSchemaMap.Values.FirstOrDefault(m => m.Type.Name == originalName);

// Try to search declaration name too if no key matches. i.e. Resource Data Type will be appended a 'Data' in the name and won't be found through key
provider ??= _schemaOrNameToModels.FirstOrDefault(s => s.Value is MgmtObjectType mot && mot.Declaration.Name == originalName).Value;

return provider?.Type;
}

Expand Down
3 changes: 3 additions & 0 deletions src/AutoRest.CSharp/MgmtTest/AutoRest/MgmtTestTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ private static string GetSourceCodePath()
if (Configuration.MgmtTestConfiguration?.SourceCodePath != null)
return Configuration.MgmtTestConfiguration.SourceCodePath;

// try to find the sdk source code path according to the default folder structure
// Azure.ResourceManager.XXX \ src <- default sdk source folder
// \ samples \ Generated <- default sample output folder defined in msbuild
return Path.Combine(Configuration.OutputFolder, "../../src");
}

Expand Down
7 changes: 5 additions & 2 deletions src/AutoRest.CSharp/MgmtTest/AutoRest/SourceCodeProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using AutoRest.CSharp.AutoRest.Plugins;
using Microsoft.CodeAnalysis;
Expand Down Expand Up @@ -41,9 +42,11 @@ public async Task<Compilation> GetCompilationAsync()
private static Project CreateSourceCodeProject(string sourceCodePath, string[] sharedSourceFolders)
{
var sourceCodeProject = CreateGeneratedCodeProject();
var sourceCodeGeneratedDirectory = Path.Join(sourceCodePath, GeneratedCodeWorkspace.GeneratedFolder);
DirectoryInfo di = new DirectoryInfo(sourceCodePath);
var genFolders = di.EnumerateDirectories(GeneratedCodeWorkspace.GeneratedFolder, SearchOption.AllDirectories).ToList();
Comment thread
RodgeFu marked this conversation as resolved.

sourceCodeProject = GeneratedCodeWorkspace.AddDirectory(sourceCodeProject, sourceCodePath, skipPredicate: sourceFile => sourceFile.StartsWith(sourceCodeGeneratedDirectory));
sourceCodeProject = GeneratedCodeWorkspace.AddDirectory(sourceCodeProject, sourceCodePath,
skipPredicate: sourceFile => genFolders.Exists(f => sourceFile.StartsWith(f.FullName)));
Comment thread
RodgeFu marked this conversation as resolved.

foreach (var sharedSourceFolder in sharedSourceFolders)
{
Expand Down