Skip to content

Commit 4f3785c

Browse files
committed
stdlib.dotnet namespace
1 parent 05d9789 commit 4f3785c

10 files changed

Lines changed: 59 additions & 13 deletions

File tree

+stdlib/+dotnet/api.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
%% DOTNET.API major version integer .NET
2+
3+
function v = api()
4+
5+
try
6+
v = System.Environment.Version.Major;
7+
catch
8+
% not empty because that breaks less-than logic
9+
v = -1;
10+
end
11+
12+
end

+stdlib/+dotnet/home.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%% DOTNET.HOME give .NET RuntimeLocation
2+
3+
function h = home()
4+
5+
h = string.empty;
6+
7+
try %#ok<TRYNC>
8+
9+
if NET.isNETSupported
10+
% need to call this at least once or dotnetenv() is empty
11+
12+
h = dotnetenv().RuntimeLocation;
13+
end
14+
15+
end
16+
17+
end

+stdlib/+dotnet/is_symlink.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
return
99
end
1010
try
11-
if stdlib.dotnet_api() >= 6
11+
if stdlib.dotnet.api() >= 6
1212
y = ~isempty(System.IO.FileInfo(file).LinkTarget);
1313
else
1414
attr = char(System.IO.File.GetAttributes(file).ToString());

+stdlib/+dotnet/version.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
%% DOTNET.VERSION version string
2+
3+
function v = version()
4+
5+
try
6+
vs = System.Environment.Version;
7+
v = sprintf('%d.%d.%d', vs.Major, vs.Minor, vs.Build);
8+
catch e
9+
v = dotnetException(e);
10+
end
11+
12+
end

+stdlib/Backend.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969
switch functionName
7070
case {'create_symlink', 'ram_total', 'read_symlink', 'uptime'}
71-
if stdlib.dotnet_api() < 6, continue, end
71+
if stdlib.dotnet.api() < 6, continue, end
7272
case {'get_owner', 'get_uid', 'is_admin'}
7373
if isunix(), continue, end
7474
end

+stdlib/doctor.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929

3030
raw.java.vendor = stdlib.java.vendor();
3131
raw.java.version = stdlib.java.version();
32+
raw.java.api = stdlib.java.api();
3233
raw.java.home = stdlib.java.home();
3334

34-
if stdlib.has_dotnet()
35-
raw.dotnet.version = stdlib.dotnet_version();
36-
end
35+
raw.dotnet.api = stdlib.dotnet.api();
36+
raw.dotnet.home = stdlib.dotnet.home();
37+
raw.dotnet.version = stdlib.dotnet.version();
3738

3839
if stdlib.has_perl()
3940
raw.perl.version = sprintf('%d.%d.%d', stdlib.perl_version());

+stdlib/has_dotnet.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
y = NET.isNETSupported;
1010
catch
1111
try
12-
y = stdlib.dotnet_api() >= 4;
12+
y = stdlib.dotnet.api() >= 4;
1313
catch
1414
y = false;
1515
end

example/dotnet/relative_to.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
function rel = relative_to(base, other)
66

7-
assert(stdlib.dotnet_api() >= 5)
7+
assert(stdlib.dotnet.api() >= 5)
88

99
if stdlib.strempty(other)
1010
rel = base;

test/TestLang.m

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ function test_python_home(tc)
2424

2525
function test_dotnet_home(tc)
2626
tc.assumeTrue(stdlib.has_dotnet(), '.NET not available')
27-
h = stdlib.dotnet_home();
27+
h = stdlib.dotnet.home();
2828

2929
tc.verifyGreaterThan(strlength(h), 0)
3030
end
3131

3232

3333
function test_dotnet_version(tc)
34-
tc.assumeTrue(stdlib.has_dotnet())
35-
v = stdlib.dotnet_version();
36-
tc.verifyClass(v, 'char')
37-
tc.verifyTrue(stdlib.version_atleast(v, '4.0'), '.NET version should be greater than 4.0')
34+
v = stdlib.dotnet.version();
35+
36+
if stdlib.has_dotnet()
37+
tc.verifyClass(v, 'char')
38+
tc.verifyTrue(stdlib.version_atleast(v, '4.0'), '.NET version should be greater than 4.0')
39+
else
40+
tc.verifyEqual(v, missing)
41+
end
3842
end
3943

4044
end

test/is_capable.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function is_capable(tc, f)
88

99
if contains(n, ".dotnet.")
1010

11-
dapi = stdlib.dotnet_api();
11+
dapi = stdlib.dotnet.api();
1212
tc.assumeGreaterThan(dapi, 0, ".NET not available")
1313

1414
elseif contains(n, ".java.")

0 commit comments

Comments
 (0)