Skip to content

Commit

Permalink
Fix some compiler errors that can occur with specific project setups
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeca committed Nov 9, 2023
1 parent 8148f98 commit d75e0cb
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Example:
#pragma warning disable

#if TASKSEXTENSIONSREFERENCED && (NETFRAMEWORK || NETSTANDARD2_0 || NETCOREAPP2_0)
#if TASKSEXTENSIONSREFERENCED && MEMORYREFERENCED && (NETFRAMEWORK || NETSTANDARD2_0 || NETCOREAPP2_0)

using System;
using System.Buffers;
Expand Down
4 changes: 4 additions & 0 deletions src/Polyfill/Nullability/NullabilityInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

using System.Linq;
using System.Diagnostics.CodeAnalysis;

// Some code bases define their own Debug class, which can cause clashes and compile errors if we aren't explicit here
using Debug = System.Diagnostics.Debug;

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

Expand Down
4 changes: 4 additions & 0 deletions src/Polyfill/Nullability/NullabilityInfoContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

using System.Linq;
using System.Diagnostics.CodeAnalysis;

// Some code bases define their own Debug class, which can cause clashes and compile errors if we aren't explicit here
using Debug = System.Diagnostics.Debug;

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

Expand Down
4 changes: 4 additions & 0 deletions src/Polyfill/PolyfillExtensions_Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

static partial class PolyfillExtensions
{
#if MEMORYREFERENCED

/// <summary>
/// Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by
/// the number of bytes read, and monitors cancellation requests.
Expand Down Expand Up @@ -64,6 +66,8 @@ public static ValueTask WriteAsync(
return new(target.WriteAsync(segment.Array!, segment.Offset, segment.Count, cancellationToken));
}

#endif

/// <summary>
/// Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified
/// cancellation token. Both streams positions are advanced by the number of bytes copied.
Expand Down
2 changes: 1 addition & 1 deletion src/Polyfill/PolyfillExtensions_TextReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

static partial class PolyfillExtensions
{
#if TASKSEXTENSIONSREFERENCED && (NETFRAMEWORK || NETSTANDARD2_0 || NETCOREAPP2_0)
#if TASKSEXTENSIONSREFERENCED && MEMORYREFERENCED && (NETFRAMEWORK || NETSTANDARD2_0 || NETCOREAPP2_0)
/// <summary>
/// Asynchronously reads the characters from the current stream into a memory block.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Polyfill/PolyfillExtensions_TextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#pragma warning disable

#if TASKSEXTENSIONSREFERENCED && (NETFRAMEWORK || NETSTANDARD2_0 || NETCOREAPP2_0)
#if TASKSEXTENSIONSREFERENCED && MEMORYREFERENCED && (NETFRAMEWORK || NETSTANDARD2_0 || NETCOREAPP2_0)

using System;
using System.Buffers;
Expand Down
4 changes: 4 additions & 0 deletions src/Tests/NullabilitySync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public async Task Run()
using System.Linq;
using System.Diagnostics.CodeAnalysis;
// Some code bases define their own Debug class, which can cause clashes and compile errors if we aren't explicit here
using Debug = System.Diagnostics.Debug;
""";

var suffix = """
Expand Down

0 comments on commit d75e0cb

Please sign in to comment.