FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
flashdevelop/PluginCore/PluginCore/Utilities/SemVer.cs at development · fdorg/flashdevelop · GitHub
fdorg
flashdevelop
Repository navigation
Code
Issues
388
(388)
Pull requests
8
(8)
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
flashdevelop
/
PluginCore
/
PluginCore
/
Utilities
/
SemVer.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
102 lines (80 loc) · 3.67 KB
Breadcrumbs
flashdevelop
/
PluginCore
/
PluginCore
/
Utilities
/
SemVer.cs
Copy path
File metadata and controls
102 lines (80 loc) · 3.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
namespace
PluginCore
.
Utilities
{
/// <summary>
/// Represents a semantic version, see http://semver.org/
/// Follows Semantic Versioning 2.0.0
/// </summary>
public
class
SemVer
{
public
static
readonly
SemVer
Zero
=
new
SemVer
(
)
;
public
readonly
int
Major
;
public
readonly
int
Minor
;
public
readonly
int
Patch
;
SemVer
(
)
{
}
public
SemVer
(
string
version
)
{
// TODO: Parse and expose pre-release and build metadata
// ignore the pre-release and build metadata denotation if present
var
hyphenIndex
=
version
.
IndexOf
(
'-'
)
;
if
(
hyphenIndex
>=
0
)
version
=
version
.
Substring
(
0
,
hyphenIndex
)
;
var
plusIndex
=
version
.
IndexOf
(
'+'
)
;
if
(
plusIndex
>=
0
)
version
=
version
.
Substring
(
0
,
plusIndex
)
;
var
numbers
=
version
.
Split
(
'.'
)
;
if
(
numbers
.
Length
>=
1
)
int
.
TryParse
(
numbers
[
0
]
,
out
Major
)
;
if
(
numbers
.
Length
>=
2
)
int
.
TryParse
(
numbers
[
1
]
,
out
Minor
)
;
if
(
numbers
.
Length
>=
3
)
int
.
TryParse
(
numbers
[
2
]
,
out
Patch
)
;
}
#region Operators
public
static
bool
operator
==
(
SemVer
left
,
SemVer
right
)
{
return
left
.
Major
==
right
.
Major
&&
left
.
Minor
==
right
.
Minor
&&
left
.
Patch
==
right
.
Patch
;
}
public
static
bool
operator
!=
(
SemVer
left
,
SemVer
right
)
{
return
left
.
Major
!=
right
.
Major
||
left
.
Minor
!=
right
.
Minor
||
left
.
Patch
!=
right
.
Patch
;
}
public
static
bool
operator
<
(
SemVer
left
,
SemVer
right
)
{
return
left
.
Major
<
right
.
Major
||
left
.
Major
==
right
.
Major
&&
(
left
.
Minor
<
right
.
Minor
||
left
.
Minor
==
right
.
Minor
&&
(
left
.
Patch
<
right
.
Patch
)
)
;
}
public
static
bool
operator
>
(
SemVer
left
,
SemVer
right
)
{
return
left
.
Major
>
right
.
Major
||
left
.
Major
==
right
.
Major
&&
(
left
.
Minor
>
right
.
Minor
||
left
.
Minor
==
right
.
Minor
&&
(
left
.
Patch
>
right
.
Patch
)
)
;
}
public
static
bool
operator
<=
(
SemVer
left
,
SemVer
right
)
{
return
left
.
Major
<
right
.
Major
||
left
.
Major
==
right
.
Major
&&
(
left
.
Minor
<
right
.
Minor
||
left
.
Minor
==
right
.
Minor
&&
(
left
.
Patch
<
right
.
Patch
||
left
.
Patch
==
right
.
Patch
)
)
;
}
public
static
bool
operator
>=
(
SemVer
left
,
SemVer
right
)
{
return
left
.
Major
>
right
.
Major
||
left
.
Major
==
right
.
Major
&&
(
left
.
Minor
>
right
.
Minor
||
left
.
Minor
==
right
.
Minor
&&
(
left
.
Patch
>
right
.
Patch
||
left
.
Patch
==
right
.
Patch
)
)
;
}
public
static
bool
operator
==
(
SemVer
left
,
string
right
)
=>
left
==
new
SemVer
(
right
)
;
public
static
bool
operator
!=
(
SemVer
left
,
string
right
)
=>
left
!=
new
SemVer
(
right
)
;
public
static
bool
operator
<
(
SemVer
left
,
string
right
)
=>
left
<
new
SemVer
(
right
)
;
public
static
bool
operator
>
(
SemVer
left
,
string
right
)
=>
left
>
new
SemVer
(
right
)
;
public
static
bool
operator
<=
(
SemVer
left
,
string
right
)
=>
left
<=
new
SemVer
(
right
)
;
public
static
bool
operator
>=
(
SemVer
left
,
string
right
)
=>
left
>=
new
SemVer
(
right
)
;
#endregion
public
override
string
ToString
(
)
=>
$
"
{
Major
}
.
{
Minor
}
.
{
Patch
}
"
;
public
bool
Equals
(
SemVer
semVer
)
=>
this
==
semVer
;
public
override
bool
Equals
(
object
obj
)
=>
obj
is
SemVer
v
?
v
==
this
:
base
.
Equals
(
obj
)
;
public
override
int
GetHashCode
(
)
=>
Major
<<
16
^
Minor
<<
8
^
Patch
;
}
}
Back
|
FazBrowse Home
|
New Git URL