Skip to content

Commit 846587b

Browse files
committed
Fix some NativeAOT warnings
1 parent 36d14a4 commit 846587b

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/Resolvers/Microsoft.DotNet.NativeWrapper/Interop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static Interop()
3333
// construction so that subsequent P/Invokes can find it.
3434
private static void PreloadWindowsLibrary(string dllFileName)
3535
{
36-
string? basePath = Path.GetDirectoryName(typeof(Interop).Assembly.Location);
36+
string? basePath = AppContext.BaseDirectory;
3737
string architecture = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
3838
string dllPath = Path.Combine(basePath ?? string.Empty, architecture, $"{dllFileName}.dll");
3939

src/Resolvers/Microsoft.DotNet.NativeWrapper/Microsoft.DotNet.NativeWrapper.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>$(ResolverTargetFramework);net472</TargetFrameworks>
5+
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsAotCompatible>
56
</PropertyGroup>
67

78
<ItemGroup>

src/Resolvers/Microsoft.DotNet.NativeWrapper/NETEnvironmentInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ internal void Initialize(IntPtr info, IntPtr resultContext)
6666
var runtimes = new hostfxr_dotnet_environment_framework_info[infoStruct.framework_count];
6767
for (var i = 0; i < (int)infoStruct.framework_count; i++)
6868
{
69-
var pointer = new IntPtr(infoStruct.frameworks.ToInt64() + i * Marshal.SizeOf(typeof(hostfxr_dotnet_environment_framework_info)));
69+
var pointer = new IntPtr(infoStruct.frameworks.ToInt64() + i * Marshal.SizeOf<hostfxr_dotnet_environment_framework_info>());
7070
runtimes[i] = Marshal.PtrToStructure<hostfxr_dotnet_environment_framework_info>(pointer);
7171
}
7272
RuntimeInfo = runtimes.Select(runtime => new NetRuntimeInfo(runtime.name, runtime.version, runtime.path));
7373

7474
var sdks = new hostfxr_dotnet_environment_sdk_info[infoStruct.sdk_count];
7575
for (var i = 0; i < (int)infoStruct.sdk_count; i++)
7676
{
77-
var pointer = new IntPtr(infoStruct.sdks.ToInt64() + i * Marshal.SizeOf(typeof(hostfxr_dotnet_environment_sdk_info)));
77+
var pointer = new IntPtr(infoStruct.sdks.ToInt64() + i * Marshal.SizeOf<hostfxr_dotnet_environment_sdk_info>());
7878
sdks[i] = Marshal.PtrToStructure<hostfxr_dotnet_environment_sdk_info>(pointer);
7979
}
8080
SdkInfo = sdks.Select(sdk => new NetSdkInfo(sdk.version, sdk.path));

0 commit comments

Comments
 (0)