Skip to content

Commit

Permalink
Merge pull request #765 from microsoft/revert-762-fix754
Browse files Browse the repository at this point in the history
Revert "Observe `DangerousAddRef` result before proceeding."
  • Loading branch information
AArnott authored Nov 11, 2022
2 parents 0d43ba7 + 48221ca commit 6abc778
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 7 deletions.
6 changes: 0 additions & 6 deletions src/Microsoft.Windows.CsWin32/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4745,12 +4745,6 @@ private IEnumerable<MethodDeclarationSyntax> DeclareFriendlyOverloads(MethodDefi
//// hTemplateFile.DangerousAddRef(ref hTemplateFileAddRef);
ExpressionStatement(InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, origName, IdentifierName(nameof(SafeHandle.DangerousAddRef))))
.WithArgumentList(ArgumentList(SingletonSeparatedList(Argument(refAddedName).WithRefKindKeyword(TokenWithSpace(SyntaxKind.RefKeyword)))))),
//// if (!hTemplateFileAddRef) throw new ArgumentException("Already released.", nameof(hTemplateFile));
IfStatement(
PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, refAddedName),
ThrowStatement(ObjectCreationExpression(IdentifierName(nameof(ArgumentException))).AddArgumentListArguments(
Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal("Already released."))),
Argument(NameOfExpression(origName))))),
//// hTemplateFileLocal = (HANDLE)hTemplateFile.DangerousGetHandle();
ExpressionStatement(
AssignmentExpression(
Expand Down
1 change: 0 additions & 1 deletion test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2651,7 +2651,6 @@ internal static unsafe Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(str
if (hTemplateFile is object)
{{
hTemplateFile.DangerousAddRef(ref hTemplateFileAddRef);
if (!hTemplateFileAddRef)throw new ArgumentException(""Already released."", nameof(hTemplateFile));
hTemplateFileLocal = (winmdroot.Foundation.HANDLE)hTemplateFile.DangerousGetHandle();
}}
else
Expand Down

0 comments on commit 6abc778

Please sign in to comment.