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

Add ToDictionarySkipDuplicates - fix duplicate key. #395

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

ricaun
Copy link
Contributor

@ricaun ricaun commented Feb 18, 2025

This pr is related to the issue: #394

@ricaun ricaun changed the title Add ToDictionarySkipDuplicates Add ToDictionarySkipDuplicates - fix duplicate key. Feb 18, 2025
@ricaun
Copy link
Contributor Author

ricaun commented Feb 18, 2025

Hey @warappa could you take a look if skip the duplicate key is a valid solution. Thanks.

@warappa
Copy link
Contributor

warappa commented Feb 18, 2025

I think this is fine! 👍

@warappa
Copy link
Contributor

warappa commented Feb 18, 2025

The only question that arises is, if the deep-first-search is then the correct one to do or if in such a case a "top-first-search" would be better. You woukd have to test if the newer System.Text.Json is detected or the older one.

EDIT: But maybe this is not of an issue here, as we compare the AssemblyDefinitions against the previously resolved and passed down AssemblyDefinitions.

@ricaun
Copy link
Contributor Author

ricaun commented Feb 18, 2025

The only question that arises is, if the deep-first-search is then the correct one to do or if in such a case a "top-first-search" would be better. You woukd have to test if the newer System.Text.Json is detected or the older one.

EDIT: But maybe this is not of an issue here, as we compare the AssemblyDefinitions against the previously resolved and passed down AssemblyDefinitions.

Actually is not a System.Text.Json problem, is because I'm repacking the same file 2 times, or two files with the same assembly name.

Like creating a copy of the dll and repack the source and the copy.
ILRepack.exe /allowdup /allowduplicateresources /out:IssueILRepackOut.dll IssueILRepack.dll IssueILRepack.Copy.dll

This trigger the same key in the dictionary. #394

var dict = new Dictionary<string, AssemblyDefinition>();
foreach (var assembly in assemblies)
{
if (!dict.ContainsKey(assembly.Name.Name))
Copy link
Collaborator

Choose a reason for hiding this comment

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

assembly.Name.Name is repeated three times, it's good to extract a local variable and reuse it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense, oh you already changed to the key. Nice!

@KirillOsenkov KirillOsenkov merged commit 357b850 into gluck:master Feb 19, 2025
1 check passed
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