Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void Clear()
{
try
{
GError err = (GError)Marshal.PtrToStructure(error, typeof(GError));
GError err = Marshal.PtrToStructure<GError>(error);
throw new InteropException(
$"An error was encountered while clearing secret from keyring in the {nameof(Storage)} domain:'{err.Domain}' code:'{err.Code}' message:'{err.Message}'",
err.Code);
Expand Down Expand Up @@ -136,7 +136,7 @@ public byte[] Read()
{
try
{
GError err = (GError)Marshal.PtrToStructure(error, typeof(GError));
GError err = Marshal.PtrToStructure<GError>(error);
throw new InteropException(
$"An error was encountered while reading secret from keyring in the {nameof(Storage)} domain:'{err.Domain}' code:'{err.Code}' message:'{err.Message}'", err.Code);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ public void Write(byte[] data)
{
try
{
GError err = (GError)Marshal.PtrToStructure(error, typeof(GError));
GError err = Marshal.PtrToStructure<GError>(error);
string message = $"An error was encountered while saving secret to keyring in the {nameof(Storage)} domain:'{err.Domain}' code:'{err.Code}' message:'{err.Message}'";
throw new InteropException(message, err.Code);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0')) ">
<IsAotCompatible>true</IsAotCompatible>
<IsTrimmable>true</IsTrimmable>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\..\README.md">
<Pack>True</Pack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ internal static class LibSystem

public static IntPtr GetGlobal(IntPtr handle, string symbol)
{
IntPtr ptr = dlsym(handle, symbol);
var structure = Marshal.PtrToStructure(ptr, typeof(IntPtr));
IntPtr ptr = dlsym(handle, symbol);
var structure = Marshal.PtrToStructure<IntPtr>(ptr);

return (IntPtr)structure;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNet)' ">
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(TargetFrameworkNet)')) ">
<IsAotCompatible>true</IsAotCompatible>
<IsTrimmable>true</IsTrimmable>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(TargetFrameworkNetDesktop462)' or '$(TargetFramework)' == '$(TargetFrameworkNetDesktop472)'">
<Compile Include="$(PathToMsalSources)\Platforms\Features\OpenTelemetry\**\*.cs" />

<PackageReference Include="System.Diagnostics.DiagnosticSource" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ [Out] out LsaSafeHandle LsaHandle
);

[DllImport(SECUR32)]
public static unsafe extern int LsaCallAuthenticationPackage(
public static extern unsafe int LsaCallAuthenticationPackage(
LsaSafeHandle LsaHandle,
int AuthenticationPackage,
void* ProtocolSubmitBuffer,
Expand Down Expand Up @@ -403,19 +403,20 @@ public void Dispose()
}
}

// Replace the usage of Marshal.PtrToStructure(IntPtr, Type) with the generic version Marshal.PtrToStructure<T>(IntPtr)
// in the ForEachBuffer method inside SecBufferDesc struct.

private void ForEachBuffer(Action<SecBuffer> onBuffer)
{
for (int Index = 0; Index < cBuffers; Index++)
{
int CurrentOffset = Index * Marshal.SizeOf(typeof(SecBuffer));
int CurrentOffset = Index * Marshal.SizeOf<SecBuffer>();

SecBuffer thisSecBuffer = (SecBuffer)Marshal.PtrToStructure(
SecBuffer thisSecBuffer = (SecBuffer)Marshal.PtrToStructure<SecBuffer>(
IntPtr.Add(
pBuffers,
CurrentOffset
),
typeof(SecBuffer)
);
));

onBuffer(thisSecBuffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public unsafe void ImportCredential(byte[] ticketBytes, long luid = 0)
{
MessageType = NativeMethods.KERB_PROTOCOL_MESSAGE_TYPE.KerbSubmitTicketMessage,
KerbCredSize = ticketBytes.Length,
KerbCredOffset = Marshal.SizeOf(typeof(NativeMethods.KERB_SUBMIT_TKT_REQUEST)),
KerbCredOffset = Marshal.SizeOf<NativeMethods.KERB_SUBMIT_TKT_REQUEST>(),
LogonId = luid
};

Expand Down
Loading