Skip to content

Commit 75823e8

Browse files
committed
Remove leftovers of custom marshaler cookies
1 parent 400cb37 commit 75823e8

File tree

5 files changed

+16
-49
lines changed

5 files changed

+16
-49
lines changed

CodeGeneration/OfferFriendlyInteropOverloadsGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private BlockSyntax CreateBodyFor(MethodDeclarationSyntax innerMethod, IEnumerab
148148
SyntaxKind.SimpleMemberAccessExpression,
149149
type,
150150
SyntaxFactory.IdentifierName("GetInstance")),
151-
SyntaxFactory.ArgumentList().AddArguments(SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(""))))))))));
151+
SyntaxFactory.ArgumentList()))))));
152152
}
153153

154154
return marshalerLocalName;

LibGit2Sharp/CodeGenerator.targets

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
<Target Name="GenerateCodeFirst">
2828
<PropertyGroup>
29-
<CoreCompileDependsOn>$(CoreCompileDependsOn);GenerateNativeDllNameCs;GenerateUniqueIdentifierCs</CoreCompileDependsOn>
29+
<CoreCompileDependsOn>$(CoreCompileDependsOn);GenerateNativeDllNameCs</CoreCompileDependsOn>
3030
<PrepareResourceNamesDependsOn>GenerateCommitIdVersion;$(PrepareResourceNamesDependsOn)</PrepareResourceNamesDependsOn>
3131
<NativeDllNamePath>$(IntermediateOutputPath)NativeDllName.cs</NativeDllNamePath>
3232
<UniqueIdentifierPath>$(IntermediateOutputPath)UniqueIdentifier.cs</UniqueIdentifierPath>
@@ -61,33 +61,6 @@ namespace LibGit2Sharp.Core
6161
</ItemGroup>
6262
</Target>
6363

64-
<!-- This target runs if any of the projects or .cs files for the project have changed since the last time
65-
the UniqueIdentifier.cs file was generated. -->
66-
<Target Name="GenerateUniqueIdentifierCs"
67-
Inputs="$(MSBuildThisFileFullPath);$(MSBuildAllProjects);@(Compile)"
68-
Outputs="$(UniqueIdentifierPath)">
69-
<PropertyGroup>
70-
<UniqueIdSourceLines>
71-
namespace LibGit2Sharp.Core
72-
{
73-
internal static class UniqueId
74-
{
75-
public const string UniqueIdentifier = "$([System.Guid]::NewGuid())"%3b
76-
}
77-
}
78-
</UniqueIdSourceLines>
79-
</PropertyGroup>
80-
81-
<WriteLinesToFile File="$(UniqueIdentifierPath)"
82-
Lines="$(UniqueIdSourceLines)"
83-
Overwrite="true" />
84-
85-
<ItemGroup>
86-
<Compile Include="$(UniqueIdentifierPath)" />
87-
<FileWrites Include="$(UniqueIdentifierPath)" />
88-
</ItemGroup>
89-
</Target>
90-
9164
<Target Name="GenerateCommitIdVersion"
9265
DependsOnTargets="GetBuildVersion">
9366
<WriteLinesToFile File="$(CommitIdVersionPath)"

