use latest language version for Miscellaneous Files workspace#25802
use latest language version for Miscellaneous Files workspace#25802JieCarolHu merged 4 commits intodotnet:dev15.7.xfrom
Conversation
This is not correct. A previously non-allocating path is now always-allocating here: |
There was a problem hiding this comment.
❗️ I would prefer to not change the behavior of GetDefaultParseOptions() (see comment in MiscellaneousFilesWorkspace)
There was a problem hiding this comment.
❗️ I would prefer to add the following method to ParseOptions:
internal abstract ParseOptions WithLatestLanguageVersion();You could then use the following:
var parseOptionsOpt = languageServices.GetService<ISyntaxTreeFactoryService>()?.GetDefaultParseOptions()
.WithLatestLanguageVersion();There was a problem hiding this comment.
This is wrong (losing other information inside the parse options you start with). See WithFeatures above for contrast.
Assuming we end adding such a compiler API, it needs corresponding API-level compiler tests.
jcouv
left a comment
There was a problem hiding this comment.
Done with review pass (iteration 4).
Let's do this without compiler change.
There was a problem hiding this comment.
@dotnet/roslyn-compiler I intended for this to be internal. Please let us know how to define such a method for use in the VS layer without a new public API.
There was a problem hiding this comment.
Why not implement this API in one of the language services? (ISyntaxTreeFactoryService seems reasonable place)
If that doesn't work for some reason, you can try making this internal, but I'm not sure there is InternalsVisibleTo from the compiler to this part of the IDE code.
If there is no IVT, there is probably a reason why it's not there, and so I would suspect it shouldn't be added.
There was a problem hiding this comment.
Originally, we couldn't even have IVT between compiler and IDE for legal reasons. Today, we simply don't want it because the compiler API should be sufficient for consumer's needs.
There was a problem hiding this comment.
If there is concern about a new API why not just make it an extension method? That doesn't need any change in the compiler.
There was a problem hiding this comment.
Added to the ISyntaxTreeFactoryService.
I am not sure how to add the override extension method for ParseOptions, VisualBasicParseOptions and CSharpParseOptions, so ISyntaxTreeFactoryService looks like a good place
|
There is no longer any compiler change in this PR, so I removed the Compiler label. This can be reviewed by IDE team. Thanks |
| [ExportLanguageServiceFactory(typeof(ISyntaxTreeFactoryService), LanguageNames.CSharp), Shared] | ||
| internal partial class CSharpSyntaxTreeFactoryServiceFactory : ILanguageServiceFactory | ||
| { | ||
| private static CSharpParseOptions _parseOptionWithLatestLanguageVersion = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Latest); |
| var compilationOptionsOpt = languageServices.GetService<ICompilationFactoryService>()?.GetDefaultCompilationOptions(); | ||
| var parseOptionsOpt = languageServices.GetService<ISyntaxTreeFactoryService>()?.GetDefaultParseOptions(); | ||
|
|
||
| // We only have one code file without project file here, so we cannot find out language version of the project |
There was a problem hiding this comment.
Comment seems out of place since that's the fact of life for this entire type. 😄
There was a problem hiding this comment.
updated the comment
|
@JieCarolHu Have we tested TypeScript and F# with this? I'm assuming they don't have an implementation of the ISyntaxTreeFactoryService (I don't know how they could...) but if they do this is a breaking change. |
|
|
||
| Private Shared ReadOnly _parseOptionsWithLatestLanguageVersion As VisualBasicParseOptions = VisualBasicParseOptions.Default.WithLanguageVersion(LanguageVersion.Latest) | ||
|
|
||
|
|
|
@jasonmalinowski tested on typescript and F#, none of them creates project for miscellaneous files. So they are not affected by this change |
|
@JieCarolHu Do they have implementations of this interface, even if they don't use Miscellaneous Files? Adding new members to interfaces is breaking unless we are careful. |
|
@jasonmalinowski Actually I was searching for the wrong interface. Just searched for "ISyntaxTreeFactoryService" again and they did not implement this interface |
|
@JieCarolHu sorry didn't realize you were waiting for my sign off since you removed the compiler change. The changes looked good to me. |
|
@Pilchie for ask mode approval |
|
@Pilchie for ask mode approval, thanks! |
|
Approved for 15.7 Preview 4. |
use latest language version for Miscellaneous Files workspace
Customer scenario
Diff window uses the default language version instead of the project language version. So when a code file contains a new feature which does not exist in the default language version, the diff window shows error which is confusing to customers.
Bugs this fixes
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/575761
Workarounds, if any
No
Risk
Low, only uses the latest language version instead of the default language version for ParserOptions when opening a historical version of code file
Performance impact
Low, no extra allocations/no complexity changes
Is this a regression from a previous update?
Not sure
Root cause analysis
NA
How was the bug found?
Customer reported on vs feedback
Test documentation updated?
No