Fixed FormatException when trying to publicize the Photon assemblies in R.E.P.O.#26
Fixed FormatException when trying to publicize the Photon assemblies in R.E.P.O.#26AraHaan wants to merge 2 commits into
Conversation
…in R.E.P.O. Refactor TryGetMetadata method to handle missing metadata correctly and improve comments regarding Photon assemblies.
|
cc: @js6pak can we please get this in ASAP, this is a blocking issue for my R.E.P.O. mod that uses BepInEx. |
|
If you can fix it locally, you can reference it locally, and use it in your project without requiring the PR to be merged ASAP. |
I fixed this in the GitHub web editor 😂. |
And you can't clone your PR locally and use it? |
|
My C# knowledge isn't much but logically this looks confusing after the change because of the duplicate
So this is untested? |
|
Here is the fix I originally suggested before the PR author edited it public static bool TryGetMetadata(this ITaskItem taskItem, string metadataName, [NotNullWhen(true)] out string? metadata)
{
metadata = null;
if (!taskItem.HasMetadata(metadataName)) return false;
metadata = taskItem.GetMetadata(metadataName);
if (!String.IsNullOrWhiteSpace(metadata)) return true;
metadata = null;
return false;
}This is untested but it doesn't need testing. It's verifiably the same behaviour as the original function, with the caveat that it returns I can't necessarily say the same for this PR's changes |
|
I will need to apply suggested changes tomorrow as my PC's power supply decided today of all days that it was time for it to quit working entirely and the replacement might arrive then. |
When |
The "variable reassignment" is a duplication of work, splitting the logic by having two sections doing the same This is what I was thinking, which would just be a three line addition and follows the original style for readability. public static bool TryGetMetadata(this ITaskItem taskItem, string metadataName, [NotNullWhen(true)] out string? metadata)
{
if (taskItem.HasMetadata(metadataName))
{
metadata = taskItem.GetMetadata(metadataName);
if (!string.IsNullOrWhiteSpace(metadata))
{
return true;
}
}
metadata = null;
return false;
} |
|
@arrowmaster i dislike this because imo nesting I don't care to argue over semantics/codestyle any further, the code-owners/maintainers should express their preference. |
Co-authored-by: Joe Clack <28568841+Lordfirespeed@users.noreply.github.com>
|
I agree with them on this, nesting ifs becomes a complex and unreadable problem at some point. |
Refactor TryGetMetadata method to handle missing metadata correctly and improve comments regarding Photon assemblies.