@carlreinke commented on Sat Jan 27 2018
Version Used: Microsoft (R) Visual C# Compiler version 2.6.0.62329 (5429b35d)
Steps to Reproduce:
c:\temp>type Program.cs
class C
{
static bool M( out System.ReadOnlyMemory<byte> x )
{
return false; // No error here!?
}
}
c:\temp>csc.exe /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\mscorlib.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\netstandard.dll" /reference:C:\Users\User\.nuget\packages\system.memory\4.5.0-preview1-26011-01\ref\netstandard2.0\System.Memory.dll /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Runtime.dll" /out:Test.dll /target:library Program.cs
Microsoft (R) Visual C# Compiler version 2.6.0.62329 (5429b35d)
Copyright (C) Microsoft Corporation. All rights reserved.
c:\temp>
Expected Behavior: Show error message and fail to compile.
Actual Behavior: Compilation succeeds.
@gafter commented on Sat Jan 27 2018
Please check to see what fields, if any, are contained in System.Collections.Generic.KeyValuePair inside of C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Runtime.dll. If it contains no fields in that reference assembly, then the compiler is correct. In that case the out parameter is definitely assigned because all (zero) of its fields are definitely assigned.
@gafter commented on Sat Jan 27 2018
To clarify, if that is the case then it is a bug in the reference assembly.
@carlreinke commented on Sat Jan 27 2018
Indeed, there are no fields in KeyValuePair<TKey, TValue> in the reference assembly. I replaced the original comment with a different example. ReadOnlyMemory<T> does have fields.
@carlreinke commented on Sat Jan 27 2018
Err, I guess the reference assembly for ReadOnlyMemory<T> doesn't have fields either... the assembly that gets used when it actually runs has fields; otherwise it wouldn't work.
Why are there no fields in the reference assemblies?
(IntelliSense/MSBuild seem to also use the ref assembly, so when I'm building in Visual Studio, I don't get any error message about the out parameter not being assigned there either.)
@gafter commented on Sat Jan 27 2018
That is a bug. We’ll move this bug to an appropriate repository.
@tannergooding commented on Sat Jan 27 2018
@gafter, I believe the issue has already been dealt with on the CoreFX side: dotnet/corefx#26286 and dotnet/buildtools#1859.
However, it was only merged 15 days ago, so nothing has shipped with the fix yet.
@gafter commented on Sun Jan 28 2018
@tannergooding I don't see anything specifically changing KeyValuePair's reference assembly. Isn't its reference assembly produced based on hand-written source?
@carlreinke commented on Sat Jan 27 2018
Version Used: Microsoft (R) Visual C# Compiler version 2.6.0.62329 (5429b35d)
Steps to Reproduce:
Expected Behavior: Show error message and fail to compile.
Actual Behavior: Compilation succeeds.
@gafter commented on Sat Jan 27 2018
Please check to see what fields, if any, are contained in
System.Collections.Generic.KeyValuePairinside ofC:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Runtime.dll. If it contains no fields in that reference assembly, then the compiler is correct. In that case theoutparameter is definitely assigned because all (zero) of its fields are definitely assigned.@gafter commented on Sat Jan 27 2018
To clarify, if that is the case then it is a bug in the reference assembly.
@carlreinke commented on Sat Jan 27 2018
Indeed, there are no fields in
KeyValuePair<TKey, TValue>in the reference assembly. I replaced the original comment with a different example.ReadOnlyMemory<T>does have fields.@carlreinke commented on Sat Jan 27 2018
Err, I guess the reference assembly for
ReadOnlyMemory<T>doesn't have fields either... the assembly that gets used when it actually runs has fields; otherwise it wouldn't work.Why are there no fields in the reference assemblies?
(IntelliSense/MSBuild seem to also use the ref assembly, so when I'm building in Visual Studio, I don't get any error message about the out parameter not being assigned there either.)
@gafter commented on Sat Jan 27 2018
That is a bug. We’ll move this bug to an appropriate repository.
@tannergooding commented on Sat Jan 27 2018
@gafter, I believe the issue has already been dealt with on the CoreFX side: dotnet/corefx#26286 and dotnet/buildtools#1859.
However, it was only merged 15 days ago, so nothing has shipped with the fix yet.
@gafter commented on Sun Jan 28 2018
@tannergooding I don't see anything specifically changing
KeyValuePair's reference assembly. Isn't its reference assembly produced based on hand-written source?