From 48221ca3df4edcaeb1b9e1e7d677d3a5f8ef0ae9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 11 Nov 2022 10:53:39 -0700 Subject: [PATCH] Revert "Observe `DangerousAddRef` result before proceeding." --- src/Microsoft.Windows.CsWin32/Generator.cs | 6 ------ test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs | 1 - 2 files changed, 7 deletions(-) diff --git a/src/Microsoft.Windows.CsWin32/Generator.cs b/src/Microsoft.Windows.CsWin32/Generator.cs index 4b6a2c5f..531a2d3d 100644 --- a/src/Microsoft.Windows.CsWin32/Generator.cs +++ b/src/Microsoft.Windows.CsWin32/Generator.cs @@ -4745,12 +4745,6 @@ private IEnumerable 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( diff --git a/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs b/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs index 93158997..0bb48252 100644 --- a/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs +++ b/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs @@ -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