8000 Updates for trimming compatibility by bording · Pull Request #2084 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

Skip to content

Updates for trimming compatibility #2084

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

Merged
merged 4 commits into from
Mar 16, 2024
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
Prev Previous commit
Next Next commit
Address trimming warnings
  • Loading branch information
bording committed Mar 16, 2024
commit 70ac848e7faa2f42a3d90a32dbc118a932051617
6 changes: 6 additions & 0 deletions LibGit2Sharp/Core/GitObjectLazyGroup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using LibGit2Sharp.Core.Handles;

namespace LibGit2Sharp.Core
Expand All @@ -21,7 +22,12 @@ protected override void EvaluateInternal(Action<ObjectHandle> evaluator)
}
}

#if NET
public static ILazy<TResult> Singleton<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TResult>(Repository repo, ObjectId id, Func<ObjectHandle, TResult> resultSelector, bool throwIfMissing = false)
#else
public static ILazy<TResult> Singleton<TResult>(Repository repo, ObjectId id, Func<ObjectHandle, TResult> resultSelector, bool throwIfMissing = false)
#endif

{
return Singleton(() =>
{
Expand Down
9 changes: 9 additions & 0 deletions LibGit2Sharp/Core/LazyGroup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace LibGit2Sharp.Core
{
Expand Down Expand Up @@ -44,7 +45,11 @@ public void Evaluate()

protected abstract void EvaluateInternal(Action<T> evaluator);

#if NET
protected static ILazy<TResult> Singleton<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TResult>(Func<TResult> resultSelector)
#else
protected static ILazy<TResult> Singleton<TResult>(Func<TResult> resultSelector)
#endif
{
return new LazyWrapper<TResult>(resultSelector);
}
Expand Down Expand Up @@ -90,7 +95,11 @@ void IEvaluator<TInput>.Evaluate(TInput input)
}
}

#if NET
protected class LazyWrapper<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TType> : Lazy<TType>, ILazy<TType>
#else
protected class LazyWrapper<TType> : Lazy<TType>, ILazy<TType>
#endif
{
public LazyWrapper(Func<TType> evaluator)
: base(evaluator)
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static IntPtr ResolveDll(string libraryName, Assembly assembly, DllImpor
{
// The libraries are located at 'runtimes/<rid>/native/lib{libraryName}.so'
// The <rid> ends with the processor architecture. e.g. fedora-x64.
string assemblyDirectory = Path.GetDirectoryName(typeof(NativeMethods).Assembly.Location);
string assemblyDirectory = Path.GetDirectoryName(AppContext.BaseDirectory);
string processorArchitecture = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
string runtimesDirectory = Path.Combine(assemblyDirectory, "runtimes");

Expand Down
4 changes: 4 additions & 0 deletions LibGit2Sharp/Core/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public static string GetNativeLibraryExtension()
/// Returns true if the runtime is Mono.
/// </summary>
public static bool IsRunningOnMono()
#if NETFRAMEWORK
=> Type.GetType("Mono.Runtime") != null;
#else
=> false;
#endif

/// <summary>
/// Returns true if the runtime is .NET Framework.
Expand Down
5 changes: 5 additions & 0 deletions LibGit2Sharp/ReferenceWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using LibGit2Sharp.Core;

Expand All @@ -10,7 +11,11 @@ namespace LibGit2Sharp
/// </summary>
/// <typeparam name="TObject">The type of the referenced Git object.</typeparam>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
#if NET
public abstract class ReferenceWrapper<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TObject> : IEquatable<ReferenceWrapper<TObject>>, IBelongToARepository where TObject : GitObject
#else
public abstract class ReferenceWrapper<TObject> : IEquatable<ReferenceWrapper<TObject>>, IBelongToARepository where TObject : GitObject
#endif
{
/// <summary>
/// The repository.
Expand Down
0