-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix misleading documentation about structure assignments in With...End With statements #48222
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
base: main
Are you sure you want to change the base?
Conversation
…d With statements Co-authored-by: BillWagner <[email protected]>
To get the samples build to work correctly, you need to add a {
"host": "visualstudio"
} |
Co-authored-by: BillWagner <[email protected]>
Added the snippets.5000.json file with the required host configuration. This should fix the samples build. Commit: 2f7db4b |
@copilot The vbproj file needs to be updated to use .NET Framework 4.8. |
Co-authored-by: BillWagner <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ready for final review
@@ -49,7 +49,7 @@ If your code accesses the same object in multiple statements, you gain the follo | |||
|
|||
- You make your code more readable by eliminating repetitive qualifying expressions. | |||
|
|||
The data type of `objectExpression` can be any class or structure type or even a Visual Basic elementary type such as `Integer`. If `objectExpression` results in anything other than an object, you can only read the values of its members or invoke methods, and you get an error if you try to assign values to members of a structure used in a `With...End With` statement. This is the same error you would get if you invoked a method that returned a structure and immediately accessed and assigned a value to a member of the function’s result, such as `GetAPoint().x = 1`. The problem in both cases is that the structure exists only on the call stack, and there is no way a modified structure member in these situations can write to a location such that any other code in the program can observe the change. | |||
The data type of `objectExpression` can be any class or structure type or even a Visual Basic elementary type such as `Integer`. If `objectExpression` is a structure, the ability to assign to its members depends on whether the structure expression is referenceable. You can assign to members of structures that are directly referenceable (such as variables, array elements, or fields), but you get an error if you try to assign values to members of structures that are returned by value from functions, properties, or operators, or when parentheses are used to cut reference ties (e.g., `With (structureVariable)`). This is the same error you would get if you invoked a method that returned a structure and immediately accessed and assigned a value to a member of the function’s result, such as `GetAPoint().x = 1`. The problem in both cases is that the structure exists only on the call stack, and there is no way a modified structure member in these situations can write to a location such that any other code in the program can observe the change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data type of `objectExpression` can be any class or structure type or even a Visual Basic elementary type such as `Integer`. If `objectExpression` is a structure, the ability to assign to its members depends on whether the structure expression is referenceable. You can assign to members of structures that are directly referenceable (such as variables, array elements, or fields), but you get an error if you try to assign values to members of structures that are returned by value from functions, properties, or operators, or when parentheses are used to cut reference ties (e.g., `With (structureVariable)`). This is the same error you would get if you invoked a method that returned a structure and immediately accessed and assigned a value to a member of the function’s result, such as `GetAPoint().x = 1`. The problem in both cases is that the structure exists only on the call stack, and there is no way a modified structure member in these situations can write to a location such that any other code in the program can observe the change. | |
The data type of `objectExpression` can be any class or structure type or even a Visual Basic elementary type such as `Integer`. If `objectExpression` is a structure, the ability to assign to its members depends on whether the structure expression is referenceable. You can assign to members of structures that are directly referenceable (such as variables, array elements, or fields), but you get an error if you try to assign values to members of structures that are returned by value from functions, properties, or operators, or when parentheses are used to cut reference ties (for example, `With (structureVariable)`). This is the same error you would get if you invoked a method that returned a structure and immediately accessed and assigned a value to a member of the function's result, such as `GetAPoint().x = 1`. The problem in both cases is that the structure exists only on the call stack, and there is no way a modified structure member in these situations can write to a location such that any other code in the program can observe the change. |
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews