Skip to content
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

aspnetcore-tooling migration #21581

Merged
merged 411 commits into from
May 27, 2020
Merged

Conversation

JunTaoLuo
Copy link
Contributor

@JunTaoLuo JunTaoLuo commented May 7, 2020

Addresses #21145.

The source code was migrated in the https://github.com/dotnet/aspnetcore/tree/johluo/tooling-soncolidation-source-2 branch and this branch contains the fixes to build and test the new migrated razor packages.

ajaybhargavb and others added 30 commits May 1, 2019 14:53
\n\nCommit migrated from dotnet/razor@c5a7e9e
Fix invalid cast in non-generic parameterized ChildContent\n\nCommit migrated from dotnet/razor@e622d7c
* Fix invalid cast in non-generic parameterized ChildContent

* Fix crash in functions block
\n\nCommit migrated from dotnet/razor@0acc18b
# Conflicts:
#	src/Razor/src/Microsoft.AspNetCore.Razor.Language/Extensions/FunctionsDirectivePass.cs
#	src/Razor/test/RazorLanguage.Test/Extensions/FunctionsDirectivePassTest.cs
\n\nCommit migrated from dotnet/razor@de4b0c7
- Diagnostics were not being raised to the `RazorSyntaxTree` and weren't being ordered on final output. This resulted in some of our tests missing the fact that certain cases were generating errors.
- Made all three phases of Razor parsing order their diagnostics.
- Added `GetAllDiagnostics` methods to `SyntaxNode`s to be more consistent with IR documents.
- Updated test files. In some cases new errors were found because we're now lifting them to the `SyntaxTree`, in most others the errors are re-ordered.

**Note: In end-to-end scenarios diagnostics were not hidden, only unordered. The IR phase would find nested/hidden documents and lift them to the IR/C# documents.**
\n\nCommit migrated from dotnet/razor@ef31a96
- This adds support for C# single line variations of: `if`, `for`, `foreach`, `do`, `while`, `lock` and `using`.
- Turns out the existing parser had 99% of the support for these scenarios already. Therefore, in this change set I went ahead and added exhaustive tests to verify things worked end-to-end.
- Added a restriction to single line markup to not allow markup in single line control flow statements. Updated resx to provide a better error message for cases when users do use markup in single line control flow statements.

dotnet/razor#9637
\n\nCommit migrated from dotnet/razor@cf474c9
- This is a pre-requisite to properly warnings users about TagHelpers in code blocks. With this change VS indicates that there's an asynchronous operation happening in a code block but because the code is auto-generated it happens behind the scenes and therefore always gets logged as a line 1 error (unusable). Therefore, to fix this issue there will be a partner PR that will go out in AspNetCore that adds analyzer errors for cases where `__tagHelperRunner.RunAsync` exists in code blocks that do not return `Task` and are not marked with `async` properly.
- Updated test files to reflect the new TagHelper codegen at design time.
- Note: This doesn't solve the `~/` case that will be in a follow up PR.

