Repository navigation
Clean up resx code - #212
Conversation
|
I feel like I need more info on what it means to "Use newer C# features where possible"; the rest I get |
|
Thanks @Liminiens for this PR! We'll review soon and get some regression testing done offline. In the meantime, please file a corresponding issue so we can better track things. Thanks! |
zsd4yr
left a comment
There was a problem hiding this comment.
In general, this is a great add to the codebase. A few questions we need answered before proceeding. You should also expect that you'll be asked to write unit tests for (some of) these (as we really need them). In particular, I think you could focus yourself on writing tests for functions where a change was made to:
- use a switch statement instead of if/elseif/else pattern
- create the object in scope
- or when this pattern "fileRef?.FileName ?? fileRefFullPath" was used
Perhaps @AdamYoblick can speak better to where tests might be most necessary
| AddDataRow(elementName, info.Name, info.ValueData, info.TypeName, info.MimeType, info.Comment); | ||
| break; | ||
| } | ||
| default: |
There was a problem hiding this comment.
maybe @dreddy-work can advise on what the default, if any, work should be done?
There was a problem hiding this comment.
what if value=null? or it can't be the case at all?.
I need better editor to review code. From browser, it is hard to look for the callers etc. :)
There was a problem hiding this comment.
oh I see the else below, my b
|
@zsd4yr sorry for being unclear, with "Use newer C# features where possible" I ment "improve code readability" with things like pattern matching, object Initializer syntax in places where it could make code more clear :) I will reword the text. |
|
@merriemcgaw i added #216 for this pr :) |
|
@zsd4yr tests should be added in |
|
@Liminiens because these code changes are in System.Windows.Forms, that’s correct. There are separate test projects for each of the three binaries currently in the solution. |
| } | ||
| else if (names != null) | ||
| { | ||
| foreach (AssemblyName asmName in names.Where(an => an.Equals(name))) |
There was a problem hiding this comment.
Compared to the previous version, this now allocates a lambda capture and an enumerator instance when hit. Unroll the LINQ inline like below to keep previous performance characteristics?
foreach (AssemblyName asmName in names) {
if (!name.Equals (asmName))
continue;
...
}
There was a problem hiding this comment.
Not sure if we want to preemptively optimize generally; however, this is a good suggestion for this spot.
This is only of concern if these allocations take a "too much" time, as they should be on the stack?
…string.IsNullOrEmpty in ResXDataNode
|
@AdamYoblick @zsd4yr I added some tests, mostly for ResXFileRef.Converter. Can you take a look? :) |
sharwell
left a comment
There was a problem hiding this comment.
Temporarily marking as blocked while I discuss a couple of items with the team. Normally changes to code style are only submitted by one of the project maintainers for two reasons:
- Avoid code churn in areas where the project has not adopted and applied a unified style
- Strictly contain style changes by subject, and ensure the changes are applied in a manner that works well with source control history (see e.g. dotnet/roslyn#31652 which was internally coordinated and applied to minimize disruption)
|
There are missing explicit this. in some places . Should I add them? |
|
@Liminiens Please note that even if the style changes from this aren't brought in, I'll find a way to ensure the tests you added are correctly assigned with you as the contributor. It can be hard to find people to write tests and very much appreciated when someone takes the time to do so. Also note that you probably shouldn't take direct action per my previous comment at this time. It's possible the style changes are handled separately, but it's also possible an exception (full or partial) gets made for this pull request. I won't know more until I meet with the maintainers. |
|
@sharwell ok, understood :) |
|
@Liminiens I am going to rake through this PR later this afternoon and mentally separate your changes into (1) code upgrades and (2) style changes. Likely we will need to work together afterwords to separate our your style changes as we have yet to agree on a cohesive style. Sorry to burden you with this, but the team really wants to take these code upgrades; we're just not ready for the style changes 😭 |
@zsd4yr is following up on the code style issues
|
@Liminiens I've finished my review; going to circulate among the team for feedback before sharing 😄 Don't want to tell you something and then later be wrong... I'll come back to this thread once things are settled. Hopefully later this week |
|
@Liminiens I believe we are satisfied to take this once you have had a chance to resolve these merge conflicts. |
…-cleanup # Conflicts: # src/System.Windows.Forms/src/System/Resources/ResXDataNode.cs # src/System.Windows.Forms/src/System/Resources/ResXFileRef.cs # src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs
|
@zsd4yr done :) |
| AddDataRow(elementName, info.Name, info.ValueData, info.TypeName, info.MimeType, info.Comment); | ||
| break; | ||
| } | ||
| default: |
There was a problem hiding this comment.
oh I see the else below, my b
Including dotnet/winforms#212.
Addreses #216
String.Splitoverloadstr != null && str.Length > 0pattern withString.IsNullOrEmptyisMetaDatainResXResourceReader.ParseAssemblyNodebinaryFormatterinResXResourceWriterifstatements where possibleforloops withforeachloops