-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Semantic versioning added to Manifest modification API (#41)
* dependencies & scope registries getter added * try get dependency/scope registry APIs * scope registry manipulation API update * set dependency API update * minor refactor changes * semantic version implementation * Version renamed to SemanticVersion & constructor is public * SemanticVersion public fields replaced with properties * redundant namespace qualifier removed * semantic version summary & minor improvements iteration * public interface methods & properties have summary now * additional SemanticVersion cunstructor added * minor description fixes for Dependency class Co-authored-by: Stanislav Osipov <[email protected]> * minor description fixes for Manifest class Co-authored-by: Stanislav Osipov <[email protected]> * minor description fixes for Manifest class Co-authored-by: Stanislav Osipov <[email protected]> Co-authored-by: Alexey Yaremenko <[email protected]> Co-authored-by: Stanislav Osipov <[email protected]>
- Loading branch information
1 parent
27143d0
commit 3900619
Showing
5 changed files
with
438 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System.Collections.Generic; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace StansAssets.Foundation.Editor | ||
{ | ||
|
@@ -8,15 +9,41 @@ namespace StansAssets.Foundation.Editor | |
public class Dependency | ||
{ | ||
/// <summary> | ||
/// The dependency name. | ||
/// The <see cref="Dependency"/> name. | ||
/// </summary> | ||
public string Name { get; } | ||
|
||
/// <summary> | ||
/// The dependency version. | ||
/// The <see cref="Dependency"/> version. | ||
/// </summary> | ||
public string Version { get; private set; } | ||
|
||
/// <summary> | ||
/// `true` if the <see cref="Dependency"/> has <see cref="SemanticVersion"/>; otherwise, `false`. | ||
/// </summary> | ||
public bool HasSemanticVersion { get; private set; } | ||
|
||
/// <summary> | ||
/// The <see cref="Dependency"/> semantic version. | ||
/// </summary> | ||
public SemanticVersion SemanticVersion { get; private set; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Dependency"/> class with provided properties. | ||
/// </summary> | ||
/// <param name="fullName"><see cref="Dependency"/> full name which contains name and version (e.g. '[email protected]').</param> | ||
public Dependency(string fullName) | ||
{ | ||
if (TryGetNameAndVersion(fullName, out string name, out string version)) | ||
{ | ||
Name = name; | ||
Version = version; | ||
TryAssignSemanticVersion(); | ||
} | ||
else | ||
throw new ArgumentException("Dependency fullName has wrong format"); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Dependency"/> class with provided properties. | ||
/// </summary> | ||
|
@@ -26,6 +53,27 @@ public Dependency(string name, string version) | |
{ | ||
Name = name; | ||
Version = version; | ||
TryAssignSemanticVersion(); | ||
} | ||
|
||
internal static bool TryGetNameAndVersion(string fullName, out string name, out string version) | ||
{ | ||
name = version = null; | ||
var dependencyData = fullName.Split('@'); | ||
if (dependencyData.Length == 2) | ||
{ | ||
name = dependencyData[0]; | ||
version = dependencyData[1]; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void TryAssignSemanticVersion() | ||
{ | ||
HasSemanticVersion = SemanticVersion.TryCreateSemanticVersion(Version, out var semanticVersion); | ||
if (HasSemanticVersion) | ||
SemanticVersion = semanticVersion; | ||
} | ||
|
||
/// <summary> | ||
|
@@ -35,6 +83,7 @@ public Dependency(string name, string version) | |
public void SetVersion(string version) | ||
{ | ||
Version = version; | ||
TryAssignSemanticVersion(); | ||
} | ||
|
||
/// <summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.