Got rid of a few warnings#413
Conversation
d703b81 to
4fd3b74
Compare
src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs
Outdated
Show resolved
Hide resolved
e039ad5 to
3a3fed7
Compare
3a3fed7 to
354d24c
Compare
…ems: - ToString() may be overridden in a class, returning a custom string instead of the type name. - Not guaranteed to return the type name, which is what ObjectDisposedException expects. - Returns the runtime type of the instance, ensuring accuracy. - Works even in derived classes, reflecting the actual type rather than the base type. - Recommended by Microsoft for ObjectDisposedException.
|
|
||
| if (File.Exists(PortableModeDir + Path.DirectorySeparatorChar + PortableModeSettingsFileName) == false) | ||
| if (!File.Exists(Path.Combine(PortableModeDir, PortableModeSettingsFileName))) |
There was a problem hiding this comment.
Path.Combine, sometimes does not work with linux and can have unforeseen consequences => https://learn.microsoft.com/en-us/dotnet/api/system.io.path.combine?view=net-9.0#remarks
| } | ||
|
|
||
| if (!File.Exists(dir + Path.DirectorySeparatorChar + "settings.json")) | ||
| if (!File.Exists(Path.Combine(dir, "settings.json"))) |
There was a problem hiding this comment.
Path.Combine, sometimes does not work with linux and can have unforeseen consequences => https://learn.microsoft.com/en-us/dotnet/api/system.io.path.combine?view=net-9.0#remarks
There was a problem hiding this comment.
I don't see the Linux part you are talking about in the link. Can you point me to it?
Reading a bit about the new Path.Join I still see no reason to not use Path.Combine. It is better than the current code and gives a better result than Path.Join in case there is an absolute path.
There was a problem hiding this comment.
in the example you can see that it happens that 2 Path Separators are printed, which could lead to problems
string[] paths = {@"d:\archives", "2001", "media", "images"};
string fullPath = Path.Combine(paths);
Console.WriteLine(fullPath);
paths = new string[] {@"d:\archives\", @"2001\", "media", "images"};
fullPath = Path.Combine(paths);
Console.WriteLine(fullPath);
paths = new string[] {"d:/archives/", "2001/", "media", "images"};
fullPath = Path.Combine(paths);
Console.WriteLine(fullPath);
// The example displays the following output if run on a Windows system:
// d:\archives\2001\media\images
// d:\archives\2001\media\images
// d:/archives/2001/media\images
//
// The example displays the following output if run on a Unix-based system:
// d:\archives/2001/media/images
// d:\archives\/2001\/media/images
// d:/archives/2001/media/images
There was a problem hiding this comment.
https://www.davidboike.dev/2020/06/path-combine-isnt-as-cross-platform-as-you-think-it-is/
but maybe I'm overthinking it
There was a problem hiding this comment.
I think you are right :)
Regarding the example you showed it is not relevant for Linux or Mac and anyway it is a bad way to use Path.Combine.
I don't think this should be dealt now. If there would be a problem the day we will go to Linux we will fix it.
Solved IDE0035
Solved IDE0058
Fixed warnings
baaa9e8 to
1a3a435
Compare
| } | ||
|
|
||
| if (!File.Exists(dir + Path.DirectorySeparatorChar + "settings.json")) | ||
| if (!File.Exists(Path.Combine(dir, "settings.json"))) |
There was a problem hiding this comment.
in the example you can see that it happens that 2 Path Separators are printed, which could lead to problems
string[] paths = {@"d:\archives", "2001", "media", "images"};
string fullPath = Path.Combine(paths);
Console.WriteLine(fullPath);
paths = new string[] {@"d:\archives\", @"2001\", "media", "images"};
fullPath = Path.Combine(paths);
Console.WriteLine(fullPath);
paths = new string[] {"d:/archives/", "2001/", "media", "images"};
fullPath = Path.Combine(paths);
Console.WriteLine(fullPath);
// The example displays the following output if run on a Windows system:
// d:\archives\2001\media\images
// d:\archives\2001\media\images
// d:/archives/2001/media\images
//
// The example displays the following output if run on a Unix-based system:
// d:\archives/2001/media/images
// d:\archives\/2001\/media/images
// d:/archives/2001/media/images
| } | ||
|
|
||
| if (!File.Exists(dir + Path.DirectorySeparatorChar + "settings.json")) | ||
| if (!File.Exists(Path.Combine(dir, "settings.json"))) |
There was a problem hiding this comment.
https://www.davidboike.dev/2020/06/path-combine-isnt-as-cross-platform-as-you-think-it-is/
but maybe I'm overthinking it
…into clean_warnings # Conflicts: # src/LogExpert.UI/Controls/BufferedDataGridView.cs # src/LogExpert.UI/Controls/LogWindow/LogWindowPublic.cs # src/LogExpert.UI/Extensions/BookmarkExporter.cs # src/LogExpert/Classes/LogExpertProxy.cs # src/LogExpert/Program.cs
No description provided.