Skip to content

Commit ba5f7d2

Browse files
committed
Fix wrong interop return types
1 parent 7ea126f commit ba5f7d2

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ internal static extern IndexEntrySafeHandle git_index_get_bypath(
564564
internal static extern int git_index_has_conflicts(IndexSafeHandle index);
565565

566566
[DllImport(libgit2)]
567-
internal static extern uint git_index_name_entrycount(IndexSafeHandle handle);
567+
internal static extern UIntPtr git_index_name_entrycount(IndexSafeHandle handle);
568568

569569
[DllImport(libgit2)]
570570
internal static extern IndexNameEntrySafeHandle git_index_name_get_byindex(IndexSafeHandle handle, UIntPtr n);
@@ -586,7 +586,7 @@ internal static extern int git_index_remove_bypath(
586586

587587

588588
[DllImport(libgit2)]
589-
internal static extern uint git_index_reuc_entrycount(IndexSafeHandle handle);
589+
internal static extern UIntPtr git_index_reuc_entrycount(IndexSafeHandle handle);
590590

591591
[DllImport(libgit2)]
592592
internal static extern IndexReucEntrySafeHandle git_index_reuc_get_byindex(IndexSafeHandle handle, UIntPtr n);

LibGit2Sharp/Core/Proxy.cs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -942,12 +942,8 @@ public static Conflict git_index_conflict_get(
942942

943943
public static int git_index_entrycount(IndexSafeHandle index)
944944
{
945-
UIntPtr count = NativeMethods.git_index_entrycount(index);
946-
if ((long)count > int.MaxValue)
947-
{
948-
throw new LibGit2SharpException("Index entry count exceeds size of int");
949-
}
950-
return (int)count;
945+
return NativeMethods.git_index_entrycount(index)
946+
.ConvertToInt();
951947
}
952948

953949
public static StageLevel git_index_entry_stage(IndexEntrySafeHandle index)
@@ -982,12 +978,8 @@ public static bool git_index_has_conflicts(IndexSafeHandle index)
982978

983979
public static int git_index_name_entrycount(IndexSafeHandle index)
984980
{
985-
uint count = NativeMethods.git_index_name_entrycount(index);
986-
if ((long)count > int.MaxValue)
987-
{
988-
throw new LibGit2SharpException("Index name entry count exceeds size of int");
989-
}
990-
return (int)count;
981+
return NativeMethods.git_index_name_entrycount(index)
982+
.ConvertToInt();
991983
}
992984

993985
public static IndexNameEntrySafeHandle git_index_name_get_byindex(IndexSafeHandle index, UIntPtr n)
@@ -1027,12 +1019,8 @@ public static void git_index_remove_bypath(IndexSafeHandle index, FilePath path)
10271019

10281020
public static int git_index_reuc_entrycount(IndexSafeHandle index)
10291021
{
1030-
uint count = NativeMethods.git_index_reuc_entrycount(index);
1031-
if ((long)count > int.MaxValue)
1032-
{
1033-
throw new LibGit2SharpException("Index REUC entry count exceeds size of int");
1034-
}
1035-
return (int)count;
1022+
return NativeMethods.git_index_reuc_entrycount(index)
1023+
.ConvertToInt();
10361024
}
10371025

10381026
public static IndexReucEntrySafeHandle git_index_reuc_get_byindex(IndexSafeHandle index, UIntPtr n)

0 commit comments

Comments
 (0)