Skip to content

Rename all the service reference things #9559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 22, 2019

Conversation

dougbu
Copy link
Contributor

@dougbu dougbu commented Apr 19, 2019

Also

@dougbu
Copy link
Contributor Author

dougbu commented Apr 19, 2019

Pity GitHub doesn't recognize the .props and .targets files were renamed before things in them were renamed. If you're primarily interested in the delta from existing code, I suggest

git checkout dougbu/code.generation.renames.7492
git show --find-renames=20 -- *.props
git show --find-renames=20 -- *.targets

@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Apr 19, 2019
@dougbu
Copy link
Contributor Author

dougbu commented Apr 19, 2019

@natemcmaster I know you found one typo. Anything else ?

@dougbu dougbu force-pushed the dougbu/code.generation.renames.7492 branch from 7e28551 to ab36245 Compare April 19, 2019 22:01
Copy link
Contributor

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only had time to look at Microsoft.Extensions.ApiDescription.Client.targets.

@dougbu
Copy link
Contributor Author

dougbu commented Apr 21, 2019

@glennc this PR partially addresses #7491 because it provides a default %(CodeGenerator) value. Does not add proposed %(Language) metadata.

dougbu added 3 commits April 21, 2019 19:03
- #7492
- remove document generation from client project; will be included in Web API project infrastructure (coming soon)

Also
- provide `%(FirstForGenerator)` metadata, #4916
- add `$(OpenApiGenerateAtDesignTime)` property (default `true` for now), #4944
- generate code in `obj` directory by default, #4945
- adjust eng/ProjectReferences.props to new project name
- simplify `_CreateOpenApiReferenceItemsForOpenApiProjectReferences` target e.g. remove batching
- simplify item de-duplication in `_CreateCompileItemsForServiceFileReferences` target i.e. use `Remove` attribute
  - also handle `.tsx` files in this target
- remove malformed `Exists(...)` check in `_GenerateOpenApiReferenceCode` target

nits:
- remove a useless `StringBuilder.Append(...)` call
- remove `%(OpenApiProjectReference.SourceProject)` metadata, duplicated `%(OriginalItemSpec)`
- be more consistent about using element syntax for item metadata
@dougbu dougbu force-pushed the dougbu/code.generation.renames.7492 branch from ab36245 to 2cff475 Compare April 22, 2019 02:03
@dougbu dougbu requested a review from a team as a code owner April 22, 2019 02:03
- set `%(FirstForGenerator)` based on `%(CodeGenerator)` metadata

Side note, PR fixes include
- add `%(FirstForGenerator)` metadata, #4916
- add support for disabling design-time builds, #4944
- change default output directory to `obj/`, #4945 1 of 2 (remainder will come with #8242)
- provide a default `%(CodeGenerator)` value, ##7491 1 of 2 (remainder will come in next milestone)

<Compile Include="@(_Files)"
Exclude="@(Compile)"
Condition="'$(DefaultLanguageSourceExtension)' != '.ts' AND '%(_Files.OutputPathExtension)' == '$(DefaultLanguageSourceExtension)'">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we tested this with F# projects? If not, should we limit this to 'Condition="'$(Language)'=='C#'"`?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is correct because compiled languages other than TypeScript are not mixed into other projects. That is, this is about the exception to normal mono-language projects.

Do not change %(ReferenceOutputAssembly) if project contains duplicate @(ProjectReference) and
@(OpenApiProjectReference) items.
-->
<ProjectReference Include="@(OpenApiProjectReference)" Exclude="@(ProjectReference)">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work if the project have different TFMs? Like does it work if you reference a netcoreapp project from a netstandard project? I know we struggled with this when we were authoring test projects in Razor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work perfectly yet and will be refined. As-is, it brings a large reliability improvement over explicit <MSBuild /> tasks to restore and build the server project.

For later consideration, could you point me to the Razor solution to this issue?

<NoWarn>NU1702</NoWarn>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Update="@(OpenApiProjectReference)">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to inline this with the previous include?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when @(ProjectReference) and @(OpenApiProjectReference) overlap we need to get the documents. The previous element is about the non-overlapping case and this covers everything.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSBuild and the SDK don't handle duplicate <ProjectReference> items well. This can cause some strange behaviors such as dotnet/msbuild#2688. Consider making this overlap an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two blocks are separate specifically to avoid creating duplicate <ProjectReference> items. Why make overlap between @(ProjectReference) and @(OpenApiProjectReference) an error with that in place?

@@ -21,9 +21,5 @@
<file src="buildMultiTargeting\*" target="buildMultiTargeting" />
<file src="bin\$configuration$\net461\Microsoft.Extensions.ApiDescription.Tasks.*" target="tasks\net461" />
<file src="bin\$configuration$\netstandard2.0\Microsoft.Extensions.ApiDescription.Tasks.*" target="tasks\netstandard2.0" />
<file src="..\..\dotnet-getdocument\src\bin\$configuration$\netcoreapp2.1\publish\*.*" target="tools" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They aren't necessary with the new client / server split. The tool will come back in Microsoft.Extensions.ApiDescription.Server

</GetFileReferenceMetadata>

<ItemGroup>
<OpenApiReference Remove="@(OpenApiReference)" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a different itemgroup rather than re-using OpenApiReference? It would be easier to debug this and wouldn't modify a user specified item.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is intended to flow @(OpenApiProjectReference) items into @(OpenApiReference). Besides, modifying user-specified items e.g. @(Compile) is just normal.

Copy link
Contributor

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few suggestions:

absolute path.
-->
<OpenApiDefaultOutputDirectory
Condition="'$(OpenApiDefaultOutputDirectory)' == ''">$(BaseIntermediateOutputPath)</OpenApiDefaultOutputDirectory>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - BaseIntermediateOutputPath might not be fully set when this file is evaluated. Would recommend moving this to a .targets file instead. BaseIntermediateOutputPath isn't defined until Microsoft.NET.DefaultOutputPaths.targets is evaluated, which happens at the end of project evaluation. Props file evaluation happens near the beginning of project eval.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it's working at the moment. I'll move it if we see issues or if I otherwise must update this PR.

<NoWarn>NU1702</NoWarn>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Update="@(OpenApiProjectReference)">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSBuild and the SDK don't handle duplicate <ProjectReference> items well. This can cause some strange behaviors such as dotnet/msbuild#2688. Consider making this overlap an error.

@dougbu dougbu merged commit ce8f053 into master Apr 22, 2019
@dougbu dougbu deleted the dougbu/code.generation.renames.7492 branch April 22, 2019 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants