Skip to content

Commit

Permalink
[printcore] Add nullability to (generated and manual) bindings (#14856)
Browse files Browse the repository at this point in the history
* use better null exceptions

* add nullable enable

* Revert "add nullable enable"

This reverts commit 7590945.

* Add nullable enable without BOM

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
  • Loading branch information
tj-devel709 and TJ Lambert authored May 3, 2022
1 parent 1c7d63f commit 0de0a2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/PrintCore/Defs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//
// Copyright 2016 Microsoft Inc
//

#nullable enable

using System;
using System.Runtime.InteropServices;
using System.Threading;
Expand Down
24 changes: 12 additions & 12 deletions src/PrintCore/PrintCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public PMStatusCode SessionError {
public void AssignDefaultSettings (PMPrintSettings settings)
{
if (settings is null)
throw new ArgumentNullException (nameof (settings));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (settings));
PMSessionDefaultPrintSettings (Handle, settings.Handle);
}

Expand All @@ -125,7 +125,7 @@ public void AssignDefaultSettings (PMPrintSettings settings)
public void AssignDefaultPageFormat (PMPageFormat pageFormat)
{
if (pageFormat is null)
throw new ArgumentNullException (nameof (pageFormat));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (pageFormat));
PMSessionDefaultPageFormat (Handle, pageFormat.Handle);
}

Expand Down Expand Up @@ -156,7 +156,7 @@ public PMStatusCode CreatePrinterList (out string? []? printerList, out int inde
public PMStatusCode ValidatePrintSettings (PMPrintSettings settings, out bool changed)
{
if (settings is null)
throw new ArgumentNullException (nameof (settings));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (settings));

var code = PMSessionValidatePrintSettings (Handle, settings.Handle, out var c);
if (code != PMStatusCode.Ok){
Expand Down Expand Up @@ -255,7 +255,7 @@ public PMStatusCode SetPageRange (uint minPage, uint maxPage)
public PMStatusCode CopySettings (PMPrintSettings destination)
{
if (destination is null)
throw new ArgumentNullException (nameof (destination));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (destination));
return PMCopyPrintSettings (Handle, destination.Handle);
}

Expand Down Expand Up @@ -473,7 +473,7 @@ public PMPaperMargins? Margins {
public string? GetLocalizedName (PMPrinter printer)
{
if (printer is null)
throw new ArgumentNullException (nameof (printer));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (printer));
var code = PMPaperCreateLocalizedName (Handle, printer.Handle, out var name);
if (code != PMStatusCode.Ok)
return null;
Expand Down Expand Up @@ -511,7 +511,7 @@ public PMPrinter ()
static IntPtr Create (string printerId)
{
if (printerId is null)
throw new ArgumentNullException (nameof (printerId));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (printerId));

var printerIdHandle = CFString.CreateNative (printerId);
try {
Expand Down Expand Up @@ -647,9 +647,9 @@ public PMPaper [] PaperList {
public PMStatusCode TryPrintFile (PMPrintSettings settings, PMPageFormat? pageFormat, NSUrl fileUrl, string? mimeType = null)
{
if (settings is null)
throw new ArgumentNullException (nameof (settings));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (settings));
if (fileUrl is null)
throw new ArgumentNullException (nameof (fileUrl));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (fileUrl));

IntPtr mime = CFString.CreateNative (mimeType);
try {
Expand All @@ -665,9 +665,9 @@ public PMStatusCode TryPrintFile (PMPrintSettings settings, PMPageFormat? pageFo
public PMStatusCode TryPrintFromProvider (PMPrintSettings settings, PMPageFormat? pageFormat, CGDataProvider provider, string? mimeType = null)
{
if (settings is null)
throw new ArgumentNullException (nameof (settings));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (settings));
if (provider is null)
throw new ArgumentNullException (nameof (provider));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (provider));

IntPtr mime = CFString.CreateNative (mimeType);
try {
Expand All @@ -685,7 +685,7 @@ public PMStatusCode TryPrintFromProvider (PMPrintSettings settings, PMPageFormat
public PMResolution GetOutputResolution (PMPrintSettings settings)
{
if (settings is null)
throw new ArgumentNullException (nameof (settings));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (settings));

if (PMPrinterGetOutputResolution (Handle, settings.Handle, out var res) == PMStatusCode.Ok)
return res;
Expand All @@ -695,7 +695,7 @@ public PMResolution GetOutputResolution (PMPrintSettings settings)
public void SetOutputResolution (PMPrintSettings settings, PMResolution res)
{
if (settings is null)
throw new ArgumentNullException (nameof (settings));
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (settings));
PMPrinterSetOutputResolution (Handle, settings.Handle, ref res);
}

Expand Down

5 comments on commit 0de0a2f

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 [CI Build] API Diff 📋

API Current PR diff

✅ API Diff (from PR only) (no change)

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

API diff

✅ API Diff from stable

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

Generator diff

Generator Diff (no change)

Pipeline on Agent XAMMINI-051.Monterey'
Hash: 0de0a2fd39ed5baea2191c188ecaedeb072ad04c

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS Mac Catalina (10.15) failed ❌

Failed tests are:

  • introspection
  • linksdk

Pipeline on Agent
Hash: 0de0a2fd39ed5baea2191c188ecaedeb072ad04c

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Failed tests are:

  • dontlink

Pipeline on Agent
Hash: 0de0a2fd39ed5baea2191c188ecaedeb072ad04c

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMMINI-061.Monterey
Hash: 0de0a2fd39ed5baea2191c188ecaedeb072ad04c

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests failed on VSTS: simulator tests iOS ❌

Tests failed on VSTS: simulator tests iOS.

Test results

2 tests failed, 232 tests passed.

Failed tests

  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 12.4) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 12.4) [dotnet]: Failed

Pipeline on Agent XAMBOT-1039.Monterey'
[printcore] Add nullability to (generated and manual) bindings (#14856)

Please sign in to comment.