Skip to content

Commit 7fca691

Browse files
committed
has_dotnet more efficient
1 parent e84fffc commit 7fca691

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

+stdlib/has_dotnet.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
function y = has_dotnet()
77

8-
y = false;
9-
10-
if stdlib.isoctave, return, end
11-
12-
if ~ispc() && isMATLABReleaseOlderThan('R2024b'), return, end
13-
14-
y = NET.isNETSupported;
8+
try
9+
y = (ispc() || ~isMATLABReleaseOlderThan('R2024b')) && NET.isNETSupported;
10+
catch e
11+
switch e.identifier
12+
case {'MATLAB:scriptNotAFunction', 'MATLAB:undefinedVarOrClass', 'Octave:undefined-function'}
13+
y = false;
14+
otherwise, rethrow(e)
15+
end
16+
end
1517

1618
end

0 commit comments

Comments
 (0)