-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some compiler errors that can occur with specific project setups
- Loading branch information
Showing
11 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
|
||
// Test to make sure there are no clashes in the Polyfill code with classes that might be defined in user code. | ||
// | ||
// Some codebases, for better or for worse, define classes with names that match common classes in the base | ||
// .NET libraries, like "Debug". This works find in those codebases because they are usually contained in the | ||
// same namespace, or are guarded in some other way. But if a Polyfill attribute is imported and uses code like: | ||
// Debug.Assert(genericParameter.IsGenericParameter); | ||
// instead of a fully qualified name like: | ||
// System.Debug.Assert(genericParameter.IsGenericParameter); | ||
// then users of Polyfill will get errors like the following, which they can't easily fix: | ||
// 'Debug' does not contain a definition for 'Assert' | ||
// | ||
// So, this file defines a custom Debug class to make sure that Polyfill code doesn't clash with user code. | ||
|
||
class Debug | ||
{ | ||
public static void Log(string content) => Console.WriteLine(content); | ||
|
||
public static void Log(ConsoleColor color, string content) | ||
{ | ||
Console.ForegroundColor = color; | ||
Console.WriteLine(content); | ||
Console.ResetColor(); | ||
} | ||
|
||
public static void LogWarning(string content) => Log(ConsoleColor.Yellow, content); | ||
public static void LogError(string content) => Log(ConsoleColor.Red, content); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/ConsumeTasksWithNoMemory/ConsumeTasksWithNoMemory.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<!-- This project is specifically designed to guard against a miscompile where System.Threading.Tasks.Extensions is referenced, but System.Memory is not. --> | ||
<!-- <PackageReference Include="System.Memory" Version="4.5.5" Condition="$(TargetFramework) != '.NETStandard' or $(TargetFrameworkIdentifier) == '.NETFramework' or $(TargetFramework.StartsWith('netcoreapp'))" /> --> | ||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" Condition="$(TargetFramework) == 'netstandard2.0' or $(TargetFramework) == 'netcoreapp2.0' or $(TargetFrameworkIdentifier) == '.NETFramework'" /> | ||
<Compile Include="..\Polyfill\*.cs"> | ||
<Link>Pollyfill\%(RecursiveDir)%(Filename).cs</Link> | ||
</Compile> | ||
<Compile Include="..\Polyfill\Nullable\*.cs"> | ||
<Link>Pollyfill\Nullable\%(RecursiveDir)%(Filename).cs</Link> | ||
</Compile> | ||
<Compile Include="..\Polyfill\Nullability\*.cs"> | ||
<Link>Pollyfill\Nullability\%(RecursiveDir)%(Filename).cs</Link> | ||
</Compile> | ||
<Compile Include="..\Polyfill\IndexRange\*.cs"> | ||
<Link>Pollyfill\IndexRange\%(RecursiveDir)%(Filename).cs</Link> | ||
</Compile> | ||
<Compile Include="..\Polyfill\Trimming\*.cs"> | ||
<Link>Pollyfill\Trimming\%(RecursiveDir)%(Filename).cs</Link> | ||
</Compile> | ||
<Compile Include="..\Polyfill\PlatformCompatibility\*.cs"> | ||
<Link>Pollyfill\PlatformCompatibility\%(RecursiveDir)%(Filename).cs</Link> | ||
</Compile> | ||
</ItemGroup> | ||
<Import Project="$(ProjectDir)..\Polyfill\Polyfill.props" /> | ||
<Import Project="$(ProjectDir)..\Polyfill\Polyfill.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters