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

Merge features/readonly-ref to master #22050

Merged
merged 311 commits into from
Sep 21, 2017
Merged

Merge features/readonly-ref to master #22050

merged 311 commits into from
Sep 21, 2017

Conversation

VSadov
Copy link
Member

@VSadov VSadov commented Sep 11, 2017

Merge from features/readonly-ref into master.

Brings a number of interconnected features geared towards system/hi-perf programming.

User facing features:

  • ref readonly parameters
  • ref readonly return
  • ref extension methods
  • ref readonly extension methods
  • ref ternary expressions
  • readonly stucts
  • ref structs (such as Span<T> and ReadonlySpan<T> and structs that contain them)
  • escape analysis for byref variables and ref struct values
  • safe stackalloc
  • various optimizations for scenarios that involve readonly fields, stackalloc, fixed, unsafe . . .
  • peverify-compat mode

Internal improvements:

  • attribute embedding infrastructure
  • separation of variable/lvalue and writeable/readonly analysis

==== See also

VSadov and others added 30 commits March 23, 2017 08:55
Added support for invoking members with "in" parameters.
Merge from master to features/readonly-ref
Allow building nuget package from features/readonly-ref branch
"readonly-ref" combined with version number crosses the limit for the version length and causes nuget errors like:
 Error : The special version part cannot exceed 20 characters.
Shorten the version moniker "readonly-ref" --> "rdonly-ref"
The code was ignoring "readonly" part for local functions,

Fixes:#18357
"ref readonly" local functions should be treated as "ref readonly"
Merge from master to features/readonly-ref
These are mostly the checks dealing with stack-only nature of the Span. With minor difference they follow the same logic as the existing checks for types such as TypedReference.

==== Not in this change:
Defining and detecting span-like types is NYI. For now we just treat any type named "System.Span" and "System.ReadonlySpan" as span-like. This will change.

Some of the checks result in somewhat generaic messages and happen at emit phase. That was ok when the failures were supposed to be rare.
Error clarity is not the goal of this change, but we will examone what errors should say and whether they should be moved to an earlier phase.
This will be allowed only for span-like containers eventually, when we can declare those.
For now allow in any struct.
Implements the initial set of span-safety checks.
* Writing attribute to metadata

* Reading attribute in PE symbols

* Added more tests for lambdas, delegates, and other types

* Use ReadOnlyAttribute instead

* Fix build break

* Fix Failed Tests

* Enable back disabled tests

* Fix more tests

* Ban usage of ReadOnlyAttribute in source

* Rename System.Runtime.InteropServices.ReadOnlyAttribute to System.Runtime.CompilerServices.ReadOnlyAttribute

* Clean up

* Address CR comments

* More PR feedback
@VSadov VSadov changed the title [WIP] Merge features/readonly-ref to master Merge features/readonly-ref to master Sep 20, 2017
@VSadov VSadov removed the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Sep 20, 2017
@VSadov
Copy link
Member Author

VSadov commented Sep 20, 2017

test windows_debug_unit64_prtest please

@VSadov
Copy link
Member Author

VSadov commented Sep 20, 2017

looks like windows_debug_unit64_prtest got stuck and did not start at all.

@VSadov
Copy link
Member Author

VSadov commented Sep 20, 2017

CC: @jaredpar @Pilchie

@VSadov
Copy link
Member Author

VSadov commented Sep 20, 2017

@dotnet/roslyn-compiler - FYI

@Pilchie
Copy link
Member

Pilchie commented Sep 20, 2017

Tagging @dpoeschl too. Assuming that the manual IDE testing for new language features has been done, I'm okay with merging this.

Temporarily revert Versions.prop to match master branch for the merge
Add a blank line in Versions.props back for nicer formatting
@VSadov
Copy link
Member Author

VSadov commented Sep 20, 2017

CC: @MeiChin-Tsai - I think this may need ask mode approval.

@VSadov
Copy link
Member Author

VSadov commented Sep 21, 2017

RE: IDE manual testpass

I went through the IDE scenarios - to be sure.

I used fairly large solution - the entire CoreFxLab repo.

There was nothing extraordinary.
I logged some bugs - mostly in cases where refatorings lose "readonly" on "ref readonly". In every case the feature otherwise worked correctly.

There was an assert that seems bogus/ignorable specifically related to "ref readonly" and hard to reproduce. - #22237
It will not have effect on code that does not have "ref readonly" in it or in Release builds, so I think we should look into this after the merge.

Otherwise everything worked fine.

@VSadov
Copy link
Member Author

VSadov commented Sep 21, 2017

Testing tags

  • 🔍 = Scenarios that are regularly tested against internal builds
  • ⏩ = Scenarios that must work as expected before new language features are merged

