-
Notifications
You must be signed in to change notification settings - Fork 55
Use CompilationUnitManager.GetFileId instead of Uri.AbsolutePath for file IDs #175
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, relying on TryGetFileId should be fine. It looks like these URIs are always absolute and are always files. (Well, the files don't necessarily exist, but at least they are paths to files. 😊) The tests should cover this code pretty thoroughly as well, such that it's probably safe to do this, though I'd love to get @cgranade's eyes on it as well.
|
It looks fine to me, but that's the part of the iqsharp codebase that @anpaz-msft would know better than I would. The only edge case I could imagine is if someone has a file named |
I think that this edge case would exist independent of this PR - |
|
@SamarSha just FYI, the CI failure you're hitting is because the conda tests that I recently activated in the iqsharp CI aren't working correctly with -beta package versions. There is a workaround for this included in #177, which should be merged to master hopefully within a day. If you want to unblock your CI build here in the meantime, you could just apply this snippet directly to your branch: iqsharp/conda-recipes/iqsharp/test.ps1 Lines 8 to 18 in afaf38f
|
In microsoft/qsharp-compiler#468, I changed the compiler's representation of file IDs from
AbsolutePathtoLocalPathto fix a bug. This PR is needed to update a few places in IQ# that assumed that the file IDs wereAbsolutePaths.Although, actually, instead of using
LocalPathexplicitly (and needing to update it again if the file ID representation changes in the future), I would rather useCompilationUnitManager.TryGetFileIdin all cases. TheTry-ness ofTryGetFileIdmakes it awkward to use in places where I believe it's guaranteed to succeed, though.Since IQ# is accessing
AbsolutePathwithout checks, I think that means the URIs in IQ# are guaranteed to be absolute. Are they also guaranteed to be file URIs? (IsAbsoluteandIsFilebeing true are the only two things thatTryGetFileIdneeds.)@bettinaheim Would you be OK with a non-
Tryversion ofTryGetFileIdbeing added to the compiler?