dotnet / project-system

The .NET Project System for Visual Studio
MIT License
971 stars 388 forks source link

.Net Core project does not respect langversion setting #983

Closed jcouv closed 7 years ago

jcouv commented 7 years ago

Repro:

  1. Using RC2 (Microsoft Visual Studio Enterprise 2017 RC - Version 15.0.26006.2 D15REL)
  2. Create a Core console app
  3. Change the language version for this project to use C# 6.0 (see screenshot below)
  4. Use a C# 7.0 feature (for instance, typing _ = 1; or (int, int) t = (1, 2);)

I expect to see an error about language version (CS8059 Feature 'xyz' is not available in C# 6. Please use language version 7 or greater.). But the discard snippet is accepted and the tuple snippet reports a missing reference to ValueTuple. I logged the build output (see line below) and it appears that no version parameter is passed in the command line parameters.

Note that this problem doesn't repro with a "Console App (.NET Framework)" project. It seems specific to "Console App (.NET Core)".

image

1>    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\csc.exe /noconfig /nowarn:1701,1702,1705,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE;NETCOREAPP1_0 /errorendlocation /preferreduilang:en-US /reference:C:\Users\jcouv\.nuget\packages\microsoft.csharp\4.0.1\ref\netstandard1.0\Microsoft.CSharp.dll /reference:C:\Users\jcouv\.nuget\packages\microsoft.visualbasic\10.0.1\ref\netstandard1.1\Microsoft.VisualBasic.dll /reference:C:\Users\jcouv\.nuget\packages\microsoft.win32.primitives\4.0.1\ref\netstandard1.3\Microsoft.Win32.Primitives.dll /reference:C:\Users\jcouv\.nuget\packages\system.appcontext\4.1.0\ref\netstandard1.6\System.AppContext.dll /reference:C:\Users\jcouv\.nuget\packages\system.buffers\4.0.0\lib\netstandard1.1\System.Buffers.dll /reference:C:\Users\jcouv\.nuget\packages\system.collections.concurrent\4.0.12\ref\netstandard1.3\System.Collections.Concurrent.dll /reference:C:\Users\jcouv\.nuget\packages\system.collections\4.3.0\ref\netstandard1.3\System.Collections.dll /reference:C:\Users\jcouv\.nuget\packages\system.collections.immutable\1.2.0\lib\netstandard1.0\System.Collections.Immutable.dll /reference:C:\Users\jcouv\.nuget\packages\system.componentmodel.annotations\4.1.0\ref\netstandard1.4\System.ComponentModel.Annotations.dll /reference:C:\Users\jcouv\.nuget\packages\system.componentmodel\4.0.1\ref\netstandard1.0\System.ComponentModel.dll /reference:C:\Users\jcouv\.nuget\packages\system.console\4.0.0\ref\netstandard1.3\System.Console.dll /reference:C:\Users\jcouv\.nuget\packages\system.diagnostics.debug\4.0.11\ref\netstandard1.3\System.Diagnostics.Debug.dll /reference:C:\Users\jcouv\.nuget\packages\system.diagnostics.diagnosticsource\4.0.0\lib\netstandard1.3\System.Diagnostics.DiagnosticSource.dll /reference:C:\Users\jcouv\.nuget\packages\system.diagnostics.process\4.1.0\ref\netstandard1.4\System.Diagnostics.Process.dll /reference:C:\Users\jcouv\.nuget\packages\system.diagnostics.tools\4.0.1\ref\netstandard1.0\System.Diagnostics.Tools.dll /reference:C:\Users\jcouv\.nuget\packages\system.diagnostics.tracing\4.1.0\ref\netstandard1.5\System.Diagnostics.Tracing.dll /reference:C:\Users\jcouv\.nuget\packages\system.dynamic.runtime\4.0.11\ref\netstandard1.3\System.Dynamic.Runtime.dll /reference:C:\Users\jcouv\.nuget\packages\system.globalization.calendars\4.0.1\ref\netstandard1.3\System.Globalization.Calendars.dll /reference:C:\Users\jcouv\.nuget\packages\system.globalization\4.3.0\ref\netstandard1.3\System.Globalization.dll /reference:C:\Users\jcouv\.nuget\packages\system.globalization.extensions\4.0.1\ref\netstandard1.3\System.Globalization.Extensions.dll /reference:C:\Users\jcouv\.nuget\packages\system.io.compression\4.1.0\ref\netstandard1.3\System.IO.Compression.dll /reference:C:\Users\jcouv\.nuget\packages\system.io.compression.zipfile\4.0.1\ref\netstandard1.3\System.IO.Compression.ZipFile.dll /reference:C:\Users\jcouv\.nuget\packages\system.io\4.3.0\ref\netstandard1.5\System.IO.dll /reference:C:\Users\jcouv\.nuget\packages\system.io.filesystem\4.0.1\ref\netstandard1.3\System.IO.FileSystem.dll /reference:C:\Users\jcouv\.nuget\packages\system.io.filesystem.primitives\4.0.1\ref\netstandard1.3\System.IO.FileSystem.Primitives.dll /reference:C:\Users\jcouv\.nuget\packages\system.io.filesystem.watcher\4.0.0\ref\netstandard1.3\System.IO.FileSystem.Watcher.dll /reference:C:\Users\jcouv\.nuget\packages\system.io.memorymappedfiles\4.0.0\ref\netstandard1.3\System.IO.MemoryMappedFiles.dll /reference:C:\Users\jcouv\.nuget\packages\system.io.unmanagedmemorystream\4.0.1\ref\netstandard1.3\System.IO.UnmanagedMemoryStream.dll /reference:C:\Users\jcouv\.nuget\packages\system.linq\4.1.0\ref\netstandard1.6\System.Linq.dll /reference:C:\Users\jcouv\.nuget\packages\system.linq.expressions\4.1.0\ref\netstandard1.6\System.Linq.Expressions.dll /reference:C:\Users\jcouv\.nuget\packages\system.linq.parallel\4.0.1\ref\netstandard1.1\System.Linq.Parallel.dll /reference:C:\Users\jcouv\.nuget\packages\system.linq.queryable\4.0.1\ref\netstandard1.0\System.Linq.Queryable.dll /reference:C:\Users\jcouv\.nuget\packages\system.net.http\4.1.0\ref\netstandard1.3\System.Net.Http.dll /reference:C:\Users\jcouv\.nuget\packages\system.net.nameresolution\4.0.0\ref\netstandard1.3\System.Net.NameResolution.dll /reference:C:\Users\jcouv\.nuget\packages\system.net.primitives\4.0.11\ref\netstandard1.3\System.Net.Primitives.dll /reference:C:\Users\jcouv\.nuget\packages\system.net.requests\4.0.11\ref\netstandard1.3\System.Net.Requests.dll /reference:C:\Users\jcouv\.nuget\packages\system.net.security\4.0.0\ref\netstandard1.3\System.Net.Security.dll /reference:C:\Users\jcouv\.nuget\packages\system.net.sockets\4.1.0\ref\netstandard1.3\System.Net.Sockets.dll /reference:C:\Users\jcouv\.nuget\packages\system.net.webheadercollection\4.0.1\ref\netstandard1.3\System.Net.WebHeaderCollection.dll /reference:C:\Users\jcouv\.nuget\packages\system.numerics.vectors\4.1.1\ref\netstandard1.0\System.Numerics.Vectors.dll /reference:C:\Users\jcouv\.nuget\packages\system.objectmodel\4.0.12\ref\netstandard1.3\System.ObjectModel.dll /reference:C:\Users\jcouv\.nuget\packages\system.reflection.dispatchproxy\4.0.1\ref\netstandard1.3\System.Reflection.DispatchProxy.dll /reference:C:\Users\jcouv\.nuget\packages\system.reflection\4.3.0\ref\netstandard1.5\System.Reflection.dll /reference:C:\Users\jcouv\.nuget\packages\system.reflection.extensions\4.0.1\ref\netstandard1.0\System.Reflection.Extensions.dll /reference:C:\Users\jcouv\.nuget\packages\system.reflection.metadata\1.3.0\lib\netstandard1.1\System.Reflection.Metadata.dll /reference:C:\Users\jcouv\.nuget\packages\system.reflection.primitives\4.3.0\ref\netstandard1.0\System.Reflection.Primitives.dll /reference:C:\Users\jcouv\.nuget\packages\system.reflection.typeextensions\4.1.0\ref\netstandard1.5\System.Reflection.TypeExtensions.dll /reference:C:\Users\jcouv\.nuget\packages\system.resources.reader\4.0.0\lib\netstandard1.0\System.Resources.Reader.dll /reference:C:\Users\jcouv\.nuget\packages\system.resources.resourcemanager\4.3.0\ref\netstandard1.0\System.Resources.ResourceManager.dll /reference:C:\Users\jcouv\.nuget\packages\system.runtime\4.3.0\ref\netstandard1.5\System.Runtime.dll /reference:C:\Users\jcouv\.nuget\packages\system.runtime.extensions\4.1.0\ref\netstandard1.5\System.Runtime.Extensions.dll /reference:C:\Users\jcouv\.nuget\packages\system.runtime.handles\4.0.1\ref\netstandard1.3\System.Runtime.Handles.dll /reference:C:\Users\jcouv\.nuget\packages\system.runtime.interopservices\4.1.0\ref\netstandard1.5\System.Runtime.InteropServices.dll /reference:C:\Users\jcouv\.nuget\packages\system.runtime.interopservices.runtimeinformation\4.0.0\ref\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll /reference:C:\Users\jcouv\.nuget\packages\system.runtime.numerics\4.0.1\ref\netstandard1.1\System.Runtime.Numerics.dll /reference:C:\Users\jcouv\.nuget\packages\system.security.cryptography.algorithms\4.2.0\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll /reference:C:\Users\jcouv\.nuget\packages\system.security.cryptography.encoding\4.0.0\ref\netstandard1.3\System.Security.Cryptography.Encoding.dll /reference:C:\Users\jcouv\.nuget\packages\system.security.cryptography.primitives\4.0.0\ref\netstandard1.3\System.Security.Cryptography.Primitives.dll /reference:C:\Users\jcouv\.nuget\packages\system.security.cryptography.x509certificates\4.1.0\ref\netstandard1.4\System.Security.Cryptography.X509Certificates.dll /reference:C:\Users\jcouv\.nuget\packages\system.security.principal\4.0.1\ref\netstandard1.0\System.Security.Principal.dll /reference:C:\Users\jcouv\.nuget\packages\system.text.encoding\4.3.0\ref\netstandard1.3\System.Text.Encoding.dll /reference:C:\Users\jcouv\.nuget\packages\system.text.encoding.extensions\4.0.11\ref\netstandard1.3\System.Text.Encoding.Extensions.dll /reference:C:\Users\jcouv\.nuget\packages\system.text.regularexpressions\4.1.0\ref\netstandard1.6\System.Text.RegularExpressions.dll /reference:C:\Users\jcouv\.nuget\packages\system.threading\4.0.11\ref\netstandard1.3\System.Threading.dll /reference:C:\Users\jcouv\.nuget\packages\system.threading.tasks.dataflow\4.6.0\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll /reference:C:\Users\jcouv\.nuget\packages\system.threading.tasks\4.3.0\ref\netstandard1.3\System.Threading.Tasks.dll /reference:C:\Users\jcouv\.nuget\packages\system.threading.tasks.extensions\4.0.0\lib\netstandard1.0\System.Threading.Tasks.Extensions.dll /reference:C:\Users\jcouv\.nuget\packages\system.threading.tasks.parallel\4.0.1\ref\netstandard1.1\System.Threading.Tasks.Parallel.dll /reference:C:\Users\jcouv\.nuget\packages\system.threading.thread\4.0.0\ref\netstandard1.3\System.Threading.Thread.dll /reference:C:\Users\jcouv\.nuget\packages\system.threading.threadpool\4.0.10\ref\netstandard1.3\System.Threading.ThreadPool.dll /reference:C:\Users\jcouv\.nuget\packages\system.threading.timer\4.0.1\ref\netstandard1.2\System.Threading.Timer.dll /reference:C:\Users\jcouv\.nuget\packages\system.valuetuple\4.3.0\lib\netstandard1.0\System.ValueTuple.dll /reference:C:\Users\jcouv\.nuget\packages\system.xml.readerwriter\4.0.11\ref\netstandard1.3\System.Xml.ReaderWriter.dll /reference:C:\Users\jcouv\.nuget\packages\system.xml.xdocument\4.0.11\ref\netstandard1.3\System.Xml.XDocument.dll /debug+ /debug:portable /filealign:512 /nologo /optimize- /out:obj\Debug\netcoreapp1.0\DotNetCore.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /target:exe /utf8output /deterministic+ /analyzer:C:\Users\jcouv\.nuget\packages\microsoft.codeanalysis.analyzers\1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll /analyzer:C:\Users\jcouv\.nuget\packages\microsoft.codeanalysis.analyzers\1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll Program.cs "C:\Users\jcouv\AppData\Local\Temp\.NETCoreApp,Version=v1.0.AssemblyAttributes.cs" obj\Debug\netcoreapp1.0\\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs obj\Debug\netcoreapp1.0\\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs obj\Debug\netcoreapp1.0\\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs obj\Debug\netcoreapp1.0\DotNetCore.AssemblyInfo.cs
srivatsn commented 7 years ago

@RaulPerez1 maybe another missing rule?

RaulPerez1 commented 7 years ago

Not a property issue, this is getting read/written properly to the project. Most likely the value is not being passed to the compiler on the targets

RaulPerez1 commented 7 years ago

I take that back, after some digging in the targets I found the problem. The compiler property is LangVersion and the property page is using LanguageVersion so it needs to be rerouted.