aspnet/AspNetCoredotnet/aspnetcore-tooling#8630
\n\nCommit migrated from dotnet/razor@17af3ef
* Do build time discovery of MVC ApplicationParts
\n\nCommit migrated from dotnet/razor@e79d560
… `$(GetCopyToOutputDirectoryItemsDependsOn)` instead of `$(GetCopyToOutputDirectoryItems)`) (dotnet/razor#603)

The intention here would have been to add to the existing GetCopyToOutputDirectoryItemsDependsOn property, defined in Microsoft.Common.Targets. Instead what was happening is that it was being completely overwitten with the _RazorGetCopyToOutputDirectoryItems entry, given that $(GetCopyToOutputDirectoryItems) doesn't exist as a property and must have been a typo (it exists as a task, not a property).

An effect of this bug was that the `AssignTargetPaths` target is not always executed before the `GetCopyToOutputDirectoryItems` target, which should explicitly depend on it. `AssignTargetPaths` is responsible for populating the `ContentWithTargetPath` itemgroup. Left empty, it appears to `GetCopyToOutputDirectoryItems` task that there are no Content files to copy to the final output directory, when in fact there are.\n\nCommit migrated from dotnet/razor@4597bc3
* Move the globs from the project system into the Razor SDK on a separate file that can be imported by itself.
* Import the file conditionally based on the EnableRazorContent property\n\nCommit migrated from dotnet/razor@62e33da
…zor#580)

* Imports static assets from packages containing custom msbuild
  targets defining a StaticWebAsset item group.
* Generates an embeds a manifest into the application assembly
  that contains a list of paths to the content roots of the
  assets defined in the packages custom msbuild targets.\n\nCommit migrated from dotnet/razor@8e70013
…otnet/razor#597)

* Directive attributes part 1: Support parameters in bound attributes

* update

* Fix test

* feedback

* Updated design

* Do case sensitive comparison

* more

* Bug fix
\n\nCommit migrated from dotnet/razor@9bbf240
This came up in the context of discussion around aspnet/AspNetCoredotnet/aspnetcore-tooling#5071.

Browsers use a 'first attribute wins' rule for evaluating attributes and
building the DOM - though duplicate attributes are considered to be a
spec violation.

Blazor wants to use 'last attribute wins' rules because that's most
sensible when you consider evaluation order and splatting.

This means that we have to have the markup block pass do the same thing
as the Blazor runtime when duplicates appear. However, since this is a
spec violation I'm proposing that we just make it an error (like we do
for malformed tags). There's no useful purpose for duplicate attributes
since browsers ignore it.

Since we're not going to allow this for elements. Let's go all of the
way and block it for components as well. And while we're here, lets
block some of the invalid cases where users try to mix onchange and
bind. These don't work today, so we should make them an error. If we
decide to add support for this case to the runtime that would require
compiler work anyway.
\n\nCommit migrated from dotnet/razor@0c59ca5
* Specify UpToDateReloadFileTypes

Specify a list of file extensions that VS will monitor for file changes to reload the app.
Includes .razor and .cshtml files.

\n\nCommit migrated from dotnet/razor@9a96412
…et/razor#605)

* Define static web assets in the current project
  * These are assets under the wwwroot folder.
  * By convention, the base path for these assets is `_content/<<PackageId>>`
    with spaces and dots removed and all characters lower-cased.
* Retrieve static web assets from referenced projects\n\nCommit migrated from dotnet/razor@50646aa
* Support parsing directive attributes
\n\nCommit migrated from dotnet/razor@5eb8ef4
* Adds support for publishing static web assets
* At publish time, it copies all the referenced assets from referenced
  projects and packages into their final locations.
* Automatically pack static web assets for consumption
* Generate Microsoft.AspNetCore.StaticWebAssets.props and pack it into
  build\Microsoft.AspNetCore.StaticWebAssets.props
* Generate `<<PackageId>>.props` and pack it into `build\<<PackageId>>.props`
  importing Microsoft.AspNetCore.StaticWebAssets.props
* Generate `<<PackageId>>.props` and pack it into buildMultiTargeting\`<<PackageId>>.props`
  importing `build\<<PackageId>>.props`
* Generate `<<PackageId>>.props` and pack it into buildTransitive\`<<PackageId>>.props`
  importing buildMultiTargeting\`<<PackageId>>.props`
* Pack all the static web assets from the current project into `staticwebassets\**`\n\nCommit migrated from dotnet/razor@87817be
…r#639)

* Allow UpToDateReloadFileTypes to be modified by packages

* Allow file watching with dotnet-watch
\n\nCommit migrated from dotnet/razor@fbcd0c2
…zor#638)

* Use an explicit intermediate node for directive attributes

* More cleanup
\n\nCommit migrated from dotnet/razor@f8d7f4c
- WTE needs a way to detect if a `TagHelperDescriptor` is a component based `TagHelper` in order to turn features like validation, completion etc. on/off.
- Updated tests to add verification points for the new `IsRazorComponentTagHelper` method.
\n\nCommit migrated from dotnet/razor@6fcd12e
…ifest

* Stops embedding the manifest in favor of using a file copied to the output folder.
\n\nCommit migrated from dotnet/razor@4c65b19
@JunTaoLuo JunTaoLuo force-pushed the johluo/tooling-consolidation-fixup branch 3 times, most recently from c8daeab to e12fec5 Compare May 26, 2020 03:58
@JunTaoLuo
Copy link
Contributor Author

