NightOwl888 commented on PR #1060:
URL: https://github.com/apache/lucenenet/pull/1060#issuecomment-3259870127

   I started a review, but got into the weeds a bit because I realized that the 
current port doesn't match the behavior of Java (at least according to ChatGPT 
- unconfirmed). The new string overload behavior should match Java, which is to 
pass the relative path down to the OS where it is resolved relative to the 
current application (the place where the jar lives). On the other hand, with 
`FileInfo` and `DirectoryInfo`, relative paths are resolved eagerly and not 
passed down to the OS. So, when we call `FullName` we don't necessarily have 
the same behavior.
   
   Unfortunately, `FileInfo` and `DirectoryInfo` have no way to retrieve the 
original string that was passed into the constructor. So, there doesn't seem to 
be a reasonable fix,. Well, there is a protected `OriginalString` property that 
we could get to using the 
[`UnsafeAccessorAttribute`](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.unsafeaccessorattribute)
 on `net8.0`+, but we are probably better off accepting the differences of 
calling `FullName` in most cases.
   
   Also, I suspect but haven't yet confirmed that the relative path behavior of 
our command line tools is broken. AFAIK, the expected behavior in a .NET 
console app is for a relative path to be resolved to the **environment's** 
current directory, but the behavior we have is relative to the directory of the 
executable. This behavior might be altered by wrapping these commands into a 
dotnet tool or by our (3rd party) wrapper project, though.
   
   One other thing I noticed is that the `FileInfo.GetCanonicalPath()` method 
was not included here, probably because you didn't think to look for the common 
base class of `FileInfo` and `DirectoryInfo`: 
[`FileSystemInfo`](https://learn.microsoft.com/en-us/dotnet/api/system.io.filesysteminfo).
 This is the only place outside of the test framework and one test where we use 
it, though.
   
   I will look into this more tomorrow. But we will need a clear idea of the 
*expected* behavior to get through this review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to