Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -811,7 +811,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
8 changes: 6 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,12 @@ 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();

sourceCodeProject = GeneratedCodeWorkspace.AddDirectory(sourceCodeProject, sourceCodePath, skipPredicate: sourceFile => sourceFile.StartsWith(sourceCodeGeneratedDirectory));
sourceCodeProject = GeneratedCodeWorkspace.AddDirectory(sourceCodeProject, sourceCodePath,
// Skip adding the generated sdk code to the project
skipPredicate: sourceFile => genFolders.Exists(f => sourceFile.StartsWith(f.FullName)));

foreach (var sharedSourceFolder in sharedSourceFolders)
{
Expand Down