Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit a07890c

Browse files
Merge pull request #417 from xamarin/publicize-it
use SwiftRuntimeLibrary Exceptions.ThrowOnNull
2 parents 8f04b67 + eedef19 commit a07890c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+168
-145
lines changed

SwiftReflector/CSKeywords.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Linq;
7+
using SwiftRuntimeLibrary;
78

89
namespace SwiftReflector {
910
public class CSKeywords {
@@ -35,7 +36,7 @@ static CSKeywords ()
3536

3637
public static bool IsKeyword (string s)
3738
{
38-
Ex.ThrowOnNull (s, "s");
39+
Exceptions.ThrowOnNull (s, "s");
3940
return keyWords.Contains (s);
4041
}
4142
}

SwiftReflector/Demangling/MatchRule.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Linq;
7+
using SwiftRuntimeLibrary;
78

89
namespace SwiftReflector.Demangling {
910
public class MatchRule {
@@ -37,7 +38,7 @@ public NodeKind NodeKind {
3738

3839
public bool Matches(Node n)
3940
{
40-
Ex.ThrowOnNull (n, nameof (n));
41+
Exceptions.ThrowOnNull (n, nameof (n));
4142
// 3 match criteria: NodeKind, Content type, children
4243
return NodeKindMatches (n) && ContentMatches (n) &&
4344
ChildrenMatches (n);

SwiftReflector/Demangling/Swift4Demangler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Text;
77
using ObjCRuntime;
88
using SwiftReflector.ExceptionTools;
9+
using SwiftRuntimeLibrary;
910

1011
namespace SwiftReflector.Demangling {
1112
public class Swift4Demangler {
@@ -20,7 +21,7 @@ public class Swift4Demangler {
2021

2122
public Swift4Demangler (string swiftIdentifier, ulong offset = 0)
2223
{
23-
Ex.ThrowOnNull (swiftIdentifier, nameof (swiftIdentifier));
24+
Exceptions.ThrowOnNull (swiftIdentifier, nameof (swiftIdentifier));
2425
if (!swiftIdentifier.StartsWith (Decomposer.kSwift4ID, StringComparison.Ordinal))
2526
throw new ArgumentOutOfRangeException (nameof (swiftIdentifier), $"Expecting '{swiftIdentifier}' to start with '{Decomposer.kSwift4ID}'");
2627
this.offset = offset;

SwiftReflector/Demangling/Swift4NodeToTLDefinition.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using SwiftReflector.ExceptionTools;
8+
using SwiftRuntimeLibrary;
89

910
namespace SwiftReflector.Demangling {
1011
public class Swift4NodeToTLDefinition {
@@ -891,7 +892,7 @@ List<MatchRule> BuildMatchRules ()
891892

892893
public TLDefinition Convert (Node node)
893894
{
894-
Ex.ThrowOnNull (node, nameof (node));
895+
Exceptions.ThrowOnNull (node, nameof (node));
895896

896897

897898
switch (node.Kind) {

SwiftReflector/Demangling/Swift5NodeToTLDefinition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Linq;
7-
7+
using SwiftRuntimeLibrary;
88

99
namespace SwiftReflector.Demangling {
1010
public class Swift5NodeToTLDefinition {
@@ -748,7 +748,7 @@ List<MatchRule> BuildMatchRules ()
748748

749749
public TLDefinition Convert (Node node)
750750
{
751-
Ex.ThrowOnNull (node, nameof (node));
751+
Exceptions.ThrowOnNull (node, nameof (node));
752752

753753

754754
switch (node.Kind) {

SwiftReflector/Demangling/TLDefinition.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using System.Text;
8+
using SwiftRuntimeLibrary;
89

910
namespace SwiftReflector.Demangling {
1011
public class TLDefinition {
@@ -14,7 +15,7 @@ protected TLDefinition (CoreCompoundType type, string mangledName, SwiftName mod
1415
throw new ArgumentNullException (nameof(module));
1516
Type = type;
1617
Module = module;
17-
MangledName = Ex.ThrowOnNull (mangledName, nameof(mangledName));
18+
MangledName = Exceptions.ThrowOnNull (mangledName, nameof(mangledName));
1819
Offset = offset;
1920
}
2021

@@ -35,7 +36,7 @@ public class TLMetadataDescriptor : TLDefinition {
3536
public TLMetadataDescriptor (SwiftType ofType, bool isBuiltIn, string mangledName, SwiftName module, ulong offset)
3637
: base (CoreCompoundType.MetadataDescriptor, mangledName, module, offset)
3738
{
38-
OfType = Ex.ThrowOnNull (ofType, nameof (ofType));
39+
OfType = Exceptions.ThrowOnNull (ofType, nameof (ofType));
3940
IsBuiltIn = isBuiltIn;
4041
}
4142
public SwiftType OfType { get; private set; }
@@ -72,8 +73,8 @@ protected TLVariable (CoreCompoundType type, string mangledName, SwiftName modul
7273
bool isStatic, ulong offset, SwiftType extensionOn)
7374
: base (type, mangledName, module, classType, offset)
7475
{
75-
Name = Ex.ThrowOnNull (ident, nameof (ident));
76-
OfType = Ex.ThrowOnNull (ofType, nameof (ofType));
76+
Name = Exceptions.ThrowOnNull (ident, nameof (ident));
77+
OfType = Exceptions.ThrowOnNull (ofType, nameof (ofType));
7778
IsStatic = isStatic;
7879
ExtensionOn = extensionOn;
7980
}
@@ -95,8 +96,8 @@ public class TLUnsafeMutableAddressor : TLClassElem {
9596
public TLUnsafeMutableAddressor(string mangledName, SwiftName module, SwiftClassType classType, SwiftName ident, SwiftType ofType, ulong offset)
9697
: base (CoreCompoundType.UnsafeMutableAddressor, mangledName, module, classType, offset)
9798
{
98-
Name = Ex.ThrowOnNull (ident, nameof (ident));
99-
OfType = Ex.ThrowOnNull (ofType, nameof (ofType));
99+
Name = Exceptions.ThrowOnNull (ident, nameof (ident));
100+
OfType = Exceptions.ThrowOnNull (ofType, nameof (ofType));
100101
}
101102
public SwiftType OfType { get; private set; }
102103
public SwiftName Name { get; private set; }
@@ -154,7 +155,7 @@ public class TLDefaultArgumentInitializer : TLDefinition {
154155
public TLDefaultArgumentInitializer(string mangledName, SwiftName module, SwiftBaseFunctionType function, int index, ulong offset)
155156
: base(CoreCompoundType.ArgumentInitializer, mangledName, module, offset)
156157
{
157-
Signature = Ex.ThrowOnNull (function, nameof (function));
158+
Signature = Exceptions.ThrowOnNull (function, nameof (function));
158159
ArgumentIndex = index;
159160
}
160161
public SwiftBaseFunctionType Signature { get; private set; }
@@ -208,7 +209,7 @@ public TLProtocolConformanceDescriptor (string mangledName, SwiftName module, Sw
208209
SwiftClassType forProtocol, ulong offset)
209210
: base (CoreCompoundType.ProtocolConformanceDescriptor, mangledName, module, offset)
210211
{
211-
ImplementingType = Ex.ThrowOnNull (implementingType, nameof (implementingType));
212+
ImplementingType = Exceptions.ThrowOnNull (implementingType, nameof (implementingType));
212213
Protocol = forProtocol;
213214
}
214215

@@ -227,7 +228,7 @@ public class TLBaseConformanceDescriptor : TLClassElem {
227228
public TLBaseConformanceDescriptor (string mangledName, SwiftName module, SwiftClassType protocol, SwiftClassType requirement, ulong offset)
228229
: base (CoreCompoundType.BaseConformanceDescriptor, mangledName, module, protocol, offset)
229230
{
230-
ProtocolRequirement = Ex.ThrowOnNull (requirement, nameof (requirement));
231+
ProtocolRequirement = Exceptions.ThrowOnNull (requirement, nameof (requirement));
231232
}
232233
public SwiftClassType ProtocolRequirement { get; private set; }
233234
}

SwiftReflector/Ex.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

SwiftReflector/Extensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ public static string ClangTargetOS (this string s)
8989

9090
public static void Merge<T> (this HashSet<T> to, IEnumerable<T> from)
9191
{
92-
Ex.ThrowOnNull (from, nameof (from));
92+
Exceptions.ThrowOnNull (from, nameof (from));
9393
foreach (T val in from)
9494
to.Add (val);
9595
}
9696

9797
public static void DisposeAll<T> (this IEnumerable<T> coll) where T : IDisposable
9898
{
99-
Ex.ThrowOnNull (coll, nameof (coll));
99+
Exceptions.ThrowOnNull (coll, nameof (coll));
100100
foreach (T obj in coll) {
101101
if ((IDisposable)obj != null)
102102
obj.Dispose ();
@@ -151,8 +151,8 @@ public static List<T> CloneAndPrepend<T>(this List<T> source, T item)
151151

152152
public static T[] And<T> (this T[] first, T[] second)
153153
{
154-
Ex.ThrowOnNull (first, nameof (first));
155-
Ex.ThrowOnNull (second, nameof (second));
154+
Exceptions.ThrowOnNull (first, nameof (first));
155+
Exceptions.ThrowOnNull (second, nameof (second));
156156
var result = new T [first.Length + second.Length];
157157
Array.Copy (first, result, first.Length);
158158
Array.Copy (second, 0, result, first.Length, second.Length);

SwiftReflector/IOUtils/ReliablePath.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// Licensed under the MIT License.
33

44
using System.IO;
5+
using SwiftRuntimeLibrary;
56

67
namespace SwiftReflector.IOUtils {
78
public class ReliablePath {
89
public static string GetParentDirectory (string path)
910
{
10-
Ex.ThrowOnNull (path, nameof (path));
11+
Exceptions.ThrowOnNull (path, nameof (path));
1112
if (path.EndsWith ("/")) {
1213
path = path.Substring (0, path.Length - 1);
1314
}

SwiftReflector/Importing/BindingImporter.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
using System.Linq;
1010
using Mono.Cecil;
1111
using SwiftReflector.SwiftXmlReflection;
12+
using SwiftRuntimeLibrary;
1213

1314
namespace SwiftReflector.Importing {
1415

1516
public class BindingImporter {
1617
class TypeDefinitionTypeDeclarationPair {
1718
public TypeDefinitionTypeDeclarationPair (TypeDefinition typeDefinition, TypeDeclaration typeDeclaration)
1819
{
19-
TypeDefinition = Ex.ThrowOnNull (typeDefinition, nameof (typeDefinition));
20-
TypeDeclaration = Ex.ThrowOnNull (typeDeclaration, nameof (typeDeclaration));
20+
TypeDefinition = Exceptions.ThrowOnNull (typeDefinition, nameof (typeDefinition));
21+
TypeDeclaration = Exceptions.ThrowOnNull (typeDeclaration, nameof (typeDeclaration));
2122
}
2223
public TypeDefinition TypeDefinition { get; }
2324
public TypeDeclaration TypeDeclaration { get; }
@@ -38,8 +39,8 @@ public BindingImporter (PlatformName platform, ErrorHandling errors, TypeDatabas
3839

3940
BindingImporter (string assemblyPath, ErrorHandling errors, TypeDatabase peerDatabase = null)
4041
{
41-
Ex.ThrowOnNull (assemblyPath, nameof (assemblyPath));
42-
this.errors = Ex.ThrowOnNull (errors, nameof (errors));
42+
Exceptions.ThrowOnNull (assemblyPath, nameof (assemblyPath));
43+
this.errors = Exceptions.ThrowOnNull (errors, nameof (errors));
4344
this.peerDatabase = peerDatabase;
4445
aggregator = new TypeAggregator (assemblyPath);
4546

@@ -60,7 +61,7 @@ public BindingImporter (PlatformName platform, ErrorHandling errors, TypeDatabas
6061

6162
public static bool ImportAndMerge (PlatformName platformName, TypeDatabase peerDatabase, ErrorHandling errors)
6263
{
63-
Ex.ThrowOnNull (peerDatabase, nameof (peerDatabase));
64+
Exceptions.ThrowOnNull (peerDatabase, nameof (peerDatabase));
6465
var initialErrorCount = errors.ErrorCount;
6566
var newDb = ImportFrom (platformName, errors, peerDatabase);
6667
peerDatabase.Merge (newDb, errors);

0 commit comments

Comments
 (0)