LibGit2Sharp/Core/FilePathMarshaler.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ namespace LibGit2Sharp.Core
1010
/// free the native pointer after conversion, because the memory is owned by libgit2.
1111
///
1212
/// Use this marshaler for return values, for example:
13-
/// [return: MarshalAs(UnmanagedType.CustomMarshaler,
14-
/// MarshalCookie = UniqueId.UniqueIdentifier,
15-
/// MarshalTypeRef = typeof(LaxFilePathNoCleanupMarshaler))]
13+
/// [return: CustomMarshaler(typeof(LaxFilePathNoCleanupMarshaler), typeof(FilePath))]
1614
/// </summary>
1715
internal class LaxFilePathNoCleanupMarshaler : LaxFilePathMarshaler
1816
{
1917
private static readonly LaxFilePathNoCleanupMarshaler staticInstance = new LaxFilePathNoCleanupMarshaler();
2018

21-
public new static ICustomMarshaler GetInstance(String cookie)
19+
public new static ICustomMarshaler GetInstance()
2220
{
2321
return staticInstance;
2422
}
@@ -41,16 +39,15 @@ public override void CleanUpNativeData(IntPtr pNativeData)
4139
///
4240
/// Use this marshaler for function parameters, for example:
4341
/// [DllImport(libgit2)]
44-
/// internal static extern int git_index_open(out IndexSafeHandle index,
45-
/// [MarshalAs(UnmanagedType.CustomMarshaler,
46-
/// MarshalCookie = UniqueId.UniqueIdentifier,
47-
/// MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath indexpath);
42+
/// private static extern unsafe int git_index_remove_bypath(
43+
/// git_index* index,
44+
/// [CustomMarshaler(typeof(StrictFilePathMarshaler), typeof(FilePath))] byte* path);
4845
/// </summary>
4946
internal class StrictFilePathMarshaler : StrictUtf8Marshaler
5047
{
5148
private static readonly StrictFilePathMarshaler staticInstance = new StrictFilePathMarshaler();
5249

53-
public new static ICustomMarshaler GetInstance(String cookie)
50+
public new static ICustomMarshaler GetInstance()
5451
{
5552
return staticInstance;
5653
}
@@ -98,7 +95,7 @@ internal class LaxFilePathMarshaler : LaxUtf8Marshaler
9895
{
9996
private static readonly LaxFilePathMarshaler staticInstance = new LaxFilePathMarshaler();
10097

101-
public new static ICustomMarshaler GetInstance(String cookie)
98+
public new static ICustomMarshaler GetInstance()
10299
{
103100
return staticInstance;
104101
}

LibGit2Sharp/Core/Utf8Marshaler.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ namespace LibGit2Sharp.Core
1111
/// free the native pointer after conversion, because the memory is owned by libgit2.
1212
///
1313
/// Use this marshaler for return values, for example:
14-
/// [return: MarshalAs(UnmanagedType.CustomMarshaler,
15-
/// MarshalCookie = UniqueId.UniqueIdentifier,
16-
/// MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))]
14+
/// [return: CustomMarshaler(typeof(LaxUtf8NoCleanupMarshaler), typeof(string))]
1715
/// </summary>
1816
internal class LaxUtf8NoCleanupMarshaler : LaxUtf8Marshaler
1917
{
2018
private static readonly LaxUtf8NoCleanupMarshaler staticInstance = new LaxUtf8NoCleanupMarshaler();
2119

22-
public new static ICustomMarshaler GetInstance(String cookie)
20+
public new static ICustomMarshaler GetInstance()
2321
{
2422
return staticInstance;
2523
}
@@ -41,10 +39,9 @@ public override void CleanUpNativeData(IntPtr pNativeData)
4139
///
4240
/// Use this marshaler for function parameters, for example:
4341
/// [DllImport(libgit2)]
44-
/// internal static extern int git_tag_delete(RepositorySafeHandle repo,
45-
/// [MarshalAs(UnmanagedType.CustomMarshaler,
46-
/// MarshalCookie = UniqueId.UniqueIdentifier,
47-
/// MarshalTypeRef = typeof(StrictUtf8Marshaler))] String tagName);
42+
/// private static extern unsafe int git_tag_delete(
43+
/// git_repository* repo,
44+
/// [CustomMarshaler(typeof(StrictUtf8Marshaler), typeof(string))] byte* tagName);
4845
/// </summary>
4946
internal class StrictUtf8Marshaler : EncodingMarshaler
5047
{
@@ -60,7 +57,7 @@ static StrictUtf8Marshaler()
6057
public StrictUtf8Marshaler() : base(encoding)
6158
{ }
6259

63-
public static ICustomMarshaler GetInstance(String cookie)
60+
public static ICustomMarshaler GetInstance()
6461
{
6562
return staticInstance;
6663
}
@@ -96,7 +93,7 @@ internal class LaxUtf8Marshaler : EncodingMarshaler
9693
public LaxUtf8Marshaler() : base(Encoding)
9794
{ }
9895

99-
public static ICustomMarshaler GetInstance(String cookie)
96+
public static ICustomMarshaler GetInstance()
10097
{
10198
return staticInstance;
10299
}

lkg/CodeGeneration.dll

512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)