Skip to content

Commit 6995d08

Browse files
committed
updated readme
1 parent 599a897 commit 6995d08

5 files changed

Lines changed: 49 additions & 12 deletions

File tree

GithubUpdateCheck/GithubUpdateCheck.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.Text.RegularExpressions;
77
using System.Collections.Generic;
8+
using System.Diagnostics.CodeAnalysis;
89

910
namespace Mayerch1.GithubUpdateCheck
1011
{
@@ -56,10 +57,11 @@ public enum CompareType
5657
/// The exception that is thrown if the version argument does not match the required pattern
5758
/// </summary>
5859
public class InvalidVersionException : ArgumentException {
59-
60+
6061
/// <summary>
6162
/// Initializes a new instance of the <see cref="InvalidVersionException"/> class
6263
/// </summary>
64+
[ExcludeFromCodeCoverage]
6365
public InvalidVersionException()
6466
{
6567
}
@@ -76,6 +78,7 @@ public InvalidVersionException(String message) : base(message)
7678
/// </summary>
7779
/// <param name="message"></param>
7880
/// <param name="innerException"></param>
81+
[ExcludeFromCodeCoverage]
7982
public InvalidVersionException(string message, Exception innerException) : base(message, innerException)
8083
{
8184
}
@@ -177,6 +180,7 @@ public GithubUpdateCheck(string Username, string Repository, CompareType compare
177180
/// </summary>
178181
/// <param name="obj">other object</param>
179182
/// <returns>False if objects are not the same type. Otherwise behaves like ==</returns>
183+
[ExcludeFromCodeCoverage]
180184
public override bool Equals(object obj)
181185
{
182186
return Equals(obj as GithubUpdateCheck);
@@ -199,6 +203,7 @@ public bool Equals(GithubUpdateCheck other)
199203
/// Get the hash code of the object (generated by VS refactoring)
200204
/// </summary>
201205
/// <returns></returns>
206+
[ExcludeFromCodeCoverage]
202207
public override int GetHashCode()
203208
{
204209
var hashCode = -1134592763;

GithubUpdateCheckTest/UnitTestBoolean.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using Mayerch1.GithubUpdateCheck;
44
using System.Threading.Tasks;
5+
using System.Diagnostics.CodeAnalysis;
56

67
namespace GithubUpdateCheckTest
78
{
@@ -11,6 +12,7 @@ namespace GithubUpdateCheckTest
1112
/// This unit test can take more than 20s runtime
1213
/// </summary>
1314
[TestClass]
15+
[ExcludeFromCodeCoverage]
1416
public class UnitTestBoolean
1517
{
1618
[TestMethod]

GithubUpdateCheckTest/UnitTestGeneral.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using Mayerch1.GithubUpdateCheck;
44
using System.Threading.Tasks;
5+
using System.Diagnostics.CodeAnalysis;
56

67
namespace GithubUpdateCheckTest
78
{
@@ -11,6 +12,7 @@ namespace GithubUpdateCheckTest
1112
/// This unit test can take more than 20s runtime
1213
/// </summary>
1314
[TestClass]
15+
[ExcludeFromCodeCoverage]
1416
public class UnitTestGeneral
1517
{
1618

GithubUpdateCheckTest/UnitTestIncremental.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using Mayerch1.GithubUpdateCheck;
44
using System.Threading.Tasks;
5+
using System.Diagnostics.CodeAnalysis;
56

67
namespace GithubUpdateCheckTest
78
{
@@ -11,6 +12,7 @@ namespace GithubUpdateCheckTest
1112
/// This unit test can take more than 20s runtime
1213
/// </summary>
1314
[TestClass]
15+
[ExcludeFromCodeCoverage]
1416
public class UnitTestIncremental
1517
{
1618
[TestMethod]

README.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,67 @@
11
# GithubUpdateCheck
2+
3+
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
4+
&nbsp;
5+
[![Nuget](https://img.shields.io/nuget/v/Mayerch1.GithubUpdateCheck)](https://www.nuget.org/packages/Mayerch1.GithubUpdateCheck/)
6+
&nbsp;
7+
[![GitHub release](https://img.shields.io/github/release/mayerch1/GithubUpdateCheck.svg)](https://github.com/mayerch1/GithubUpdateCheck/releases/latest)
8+
29
NuGet package to check if an update is available. Always compares to the latest github release
310

11+
412
## Usage
513
Create an instance of the `GithubUpdateCheck` and specify your Github username and Github repository, as seen in the url.
14+
15+
616
```cs
17+
using Mayerch1.GithubUpdateCheck;
18+
719
GithubUpdateCheck update = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck");
820
bool isUpdate = update.IsUpdateAvailable("1.0.0", VersionChange.Minor);
921
bool isAsyncUpdate = await update.IsUpdateAvailable("1.0.0.5", VersionChange.Revision);
1022
```
1123

24+
---
25+
26+
### Incremental Compare
27+
The default constructor is implicite setting the compare type to `CompareType.Incremental`.
28+
Alternatively call
29+
```cs
30+
GithubUpdateCheck update = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Incremental);
31+
```
32+
1233
The version will be compared to the latest release on Github (e.g. https://github.com/Mayerch1/GithubUpdateCheck/releases/latest).
1334
Allowed are the following patterns
1435
```
1536
1.0.0
1637
1.0.0.0
1738
18-
v.1.0.0.0
1939
v.1.0.0
20-
21-
v1.0.0.0
2240
v1.0.0
23-
```
24-
(`v` can be any non-digit)
25-
The version string and the tag of the github release must comply with those patterns, otherwise a `InvalidVersionException` will be thrown.
2641
27-
The second argument `VersionChange changeLevel` specifies the level of comparison.
42+
1.0.0.[...].5 (any amount of '.' seperators)
43+
```
44+
`v` can be any non-digit and the version (local and repository) must comply with those patterns, otherwise a `InvalidVersionException` will be thrown
2845

46+
The second argument `VersionChange` specifies the level of comparison.
2947

3048
</br>For `Major`, only the first number will be compared (x.0.0.0)
3149
</br>For `Minor`, the first and second number will be compared (x.y.0.0)
3250
</br>For `Build`, the numbers 1-3 will be compared (x.y.z.0)
3351
</br>For `Revision`, all numbers will be compared (x.y.z.a)
3452

53+
If the version number if exceeding this enum, simply pass an integer `...IsUpdateAvailable("1.0.0.0.9", (VersionChange)5);`. The index is 1-offset from the Major version and will be corrected if it is too big for the present number.
3554

36-
37-
All numbers below the specified level (all 0 is this example) will be ignored.
38-
If the remote or local version has a lower level than the specified compare Method (e.g. `1.2.0` at `Revision`), only
39-
the present version levels will be compared.
55+
All numbers below the specified level will be ignored.
4056

4157
The prefix `v.` can be present on none, one or both sides.
58+
59+
---
60+
61+
### Boolean Compare
62+
If the used version system does not match the "Incremental" Compare, you can use the boolean compare.
63+
```cs
64+
GithubUpdateCheck update = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Boolean);
65+
```
66+
The class will then compare both version strings (local and remote) and will assume an available update as
67+
soon as they are not equal.

0 commit comments

Comments
 (0)