Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Remove unnecessary cast now that we are targeting C# 7.3 with latest compiler #2299

Merged
merged 2 commits into from
May 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public ref partial struct BufferWriter
{
#region Byte
public bool TryWriteBytes(byte[] bytes)
=> TryWriteBytes((ReadOnlySpan<byte>)bytes.AsSpan());
=> TryWriteBytes(bytes.AsSpan());

public void WriteBytes(byte[] bytes)
=> WriteBytes((ReadOnlySpan<byte>)bytes.AsSpan());
=> WriteBytes(bytes.AsSpan());

public bool TryWriteBytes(ReadOnlySpan<byte> bytes)
{
Expand Down
4 changes: 1 addition & 3 deletions tools/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Key.snk</AssemblyOriginatorKeyFile>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
<PackageReference Include="Microsoft.NETCore.Compilers" Version="$(RoslynVersion)" PrivateAssets="All" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you need this anymore? Do you have a min req for .NET Core that is guaranteed to have C# 7.3?

Copy link
Member Author

@ahsonkhan ahsonkhan May 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a min req for .NET Core that is guaranteed to have C# 7.3?

Yes we do, but it looks like the csc.dll within roslyn that comes with the dotnet cli that we install has a recent enough version and has support for C#7.3.(https://dotnet.myget.org/feed/roslyn/package/nuget/Microsoft.NETCore.Compilers/2.8.1-beta6-62911-06)
image

Otherwise, the code change in this PR to remove the cast wouldn't compile (based on recent overload resolution changes - dotnet/roslyn#24756). That change wouldn't build on C#7.2.

System\Buffers\Writer\BufferWriter_writable.cs(14,16): error CS0306: The type 'Span' may not be used as a type argument [D:\GitHub\Fork\corefxlab\src\System.Buffers.ReaderWriter\System.Buffers.ReaderWriter.csproj]

</ItemGroup>

</Project>