diff --git a/src/PSRule.Types/Definitions/ISourceExtent.cs b/src/PSRule.Types/Definitions/ISourceExtent.cs
new file mode 100644
index 0000000000..db91e639d7
--- /dev/null
+++ b/src/PSRule.Types/Definitions/ISourceExtent.cs
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+namespace PSRule.Definitions;
+
+///
+/// A source location for a PSRule expression.
+///
+public interface ISourceExtent
+{
+ ///
+ /// The source file path.
+ ///
+ string File { get; }
+
+ ///
+ /// The first line of the expression.
+ ///
+ int? Line { get; }
+
+ ///
+ /// The first position of the expression.
+ ///
+ int? Position { get; }
+}
diff --git a/src/PSRule/Definitions/InfoString.cs b/src/PSRule.Types/Definitions/InfoString.cs
similarity index 84%
rename from src/PSRule/Definitions/InfoString.cs
rename to src/PSRule.Types/Definitions/InfoString.cs
index 3e939a7fab..072079c17f 100644
--- a/src/PSRule/Definitions/InfoString.cs
+++ b/src/PSRule.Types/Definitions/InfoString.cs
@@ -11,12 +11,12 @@ namespace PSRule.Definitions;
[DebuggerDisplay("{Text}")]
public sealed class InfoString
{
- private string _Text;
- private string _Markdown;
+ private string? _Text;
+ private string? _Markdown;
internal InfoString() { }
- internal InfoString(string text, string markdown = null)
+ internal InfoString(string text, string? markdown = null)
{
Text = text;
Markdown = markdown ?? text;
@@ -33,7 +33,7 @@ public bool HasValue
///
/// A plain text representation.
///
- public string Text
+ public string? Text
{
get { return _Text; }
set
@@ -46,7 +46,7 @@ public string Text
///
/// A markdown formatted representation if set. Otherwise this is the same as .
///
- public string Markdown
+ public string? Markdown
{
get { return _Markdown; }
set
@@ -59,7 +59,7 @@ public string Markdown
///
/// Create an info string when not null or empty.
///
- internal static InfoString Create(string text, string markdown = null)
+ internal static InfoString? Create(string text, string? markdown = null)
{
return string.IsNullOrEmpty(text) && string.IsNullOrEmpty(markdown) ? null : new InfoString(text, markdown);
}
diff --git a/src/PSRule/Definitions/SourceExtent.cs b/src/PSRule/Definitions/SourceExtent.cs
index 4ec73631a7..e48adadcc8 100644
--- a/src/PSRule/Definitions/SourceExtent.cs
+++ b/src/PSRule/Definitions/SourceExtent.cs
@@ -3,27 +3,6 @@
namespace PSRule.Definitions;
-///
-/// A source location for a PSRule expression.
-///
-public interface ISourceExtent
-{
- ///
- /// The source file path.
- ///
- string File { get; }
-
- ///
- /// The first line of the expression.
- ///
- int? Line { get; }
-
- ///
- /// The first position of the expression.
- ///
- int? Position { get; }
-}
-
internal sealed class SourceExtent : ISourceExtent
{
internal SourceExtent(string file, int? line)
diff --git a/src/PSRule/Pipeline/Dependencies/LockFile.cs b/src/PSRule/Pipeline/Dependencies/LockFile.cs
index 1a4639ef4c..12464c59f1 100644
--- a/src/PSRule/Pipeline/Dependencies/LockFile.cs
+++ b/src/PSRule/Pipeline/Dependencies/LockFile.cs
@@ -31,22 +31,22 @@ public sealed class LockFile
///
/// An alternative path to the lock file.
/// Returns an instance of the lock file or a default instance if the file does not exist.
- public static LockFile Read(string path)
+ public static LockFile Read(string? path)
{
path = Environment.GetRootedPath(path);
path = Path.GetExtension(path) == ".json" ? path : Path.Combine(path, DEFAULT_FILE);
- LockFile result = null;
+ LockFile? result = null;
if (File.Exists(path))
{
var json = File.ReadAllText(path, Encoding.UTF8);
result = JsonConvert.DeserializeObject(json, new JsonSerializerSettings
{
- Converters = new List
- {
+ Converters =
+ [
new SemanticVersionConverter()
- },
+ ],
});
- return result;
+ return result ?? new LockFile();
}
result ??= new LockFile();
result.Modules ??= new Dictionary(StringComparer.OrdinalIgnoreCase);
@@ -57,7 +57,7 @@ public static LockFile Read(string path)
/// Write the lock file to disk.
///
/// An alternative path to the lock file.
- public void Write(string path)
+ public void Write(string? path)
{
Version = 1;
@@ -65,10 +65,10 @@ public void Write(string path)
path = Path.GetExtension(path) == "json" ? path : Path.Combine(path, DEFAULT_FILE);
var json = JsonConvert.SerializeObject(this, Formatting.Indented, new JsonSerializerSettings
{
- Converters = new List
- {
+ Converters =
+ [
new SemanticVersionConverter()
- }
+ ]
});
File.WriteAllText(path, json, Encoding.UTF8);
}
diff --git a/src/PSRule/Runtime/RuleConditionHelper.cs b/src/PSRule/Runtime/RuleConditionHelper.cs
index 949b5c290c..714dc748b0 100644
--- a/src/PSRule/Runtime/RuleConditionHelper.cs
+++ b/src/PSRule/Runtime/RuleConditionHelper.cs
@@ -24,7 +24,7 @@ internal static RuleConditionResult Create(IEnumerable