Skip to content

Commit

Permalink
Rename zee properties
Browse files Browse the repository at this point in the history
- make it clear these properties control code generation
- use "OnBuild" for consistency with properties elsewhere in ASP.NET Core
- remove "Default" from a comple of property names because commaents are pretty clear
- rename a few targets for consistency with the new properties
  - word "Reference" didn't add much
  • Loading branch information
dougbu committed May 31, 2019
1 parent 7b76256 commit 154deaa
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@
Options added to the code generator command line by default. Provides the default %(Options) metadata of
@(OpenApiReference) and @(OpenApiProjectReference) items.
-->
<OpenApiDefaultGeneratorOptions Condition="'$(OpenApiDefaultGeneratorOptions)' == ''"></OpenApiDefaultGeneratorOptions>
<OpenApiGenerateCodeOptions Condition="'$(OpenApiGenerateCodeOptions)' == ''"></OpenApiGenerateCodeOptions>

<!--
If 'true' (the default), generate code for @(OpenApiReference) and @(OpenApiProjectReference) items before the
BeforeCompile target.
If 'false', the GenerateOpenApiReferenceCode target is not part of the build (by default) but can run when
explicitly referenced. That is, the target may be invoked from the command line or tied in through another target.
If 'false', the 'GenerateOpenApiCode' target is not part of the build (by default) but can run when explicitly
referenced. That is, the target may be invoked from the command line or tied in through another target.
-->
<OpenApiGenerateBeforeCompile Condition="'$(OpenApiGenerateBeforeCompile)' == ''">true</OpenApiGenerateBeforeCompile>
<OpenApiGenerateCodeOnBuild Condition="'$(OpenApiGenerateCodeOnBuild)' == ''">true</OpenApiGenerateCodeOnBuild>

<!--
If 'true' (the default), generate code for @(OpenApiReference) and @(OpenApiProjectReference) items during
design-time builds. Otherwise, generate code only during a full build.
-->
<OpenApiGenerateAtDesignTime Condition="'$(OpenApiGenerateAtDesignTime)' == ''">true</OpenApiGenerateAtDesignTime>
<OpenApiGenerateCodeAtDesignTime
Condition="'$(OpenApiGenerateCodeAtDesignTime)' == ''">true</OpenApiGenerateCodeAtDesignTime>

<!--
If 'true' (the default), build projects referenced in @(OpenApiProjectReference) items before retrieving that
Expand All @@ -44,15 +45,16 @@
If 'false', ensure the referenced projects build before this one in the solution or through other means. IDEs may
be confused about the project dependency graph in this case.
-->
<OpenApiBuildReferencedProjects Condition="'$(OpenApiBuildReferencedProjects)' == ''">true</OpenApiBuildReferencedProjects>
<OpenApiBuildReferencedProjects
Condition="'$(OpenApiBuildReferencedProjects)' == ''">true</OpenApiBuildReferencedProjects>

<!--
Default folder to place code generated from Open API documents. Value is interpreted relative to the project
folder, unless already an absolute path. Part of the default %(OutputPath) metadata of @(OpenApiReference) and
@(OpenApiProjectReference) items.
-->
<OpenApiDefaultOutputDirectory
Condition="'$(OpenApiDefaultOutputDirectory)' == ''">$(BaseIntermediateOutputPath)</OpenApiDefaultOutputDirectory>
<OpenApiCodeDirectory
Condition="'$(OpenApiCodeDirectory)' == ''">$(BaseIntermediateOutputPath)</OpenApiCodeDirectory>
</PropertyGroup>

<!--
Expand All @@ -65,24 +67,28 @@
<OpenApiReference>
<!-- Name of the class to generate. Defaults to match filename in %(OutputPath). -->
<ClassName />

<!--
Code generator to use. Required and must end with "CSharp" or "TypeScript" (the currently-supported target
languages) unless %(OutputPath) is set. Builds will invoke a target named "Generate%(CodeGenerator)" to do
actual code generation.
-->
<CodeGenerator>NSwagCSharp</CodeGenerator>

<!-- Namespace to contain generated class. Default is $(RootNamespace). -->
<Namespace />

<!--
Options to pass to the code generator target then (likely) added to a tool's command line. Value is passed
along to the code generator but otherwise unused in this package.
-->
<Options>$(OpenApiDefaultGeneratorOptions)</Options>
<Options>$(OpenApiGenerateCodeOptions)</Options>

