Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,18 @@ If using Span APIs and consuming in a project that targets `netstandard`, `netfr
$(TargetFramework.StartsWith('netcoreapp2'))" />
```

#### Version Warning

If System.Memory is installed but the version is older than 4.5.5, a build warning `PolyfillMemoryVersion` will be raised. This is because older versions lack the required types for FeatureMemory to be enabled, which can cause polyfills to silently fail.

To suppress this warning:

```xml
<PropertyGroup>
<PolyfillNoWarnIncorrectVersion>true</PolyfillNoWarnIncorrectVersion>
</PropertyGroup>
```


### System.Threading.Tasks.Extensions

Expand Down
16 changes: 16 additions & 0 deletions src/ConsumeIncorrectVersions/ConsumeIncorrectVersions.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<NoWarn>$(NoWarn);PolyfillTargetsForNuget</NoWarn>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Memory" VersionOverride="4.5.4" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Consume\*.cs" />
</ItemGroup>
<Import Project="$(SolutionDir)\TestIncludes.targets" />
<Import Project="$(SolutionDir)\Polyfill\Polyfill.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<NoWarn>$(NoWarn);PolyfillTargetsForNuget</NoWarn>
<PolyfillNoWarnIncorrectVersion>true</PolyfillNoWarnIncorrectVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Memory" VersionOverride="4.5.4" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Consume\*.cs" />
</ItemGroup>
<Import Project="$(SolutionDir)\TestIncludes.targets" />
<Import Project="$(SolutionDir)\Polyfill\Polyfill.targets" />
</Project>
2 changes: 2 additions & 0 deletions src/Polyfill.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<Project Path="ConsumeCsLatest/ConsumeCsLatest.csproj" />
<Project Path="ConsumeCsLatestMajor/ConsumeCsLatestMajor.csproj" />
<Project Path="ConsumeEmbeddedLib/ConsumeEmbeddedLib.csproj" />
<Project Path="ConsumeIncorrectVersions/ConsumeIncorrectVersions.csproj" />
<Project Path="ConsumeIncorrectVersionsSuppress/ConsumeIncorrectVersionsSuppress.csproj" />
<Project Path="ConsumeIndirect/ConsumeIndirect.csproj" />
<Project Path="ConsumeLib/ConsumeLib.csproj" />
<Project Path="ConsumeNoOptional/ConsumeNoOptional.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/Polyfill/Polyfill.targets
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ For example:
<Warning
Code="PolyfillMemoryVersion"
Text="Polyfill: System.Memory version $(MemoryVersion) is installed, but 4.5.5 or newer is required to enable FeatureMemory."
Condition="'$(MemoryVersion)' != '' AND !$([MSBuild]::VersionGreaterThanOrEquals($(MemoryVersion), '4.5.5'))" />
Condition="'$(PolyfillNoWarnIncorrectVersion)' != 'true' AND '$(MemoryVersion)' != '' AND !$([MSBuild]::VersionGreaterThanOrEquals($(MemoryVersion), '4.5.5'))" />

<!-- The whole point of EmbeddedAttribute is to avoid the exposing the internal polyfilled APIs to consuming projects via IVT. -->
<Error Text="PolyPublic and PolyUseEmbeddedAttribute shouldn't be used together." Condition="'$(PolyPublic)' == 'true' AND '$(PolyUseEmbeddedAttribute)' == 'true'" />
Expand Down