mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Remove all uses of InlineIL.Fody
This commit is contained in:
parent
72b9a1e5d0
commit
c7dcbab6ff
8 changed files with 46 additions and 75 deletions
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using InlineIL;
|
||||
using LibHac.Diag;
|
||||
|
||||
#pragma warning disable LH0001
|
||||
|
@ -13,17 +12,13 @@ public static class SharedRefExtensions
|
|||
// ReSharper disable once EntityNameCapturedOnly.Global
|
||||
public static ref SharedRef<T> Ref<T>(this in SharedRef<T> value) where T : class, IDisposable
|
||||
{
|
||||
IL.Emit.Ldarg(nameof(value));
|
||||
IL.Emit.Ret();
|
||||
throw IL.Unreachable();
|
||||
return ref Unsafe.AsRef(in value);
|
||||
}
|
||||
|
||||
// ReSharper disable once EntityNameCapturedOnly.Global
|
||||
public static ref WeakRef<T> Ref<T>(this in WeakRef<T> value) where T : class, IDisposable
|
||||
{
|
||||
IL.Emit.Ldarg(nameof(value));
|
||||
IL.Emit.Ret();
|
||||
throw IL.Unreachable();
|
||||
return ref Unsafe.AsRef(in value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using InlineIL;
|
||||
using static InlineIL.IL.Emit;
|
||||
|
||||
namespace LibHac.Common;
|
||||
|
||||
|
@ -10,9 +9,7 @@ public static class UniqueRefExtensions
|
|||
// ReSharper disable once EntityNameCapturedOnly.Global
|
||||
public static ref UniqueRef<T> Ref<T>(this in UniqueRef<T> value) where T : class, IDisposable
|
||||
{
|
||||
Ldarg(nameof(value));
|
||||
Ret();
|
||||
throw IL.Unreachable();
|
||||
return ref Unsafe.AsRef(in value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,16 +18,8 @@ public struct UniqueRef<T> : IDisposable where T : class, IDisposable
|
|||
{
|
||||
private T _value;
|
||||
|
||||
public readonly ref T Get
|
||||
{
|
||||
get
|
||||
{
|
||||
Ldarg_0();
|
||||
Ldflda(new FieldRef(typeof(UniqueRef<T>), nameof(_value)));
|
||||
Ret();
|
||||
throw IL.Unreachable();
|
||||
}
|
||||
}
|
||||
[UnscopedRef]
|
||||
public readonly ref readonly T Get => ref _value;
|
||||
|
||||
public readonly bool HasValue => Get is not null;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.Diagnostics;
|
|||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Util;
|
||||
using static InlineIL.IL.Emit;
|
||||
using static LibHac.Fs.StringTraits;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
|
@ -45,30 +44,40 @@ public static class PathExtensions
|
|||
/// of the input <see langword="readonly"/> reference.</para></remarks>
|
||||
/// <param name="path">The read-only reference to reinterpret.</param>
|
||||
/// <returns>A reference to the given <see cref="Path"/>.</returns>
|
||||
// ReSharper disable once EntityNameCapturedOnly.Global
|
||||
public static ref Path Ref(this scoped in Path path)
|
||||
#pragma warning disable LH0001 // DoNotCopyValue
|
||||
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
|
||||
public static unsafe ref Path Ref(this scoped in Path path)
|
||||
{
|
||||
Ldarg(nameof(path));
|
||||
Ret();
|
||||
throw InlineIL.IL.Unreachable();
|
||||
fixed (Path* p = &path)
|
||||
{
|
||||
return ref *p;
|
||||
}
|
||||
}
|
||||
|
||||
public static ref Path GetNullRef()
|
||||
public static unsafe ref Path GetNullRef()
|
||||
{
|
||||
Ldc_I4_0();
|
||||
Conv_U();
|
||||
Ret();
|
||||
throw InlineIL.IL.Unreachable();
|
||||
// Todo: Combine into one statement once ReSharper stops detecting that as an error
|
||||
var p = (Path*)null;
|
||||
return ref *p;
|
||||
}
|
||||
|
||||
public static bool IsNullRef(in Path path)
|
||||
public static unsafe bool IsNullRef(in Path path)
|
||||
{
|
||||
Ldarg_0();
|
||||
Ldc_I4_0();
|
||||
Conv_U();
|
||||
Ceq();
|
||||
return InlineIL.IL.Return<bool>();
|
||||
fixed (Path* p = &path)
|
||||
{
|
||||
return p == null;
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe bool IsNullRef(in int path)
|
||||
{
|
||||
fixed (int* p = &path)
|
||||
{
|
||||
return p == null;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
|
||||
#pragma warning restore LH0001 // DoNotCopyValue
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1214,7 +1223,7 @@ public static class PathFunctions
|
|||
/// <returns><see cref="Result.Success"/>: The operation was successful.<br/>
|
||||
/// <see cref="ResultFs.InvalidArgument"/>: <paramref name="pathBuffer"/> was too small to contain the built path.</returns>
|
||||
internal static Result SetUpFixedPathDoubleEntry(scoped ref Path path, Span<byte> pathBuffer,
|
||||
scoped ReadOnlySpan<byte> entryName1, scoped ReadOnlySpan<byte> entryName2)
|
||||
scoped ReadOnlySpan<byte> entryName1, scoped ReadOnlySpan<byte> entryName2)
|
||||
{
|
||||
var sb = new U8StringBuilder(pathBuffer);
|
||||
sb.Append((byte)'/').Append(entryName1)
|
||||
|
|
|
@ -590,7 +590,7 @@ namespace LibHac.Fs.Shim
|
|||
}
|
||||
|
||||
public static Result ReadSaveDataIteratorSaveDataInfo(this FileSystemClientImpl fs, out long readCount,
|
||||
Span<SaveDataInfo> buffer, ref SaveDataIterator iterator)
|
||||
Span<SaveDataInfo> buffer, SaveDataIterator iterator)
|
||||
{
|
||||
Result res = iterator.ReadSaveDataInfo(out readCount, buffer);
|
||||
if (res.IsFailure()) return res.Miss();
|
||||
|
|
|
@ -367,7 +367,7 @@ namespace LibHac.Fs.Shim
|
|||
Unsafe.SkipInit(out SaveDataInfo info);
|
||||
|
||||
res = fs.Impl.ReadSaveDataIteratorSaveDataInfo(out long count, SpanHelpers.AsSpan(ref info),
|
||||
ref iterator.Get);
|
||||
iterator.Get);
|
||||
|
||||
fs.Impl.LogResultErrorMessage(res);
|
||||
if (res.IsFailure()) return res.Miss();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
|
@ -887,15 +888,8 @@ public partial class BucketTree : IDisposable
|
|||
/// <remarks><para>This property allows using a <see langword="using"/> expression with <see cref="Visitor"/>s
|
||||
/// while still being able to pass it by reference.</para></remarks>
|
||||
/// <returns>A reference to this <see cref="Visitor"/>.</returns>
|
||||
public ref Visitor Ref
|
||||
{
|
||||
get
|
||||
{
|
||||
InlineIL.IL.Emit.Ldarg_0();
|
||||
InlineIL.IL.Emit.Ret();
|
||||
throw InlineIL.IL.Unreachable();
|
||||
}
|
||||
}
|
||||
[UnscopedRef]
|
||||
public ref Visitor Ref => ref this;
|
||||
|
||||
internal Result Initialize(BucketTree tree, in Offsets offsets)
|
||||
{
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
<PathMap Condition=" '$(BuildType)' == 'Release' and '$(HasGitDir)' == 'false' ">$(MSBuildProjectDirectory)=C:/LibHac/</PathMap>
|
||||
<DeterministicSourcePaths Condition=" '$(BuildType)' == 'Release' and '$(HasGitDir)' == 'true' ">true</DeterministicSourcePaths>
|
||||
|
||||
<!-- Workaround https://github.com/jbevain/cecil/issues/610 by including the pdb in the main .nupkg -->
|
||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -41,8 +38,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fody" Version="6.6.4" PrivateAssets="All" />
|
||||
<PackageReference Include="InlineIL.Fody" Version="1.7.2" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -52,13 +47,4 @@
|
|||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Configuration for Fody -->
|
||||
<PropertyGroup>
|
||||
<WeaverConfiguration>
|
||||
<Weavers>
|
||||
<InlineIL />
|
||||
</Weavers>
|
||||
</WeaverConfiguration>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -2,7 +2,6 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using LibHac.Common;
|
||||
using static InlineIL.IL.Emit;
|
||||
|
||||
namespace LibHac.Os;
|
||||
|
||||
|
@ -26,20 +25,19 @@ public static class UniqueLock
|
|||
return new UniqueLock<TMutex>(lockable);
|
||||
}
|
||||
|
||||
// ReSharper disable once EntityNameCapturedOnly.Global
|
||||
public static ref UniqueLockRef<T> Ref<T>(this in UniqueLockRef<T> value) where T : struct, ILockable
|
||||
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
|
||||
public static unsafe ref UniqueLockRef<T> Ref<T>(this in UniqueLockRef<T> value) where T : struct, ILockable
|
||||
{
|
||||
Ldarg(nameof(value));
|
||||
Ret();
|
||||
throw InlineIL.IL.Unreachable();
|
||||
fixed (UniqueLockRef<T>* p = &value)
|
||||
{
|
||||
return ref *p;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
|
||||
|
||||
// ReSharper disable once EntityNameCapturedOnly.Global
|
||||
public static ref UniqueLock<T> Ref<T>(this in UniqueLock<T> value) where T : class, ILockable
|
||||
{
|
||||
Ldarg(nameof(value));
|
||||
Ret();
|
||||
throw InlineIL.IL.Unreachable();
|
||||
return ref Unsafe.AsRef(in value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue