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

Make it easy to include NetCore-only and NetFx-only files #10572

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

DustinCampbell
Copy link
Member

This migrates a change from Razor tooling and makes it available for all the Razor repo. Essentially, this allows a C# file to be compiled for just .NET Framework or .NET Core by its name or the name of the folder its contained in.

  1. Naming a C# file as .NetCore.cs or .NetFx.cs it will compile only for NetCore or NetFx, respectively.
  2. C# files placed in a folder called NetCore or NetFx will compile only for NetCore or NetFx, respectively.
  3. C# files placed in a folder whose name ends in _NetCore or _NetFx will compile only for NetCore or NetFx, respectively.

This makes it clear from the Solution Explorer if there are files that only compile for one target or another without having to open them and look at #if..#endif blocks.

This migrates a change from Razor tooling and makes it available for all the Razor repo. By naming a C# file as `.NetCore.cs` or `.NetFx.cs` it will compile _only_ for NetCore or NetFx, respectively. Alternatively, files can be placed in a folder called `NetCore` or `NetFx`, or with a name that ends in `_NetCore` or `_NetFx` to control the target framework they're compiled for. This makes it clearer from the Solution Explorer if there are files that only compile for one target or another rather than having to look at `#if..#endif` blocks.
@DustinCampbell DustinCampbell requested a review from a team as a code owner July 2, 2024 19:58
@DustinCampbell DustinCampbell merged commit f648105 into dotnet:main Jul 2, 2024
12 checks passed
@DustinCampbell DustinCampbell deleted the tfm-only-files branch July 2, 2024 22:36
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 2, 2024
@RikkiGibson RikkiGibson modified the milestones: Next, 17.12 Preview 1 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants