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

Supporting namespaces in partial classes #149

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

RunninglVlan
Copy link
Contributor

@RunninglVlan RunninglVlan commented Nov 14, 2024

I got tired of waiting and fixed #137 myself 😅
Also included fix for tests - all of them are now green on my machine too.
And small performance improvement.
Found another bug and fixed it - partial type inner types were duplicated on namespace level (there was correct inner type inside partial type and the same was duplicated on namespace level and resulting file wouldn't compile).
And another bug and fixed it - using directives were duplicated in merged partial classes.

Removed unused collection
They didn't check for namespace - it started missing
@RunninglVlan RunninglVlan changed the title Fixes #137: Supporting namespaces in partial classes Supporting namespaces in partial classes Nov 14, 2024
@handzlikchris
Copy link
Owner

that's the spirit! I'll check it out, thanks!

Copy link
Owner

@handzlikchris handzlikchris left a comment

Choose a reason for hiding this comment

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

Nice, thanks for adding those. I've left some changes we should do before merging - so it'll be bit easier to understand.

var combinedUsingDirectives = new HashSet<UsingDirectiveSyntax>();
var combinedTypesDefined = new HashSet<string>();
// root key is namespace, inner key is type
var combinedTypes = new Dictionary<string, Dictionary<string, List<TypeDeclarationSyntax>>>();
Copy link
Owner

Choose a reason for hiding this comment

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

would be good to use named type - this way comment is not necessary and whoever works with the structure knows what it represents

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So how would you like this type to look like? Anyway, feel free to make it a type ;)

Copy link
Owner

Choose a reason for hiding this comment

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

no probs - I'll try

continue;
}

var namespaceName = NamespaceHelper.GetNamespaceName(typeDecl);
Copy link
Owner

Choose a reason for hiding this comment

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

why did we previously need FQDN and now we just use namespace instead? Does that not break some other use cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Type name is still used below. We're grouping namespaces and types in those namespaces.

Copy link
Owner

Choose a reason for hiding this comment

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

Alright just to clarify my question some more - FQDN would suggest like RootNamespace.ChildNamespace - so to me GetNamespaceFQDNName would return whole string where GetNamespaceName would return just ChildNamespace - from code it looks that's the case. I'm just wondering if that change doesn't break previous code that assumed it'll be FQND?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously it was returning full namespace + type name, now it returns just full namespace.
I just tested and it works as I said.

@handzlikchris
Copy link
Owner

Nice! Some good stuff here, thanks for the changes.

I left some notes - I think we should change it a little bit so it's easier to understand.

Also flagging @Jlabarca as he made partials support intially and may be able to see something I don't with regards to existing functionality

Copy link
Contributor Author

@RunninglVlan RunninglVlan left a comment

Choose a reason for hiding this comment

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

Added answers/comments.

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.

Partial class merging doesn't keep namespace
2 participants