Skip to content

Commit 69406e8

Browse files
committed
Refactor GetVersion() into a property
1 parent dcb1fb4 commit 69406e8

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

src/libvirt/Connect.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void Open(bool readOnly = false)
2525
{
2626
if (IsDisposed)
2727
{
28-
throw new ObjectDisposedException(null, "Cannot open a disposed Connect.");
28+
throw new ObjectDisposedException("Connect", "Cannot open a disposed connection.");
2929
}
3030

3131
if (readOnly)

src/libvirt/Libvirt.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ private static IntPtr ImportResolver(string libraryName, Assembly assembly, DllI
3434

3535
public const int VIR_UUID_BUFLEN = 36;
3636

37-
public static Version GetVersion()
37+
public static Version Version
3838
{
39-
LibvirtHelper.ThrowExceptionOnError(virGetVersion(out ulong libVer, null, out _));
40-
41-
int release = (int) (libVer % 1000);
42-
int minor = (int) ((libVer % 1000000) / 1000);
43-
int major = (int) (libVer / 1000000);
39+
get
40+
{
41+
LibvirtHelper.ThrowExceptionOnError(virGetVersion(out ulong libVer, null, out _));
4442

45-
return new Version(major, minor, release);
43+
int release = (int) (libVer % 1000);
44+
int minor = (int) ((libVer % 1000000) / 1000);
45+
int major = (int) (libVer / 1000000);
4646

47+
return new Version(major, minor, release);
48+
}
4749
}
4850

4951
#region Library

src/libvirt/libvirt.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<AssemblyName>libvirt-csharp</AssemblyName>
6-
<Version>0.0.1-alpha1</Version>
6+
<Version>0.0.1-alpha2</Version>
77
<SignAssembly>true</SignAssembly>
88
<AssemblyOriginatorKeyFile>libvirt-csharp.snk</AssemblyOriginatorKeyFile>
99
</PropertyGroup>

tests/libvirt.Tests/LibraryTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ public class LibraryTests
77
[Fact]
88
public void GetVersion_ReturnVersion()
99
{
10-
Libvirt.GetVersion();
10+
// Act
11+
var version = Libvirt.Version;
12+
13+
// Assert
14+
Assert.True(version > new System.Version(0,0,1));
1115
}
1216
}
1317
}

0 commit comments

Comments
 (0)