Skip to content

Commit

Permalink
Publish nuget package
Browse files Browse the repository at this point in the history
Dreamescaper committed May 31, 2024
1 parent 7bdd2f5 commit 7f150eb
Showing 3 changed files with 28 additions and 28 deletions.
3 changes: 2 additions & 1 deletion DependencyInjection.SourceGenerator.sln
Original file line number Diff line number Diff line change
@@ -7,11 +7,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjection.SourceG
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjection.SourceGenerator", "DependencyInjection.SourceGenerator\DependencyInjection.SourceGenerator.csproj", "{5C56A256-7DF0-4E8B-9280-6AB76247E039}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyInjection.SourceGenerator.Playground", "DependencyInjection.SourceGenerator.Playground\DependencyInjection.SourceGenerator.Playground.csproj", "{3FF68E92-214B-42F3-B5D1-BD3B35D1199F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjection.SourceGenerator.Playground", "DependencyInjection.SourceGenerator.Playground\DependencyInjection.SourceGenerator.Playground.csproj", "{3FF68E92-214B-42F3-B5D1-BD3B35D1199F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B4814492-C04A-4DDF-8C13-0F2A009ADBBF}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
README.md = README.md
EndProjectSection
EndProject
Global
Original file line number Diff line number Diff line change
@@ -5,8 +5,22 @@
<LangVersion>12.0</LangVersion>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<Nullable>annotations</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageProjectUrl></PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/Dreamescaper/DependencyInjection.SourceGenerator</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageReference Include="PolySharp" Version="1.14.1">
39 changes: 12 additions & 27 deletions DependencyInjection.SourceGenerator/EquatableArray.cs
Original file line number Diff line number Diff line change
@@ -5,23 +5,13 @@

namespace DependencyInjection.SourceGenerator;

internal readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IEnumerable<T> where T : IEquatable<T>
/// <summary>
/// Creates a new <see cref="EquatableArray{T}"/> instance.
/// </summary>
/// <param name="array">The input <see cref="ImmutableArray"/> to wrap.</param>
internal readonly struct EquatableArray<T>(T[] array) : IEquatable<EquatableArray<T>>, IEnumerable<T> where T : IEquatable<T>
{
public static readonly EquatableArray<T> Empty = new(Array.Empty<T>());

/// <summary>
/// The underlying <typeparamref name="T"/> array.
/// </summary>
private readonly T[]? _array;

/// <summary>
/// Creates a new <see cref="EquatableArray{T}"/> instance.
/// </summary>
/// <param name="array">The input <see cref="ImmutableArray"/> to wrap.</param>
public EquatableArray(T[] array)
{
_array = array;
}
public static readonly EquatableArray<T> Empty = new([]);

/// <sinheritdoc/>
public bool Equals(EquatableArray<T> array)
@@ -40,8 +30,8 @@ public override int GetHashCode()
{
int hashCode = 0;

for (int i = 0; i < _array.Length; i++)
hashCode ^= _array[i].GetHashCode();
for (int i = 0; i < array.Length; i++)
hashCode ^= array[i].GetHashCode();

return hashCode;
}
@@ -52,27 +42,22 @@ public override int GetHashCode()
/// <returns>A <see cref="ReadOnlySpan{T}"/> wrapping the current items.</returns>
public ReadOnlySpan<T> AsSpan()
{
return _array.AsSpan();
return array.AsSpan();
}

/// <summary>
/// Gets the underlying array if there is one
/// </summary>
public T[]? GetArray() => _array;

/// <sinheritdoc/>
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return ((IEnumerable<T>)(_array ?? Array.Empty<T>())).GetEnumerator();
return ((IEnumerable<T>)(array ?? [])).GetEnumerator();
}

/// <sinheritdoc/>
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<T>)(_array ?? Array.Empty<T>())).GetEnumerator();
return ((IEnumerable<T>)(array ?? [])).GetEnumerator();
}

public int Count => _array?.Length ?? 0;
public int Count => array?.Length ?? 0;

/// <summary>
/// Checks whether two <see cref="EquatableArray{T}"/> values are the same.

0 comments on commit 7f150eb

Please sign in to comment.