diff options
author | Elinor Fung <elfung@microsoft.com> | 2021-11-17 19:12:15 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-17 19:12:15 +0300 |
commit | a508fb574ce40054ac67d38bfc110b1b42587cc8 (patch) | |
tree | a450d9acd6c85165e08d5cdb3f624da82c66c00a /eng/generators.targets | |
parent | de883e3b6fb4926a59d75c5dce6c734d0b92d4e1 (diff) |
[DllImportGenerator] Enable on projects without System.Memory and System.Runtime.CompilerServices.Unsafe (#61704)
Diffstat (limited to 'eng/generators.targets')
-rw-r--r-- | eng/generators.targets | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/eng/generators.targets b/eng/generators.targets index aec6e667a6e..4e7d7b99b44 100644 --- a/eng/generators.targets +++ b/eng/generators.targets @@ -10,10 +10,7 @@ <!-- If the current project is not System.Private.CoreLib, we enable the DllImportGenerator source generator when the project is a C# source project that either: - references System.Private.CoreLib, or - - references the following assemblies: - - System.Runtime.InteropServices - - System.Runtime.CompilerServices.Unsafe - - System.Memory --> + - references System.Runtime.InteropServices --> <EnabledGenerators Include="DllImportGenerator" Condition="'$(EnableDllImportGenerator)' == '' and '$(IsFrameworkSupportFacade)' != 'true' @@ -21,11 +18,7 @@ and '$(MSBuildProjectExtension)' == '.csproj' and ( ('@(Reference)' != '' - and @(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices')) - and (@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.CompilerServices.Unsafe')) - or ('@(ProjectReference)' != '' - and @(ProjectReference->AnyHaveMetadataValue('Identity', $([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'System.Runtime.CompilerServices.Unsafe', 'src', 'System.Runtime.CompilerServices.Unsafe.ilproj')))))) - and @(Reference->AnyHaveMetadataValue('Identity', 'System.Memory'))) + and @(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices'))) or ('@(ProjectReference)' != '' and @(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))))" /> <EnabledGenerators Include="DllImportGenerator" @@ -45,7 +38,19 @@ <!-- Only add the following files if we are on the latest TFM (that is, net7). --> <Compile Condition="'$(NetCoreAppCurrentTargetFrameworkMoniker)' == '$(TargetFrameworkMoniker)'" Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\GeneratedMarshallingAttribute.cs" /> - <Compile Condition="'$(NetCoreAppCurrentTargetFrameworkMoniker)' == '$(TargetFrameworkMoniker)'" Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\ArrayMarshaller.cs" /> + + <!-- Only add the following files if we are on the latest TFM (that is, net7) and the project is SPCL or has references to System.Runtime.CompilerServices.Unsafe and System.Memory --> + <Compile Condition="'$(NetCoreAppCurrentTargetFrameworkMoniker)' == '$(TargetFrameworkMoniker)' + and ( + '$(MSBuildProjectName)' == 'System.Private.CoreLib' + or '$(EnableDllImportGenerator)' == 'true' + or ('@(Reference)' != '' + and (@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.CompilerServices.Unsafe')) + or ('@(ProjectReference)' != '' + and @(ProjectReference->AnyHaveMetadataValue('Identity', $([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'System.Runtime.CompilerServices.Unsafe', 'src', 'System.Runtime.CompilerServices.Unsafe.ilproj')))))) + and @(Reference->AnyHaveMetadataValue('Identity', 'System.Memory'))) + or ('@(ProjectReference)' != '' + and @(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))))" Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\ArrayMarshaller.cs" /> </ItemGroup> <Target Name="ConfigureGenerators" |