Skip to content

Commit b5fb7cb

Browse files
committed
Automatically add NullableAttributes support to netstandard2.0 projects that enable NRT.
1 parent 6182baf commit b5fb7cb

File tree

6 files changed

+12
-20
lines changed

6 files changed

+12
-20
lines changed

Directory.Build.targets

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
33

4+
<!-- Automatically add NRT attribute support for netstandard2.0 projects using NRT -->
5+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' AND '$(Nullable)' == 'enable' ">
6+
<Compile Include="$(MSBuildThisFileDirectory)src\utils\NullableAttributes.cs">
7+
<Link>NullableAttributes.cs</Link>
8+
</Compile>
9+
</ItemGroup>
10+
11+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' AND '$(Nullable)' == 'enable' ">
12+
<DefineConstants>$(DefineConstants);INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
13+
</PropertyGroup>
14+
415
<!-- Add Roslyn analyzers NuGet to all projects -->
516
<ItemGroup Condition=" '$(DisableRoslynAnalyzers)' != 'True' ">
617
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">

src/Java.Interop.Localization/Java.Interop.Localization.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<LangVersion>8.0</LangVersion>
66
<Nullable>enable</Nullable>
7-
<DefineConstants>INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
87
<NeutralLanguage>en</NeutralLanguage>
98
<SignAssembly>true</SignAssembly>
109
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
@@ -20,10 +19,6 @@
2019
</Compile>
2120
</ItemGroup>
2221

23-
<ItemGroup>
24-
<Compile Include="..\utils\NullableAttributes.cs" />
25-
</ItemGroup>
26-
2722
<ItemGroup>
2823
<EmbeddedResource Update="Resources.resx">
2924
<Generator>PublicResXFileCodeGenerator</Generator>

src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<LangVersion>8.0</LangVersion>
66
<Nullable>enable</Nullable>
7-
<DefineConstants>INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
87
<SignAssembly>true</SignAssembly>
98
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
109
</PropertyGroup>
@@ -17,10 +16,6 @@
1716

1817
<Import Project="..\..\build-tools\scripts\cecil.projitems" />
1918

20-
<ItemGroup>
21-
<Compile Include="..\utils\NullableAttributes.cs" />
22-
</ItemGroup>
23-
2419
<ItemGroup>
2520
<ProjectReference Include="..\Java.Interop.Localization\Java.Interop.Localization.csproj" />
2621
<ProjectReference Include="..\Java.Interop.Tools.Diagnostics\Java.Interop.Tools.Diagnostics.csproj" />

src/Java.Interop.Tools.Diagnostics/Java.Interop.Tools.Diagnostics.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<LangVersion>8.0</LangVersion>
66
<Nullable>enable</Nullable>
7-
<DefineConstants>INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
87
<SignAssembly>true</SignAssembly>
98
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
109
</PropertyGroup>
@@ -17,10 +16,6 @@
1716

1817
<Import Project="..\..\build-tools\scripts\cecil.projitems" />
1918

20-
<ItemGroup>
21-
<Compile Include="..\utils\NullableAttributes.cs" />
22-
</ItemGroup>
23-
2419
<ItemGroup>
2520
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
2621
</ItemGroup>

src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
<Compile Include="..\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings\JavaNativeTypeManager.cs">
2424
<Link>JavaNativeTypeManager.cs</Link>
2525
</Compile>
26-
<Compile Include="..\utils\NullableAttributes.cs">
27-
<Link>NullableAttributes.cs</Link>
28-
</Compile>
2926
</ItemGroup>
3027

3128
<ItemGroup>

src/Java.Interop/Java.Interop.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</PropertyGroup>
2222
<Import Project="..\..\TargetFrameworkDependentValues.props" />
2323
<PropertyGroup>
24-
<DefineConstants>INTEROP;FEATURE_JNIOBJECTREFERENCE_INTPTRS;INTERNAL_NULLABLE_ATTRIBUTES;$(JavaInteropDefineConstants)</DefineConstants>
24+
<DefineConstants>INTEROP;FEATURE_JNIOBJECTREFERENCE_INTPTRS;$(JavaInteropDefineConstants)</DefineConstants>
2525
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
2626
<OutputPath>$(ToolOutputFullPath)</OutputPath>
2727
<DocumentationFile>$(ToolOutputFullPath)Java.Interop.xml</DocumentationFile>
@@ -38,7 +38,6 @@
3838
<DefineConstants>FEATURE_JNIENVIRONMENT_JI_PINVOKES;$(DefineConstants)</DefineConstants>
3939
</PropertyGroup>
4040
<ItemGroup>
41-
<Compile Condition=" '$(TargetFramework)' == 'netstandard2.0' " Include="..\utils\NullableAttributes.cs" />
4241
<Compile Remove="Java.Interop\JniLocationException.cs" />
4342
</ItemGroup>
4443
<PropertyGroup>

0 commit comments

Comments
 (0)