@dougbu @pranavkm I think I addressed all the feedback, can you take another look?

<PackageReference Include="Microsoft.NET.Sdk.Razor" PrivateAssets="All" Version="$(MicrosoftNETSdkRazorPackageVersion)" IsImplicitlyDefined="true" />
</ItemGroup>
<Choose>
<When Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

@dougbu
Copy link
Member

dougbu commented May 26, 2020

@JunTaoLuo I'll likely look at this tomorrow, when I'm not on-call anymore.

@JunTaoLuo
Copy link
Contributor Author

@dougbu I'd like to get this in asap since I need to also react to it in aspnetcore-tooling and I'll need to complete those before preview6 branching. If the build passes I'll likely just merge it and address remaining comments you have separately.

@JunTaoLuo JunTaoLuo force-pushed the johluo/tooling-consolidation-fixup branch from c0e028e to 50f3a16 Compare May 26, 2020 19:32
@JunTaoLuo JunTaoLuo changed the base branch from johluo/tooling-soncolidation-source-2 to master May 26, 2020 21:58
@dougbu
Copy link
Member

dougbu commented May 26, 2020

@dougbu I'd like to get this in asap since I need to also react to it in aspnetcore-tooling and I'll need to complete those before preview6 branching. If the build passes I'll likely just merge it and address remaining comments you have separately.

Not sure I get how 1 day will mess this up. Could you clarify?

In addition, merging the two branches made the changes impossible to view in GitHub. How would I verify the changes you made in response to my comments?

@JunTaoLuo
Copy link
Contributor Author

I'm trying to get this done as soon as possible. I don't want to jeopardize this work given that there's reactionary changes in aspnetcore-tooling and a mop-up merge. To review, you'd want to take a look at the individual commit. 50f3a16. I've squashed already, so you'll need to review the entire commit again.

@JunTaoLuo
Copy link
Contributor Author

Note that the CI has been terribly slow so any change takes a few hours to verify so that's why I want to get things merged. I feel waiting even a day is risky.

@JunTaoLuo JunTaoLuo requested a review from dougbu May 27, 2020 03:09
@JunTaoLuo JunTaoLuo dismissed dougbu’s stale review May 27, 2020 03:10

Any lingering comments will be addressed in a mop up PR.

@JunTaoLuo JunTaoLuo merged commit 66dd491 into master May 27, 2020
@JunTaoLuo JunTaoLuo deleted the johluo/tooling-consolidation-fixup branch May 27, 2020 03:10
Copy link
Member

@dougbu dougbu left a comment

Choose a reason for hiding this comment

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

Looks like a few issues remain from my previous review. I don't see anything new other than the downstream build failures.

@@ -149,7 +149,7 @@ stages:
$(_InternalRuntimeDownloadArgs)
displayName: Build x86

# This is in a separate build step with -forceCoreMsbuild to workaround MAX_PATH limitations - https://github.com/Microsoft/msbuild/issues/53
# This is in a separate build step with to workaround MAX_PATH limitations - https://github.com/Microsoft/msbuild/issues/53
Copy link
Member

Choose a reason for hiding this comment

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

Bad merge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />

<PropertyGroup>
<DisablePubternalApiCheck>true</DisablePubternalApiCheck>
Copy link
Member

Choose a reason for hiding this comment

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

Actually, this shouldn't be necessary at all because the $(DisablePubternalApiCheck) property is only read in the root Directory.Build.props and that check also excludes test projects.

@@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<DisablePubternalApiCheck>true</DisablePubternalApiCheck>
Copy link
Member

Choose a reason for hiding this comment

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

Again, this change shouldn't be necessary given how the root Directory.Build.props uses this property.


<PropertyGroup>
<RazorSdkDirectoryRoot>${ArtifactsBinDir}Microsoft.NET.Sdk.Razor\${Configuration}\sdk-output\</RazorSdkDirectoryRoot>
</PropertyGroup>
Copy link
Member

Choose a reason for hiding this comment

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

The logic in eng/targets/CSharp.Common.props also uses $(Configuration) as an input. Why must this new <Import/> and <PropertyGroup/> be repeated six times? The logic will need to change and having it spread out like this will cause problems in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.