8000 Address trimming warnings · libgit2/libgit2sharp@70ac848 · GitHub
[go: up one dir, main page]

Skip to content

Commit 70ac848

Browse files
committed
Address trimming warnings
1 parent 2cad6cd commit 70ac848

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

LibGit2Sharp/Core/GitObjectLazyGroup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics.CodeAnalysis;
23
using LibGit2Sharp.Core.Handles;
34

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

25+
#if NET
26+
public static ILazy<TResult> Singleton<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TResult>(Repository repo, ObjectId id, Func<ObjectHandle, TResult> resultSelector, bool throwIfMissing = false)
27+
#else
2428
public static ILazy<TResult> Singleton<TResult>(Repository repo, ObjectId id, Func<ObjectHandle, TResult> resultSelector, bool throwIfMissing = false)
29+
#endif
30+
2531
{
2632
return Singleton(() =>
2733
{

LibGit2Sharp/Core/LazyGroup.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34

45
namespace LibGit2Sharp.Core
56
{
@@ -44,7 +45,11 @@ public void Evaluate()
4445

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

48+
#if NET
49+
protected static ILazy<TResult> Singleton<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TResult>(Func<TResult> resultSelector)
50+
#else
4751
protected static ILazy<TResult> Singleton<TResult>(Func<TResult> resultSelector)
52+
#endif
4853
{
4954
return new LazyWrapper<TResult>(resultSelector);
5055
}
@@ -90,7 +95,11 @@ void IEvaluator<TInput>.Evaluate(TInput input)
9095
}
9196
}
9297

98+
#if NET
99+
protected class LazyWrapper<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TType> : Lazy<TType>, ILazy<TType>
100+
#else
93101
protected class LazyWrapper<TType> : Lazy<TType>, ILazy<TType>
102+
#endif
94103
{
95104
public LazyWrapper(Func<TType> evaluator)
96105
: base(evaluator)

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private static IntPtr ResolveDll(string libraryName, Assembly assembly, DllImpor
102102
{
103103
// The libraries are located at 'runtimes/<rid>/native/lib{libraryName}.so'
104104
// The <rid> ends with the processor architecture. e.g. fedora-x64.
105-
string assemblyDirectory = Path.GetDirectoryName(typeof(NativeMethods).Assembly.Location);
105+
string assemblyDirectory = Path.GetDirectoryName(AppContext.BaseDirectory);
106106
string processorArchitecture = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
107107
string runtimesDirectory = Path.Combine(assemblyDirectory, "runtimes");
108108

LibGit2Sharp/Core/Platform.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ public static string GetNativeLibraryExtension()
5858
/// Returns true if the runtime is Mono.
5959
/// </summary>
6060
public static bool IsRunningOnMono()
61+
#if NETFRAMEWORK
6162
=> Type.GetType("Mono.Runtime") != null;
63+
#else
64+
=> false;
65+
#endif
6266

6367
/// <summary>
6468
/// Returns true if the runtime is .NET Framework.

LibGit2Sharp/ReferenceWrapper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.Globalization;
45
using LibGit2Sharp.Core;
56

@@ -10,7 +11,11 @@ namespace LibGit2Sharp
1011
/// </summary>
1112
/// <typeparam name="TObject">The type of the referenced Git object.</typeparam>
1213
[DebuggerDisplay("{DebuggerDisplay,nq}")]
14+
#if NET
15+
public abstract class ReferenceWrapper<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TObject> : IEquatable<ReferenceWrapper<TObject>>, IBelongToARepository where TObject : GitObject
16+
#else
1317
public abstract class ReferenceWrapper<TObject> : IEquatable<ReferenceWrapper<TObject>>, IBelongToARepository where TObject : GitObject
18+
#endif
1419
{
1520
/// <summary>
1621
/// The repository.

0 commit comments

Comments
 (0)
0