<!--
Path to place generated code. Code generator may interpret path as a filename or directory. Default filename or
folder name is %(Filename)Client.[cs|ts]. Filenames and relative paths (if explicitly set) are combined with
$(OpenApiDefaultOutputDirectory). Final value (depending on $(OpenApiDefaultOutputDirectory)) is likely to be
a path relative to the client project.
$(OpenApiCodeDirectory). Final value (depending on $(OpenApiCodeDirectory)) is likely to be a path relative to
the client project.
-->
<OutputPath />
</OpenApiReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<Project>
<!-- Internal settings. Not intended for customization. -->
<PropertyGroup>
<GenerateOpenApiReferenceCodeDependsOn>
<GenerateOpenApiCodeDependsOn>
_GenerateErrorsForOldItems;
_CreateOpenApiReferenceItemsForOpenApiProjectReferences;
_GetMetadataForOpenApiReferences;
_GenerateOpenApiReferenceCode;
_GenerateOpenApiCode;
_CreateCompileItemsForOpenApiReferences
</GenerateOpenApiReferenceCodeDependsOn>
</GenerateOpenApiCodeDependsOn>
</PropertyGroup>

<!-- OpenApiProjectReference support. -->
Expand Down Expand Up @@ -56,7 +56,7 @@
<GetFileReferenceMetadata Inputs="@(OpenApiReference)"
Extension="$(DefaultLanguageSourceExtension)"
Namespace="$(RootNamespace)"
OutputDirectory="$(OpenApiDefaultOutputDirectory)">
OutputDirectory="$(OpenApiCodeDirectory)">
<Output TaskParameter="Outputs" ItemName="_Temporary" />
</GetFileReferenceMetadata>

Expand All @@ -73,16 +73,16 @@
</GetCurrentItems>
</Target>

<Target Name="_InnerGenerateOpenApiReferenceCode" DependsOnTargets="_GetCurrentOpenApiReference;$(GeneratorTarget)" />
<Target Name="_InnerGenerateOpenApiCode" DependsOnTargets="_GetCurrentOpenApiReference;$(GeneratorTarget)" />

<Target Name="_GenerateOpenApiReferenceCode"
Condition="$(OpenApiGenerateAtDesignTime) OR ('$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true')"
<Target Name="_GenerateOpenApiCode"
Condition="$(OpenApiGenerateCodeAtDesignTime) OR ('$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true')"
Inputs="@(OpenApiReference)"
Outputs="%(OutputPath)">
<MSBuild Projects="$(MSBuildProjectFullPath)"
BuildInParallel="$(BuildInParallel)"
Properties="GeneratorTargetPath=%(OpenApiReference.OutputPath);GeneratorTarget=Generate%(CodeGenerator);GeneratorMetadata=%(SerializedMetadata)"
Targets="_InnerGenerateOpenApiReferenceCode" />
Targets="_InnerGenerateOpenApiCode" />
</Target>

<Target Name="_CreateCompileItemsForOpenApiReferences" Condition="'@(OpenApiReference)' != ''">
Expand Down Expand Up @@ -136,12 +136,12 @@

<!-- Main code generation entry point. -->

<Target Name="GenerateOpenApiReferenceCode" DependsOnTargets="$(GenerateOpenApiReferenceCodeDependsOn)" />
<Target Name="GenerateOpenApiCode" DependsOnTargets="$(GenerateOpenApiCodeDependsOn)" />

<!-- Unless this is an inner build or default timing is disabled, tie code generation into the build. -->

<Target Name="_TieInGenerateOpenApiReferenceCode"
<Target Name="_TieInGenerateOpenApiCode"
BeforeTargets="BeforeCompile"
Condition=" '$(OpenApiGenerateBeforeCompile)' == 'true' AND ('$(TargetFramework)' == '' OR '$(TargetFrameworks)' == '') "
DependsOnTargets="GenerateOpenApiReferenceCode" />
Condition=" '$(OpenApiGenerateCodeOnBuild)' == 'true' AND ('$(TargetFramework)' == '' OR '$(TargetFrameworks)' == '') "
DependsOnTargets="GenerateOpenApiCode" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project>
<Target Name="GenerateOpenApiReferenceCode">
<Target Name="GenerateOpenApiCode">
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="GenerateOpenApiReferenceCode"
Targets="GenerateOpenApiCode"
Properties="TargetFramework=$(TargetFrameworks.Split(';')[0])"
RemoveProperties="RuntimeIdentifier" />
</Target>

<Target Name="_TieInGenerateOpenApiReferenceCode"
<Target Name="_TieInGenerateOpenApiCode"
BeforeTargets="BeforeCompile"
Condition=" ''$(OpenApiGenerateBeforeCompile)' == 'true' "
DependsOnTargets="GenerateOpenApiReferenceCode" />
Condition=" ''$(OpenApiGenerateCodeOnBuild)' == 'true' "
DependsOnTargets="GenerateOpenApiCode" />
</Project>

0 comments on commit 154deaa

Please sign in to comment.