-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Split dotnet/runtime-only downlevel LibraryImport support into its own source generator #106436
Changes from all commits
32288f8
68cbdb8
1bad185
1f2eea3
e50eeeb
69e4ae5
942be9b
323f12d
17502b8
f79555a
aab7b49
caca1aa
9aa80ad
81ddddd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,56 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<!-- Enable LibraryImportGenerator for CoreLib. --> | ||
<EnableLibraryImportGenerator Condition="'$(EnableLibraryImportGenerator)' == '' and | ||
'$(MSBuildProjectName)' == 'System.Private.CoreLib'">true</EnableLibraryImportGenerator> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<EnabledGenerators Include="LibraryImportGenerator" Condition="'$(EnableLibraryImportGenerator)' == 'true'" /> | ||
<!-- If the current project is not System.Private.CoreLib, we enable the LibraryImportGenerator source generator | ||
<!-- We enable the Downlevel LibraryImportGenerator | ||
when the project is a C# source or test project that: | ||
- doesn't target the a TFM that includes LibraryImportGenerator or | ||
- doesn't reference the live targeting pack (i.e. when inbox) and | ||
- references System.Private.CoreLib, or | ||
- references System.Runtime.InteropServices --> | ||
<EnabledGenerators Include="LibraryImportGenerator" | ||
- doesn't target the a TFM that includes LibraryImportGenerator --> | ||
<EnabledGenerators Include="DownlevelLibraryImportGenerator" | ||
Condition="'$(EnableLibraryImportGenerator)' == '' and | ||
( | ||
'$(IsSourceProject)' == 'true' or | ||
'$(IsTestProject)' == 'true' or | ||
'$(IsTestSupportProject)' == 'true' | ||
) and | ||
'$(MSBuildProjectExtension)' == '.csproj' and | ||
!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppMinimum)'))" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should just be |
||
|
||
<!-- We enable the LibraryImportGenerator source generator | ||
when the project is a C# source project that: | ||
- references System.Private.CoreLib directly | ||
- references System.Runtime.InteropServices directly and not through the live targeting pack (i.e. when inbox) --> | ||
<EnabledGenerators Include="LibraryImportGenerator" | ||
Condition="'$(EnableLibraryImportGenerator)' == '' and | ||
'$(IsSourceProject)' == 'true' and | ||
'$(MSBuildProjectExtension)' == '.csproj' and | ||
( | ||
!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) or | ||
( | ||
'$(DisableImplicitFrameworkReferences)' == 'true' and | ||
( | ||
'@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices'))' == 'true' or | ||
'@(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))' == 'true' | ||
'@(Reference->AnyHaveMetadataValue('Identity', 'System.Private.CoreLib'))' == 'true' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change looks wrong. System.Private.CoreLib is never a reference as it isn't part of the targeting pack. |
||
) | ||
) | ||
)" /> | ||
|
||
<!-- We enable the ComInterfaceGenerator source generator | ||
when the project is a C# source project that: | ||
- references System.Runtime.InteropServices directly and not through the live targeting pack (i.e. when inbox) --> | ||
<EnabledGenerators Include="ComInterfaceGenerator" | ||
Condition="'$(IsSourceProject)' == 'true' and | ||
'$(MSBuildProjectExtension)' == '.csproj' and | ||
( | ||
'$(DisableImplicitFrameworkReferences)' == 'true' and | ||
'@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices'))' == 'true' | ||
)" /> | ||
'$(MSBuildProjectExtension)' == '.csproj' and | ||
( | ||
'$(DisableImplicitFrameworkReferences)' == 'true' and | ||
'@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices'))' == 'true' | ||
)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'@(EnabledGenerators)' != '' and | ||
@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'LibraryImportGenerator')) and | ||
!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))"> | ||
@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'DownlevelLibraryImportGenerator'))"> | ||
<Compile Include="$(CoreLibSharedDir)System\Runtime\InteropServices\LibraryImportAttribute.cs" /> | ||
<Compile Include="$(CoreLibSharedDir)System\Runtime\InteropServices\StringMarshalling.cs" /> | ||
</ItemGroup> | ||
|
@@ -57,6 +62,11 @@ | |
ReferenceOutputAssembly="false" | ||
OutputItemType="Analyzer" | ||
SetConfiguration="Configuration=$(LibrariesConfiguration)" /> | ||
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\DownlevelLibraryImportGenerator\DownlevelLibraryImportGenerator.csproj" | ||
ReferenceOutputAssembly="false" | ||
OutputItemType="Analyzer" | ||
SetConfiguration="Configuration=$(LibrariesConfiguration)" | ||
Condition="@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'DownlevelLibraryImportGenerator'))" /> | ||
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj" | ||
ReferenceOutputAssembly="false" | ||
OutputItemType="Analyzer" | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this already existed before this change but it feels weird to special case CoreLib in here. Can we move this property into the shared CoreLib project instead?