Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Get correct PackageCompiler.SdkDirectory for all platforms #2271

Merged
merged 1 commit into from
May 26, 2024

Conversation

Jklawreszuk
Copy link
Collaborator

PR Details

Description

PR simplifies getting correct SdkDirectory path. The previous way of moving folders two up, used UriBuilder, but it threw an exception on Unix systems

Motivation and Context

This PR is a part of making AssetCompiler crossplatform.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

Comment on lines 24 to 25
// from ../bin/Debug/net{version} -> ../bin
SdkDirectory = Directory.GetParent(codeBase)?.Parent?.Parent?.FullName ?? "";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directory goes through and reads from the filesystem afair while Path just works on the string representation of the path.
You can chain Path.GetDirectoryName calls if you want to do something similar, see examples in
https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getdirectoryname?view=net-8.0#system-io-path-getdirectoryname(system-string)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Eideren Good point. I did a simple benchmark and my fix was about 2 times slower. I started all over and I noticed UriBuilder does nothing so I removed it so it wouldn't throw an exception anymore

Copy link
Collaborator Author

@Jklawreszuk Jklawreszuk May 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Eideren I get it now why UriBuilder was in the first place! Thats because .NET Framework Assembly.CodeBase (5059972) was returning URI path : https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.codebase?view=net-8.0 which is useless now.

@Jklawreszuk Jklawreszuk requested a review from Eideren May 25, 2024 21:59
@Eideren Eideren merged commit 59ec859 into stride3d:master May 26, 2024
13 checks passed
@Eideren
Copy link
Collaborator

Eideren commented May 26, 2024

Thanks !

@Jklawreszuk Jklawreszuk deleted the StrideSdkDirFix branch May 26, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants