Skip to content

Commit

Permalink
#27: Removed dependency between Synergy.Documentation and Synergy.Con…
Browse files Browse the repository at this point in the history
…tracts
  • Loading branch information
MarcinCelej committed Dec 22, 2023
1 parent abfe92e commit 9a1346a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 31 deletions.
3 changes: 0 additions & 3 deletions Documentation/Synergy.Documentation/Api/ApiDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using JetBrains.Annotations;
using Synergy.Catalogue;
using Synergy.Catalogue.Reflection;

Expand Down Expand Up @@ -179,11 +178,9 @@ private static string GetPropertyName(PropertyInfo property)
private static bool IsStatic(this PropertyInfo source, bool nonPublic = false)
=> source.GetAccessors(nonPublic).Any(x => x.IsStatic);

[Pure]
private static bool In<T>(this T value, params T[] values)
=> values.Contains(value);

[Pure]
private static bool NotIn<T>(this T value, params T[] values)
=> value.In(values) == false;

Expand Down
3 changes: 1 addition & 2 deletions Documentation/Synergy.Documentation/Code/CodeFile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using Synergy.Contracts;

namespace Synergy.Documentation.Code;

Expand All @@ -17,7 +16,7 @@ public static CodeFolder Current([CallerFilePath] string path = "")

public CodeFile(string filePath)
{
FilePath = filePath.OrFailIfWhiteSpace(nameof(filePath));
FilePath = filePath;
}

public CodeFolder Folder
Expand Down
20 changes: 4 additions & 16 deletions Documentation/Synergy.Documentation/Markup/Markdown.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System.Collections;
using System.Text;
using Synergy.Catalogue;
using Synergy.Contracts;
using Synergy.Documentation.Code;

// TODO: Marcin Celej [from: Marcin Celej on: 21-05-2023]: Stop referencing Synergy.Contracts from Synergy.Documentation

namespace Synergy.Documentation.Markup
{
#if INTERNAL_MARKDOWN
Expand All @@ -28,14 +25,12 @@ public class Document : IEnumerable<IElement>

public Document Append(IElement element)
{
Fail.IfArgumentNull(element, nameof(element));
this.elements.Add(element);
return this;
}

public Document Append(IEnumerable<IElement> newElements)
{
Fail.IfArgumentNull(newElements, nameof(newElements));
this.elements.AddRange(newElements);
return this;
}
Expand Down Expand Up @@ -71,8 +66,7 @@ public abstract class Header : IElement
protected Header(int level, string header)
{
this.level = level;
this.header = header.OrFail(nameof(header))
.Trim();
this.header = header.Trim();
}

public override string ToString() => $"{new string('#', this.level)} {this.header}{Markdown.NL}";
Expand Down Expand Up @@ -116,8 +110,6 @@ public Code(string? text = null, string? language = "csharp")

public Code Line(string line)
{
Fail.IfNull(line, nameof(line));

if (this.text == null)
return new Code(line, this.language);
return new Code(this.text + Markdown.NL + line, this.language);
Expand All @@ -137,12 +129,10 @@ public class Paragraph : IElement
private readonly string text;

public Paragraph(string text)
=> this.text = text.OrFail(nameof(text))
.Trim();
=> this.text = text.Trim();

public Paragraph Line(string line)
{
Fail.IfArgumentWhiteSpace(line, nameof(line));
return new Paragraph(this.text + Markdown.NL + line);
}

Expand All @@ -164,15 +154,13 @@ public Quote(string? text)

this.lines = new List<string>()
{
text.OrFail(nameof(text))
.Trim()
text.Trim()
};
}

public Quote Line(string line)
{
this.lines.Add(line.OrFail(nameof(line))
.Trim());
this.lines.Add(line.Trim());
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,4 @@
</Compile>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Contracts\Synergy.Contracts\Synergy.Contracts.csproj" />
</ItemGroup>


</Project>
9 changes: 4 additions & 5 deletions Synergy.Catalogue/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections;
using System.Collections.ObjectModel;
using Synergy.Contracts;

namespace Synergy.Catalogue
{
Expand All @@ -12,10 +11,10 @@ namespace Synergy.Catalogue
static class EnumerableExtensions
{
public static bool IsEmpty<T>(IEnumerable<T> collection)
=> collection.OrFail(nameof(collection)).Any() == false;
=> collection.Any() == false;

public static bool IsNotEmpty<T>(IEnumerable<T> collection)
=> collection.OrFail(nameof(collection)).Any();
=> collection.Any();

public static bool In<T>(this T value, params T[] values)
=> values.Contains(value);
Expand Down Expand Up @@ -45,8 +44,8 @@ public static List<T> ToList<T>(this IEnumerable<T> collection, int expectedCapa
}

public static List<TDestination> ConvertAll<TSource, TDestination>(this IEnumerable<TSource> source, Func<TSource, TDestination> converter)
=> source.OrFail(nameof(source))
.Select(converter.OrFail(nameof(converter)))
=> source
.Select(converter)
.ToList(source.ExpectedCapacity());

private static int ExpectedCapacity<TSource>(this IEnumerable<TSource> source)
Expand Down

0 comments on commit 9a1346a

Please sign in to comment.