When doing a test pass, copy this page and consider using these status indicators:

  • ✅ = Tested & Approved (possibly with linked bugs)
  • ❌ = Merge blocking
  • 🚧 = Non-blocking bugs
  • 🆗 = Issue has been fixed
  • 🆓 = No expected impact
  • ❓ = Open question

1 Feature updated by compiler team, with appropriate unit tests.

2 Feature requires more complete testing by IDE team.

Product Features

Core Scenarios in Editing, Navigating, and Viewing

Category Feature/Description C# Signoff/Notes VB Signoff/Notes F# Signoff/Notes
Enable/Disable Feature Flags
To completely enables/disable new compiler features in the compiler & IDE
N/A
Typing General Typing
- Type and paste new constructs
- Nothing interferes with verbatim typing
🔍 ⏩ Completion
- Typing new keyword/construct names
- Dotting off of new constructs
- Matching part of the identifier is highlighted (including word prefix matches) [Visual Studio 2015 Update 1]
- Target type preselection [Visual Studio 2017]
IntelliSense filtering [Visual Studio 2017]
Formatting
- Spacing in and around new constructs
- Spacing options
- Format Document command
Tools > Options settings should be respected
Automatic Brace Completion (C# only)
- Auto-insert close brace
- Shift+Enter commit of IntelliSense and any pending brace completion sessions (Known issue: #18065)
N/A N/A
Indentation
- Typing Enter in an unfinished statement indents the next line
Navigating 🔍 ⏩ Go To Definition
- F12 from callsites to definition
- Ctrl+click [Visual Studio 2017 version 15.4]
Go To Implementation
- Ctrl+F12 to jump from virtual members to their implementations
- Jump from inheritable types to their implementations
N/A
🔍 ⏩ Find All References
- Lists references to a symbol in "Find Symbol Results" window
- Shows results in hierarchy grouped by definition [Visual Studio 2015]
- Results should be groupable/filterable/classified appropriately [Visual Studio 2017]
- Find All References on literals [Visual Studio 2017 version 15.3]
Viewing 🔍 ⏩ Colorization
- Keywords, literals, and identifiers colored appropriately in code
- Colors should theme appropriately
- The "Blue Theme (Additional Contrast)" should have sufficiently dark colors
Error Squiggles
- Squiggles appear as expected on reasonable spans

Code Transformations

Category Feature/Description C# Signoff/Notes VB Signoff/Notes F# Signoff/Notes
Refactoring with UI 🔍 Inline Rename (with UI)
- Dashboard shows correct information
- Highlighted spans are updated appropriately
- Rename operation updates the correct set of symbols
🔍 Change Signature (with UI)
- Updates all direct & cascaded definitions/callsites
- Shows appropriate signature & parameter previews in UI
- Reorder and Remove in the same session [Visual Studio 2015]
#22239 N/A
🔍 Extract Interface (with UI)
- Generated Interface has expected shape
- UI shows appropriate method previews
#22238 N/A
Generate Type (with UI)
- Dialog gives all valid options
N/A N/A
Generate Overrides [Visual Studio 2017 version 15.3] N/A N/A
Refactorings Rename Tracking
- Tracking span tracks & dismisses as expected
- Invokable from references [Visual Studio 2015]
N/A
🔍 Extract Method
- Extracted method has the expected signature
- All arguments/return values handled correctly
- Extracted code block is reasonable
- Automatically starts Inline Rename
N/A N/A
Introduce Variable
- Introduced variable has the expected signature and initializer expression
- "Introduce for All" correctly finds dupes
N/A N/A
Inline Temporary Variable
- Inlined values are appropriately expanded/reduced
N/A N/A
Organize Usings
- Honors "Place 'System' namespace first" option
N/A N/A
Convert Get* Methods to Properties
Add Description
N/A N/A
🔍 Encapsulate Field
- Select a field and convert it to a property backed by the field
- Try selecting multiple fields at once
N/A N/A
Modifier Ordering [Visual Studio 2017 version 15.5] N/A
Convert ReferenceEquals to is null [Visual Studio 2017 version 15.5] N/A N/A
Add Missing Modifiers [Visual Studio 2017 version 15.5] #22240 N/A
Convert Lambda to Local Function [Visual Studio 2017 version 15.5] #22241 N/A
Move Declaration Near Reference [Visual Studio 2017 version 15.5] N/A N/A
Introduce Pattern Matching [Visual Studio 2017 version 15.5] N/A N/A
Simplify Inferred Tuple Names [Visual Studio 2017 version 15.5] Requires C# 7.1 or greater N/A N/A
Convert keyword and symbol references to doc comment tags [Visual Studio 2017 version 15.5] N/A
Fixes Add Using
- Triggers on appropriate constructs
- Including NuGet references
- Including Referenced Assemblies
- Includes spelling fixes
N/A
Generate Local
- Select an expression and introduce a local variable to represent it
- This should start an Inline Rename session
N/A N/A
Generate Field
- Select an expression and introduce a field to represent it
- This should start an Inline Rename session
N/A N/A
Generate Method/Constructor
- Call a nonexistent method or constructor to generate it from its usage
- Generated method has the expected signature and accessibility
- Add parameter to existing constructor from callsite [Visual Studio 2017 version 15.3]
N/A N/A
Generate Constructor from members
- Select fields/properties to generate a constructor accepting corresponding arguments
- Generated constructor has the expected signature and accessibility
N/A N/A
Implement Interface
- Only missing methods added
- All added methods have the expected signature and accessibility
#22242 N/A
Implement IDisposable
- Implement IDisposable and you should see a large block of code properly implementing that particular interface
N/A N/A
Implement Abstract Class
- Inherit from an abstract class, and you should be able to auto-generate all of the missing members
✅ N/A N/A
Remove Unused Variables [Visual Studio 2017 version 15.3] N/A N/A
Remove Unused Usings N/A
Sort Usings N/A N/A
Convert Get Methods to Properties
- Name a method GetStuff and convert it to a property called Stuff
N/A N/A
Make Method Async/Sync
- Add an await to a synchronous method, you should be offered to add the async keyword
- Remove all await keywords from an async method, you should be offered to remove the async keyword
N/A N/A
Use Object Initializer Over Property Assignment
- Create a new instance of a type and then assign each of its properties on subsequent lines
- You should be offered to convert that to an object initializer
N/A N/A
Insert Digit Separators [Visual Studio 2017 version 15.3] N/A N/A
Code Gen 🔍 Snippets
- Tab completion, presence in completion list
- Insertion via Snippet Picker UI (Ctrl + K, Ctrl + X) or (Ctrl + K, Ctrl + S)
- (VB) Snippet Picker UI via ?<Tab>
- (VB) Special snippet completion list (p?<esc><tab>)
N/A N/A
Event Hookup on Tab (C# only)
- Type "+=" after an event name and QuickInfo shows
- Invoking should pick good name & launch Inline Rename
N/A N/A N/A
End Construct Generation (VB only)
- Type Sub Test() and hit enter, the End Sub should be generated automatically
N/A N/A
Automatic End Construct Update (VB only)
- Type Sub Test() and End Sub, changing Sub to Function in either one should update the other
N/A N/A
Spell checking
- Type a name that's close to a variable name but off by a character or two
- Lightbulb should have option to fix up the spelling
- Includes type names that will require a using
N/A N/A
Move type to file
- Lightbulb to move type to another file when the type name doesn't match the filename
- Option to change the file name if the type doesn't match the file name
N/A
Convert between properties and Get methods
- Offers to change a method named GetStuff to a property named Stuff
N/A N/A
Convert auto property to full property [Visual Studio 2017 version 15.5] N/A N/A
Add missing cases
Use a switch on a strict subset of an Enum's members
- It should offer to generate the rest of the cases
N/A N/A
Add null checks for parameters [Visual Studio 2017 version 15.3] N/A N/A
Change base for numeric literals [Visual Studio 2017 version 15.3] N/A N/A
Convert if to switch [Visual Studio 2017 version 15.3] N/A N/A
Resolve git merge conflicts [Visual Studio 2017 version 15.3] N/A N/A
Add argument name [Visual Studio 2017 version 15.3 N/A
Fade and remove unreachable code [Visual Studio 2017 version 15.5] N/A N/A
Add missing file banner [Visual Studio 2017 version 15.5] N/A N/A

IDE Features

Category Feature/Description C# Signoff/Notes VB Signoff/Notes F# Signoff/Notes
General Signature Help
- Overloads shown with appropriate, colorized signature
Quick Info
- Hover on identifiers
- On completion list items
🔍 Outlining
- Make sure outlining is enabled under options
- Define a method and expect to see a collapsible region around the method definition
- Make sure collapse and expand work
Brace Matching (C# only)
- Highlights matching brace token, if caret is on an open or close brace.
- Hovering on a close brace shows the code around the open brace
N/A N/A
Highlight References
- Ensure "Highlight references to symbol under cursor" is enabled in options
- If caret is on an identifier, all references to that identifier in the active document should be highlighted
- We also show related keywords, so placing the caret on a return should show the other returns, if should show elses, try shows catches and finallys, etc.
- Should be able to navigate between highlighted references with Ctrl+Shift+Up/Down
🔍 Peek
Press Alt + F12 after placing the cursor on a predefined Type or predefined member and expect to see to a temporary window showing the appropriate definition
🔍 Navigation Bars
- Open some existing source files, make sure you can navigate around the file choosing classes or methods.
- Switch between project contexts
- In VB, the NavBar can do code generation for events and for New/Finalize methods
Metadata As Source
- Press F12 on a predefined type and expect the cursor to move the predefined type definition inside a Metadata-As-Source Generated document.
- Expect to see the xml doc comments collapsed above the method.
N/A
🔍 Navigate To
- Place caret on a user defined Type reference and press "ctrl + ,"
- This should list the User Defined Type in the drop down on the Upper Right corner of the editor and selecting this item will move the cursor to the User Reference Definition
- Filters per kind of symbol [Visual Studio 2017]
Go to Next/Previous Method
- Edit.NextMethod and Edit.PreviousMethod should work
- You may need to set up keyboard bindings for these commands under Tools > Options > Environment > Keyboard
N/A
Solution Explorer Pivots
- Define a Type and some members in a sample Document.
- Expand the Document listed in the Solution Explorer window and expect to see the Type and Members defined
- Right-click types and try Base Types / Derived Types / Is Used By / Implements
- Right-click methods and try Calls / Is Called By / Is Used By / Implements
N/A
Call Hierarchy
- Place the caret over a method, right click & select View Hierarchy
- This should open the "Call Hierarchy window" listing the methods that call the original method and also the callsites within each calling method.
N/A
🔍 Code Lens
- Make sure Code Lens is enabled from the options. Look for an adornment on top of each method declaration with lists the number of references for that method, last time someone modified the method, who modified the method and other information
N/A
Project System
- Open/close a project
- Add/remove references
- Unload/reload projects
- Source Control integration (adding references checks out projects, etc.)
N/A
Debugger IntelliSense
- Hit a breakpoint (or step) and verify that there's IntelliSense in the Immediate Window (C#, VB)
- Type an expression, and hit enter. Verify it's evaluated. Type another expression. IntelliSense should still work.
- (VB) there should be IntelliSense if you type "?" followed by an expression (eg, the text of the line in the window is "?foo")
- Hit a breakpoint (or step) and verify that there's IntelliSense in the Watch Window
- Hit a breakpoint (or step) and verify that there's IntelliSense in the Quick Watch Window
- Verify intellisense in the Conditional Breakpoint view
- Verify each of the above scenarios after hitting f5 and hitting another breakpoint, and after stepping
Breakpoint Spans
- The span highlighted when a breakpoint is set should be logical
Code Model / Class Designer
- Right click a file in Solution Explorer & choose View Class Diagram.
- This shows the "Class Details" window where you can add/remove members, change their type/accessibility/name, parameter info, etc.
N/A
Object Browser / Class View
- Open object browser and classview and verify that project contents are represented live.
- Should be able to invoke find all references, navigate to the definition, and do searches.
N/A
Lightbulb
- Should work with Ctrl+. and the right-click menu
- Should include a diff view
- Should include options to fix all in Document/Project/Solution, and to Preview Changes
Varying icons for lightbulb items [Visual Studio 2017 version 15.4]
Line Separators
- Turn the option on under Tools > Options
- Ensure there's a line between methods.
N/A
Indent Guides
- Vertical dotted lines appear between braces for declaration-level things
- Hovering on the line shows context
Code Style Naming Rules N/A N/A
Use this./me. N/A N/A
Use predefined type N/A N/A
Prefer object/collection initializer N/A N/A
Prefer explicit tuple name N/A N/A
Prefer coalesce expression over null check N/A N/A
Prefer null propagation over null check N/A N/A
var preferences (C# only) N/A N/A N/A
Prefer braces (C# only) N/A N/A N/A
Prefer pattern matching over is/as checks (C# only) N/A N/A N/A
Use expression body (C# only) N/A N/A N/A
Prefer inlined variable declaration (C# only) N/A N/A N/A
Prefer throw expression (C# only) N/A N/A N/A
Prefer conditional delegate call (C# only) N/A N/A N/A

@VSadov
Copy link
Member Author

VSadov commented Sep 21, 2017

According to Jenkins the integration tests have been failing continuously for the last 7 days now. They are not merge-blocking though.

I will ignore the integration test results.

@MeiChin-Tsai
Copy link

Please make sure all tests pass. Otherwise, approved.

@VSadov
Copy link
Member Author

VSadov commented Sep 21, 2017

Thanks!! All required tests are passing.

@VSadov VSadov merged commit 3bbb684 into master Sep 21, 2017
4creators added a commit to dotnetrt/roslyn that referenced this pull request Sep 23, 2017
…donly-ref branch

Merge required reconciling conflicting changes. For details see readonly-ref PR in
dotnet/roslyn repo: dotnet#22050
@davkean davkean deleted the features/readonly-ref branch June 21, 2018 06:40
@davkean davkean restored the features/readonly-ref branch June 21, 2018 06:40
@davkean davkean deleted the features/readonly-ref branch June 21, 2018 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants