Skip to content

Commit

Permalink
Initial version (#1)
Browse files Browse the repository at this point in the history
* Implement generator
* Add initial tests
  • Loading branch information
viceroypenguin authored Mar 19, 2024
1 parent b2c844c commit d9887aa
Show file tree
Hide file tree
Showing 65 changed files with 2,167 additions and 49 deletions.
41 changes: 20 additions & 21 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<PropertyGroup>
<LangVersion>latest</LangVersion>

<Nullable>enable</Nullable>
<WarningsAsErrors>$(WarningsAsErrors);nullable;</WarningsAsErrors>
<Nullable>enable</Nullable>
<WarningsAsErrors>$(WarningsAsErrors);nullable;</WarningsAsErrors>

<ImplicitUsings>enable</ImplicitUsings>
<ImplicitUsings>enable</ImplicitUsings>

<AnalysisLevel>latest-all</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-all</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<IsPackable>false</IsPackable>
</PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PolySharp" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PolySharp" PrivateAssets="All" />
</ItemGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<CollectCoverage>true</CollectCoverage>
<CoverletOutputFormat>opencover</CoverletOutputFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<CollectCoverage>true</CollectCoverage>
<CoverletOutputFormat>opencover</CoverletOutputFormat>
</PropertyGroup>
</Project>
57 changes: 29 additions & 28 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Basic.Reference.Assemblies.Net80" Version="1.4.5" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageVersion Include="Immediate.Handlers" Version="1.1.0" />
<PackageVersion Include="Basic.Reference.Assemblies.Net80" Version="1.5.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageVersion Include="Immediate.Handlers" Version="1.1.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="8.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="MinVer" Version="4.3.0" />
<PackageVersion Include="PolySharp" Version="1.14.1" />
<PackageVersion Include="Scriban" Version="5.9.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="MinVer" Version="5.0.0" />
<PackageVersion Include="PolySharp" Version="1.14.1" />
<PackageVersion Include="Scriban" Version="5.9.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.2.0" />
<PackageVersion Include="Verify.Xunit" Version="23.1.0" />
<PackageVersion Include="xunit" Version="2.6.6" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.2.0" />
<PackageVersion Include="Verify.Xunit" Version="23.5.2" />
<PackageVersion Include="xunit" Version="2.7.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7" />
</ItemGroup>
</Project>
35 changes: 35 additions & 0 deletions Immediate.Apis.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,53 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{681429
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{4A2C6A96-653A-40CC-9354-535F92A0BBD8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Immediate.Apis", "src\Immediate.Apis\Immediate.Apis.csproj", "{EC7C9E81-8A2D-4BEA-9D6B-44FCC3796129}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Immediate.Apis.Generators", "src\Immediate.Apis.Generators\Immediate.Apis.Generators.csproj", "{01D48E54-9A25-4795-B154-19F97C306FC2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Immediate.Apis.Shared", "src\Immediate.Apis.Shared\Immediate.Apis.Shared.csproj", "{0EF463C2-6237-4491-A446-80860ACD280D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Immediate.Apis.FunctionalTests", "tests\Immediate.Apis.FunctionalTests\Immediate.Apis.FunctionalTests.csproj", "{4D9D5A85-102D-4F71-9E8A-FECBFE47EBA3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Immediate.Apis.Tests", "tests\Immediate.Apis.Tests\Immediate.Apis.Tests.csproj", "{058EFC02-6DDA-486F-8C4F-08BA816061CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC7C9E81-8A2D-4BEA-9D6B-44FCC3796129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC7C9E81-8A2D-4BEA-9D6B-44FCC3796129}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC7C9E81-8A2D-4BEA-9D6B-44FCC3796129}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC7C9E81-8A2D-4BEA-9D6B-44FCC3796129}.Release|Any CPU.Build.0 = Release|Any CPU
{01D48E54-9A25-4795-B154-19F97C306FC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01D48E54-9A25-4795-B154-19F97C306FC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01D48E54-9A25-4795-B154-19F97C306FC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01D48E54-9A25-4795-B154-19F97C306FC2}.Release|Any CPU.Build.0 = Release|Any CPU
{0EF463C2-6237-4491-A446-80860ACD280D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EF463C2-6237-4491-A446-80860ACD280D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EF463C2-6237-4491-A446-80860ACD280D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EF463C2-6237-4491-A446-80860ACD280D}.Release|Any CPU.Build.0 = Release|Any CPU
{4D9D5A85-102D-4F71-9E8A-FECBFE47EBA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D9D5A85-102D-4F71-9E8A-FECBFE47EBA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D9D5A85-102D-4F71-9E8A-FECBFE47EBA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D9D5A85-102D-4F71-9E8A-FECBFE47EBA3}.Release|Any CPU.Build.0 = Release|Any CPU
{058EFC02-6DDA-486F-8C4F-08BA816061CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{058EFC02-6DDA-486F-8C4F-08BA816061CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{058EFC02-6DDA-486F-8C4F-08BA816061CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{058EFC02-6DDA-486F-8C4F-08BA816061CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CA4DD675-66D2-45F3-B57B-F751AF1E66D3} = {AF02160B-E028-444A-9B6E-B548463E4A4D}
{EC7C9E81-8A2D-4BEA-9D6B-44FCC3796129} = {68142973-97B4-45D0-B6C7-BE884990AB7E}
{01D48E54-9A25-4795-B154-19F97C306FC2} = {68142973-97B4-45D0-B6C7-BE884990AB7E}
{0EF463C2-6237-4491-A446-80860ACD280D} = {68142973-97B4-45D0-B6C7-BE884990AB7E}
{4D9D5A85-102D-4F71-9E8A-FECBFE47EBA3} = {4A2C6A96-653A-40CC-9354-535F92A0BBD8}
{058EFC02-6DDA-486F-8C4F-08BA816061CE} = {4A2C6A96-653A-40CC-9354-535F92A0BBD8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E947E0E4-B196-46E5-8CFE-A6AE390B8897}
Expand Down
53 changes: 53 additions & 0 deletions src/Immediate.Apis.Generators/EquatableReadOnlyList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Collections;
using System.Diagnostics.CodeAnalysis;

namespace Immediate.Apis.Generators;

[ExcludeFromCodeCoverage]
public static class EquatableReadOnlyList
{
public static EquatableReadOnlyList<T> ToEquatableReadOnlyList<T>(this IEnumerable<T> enumerable)
=> new(enumerable.ToArray());
}

/// <summary>
/// A wrapper for IReadOnlyList that provides value equality support for the wrapped list.
/// </summary>
[ExcludeFromCodeCoverage]
public readonly struct EquatableReadOnlyList<T>(
IReadOnlyList<T>? collection
) : IEquatable<EquatableReadOnlyList<T>>, IReadOnlyList<T>
{
private IReadOnlyList<T> Collection => collection ?? [];

public bool Equals(EquatableReadOnlyList<T> other)
=> this.SequenceEqual(other);

public override bool Equals(object? obj)
=> obj is EquatableReadOnlyList<T> other && Equals(other);

public override int GetHashCode()
{
var hashCode = new HashCode();

foreach (var item in Collection)
hashCode.Add(item);

return hashCode.ToHashCode();
}

IEnumerator<T> IEnumerable<T>.GetEnumerator()
=> Collection.GetEnumerator();

IEnumerator IEnumerable.GetEnumerator()
=> Collection.GetEnumerator();

public int Count => Collection.Count;
public T this[int index] => Collection[index];

public static bool operator ==(EquatableReadOnlyList<T> left, EquatableReadOnlyList<T> right)
=> left.Equals(right);

public static bool operator !=(EquatableReadOnlyList<T> left, EquatableReadOnlyList<T> right)
=> !left.Equals(right);
}
43 changes: 43 additions & 0 deletions src/Immediate.Apis.Generators/Immediate.Apis.Generators.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
</PropertyGroup>

<ItemGroup>
<None Remove="Templates\*.sbntxt" />
<EmbeddedResource Include="Templates\*.sbntxt" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.HashCode" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
<PackageReference Include="Scriban" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="MinVer" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../Immediate.Apis.Shared/Immediate.Apis.Shared.csproj" PrivateAssets="all" />
</ItemGroup>

<PropertyGroup>
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
</PropertyGroup>

<Target Name="GetDependencyTargetPaths">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PkgScriban)/lib/netstandard2.0/Scriban.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="$(MSBuildThisFileDirectory)bin/$(Configuration)/$(TargetFramework)/Immediate.Apis.Shared.dll" IncludeRuntimeDependency="false" />
</ItemGroup>
</Target>

<PropertyGroup Label="MinVer">
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
<MinVerDefaultPreReleaseIdentifiers>preview.0</MinVerDefaultPreReleaseIdentifiers>
<MinVerTagPrefix>v</MinVerTagPrefix>
</PropertyGroup>

</Project>
Loading

0 comments on commit d9887aa

Please sign in to comment.