Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/PrintCore/Defs.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
//
//
Copy link
Member Author

Choose a reason for hiding this comment

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

I cannot figure out what is going on here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh okay thanks, I reverted that commit and redid the part I wanted. I think it should be good now

// Defs.cs: PrintCore definitions
//
// Authors:
// Miguel de Icaza ([email protected])
//
// 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