Skip to content

Conversation

@adamint
Copy link
Member

@adamint adamint commented Mar 2, 2023

Fixes AB#1741242

If the user has not defined a default namespace in VB .net framework, it will default to "My". We want to avoid My.My. being generated in the file generator.

Microsoft Reviewers: Open in CodeFlow

@adamint adamint requested a review from a team as a code owner March 2, 2023 00:36
End If

If defaultNamespace <> "" Then
If defaultNamespace <> "" And Not defaultNamespace.Equals(MyNamespaceName) Then ' defaultNamespace, if none exists, will come in thru wszDefaultNamespace as My. We don't want to duplicate it.
Copy link
Member

Choose a reason for hiding this comment

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

I took a look at the blame for this. Looks like you added the if-statement above this one for projectRootNamespace. So, is My being duplicated because your new if-statement prior to this has projectRootNamespace set to My? Then this if-statement was also executing causing My.My for fullTypeName?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

Relevant snippet:

There was a line that checks whether default namespace is empty, and if so does not append it to the generated type. So my assumption when modifying the file was that meant that having no default namespace would mean that the default namespace passed into the generator would be “”

Copy link
Member

Choose a reason for hiding this comment

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

Summoning a Ballad by Paul Vick:

Suggested change
If defaultNamespace <> "" And Not defaultNamespace.Equals(MyNamespaceName) Then ' defaultNamespace, if none exists, will come in thru wszDefaultNamespace as My. We don't want to duplicate it.
If defaultNamespace <> "" AndAlso Not defaultNamespace.Equals(MyNamespaceName) Then ' defaultNamespace, if none exists, will come in thru wszDefaultNamespace as My. We don't want to duplicate it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting. Will add

Copy link
Member

@drewnoakes drewnoakes left a comment

Choose a reason for hiding this comment

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

Is there a bug we can link this to, or repro steps to get into the state you are trying to prevent? The fix seems fine, but it's a bit abstract without that extra detail.

@adamint
Copy link
Member Author

adamint commented Mar 3, 2023

@drewnoakes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1741242/

@adamint adamint enabled auto-merge March 3, 2023 00:35
@adamint adamint merged commit 7df0c34 into dotnet:main Mar 3, 2023
@ghost ghost added this to the 17.6 milestone Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants