From a7d1ec5f78e02db212dd586699c6ee9cd8dd831b Mon Sep 17 00:00:00 2001 From: Philip Kelley Date: Wed, 29 May 2013 16:58:06 -0400 Subject: [PATCH 1/3] Generate a unique ID at compile time to work around a CLR bug --- CustomBuildTasks/CustomBuildTasks.csproj | 42 ++++ CustomBuildTasks/Drop/CustomBuildTasks.dll | Bin 0 -> 4608 bytes .../GenerateUniqueIdentifierTask.cs | 36 ++++ LibGit2Sharp.sln | 8 + LibGit2Sharp/Core/FilePathMarshaler.cs | 2 + LibGit2Sharp/Core/NativeMethods.cs | 182 +++++++++--------- LibGit2Sharp/Core/Utf8Marshaler.cs | 2 + LibGit2Sharp/LibGit2Sharp.csproj | 1 + LibGit2Sharp/UniqueIdentifier.targets | 28 +++ 9 files changed, 210 insertions(+), 91 deletions(-) create mode 100644 CustomBuildTasks/CustomBuildTasks.csproj create mode 100644 CustomBuildTasks/Drop/CustomBuildTasks.dll create mode 100644 CustomBuildTasks/GenerateUniqueIdentifierTask.cs create mode 100644 LibGit2Sharp/UniqueIdentifier.targets diff --git a/CustomBuildTasks/CustomBuildTasks.csproj b/CustomBuildTasks/CustomBuildTasks.csproj new file mode 100644 index 000000000..4afb282bc --- /dev/null +++ b/CustomBuildTasks/CustomBuildTasks.csproj @@ -0,0 +1,42 @@ + + + + + Debug + AnyCPU + {B6138573-A4B9-44E7-83C2-8964CAF51EDA} + Library + Properties + CustomBuildTasks + CustomBuildTasks + v3.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + diff --git a/CustomBuildTasks/Drop/CustomBuildTasks.dll b/CustomBuildTasks/Drop/CustomBuildTasks.dll new file mode 100644 index 0000000000000000000000000000000000000000..3cd023b83a9f8bfad3f972816be2d5e08a5d38d3 GIT binary patch literal 4608 zcmeHKZ){sv75}|wH%^_^)J97(x@FI4E7DRduLQb|ZgmnTT~Pk5c3L_GCC~P)^Ok2n z_r2%-*;EK1kUAs;MUyJv3s511K&nI~CZvf9@lS|>gtTwfG{hIa!50KVV&!-4v+Jfo z!1k@uu5-^l_x!u(oO|ziH}lVb1u+0|_B(fgS2;>6X!zg3CfTXSf0Dw@ov&wKHRfK= zme-xYYWZH>w;NW~ZZ^Hpswm5EH!Y`W6&FiZ!>g&>u3gD}9n(wGz?>1o@s003*In%` znArhi07#P37g2KuI9lulc3`*0&B$*di2u565|S=0hQb#_RQ`HnXDTGN+hf3@AO+yp z9X*-eZEL_ooLv7P@aSFQ|AAOQ|2<;;oIiWdJQu2qA?M>e3CPp2-nTx*KD^bHRW26Q@^>>Jy`A)xW(K*Fa$%S#YXc+68W;Xihl;4k;kGd=VhJ@h+7 z$C$a~LmBh!!4#MCcvh1Bzl1IaC$j9vjP4@-Ko@;8nK;y!@R+FN?KhKshx+;=eCVLT z4K}d{m#^vFApSnQay`OF%$MkK{NSh=yR4BBbByaI4>H!t(kCX3PR1nv=MU%dxsT?L z96loX+X0vGA5_}=X`sfG6xjEcLf>iD1ChAS^z0V?atSw?BiXjSCzfZ69DmOFH)THQ zdKHe+sBWBo_}hjY9sG0uM=%)eS0>_VPvn@;B3h@gXZff`?4Zmf)Li&$1eoMn&Y4|7OHtB!W5T@WM4M)wmIMP{F z@@6pN$8n6Aie}fi2TPX7{F1p7|HiU1`(l5{cnst_v(F>L+0ke=d=*2I8B%_VG_K-9 z$Pzw*1B62yui|5P4&OH>aEAB{9Q?t^XgGv(__MKqOZdBy!e@~%OSpm$m_zug*4?RL z78|G{$K0$FzMncd`uQRXn!cvt^YlQ1yNMBECM%G^9z%SS#4YU@XHotmvccR-yO%bK zUqnoS$L76S+f~nCsvU%0W3uhIwXz*-1i6~);)H4{-wxGs(>d2xvo+NWowJVeMPi!< z=AEkV1>V^(r_JP+L&tSOM+MOG(-&2>9V*mSxVqR5TkUYhaTS8C(_A(5d>rcuJhQR7 zI%!uoc&uj}<<`(+;k@m(6&gX+^IfNc(xo6&ja<>O>rF2Rooaxhs);2J779!e>rh!r`E;}D)#$3u+H!g3Nkk@2`%b9*&IBUb zq3B`GX?D%vMBAxhL0!<}V&w%@4N>-@IwAUEe9CK9?GUp?Cun(rWD60hI?*e?dlYKD z(B%B=X(QliZ}OH~DDkWZ2*EAE$AKeF*u=QSXc4OtvoJ^L3QiD)I82Roa(wc0n1V-4 z@dNu3Fkw+v?20v?qs=>OY3nv=4y{@2F6jY(7M3aF@b_p{(;4kRqo$UKobz)AXOA7UxC{zNSENan-oqq^+%8=WgoBzhl=NYN{sgQtDF zwcs_UFIH7cj&OP1_bvp6>>XS8ePj}Ul*C(nkKE!1;AE*-`q@C^>ucveHFxC)iQ%t( zE|5!R#HZDZzIwTi6%V77SYZ6n@~ z2yO|sy>;I}5odME^NX%KZ#&JXU@4_btZ?t_r;YnwRom@7xD@#k1H-`P))?f70{Qci#eCT^WyeCcH^o zzKKFEvKzE2^+>+suC63a-g{5j*ry-KWpZs@Ii&VTC6YQ4wHxu@G9Y71J=t#Qds-&X zxTD`Vs}gg7L-feFyK<4M2dr>Xms(rau_&A8E$_*m(sfDdaMzbS>uIm^e<3_f`B`1b zdi8XH5lDRoYp>MtkopZi=G!{@8p`Ace1QbCR%1To#R-gQKj)}dC*Rd|yT!^cp4M5< z<^KP6p+TXFzAsdXkO5m2(B gzX6x%;s4U3>U-_oX26R6XUrdcw+7zRdyq5mZ?e}p)c^nh literal 0 HcmV?d00001 diff --git a/CustomBuildTasks/GenerateUniqueIdentifierTask.cs b/CustomBuildTasks/GenerateUniqueIdentifierTask.cs new file mode 100644 index 000000000..f33c33e8b --- /dev/null +++ b/CustomBuildTasks/GenerateUniqueIdentifierTask.cs @@ -0,0 +1,36 @@ +using System; +using System.IO; +using System.Text; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace CustomBuildTasks +{ + public class GenerateUniqueIdentifierTask : Task + { + public override bool Execute() + { + using (FileStream fs = new FileStream(this.OutputFile, FileMode.Create, FileAccess.Write, FileShare.None)) + using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8)) + { + sw.WriteLine("using System;"); + sw.WriteLine(); + sw.WriteLine("namespace LibGit2Sharp.Core"); + sw.WriteLine("{"); + sw.WriteLine(" internal static class UniqueId"); + sw.WriteLine(" {"); + sw.WriteLine(" public const String UniqueIdentifier = \"" + Guid.NewGuid().ToString() + "\";"); + sw.WriteLine(" }"); + sw.WriteLine("}"); + } + + return true; + } + + public String OutputFile + { + get; + set; + } + } +} diff --git a/LibGit2Sharp.sln b/LibGit2Sharp.sln index 8d9f849eb..bc869cd9c 100644 --- a/LibGit2Sharp.sln +++ b/LibGit2Sharp.sln @@ -5,6 +5,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp", "LibGit2Shar EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp.Tests", "LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj", "{286E63EB-04DD-4ADE-88D6-041B57800761}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomBuildTasks", "CustomBuildTasks\CustomBuildTasks.csproj", "{B6138573-A4B9-44E7-83C2-8964CAF51EDA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -24,6 +26,12 @@ Global {286E63EB-04DD-4ADE-88D6-041B57800761}.Leaks|Any CPU.Build.0 = Leaks|Any CPU {286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.ActiveCfg = Release|Any CPU {286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.Build.0 = Release|Any CPU + {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Leaks|Any CPU.ActiveCfg = Release|Any CPU + {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Leaks|Any CPU.Build.0 = Release|Any CPU + {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LibGit2Sharp/Core/FilePathMarshaler.cs b/LibGit2Sharp/Core/FilePathMarshaler.cs index ec239f354..97f81fa2e 100644 --- a/LibGit2Sharp/Core/FilePathMarshaler.cs +++ b/LibGit2Sharp/Core/FilePathMarshaler.cs @@ -11,6 +11,7 @@ namespace LibGit2Sharp.Core /// /// Use this marshaler for return values, for example: /// [return: MarshalAs(UnmanagedType.CustomMarshaler, + /// MarshalCookie = UniqueId.UniqueIdentifier, /// MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] /// internal class FilePathNoCleanupMarshaler : FilePathMarshaler @@ -42,6 +43,7 @@ public override void CleanUpNativeData(IntPtr pNativeData) /// [DllImport(libgit2)] /// internal static extern int git_index_open(out IndexSafeHandle index, /// [MarshalAs(UnmanagedType.CustomMarshaler, + /// MarshalCookie = UniqueId.UniqueIdentifier, /// MarshalTypeRef = typeof(FilePathMarshaler))] FilePath indexpath); /// internal class FilePathMarshaler : ICustomMarshaler diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index cd0078a69..b64c72a4d 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -110,13 +110,13 @@ internal static extern void giterr_set_str( internal static extern int git_blob_create_fromdisk( ref GitOid id, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_blob_create_fromworkdir( ref GitOid id, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath relative_path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath relative_path); internal delegate int source_callback( IntPtr content, @@ -127,7 +127,7 @@ internal delegate int source_callback( internal static extern int git_blob_create_fromchunks( ref GitOid oid, RepositorySafeHandle repositoryPtr, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath hintpath, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath hintpath, source_callback fileCallback, IntPtr data); @@ -141,7 +141,7 @@ internal static extern int git_blob_create_fromchunks( internal static extern int git_branch_create( out ReferenceSafeHandle ref_out, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string branch_name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string branch_name, GitObjectSafeHandle target, // TODO: GitCommitSafeHandle? [MarshalAs(UnmanagedType.Bool)] bool force); @@ -165,7 +165,7 @@ internal static extern int git_branch_foreach( internal static extern int git_branch_move( out ReferenceSafeHandle ref_out, ReferenceSafeHandle reference, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string new_branch_name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string new_branch_name, [MarshalAs(UnmanagedType.Bool)] bool force); [DllImport(libgit2)] @@ -173,14 +173,14 @@ internal static extern int git_branch_remote_name( byte[] remote_name_out, UIntPtr buffer_size, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string canonical_branch_name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string canonical_branch_name); [DllImport(libgit2)] internal static extern int git_branch_upstream_name( byte[] tracking_branch_name_out, // NB: This is more properly a StringBuilder, but it's UTF8 UIntPtr buffer_size, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string referenceName); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string referenceName); [DllImport(libgit2)] internal static extern int git_checkout_tree( @@ -197,8 +197,8 @@ internal static extern int git_checkout_index( [DllImport(libgit2)] internal static extern int git_clone( out RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string origin_url, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath workdir_path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string origin_url, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath workdir_path, GitCloneOptions opts); [DllImport(libgit2)] @@ -211,21 +211,21 @@ internal static extern int git_clone( internal static extern int git_commit_create( out GitOid id, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string updateRef, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string updateRef, SignatureSafeHandle author, SignatureSafeHandle committer, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string encoding, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string encoding, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message, GitObjectSafeHandle tree, int parentCount, [MarshalAs(UnmanagedType.LPArray)] [In] IntPtr[] parents); [DllImport(libgit2)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_commit_message(GitObjectSafeHandle commit); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_commit_message_encoding(GitObjectSafeHandle commit); [DllImport(libgit2)] @@ -256,12 +256,12 @@ internal static extern int git_commit_create( internal static extern int git_config_get_entry( out GitConfigEntryHandle entry, ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); [DllImport(libgit2)] internal static extern int git_config_add_file_ondisk( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, uint level, bool force); @@ -277,41 +277,41 @@ internal static extern int git_config_open_level( [DllImport(libgit2)] internal static extern int git_config_parse_bool( [MarshalAs(UnmanagedType.Bool)] out bool value, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); [DllImport(libgit2)] internal static extern int git_config_parse_int32( [MarshalAs(UnmanagedType.I4)] out int value, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); [DllImport(libgit2)] internal static extern int git_config_parse_int64( [MarshalAs(UnmanagedType.I8)] out long value, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); [DllImport(libgit2)] internal static extern int git_config_set_bool( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, [MarshalAs(UnmanagedType.Bool)] bool value); [DllImport(libgit2)] internal static extern int git_config_set_int32( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, int value); [DllImport(libgit2)] internal static extern int git_config_set_int64( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, long value); [DllImport(libgit2)] internal static extern int git_config_set_string( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string value); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string value); internal delegate int config_foreach_callback( IntPtr entry, @@ -338,8 +338,8 @@ internal delegate int git_cred_acquire_cb( [DllImport(libgit2)] internal static extern int git_cred_userpass_plaintext_new( out IntPtr cred, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Utf8Marshaler))] string username, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Utf8Marshaler))] string password); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (Utf8Marshaler))] string username, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (Utf8Marshaler))] string password); [DllImport(libgit2)] internal static extern void git_diff_list_free(IntPtr diff); @@ -429,7 +429,7 @@ internal static extern int git_diff_foreach( [DllImport(libgit2)] internal static extern int git_ignore_add_rule( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Utf8Marshaler))] string rules); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (Utf8Marshaler))] string rules); [DllImport(libgit2)] internal static extern int git_ignore_clear_internal_rules(RepositorySafeHandle repo); @@ -438,12 +438,12 @@ internal static extern int git_ignore_add_rule( internal static extern int git_ignore_path_is_ignored( out int ignored, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_index_add_bypath( IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_index_add( @@ -456,7 +456,7 @@ internal static extern int git_index_conflict_get( out IndexEntrySafeHandle ours, out IndexEntrySafeHandle theirs, IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern UIntPtr git_index_entrycount(IndexSafeHandle index); @@ -468,7 +468,7 @@ internal static extern int git_index_conflict_get( internal static extern int git_index_find( out UIntPtr pos, IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern void git_index_free(IntPtr index); @@ -479,7 +479,7 @@ internal static extern int git_index_find( [DllImport(libgit2)] internal static extern IndexEntrySafeHandle git_index_get_bypath( IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, int stage); [DllImport(libgit2)] @@ -488,12 +488,12 @@ internal static extern IndexEntrySafeHandle git_index_get_bypath( [DllImport(libgit2)] internal static extern int git_index_open( out IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath indexpath); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath indexpath); [DllImport(libgit2)] internal static extern int git_index_remove_bypath( IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_index_write(IndexSafeHandle index); @@ -512,7 +512,7 @@ internal static extern int git_merge_base( internal static extern int git_message_prettify( byte[] message_out, // NB: This is more properly a StringBuilder, but it's UTF8 UIntPtr buffer_size, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message, bool strip_comments); [DllImport(libgit2)] @@ -521,16 +521,16 @@ internal static extern int git_note_create( RepositorySafeHandle repo, SignatureSafeHandle author, SignatureSafeHandle committer, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, ref GitOid oid, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string note, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string note, int force); [DllImport(libgit2)] internal static extern void git_note_free(IntPtr note); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_note_message(NoteSafeHandle note); [DllImport(libgit2)] @@ -540,20 +540,20 @@ internal static extern int git_note_create( internal static extern int git_note_read( out NoteSafeHandle note, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, ref GitOid oid); [DllImport(libgit2)] internal static extern int git_note_remove( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, SignatureSafeHandle author, SignatureSafeHandle committer, ref GitOid oid); [DllImport(libgit2)] internal static extern int git_note_default_ref( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] out string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] out string notes_ref, RepositorySafeHandle repo); internal delegate int git_note_foreach_cb( @@ -564,7 +564,7 @@ internal delegate int git_note_foreach_cb( [DllImport(libgit2)] internal static extern int git_note_foreach( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, git_note_foreach_cb cb, IntPtr payload); @@ -604,7 +604,7 @@ internal static extern int git_object_peel( [DllImport(libgit2)] internal static extern int git_push_add_refspec( PushSafeHandle push, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string pushRefSpec); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string pushRefSpec); [DllImport(libgit2)] internal static extern int git_push_finish(PushSafeHandle push); @@ -633,7 +633,7 @@ internal delegate int push_status_foreach_cb( internal static extern int git_reference_create( out ReferenceSafeHandle reference, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, ref GitOid oid, [MarshalAs(UnmanagedType.Bool)] bool force); @@ -641,8 +641,8 @@ internal static extern int git_reference_create( internal static extern int git_reference_symbolic_create( out ReferenceSafeHandle reference, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string target, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string target, [MarshalAs(UnmanagedType.Bool)] bool force); [DllImport(libgit2)] @@ -655,7 +655,7 @@ internal delegate int ref_glob_callback( [DllImport(libgit2)] internal static extern int git_reference_foreach_glob( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string glob, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string glob, ref_glob_callback callback, IntPtr payload); @@ -664,16 +664,16 @@ internal static extern int git_reference_foreach_glob( [DllImport(libgit2)] internal static extern int git_reference_is_valid_name( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string refname); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string refname); [DllImport(libgit2)] internal static extern int git_reference_lookup( out ReferenceSafeHandle reference, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_reference_name(ReferenceSafeHandle reference); [DllImport(libgit2)] @@ -683,7 +683,7 @@ internal static extern int git_reference_lookup( internal static extern int git_reference_rename( out ReferenceSafeHandle ref_out, ReferenceSafeHandle reference, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string newName, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string newName, [MarshalAs(UnmanagedType.Bool)] bool force); [DllImport(libgit2)] @@ -696,10 +696,10 @@ internal static extern int git_reference_rename( internal static extern int git_reference_symbolic_set_target( out ReferenceSafeHandle ref_out, ReferenceSafeHandle reference, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string target); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string target); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_reference_symbolic_target(ReferenceSafeHandle reference); [DllImport(libgit2)] @@ -740,13 +740,13 @@ internal static extern int git_reflog_append( ReflogSafeHandle reflog, ref GitOid id, SignatureSafeHandle committer, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string msg); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string msg); [DllImport(libgit2)] internal static extern int git_reflog_write(ReflogSafeHandle reflog); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_reflog_entry_message(SafeHandle entry); [DllImport(libgit2)] @@ -754,7 +754,7 @@ internal static extern int git_refspec_rtransform( byte[] target, UIntPtr outlen, GitRefSpecHandle refSpec, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); [DllImport(libgit2)] internal static extern int git_remote_connect(RemoteSafeHandle remote, GitDirection direction); @@ -763,8 +763,8 @@ internal static extern int git_refspec_rtransform( internal static extern int git_remote_create( out RemoteSafeHandle remote, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string url); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string url); [DllImport(libgit2)] internal static extern void git_remote_disconnect(RemoteSafeHandle remote); @@ -783,13 +783,13 @@ internal static extern int git_remote_download( [DllImport(libgit2)] internal static extern int git_remote_is_valid_name( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string remote_name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string remote_name); [DllImport(libgit2)] internal static extern int git_remote_load( out RemoteSafeHandle remote, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); internal delegate int git_headlist_cb(ref GitRemoteHead remoteHeadPtr, IntPtr payload); @@ -797,7 +797,7 @@ internal static extern int git_remote_load( internal static extern int git_remote_ls(RemoteSafeHandle remote, git_headlist_cb headlist_cb, IntPtr payload); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_remote_name(RemoteSafeHandle remote); [DllImport(libgit2)] @@ -810,7 +810,7 @@ internal static extern void git_remote_set_cred_acquire_cb( IntPtr payload); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_remote_url(RemoteSafeHandle remote); [DllImport(libgit2)] @@ -824,7 +824,7 @@ internal static extern int git_remote_set_callbacks( [DllImport(libgit2)] internal static extern int git_remote_add_fetch( RemoteSafeHandle remote, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Utf8Marshaler))] string refspec); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (Utf8Marshaler))] string refspec); internal delegate void remote_progress_callback(IntPtr str, int len, IntPtr data); @@ -843,9 +843,9 @@ internal delegate int remote_update_tips_callback( internal static extern int git_repository_discover( byte[] repository_path, // NB: This is more properly a StringBuilder, but it's UTF8 UIntPtr size, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath start_path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath start_path, [MarshalAs(UnmanagedType.Bool)] bool across_fs, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath ceiling_dirs); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath ceiling_dirs); internal delegate int git_repository_fetchhead_foreach_cb( IntPtr remote_name, @@ -875,7 +875,7 @@ internal static extern int git_repository_fetchhead_foreach( [DllImport(libgit2)] internal static extern int git_repository_init( out RepositorySafeHandle repository, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, [MarshalAs(UnmanagedType.Bool)] bool isBare); [DllImport(libgit2)] @@ -909,17 +909,17 @@ internal static extern int git_repository_message( [DllImport(libgit2)] internal static extern int git_repository_open( out RepositorySafeHandle repository, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_repository_open_ext( NullRepositorySafeHandle repository, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, RepositoryOpenFlags flags, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath ceilingDirs); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath ceilingDirs); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] internal static extern FilePath git_repository_path(RepositorySafeHandle repository); [DllImport(libgit2)] @@ -935,7 +935,7 @@ internal static extern void git_repository_set_index( [DllImport(libgit2)] internal static extern int git_repository_set_workdir( RepositorySafeHandle repository, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath workdir, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath workdir, bool update_gitlink); [DllImport(libgit2)] @@ -943,7 +943,7 @@ internal static extern int git_repository_state( RepositorySafeHandle repository); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] internal static extern FilePath git_repository_workdir(RepositorySafeHandle repository); [DllImport(libgit2)] @@ -956,7 +956,7 @@ internal static extern int git_reset( internal static extern int git_revparse_single( out GitObjectSafeHandle obj, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string spec); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string spec); [DllImport(libgit2)] internal static extern void git_revwalk_free(IntPtr walker); @@ -985,8 +985,8 @@ internal static extern int git_revparse_single( [DllImport(libgit2)] internal static extern int git_signature_new( out SignatureSafeHandle signature, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string email, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string email, long time, int offset); @@ -995,7 +995,7 @@ internal static extern int git_stash_save( out GitOid id, RepositorySafeHandle repo, SignatureSafeHandle stasher, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message, StashOptions flags); internal delegate int git_stash_cb( @@ -1017,7 +1017,7 @@ internal static extern int git_stash_foreach( internal static extern int git_status_file( out FileStatus statusflags, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath filepath); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath filepath); internal delegate int git_status_cb( IntPtr path, @@ -1031,7 +1031,7 @@ internal delegate int git_status_cb( internal static extern int git_submodule_lookup( out SubmoduleSafeHandle reference, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); internal delegate int submodule_callback( IntPtr sm, @@ -1054,12 +1054,12 @@ internal static extern int git_submodule_save( SubmoduleSafeHandle submodule); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_submodule_path( SubmoduleSafeHandle submodule); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_submodule_url( SubmoduleSafeHandle submodule); @@ -1100,19 +1100,19 @@ internal static extern int git_submodule_status( internal static extern int git_tag_annotation_create( out GitOid oid, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, GitObjectSafeHandle target, SignatureSafeHandle signature, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message); [DllImport(libgit2)] internal static extern int git_tag_create( out GitOid oid, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, GitObjectSafeHandle target, SignatureSafeHandle signature, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message, [MarshalAs(UnmanagedType.Bool)] bool force); @@ -1120,7 +1120,7 @@ internal static extern int git_tag_create( internal static extern int git_tag_create_lightweight( out GitOid oid, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, GitObjectSafeHandle target, [MarshalAs(UnmanagedType.Bool)] bool force); @@ -1128,14 +1128,14 @@ internal static extern int git_tag_create_lightweight( [DllImport(libgit2)] internal static extern int git_tag_delete( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string tagName); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string tagName); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_tag_message(GitObjectSafeHandle tag); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_tag_name(GitObjectSafeHandle tag); [DllImport(libgit2)] @@ -1165,7 +1165,7 @@ internal static extern int git_tag_delete( internal static extern int git_tree_entry_bypath( out TreeEntrySafeHandle_Owned tree, GitObjectSafeHandle root, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath treeentry_path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath treeentry_path); [DllImport(libgit2)] internal static extern void git_tree_entry_free(IntPtr treeEntry); @@ -1174,7 +1174,7 @@ internal static extern int git_tree_entry_bypath( internal static extern OidSafeHandle git_tree_entry_id(SafeHandle entry); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_tree_entry_name(SafeHandle entry); [DllImport(libgit2)] @@ -1190,7 +1190,7 @@ internal static extern int git_tree_entry_bypath( internal static extern int git_treebuilder_insert( IntPtr entry_out, TreeBuilderSafeHandle builder, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string treeentry_name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string treeentry_name, ref GitOid id, uint attributes); diff --git a/LibGit2Sharp/Core/Utf8Marshaler.cs b/LibGit2Sharp/Core/Utf8Marshaler.cs index ec78db8fc..79fd2a6c4 100644 --- a/LibGit2Sharp/Core/Utf8Marshaler.cs +++ b/LibGit2Sharp/Core/Utf8Marshaler.cs @@ -11,6 +11,7 @@ namespace LibGit2Sharp.Core /// /// Use this marshaler for return values, for example: /// [return: MarshalAs(UnmanagedType.CustomMarshaler, + /// MarshalCookie = UniqueId.UniqueIdentifier, /// MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] /// internal class Utf8NoCleanupMarshaler : Utf8Marshaler @@ -42,6 +43,7 @@ public override void CleanUpNativeData(IntPtr pNativeData) /// [DllImport(libgit2)] /// internal static extern int git_tag_delete(RepositorySafeHandle repo, /// [MarshalAs(UnmanagedType.CustomMarshaler, + /// MarshalCookie = UniqueId.UniqueIdentifier, /// MarshalTypeRef = typeof(Utf8Marshaler))] String tagName); /// internal class Utf8Marshaler : ICustomMarshaler diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 65a9f90ee..cac1784ba 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -261,6 +261,7 @@ + diff --git a/LibGit2Sharp/UniqueIdentifier.targets b/LibGit2Sharp/UniqueIdentifier.targets new file mode 100644 index 000000000..539320779 --- /dev/null +++ b/LibGit2Sharp/UniqueIdentifier.targets @@ -0,0 +1,28 @@ + + + + + + + + + $(IntermediateOutputPath)UniqueIdentifier.cs + $(CoreCompileDependsOn);CreateUniqueIdentifierItem + + + + + + + + + + + + + + From e26125098212710cc890eb6ecfa672ef162c8527 Mon Sep 17 00:00:00 2001 From: Philip Kelley Date: Thu, 30 May 2013 12:54:39 -0400 Subject: [PATCH 2/3] Remove CustomBuildTasks from sln. Move drop into the Lib directory. --- .../CustomBuildTasks}/CustomBuildTasks.dll | Bin LibGit2Sharp.sln | 8 -------- LibGit2Sharp/UniqueIdentifier.targets | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) rename {CustomBuildTasks/Drop => Lib/CustomBuildTasks}/CustomBuildTasks.dll (100%) diff --git a/CustomBuildTasks/Drop/CustomBuildTasks.dll b/Lib/CustomBuildTasks/CustomBuildTasks.dll similarity index 100% rename from CustomBuildTasks/Drop/CustomBuildTasks.dll rename to Lib/CustomBuildTasks/CustomBuildTasks.dll diff --git a/LibGit2Sharp.sln b/LibGit2Sharp.sln index bc869cd9c..8d9f849eb 100644 --- a/LibGit2Sharp.sln +++ b/LibGit2Sharp.sln @@ -5,8 +5,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp", "LibGit2Shar EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp.Tests", "LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj", "{286E63EB-04DD-4ADE-88D6-041B57800761}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomBuildTasks", "CustomBuildTasks\CustomBuildTasks.csproj", "{B6138573-A4B9-44E7-83C2-8964CAF51EDA}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,12 +24,6 @@ Global {286E63EB-04DD-4ADE-88D6-041B57800761}.Leaks|Any CPU.Build.0 = Leaks|Any CPU {286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.ActiveCfg = Release|Any CPU {286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.Build.0 = Release|Any CPU - {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Leaks|Any CPU.ActiveCfg = Release|Any CPU - {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Leaks|Any CPU.Build.0 = Release|Any CPU - {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B6138573-A4B9-44E7-83C2-8964CAF51EDA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LibGit2Sharp/UniqueIdentifier.targets b/LibGit2Sharp/UniqueIdentifier.targets index 539320779..76b8dbad1 100644 --- a/LibGit2Sharp/UniqueIdentifier.targets +++ b/LibGit2Sharp/UniqueIdentifier.targets @@ -2,7 +2,7 @@ - + From 2e8be1e40c24baa32ad00f3a83496a05030281dc Mon Sep 17 00:00:00 2001 From: Philip Kelley Date: Fri, 31 May 2013 14:04:04 -0400 Subject: [PATCH 3/3] Put the generated UniqueIdentifier.cs statically in the csproj --- .gitignore | 2 ++ LibGit2Sharp/LibGit2Sharp.csproj | 1 + LibGit2Sharp/UniqueIdentifier.targets | 14 ++++++-------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 3e4e585ce..8bb24a91b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,5 +35,7 @@ _ReSharper*/ *.userprefs *.swp *.DotSettings +#Ignore custom generated files +LibGit2Sharp/Core/UniqueIdentifier.cs !Lib/NativeBinaries/*/*.pdb diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index cac1784ba..5e1442721 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -250,6 +250,7 @@ + diff --git a/LibGit2Sharp/UniqueIdentifier.targets b/LibGit2Sharp/UniqueIdentifier.targets index 76b8dbad1..ef65ddf11 100644 --- a/LibGit2Sharp/UniqueIdentifier.targets +++ b/LibGit2Sharp/UniqueIdentifier.targets @@ -6,8 +6,9 @@ - $(IntermediateOutputPath)UniqueIdentifier.cs - $(CoreCompileDependsOn);CreateUniqueIdentifierItem + Core\UniqueIdentifier.cs + $(CoreCompileDependsOn);GenerateUniqueIdentifierCs + $(CoreCleanDependsOn);CleanUniqueIdentifierCs - - - - + + +