Skip to content

Commit 457ea8c

Browse files
Move schema/ConfigurationSchema.json under the Generated folder (#10271)
Moves the generated `ConfigurationSchema.json` from `schema/` to `Generated/schema/` in the output directory, aligning it with the existing `Generated/` folder convention for auto-generated artifacts. Also skips schema generation when a custom `ConfigurationSchema.json` is detected at `schema/ConfigurationSchema.json`. - **`ScmCodeModelGenerator.cs`**: Output path changed to `Generated/schema/ConfigurationSchema.json`; added early return to skip generation when a custom schema exists at `schema/ConfigurationSchema.json` - **`NewProjectScaffolding.cs`**: Updated pack item path to `Generated/schema/ConfigurationSchema.json`; guarded pack items (schema + `.targets`) with a custom schema check so they are only added when no custom `schema/ConfigurationSchema.json` exists - **Test projects**: All 72 test projects regenerated via `Generate.ps1`; schema files moved, `.csproj` references updated --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
1 parent e149aab commit 457ea8c

146 files changed

Lines changed: 85 additions & 77 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmCodeModelGenerator.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,21 @@ protected override void Configure()
5454

5555
public override async Task WriteAdditionalFiles(string outputPath)
5656
{
57+
// Skip generation if a custom ConfigurationSchema.json exists outside the Generated folder
58+
var customSchemaPath = Path.Combine(outputPath, "schema", "ConfigurationSchema.json");
59+
if (File.Exists(customSchemaPath))
60+
{
61+
Emitter.Info($"Custom ConfigurationSchema.json detected at {Path.GetFullPath(customSchemaPath)}, skipping generation.");
62+
return;
63+
}
64+
5765
var schemaContent = ConfigurationSchemaGenerator.Generate(
5866
OutputLibrary,
5967
ConfigurationSchema.SectionName,
6068
ConfigurationSchema.OptionsRef);
6169
if (schemaContent != null)
6270
{
63-
var schemaPath = Path.Combine(outputPath, "schema", "ConfigurationSchema.json");
71+
var schemaPath = Path.Combine(outputPath, "Generated", "schema", "ConfigurationSchema.json");
6472
var schemaDir = Path.GetDirectoryName(schemaPath);
6573
if (schemaDir != null)
6674
{

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/NewProjectScaffolding.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ protected virtual string GetSourceProjectFileContent()
7171
builder.CompileIncludes.Add(compileInclude);
7272
}
7373

74-
// Add pack items for ConfigurationSchema.json and .targets file
74+
// Add pack items for ConfigurationSchema.json and .targets file if no custom schema is defined
7575
var packageName = CodeModelGenerator.Instance.Configuration.PackageName;
76-
var schemaPath = Path.Combine(CodeModelGenerator.Instance.Configuration.OutputDirectory, "schema", "ConfigurationSchema.json");
77-
if (File.Exists(schemaPath))
76+
var customSchemaPath = Path.Combine(CodeModelGenerator.Instance.Configuration.OutputDirectory, "schema", "ConfigurationSchema.json");
77+
if (!File.Exists(customSchemaPath))
7878
{
79-
builder.PackItems.Add(new CSharpProjectWriter.CSProjPackItem(@"..\schema\ConfigurationSchema.json", @"\"));
79+
builder.PackItems.Add(new CSharpProjectWriter.CSProjPackItem(@"..\Generated\schema\ConfigurationSchema.json", @"\"));
8080
builder.PackItems.Add(new CSharpProjectWriter.CSProjPackItem($@"..\{packageName}.NuGet.targets", @"buildTransitive\netstandard2.0\" + $"{packageName}.targets"));
8181
}
8282

packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/schema/ConfigurationSchema.json renamed to packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/Generated/schema/ConfigurationSchema.json

File renamed without changes.

packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/SampleTypeSpec.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<None Include="..\schema\ConfigurationSchema.json" Pack="true" PackagePath="\" />
17+
<None Include="..\Generated\schema\ConfigurationSchema.json" Pack="true" PackagePath="\" />
1818
<None Include="..\SampleTypeSpec.NuGet.targets" Pack="true" PackagePath="buildTransitive\netstandard2.0\SampleTypeSpec.targets" />
1919
</ItemGroup>
2020
</Project>

packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/api-key/schema/ConfigurationSchema.json renamed to packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/api-key/Generated/schema/ConfigurationSchema.json

File renamed without changes.

packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/api-key/src/Authentication.ApiKey.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<None Include="..\schema\ConfigurationSchema.json" Pack="true" PackagePath="\" />
17+
<None Include="..\Generated\schema\ConfigurationSchema.json" Pack="true" PackagePath="\" />
1818
<None Include="..\Authentication.ApiKey.NuGet.targets" Pack="true" PackagePath="buildTransitive\netstandard2.0\Authentication.ApiKey.targets" />
1919
</ItemGroup>
2020
</Project>

packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/http/custom/schema/ConfigurationSchema.json renamed to packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/http/custom/Generated/schema/ConfigurationSchema.json

File renamed without changes.

packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/http/custom/src/Authentication.Http.Custom.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<None Include="..\schema\ConfigurationSchema.json" Pack="true" PackagePath="\" />
17+
<None Include="..\Generated\schema\ConfigurationSchema.json" Pack="true" PackagePath="\" />
1818
<None Include="..\Authentication.Http.Custom.NuGet.targets" Pack="true" PackagePath="buildTransitive\netstandard2.0\Authentication.Http.Custom.targets" />
1919
</ItemGroup>
2020
</Project>

packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/oauth2/schema/ConfigurationSchema.json renamed to packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/oauth2/Generated/schema/ConfigurationSchema.json

File renamed without changes.

packages/http-client-csharp/generator/TestProjects/Spector/http/authentication/oauth2/src/Authentication.OAuth2.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<None Include="..\schema\ConfigurationSchema.json" Pack="true" PackagePath="\" />
17+
<None Include="..\Generated\schema\ConfigurationSchema.json" Pack="true" PackagePath="\" />
1818
<None Include="..\Authentication.OAuth2.NuGet.targets" Pack="true" PackagePath="buildTransitive\netstandard2.0\Authentication.OAuth2.targets" />
1919
</ItemGroup>
2020
</Project>

0 commit comments

Comments
 (0)