Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some compiler errors that can occur with specific project setups (Memory references) #103

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

sbeca
Copy link
Contributor

@sbeca sbeca commented Nov 9, 2023

While testing Polyfill in a few different projects, I hit a few compiler errors which this PR attempts to resolve.

First, in a netstandard2.0 project that references System.Threading.Tasks.Extensions but doesn't reference System.Memory, I saw the following errors:

/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/PolyfillExtensions_TextWriter.cs(8,14): error CS0234: The type or namespace name 'Buffers' does not exist in the namespace 'System' (are you missing an assembly reference?)
/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/PolyfillExtensions_Stream.cs(33,9): error CS0246: The type or namespace name 'Memory<>' could not be found (are you missing a using directive or an assembly reference?)
/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/PolyfillExtensions_TextReader.cs(34,9): error CS0246: The type or namespace name 'Memory<>' could not be found (are you missing a using directive or an assembly reference?)
/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/PolyfillExtensions_Stream.cs(56,9): error CS0246: The type or namespace name 'ReadOnlyMemory<>' could not be found (are you missing a using directive or an assembly reference?)
/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/PolyfillExtensions_TextWriter.cs(29,9): error CS0246: The type or namespace name 'ReadOnlyMemory<>' could not be found (are you missing a using directive or an assembly reference?)
/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/PolyfillExtensions_TextWriter.cs(55,9): error CS0246: The type or namespace name 'ReadOnlyMemory<>' could not be found (are you missing a using directive or an assembly reference?)
/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/PolyfillExtensions_TextWriter.cs(76,9): error CS0246: The type or namespace name 'ReadOnlySpan<>' could not be found (are you missing a using directive or an assembly reference?)
/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/PolyfillExtensions_TextWriter.cs(99,9): error CS0246: The type or namespace name 'ReadOnlySpan<>' could not be found (are you missing a using directive or an assembly reference?)

This was fixed in this PR by adding the MEMORYREFERENCED define in a few extra places.

Then, in another project that defined its own Debug class, I saw the following errors:

/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/Nullability/NullabilityInfoContext.cs(507,13): error CS0104: 'Debug' is an ambiguous reference between 'MBT.Utilities.Debug' and 'System.Diagnostics.Debug'
/Users/scott/.nuget/packages/polyfill/1.32.0/contentFiles/cs/netstandard2.0/Polyfill/Nullability/NullabilityInfoContext.cs(541,13): error CS0104: 'Debug' is an ambiguous reference between 'MBT.Utilities.Debug' and 'System.Diagnostics.Debug'

This was solved by adding some explicit using Debug = System.Diagnostics.Debug; lines in Polyfill.

EDIT: Second issue/fix extracted into separate PR #122.

@SimonCropp
Copy link
Owner

can you add a new project that replicates this scenario. so the changes can be verified

@sbeca
Copy link
Contributor Author

sbeca commented Nov 16, 2023

Yep, I can look into doing that

@sbeca
Copy link
Contributor Author

sbeca commented Dec 3, 2023

@SimonCropp: I have added a new project (ConsumeTasksWithNoMemory.csproj) and a new class (Debug.cs) that replicates these 2 issues. They both fail to compile when included in main but compile fine with the changes in this PR.

@SimonCropp SimonCropp added this to the 1.33.1 milestone Dec 3, 2023
@SimonCropp
Copy link
Owner

can u split the Debug change into a different PR

@sbeca
Copy link
Contributor Author

sbeca commented Jan 8, 2024

Sorry about the delay, I have now split the Debug change out into PR #122

@sbeca sbeca changed the title Fix some compiler errors that can occur with specific project setups Fix some compiler errors that can occur with specific project setups (Memory references) Jan 8, 2024
@SimonCropp SimonCropp modified the milestones: 1.33.1, 2.0.1 Jan 8, 2024
@SimonCropp SimonCropp merged commit f179c38 into SimonCropp:main Jan 8, 2024
2 checks passed
@SimonCropp
Copy link
Owner

thanks. will deploy now. pending nuget updating its cache

@sbeca sbeca deleted the fix-compiler-errors branch January 9, 2024 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants