Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 2, 2025

  • Fix misleading documentation about structure assignments in With...End With statements
  • Update documentation to correctly explain when structure member assignments work vs fail
  • Add comprehensive code examples showing valid and invalid scenarios
  • Add snippets.5000.json file to fix sample build configuration
  • Update vbproj file to target .NET Framework 4.8

✨ 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

📄 File 🔗 Preview link
docs/visual-basic/language-reference/statements/with-end-with-statement.md docs/visual-basic/language-reference/statements/with-end-with-statement

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Sep 2, 2025
@Copilot Copilot AI changed the title [WIP] Misleading details about Structure and With statement Fix misleading documentation about structure assignments in With...End With statements Sep 2, 2025
@Copilot Copilot AI requested a review from BillWagner September 2, 2025 21:41
Copilot finished work on behalf of BillWagner September 2, 2025 21:41
@BillWagner
Copy link
Member

@copilot

To get the samples build to work correctly, you need to add a snippets.5000.json file in the "samples/snippets/visualbasic/VS_Snippets_VBCSharp/vbvbalrwithstatement/vb" folder. The contents should be:

{
    "host": "visualstudio"
}

Copy link
Contributor Author

Copilot AI commented Sep 3, 2025

@copilot

To get the samples build to work correctly, you need to add a snippets.5000.json file in the "samples/snippets/visualbasic/VS_Snippets_VBCSharp/vbvbalrwithstatement/vb" folder. The conte...

Added the snippets.5000.json file with the required host configuration. This should fix the samples build. Commit: 2f7db4b

Copilot finished work on behalf of BillWagner September 3, 2025 14:09
@BillWagner
Copy link
Member

@copilot The vbproj file needs to be updated to use .NET Framework 4.8.

Copy link
Contributor Author

Copilot AI commented Sep 3, 2025

@copilot The vbproj file needs to be updated to use .NET Framework 4.8.

Updated the vbproj file to target .NET Framework 4.8 and removed the client profile setting. Commit: 69af60f

Copilot finished work on behalf of BillWagner September 3, 2025 14:19
@BillWagner BillWagner marked this pull request as ready for review September 4, 2025 13:45
@BillWagner BillWagner requested a review from a team as a code owner September 4, 2025 13:45
Copy link
Member

@BillWagner BillWagner left a 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

@BillWagner BillWagner requested review from gewarren and a team and removed request for a team September 4, 2025 13:45
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested 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.
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-visualbasic/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants