Skip to content

Commit

Permalink
feature: AutoFixture Source Generator (#1136)
Browse files Browse the repository at this point in the history
* feature: AutoFixture Source Generator

* tests passing

adding new test for potential use case

* moving builder extensions

* fixing up all the warnings, realizing I am on CSharp11

* clean up after rebase

* everything seems fantastic?

* tests passing

* I AM WERKING

* fake it easy supported

* fixing more stuffs

* fixed using for mocking library

* thanks to David no recursion for me!

* this language version goes to 11

* thinking this gets rid of the cruff

* reduced regex

* more clean up

* cleaned up folders and default source generator inclusions

* attempting to generate the methods

realizing some of the methods I will likely never use
wondering if I should just generate the methods on a base type and force inheritance

* generating fixture correctly, attribute went missing?

* more fixing of stuffs

seems the txt files are more correct

* rebuilding verified source for tests

* Automatically linting code

* fixing the build

* Automatically linting code

* fixing the build... again

* Automatically linting code

* ensuring package is created or I would be salty

---------

Co-authored-by: RLittlesII <[email protected]>
Co-authored-by: David Driscoll <[email protected]>
Co-authored-by: david-driscoll <[email protected]>
  • Loading branch information
4 people authored Mar 10, 2024
1 parent 84dd527 commit 2883969
Show file tree
Hide file tree
Showing 42 changed files with 2,877 additions and 369 deletions.
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<ItemGroup>
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
Expand All @@ -25,6 +26,7 @@
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.4.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Features" Version="4.4.0" />
Expand All @@ -33,6 +35,7 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="PolySharp" Version="1.14.1" />
<PackageVersion Include="Serilog" Version="3.1.1" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Serilog.Sinks.Observable" Version="2.0.2" />
Expand Down
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
| ------- | ----- |
| Rocket.Surgery.Extensions.Testing | [![nuget-version-ingbk+ngdt+w-badge]![nuget-downloads-ingbk+ngdt+w-badge]][nuget-ingbk+ngdt+w] |
| Rocket.Surgery.Extensions.Testing.Analyzers | [![nuget-version-is2d/pp3l2nq-badge]![nuget-downloads-is2d/pp3l2nq-badge]][nuget-is2d/pp3l2nq] |
| Rocket.Surgery.Extensions.Testing.AutoFixtures | [![nuget-version-zo+gi4/wtnoq-badge]![nuget-downloads-zo+gi4/wtnoq-badge]][nuget-zo+gi4/wtnoq] |
| Rocket.Surgery.Extensions.Testing.Coverlet | [![nuget-version-2jdbmqdcrhfg-badge]![nuget-downloads-2jdbmqdcrhfg-badge]][nuget-2jdbmqdcrhfg] |
| Rocket.Surgery.Extensions.Testing.FakeItEasy | [![nuget-version-6rnnzg4ixtvq-badge]![nuget-downloads-6rnnzg4ixtvq-badge]][nuget-6rnnzg4ixtvq] |
| Rocket.Surgery.Extensions.Testing.Fixtures | [![nuget-version-xegxxxxh/pzg-badge]![nuget-downloads-xegxxxxh/pzg-badge]][nuget-xegxxxxh/pzg] |
Expand Down Expand Up @@ -49,6 +50,9 @@ TBD
[nuget-is2d/pp3l2nq]: https://www.nuget.org/packages/Rocket.Surgery.Extensions.Testing.Analyzers/
[nuget-version-is2d/pp3l2nq-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.Extensions.Testing.Analyzers.svg?color=004880&logo=nuget&style=flat-square "NuGet Version"
[nuget-downloads-is2d/pp3l2nq-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.Extensions.Testing.Analyzers.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads"
[nuget-zo+gi4/wtnoq]: https://www.nuget.org/packages/Rocket.Surgery.Extensions.Testing.AutoFixtures/
[nuget-version-zo+gi4/wtnoq-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.Extensions.Testing.AutoFixtures.svg?color=004880&logo=nuget&style=flat-square "NuGet Version"
[nuget-downloads-zo+gi4/wtnoq-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.Extensions.Testing.AutoFixtures.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads"
[nuget-2jdbmqdcrhfg]: https://www.nuget.org/packages/Rocket.Surgery.Extensions.Testing.Coverlet/
[nuget-version-2jdbmqdcrhfg-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.Extensions.Testing.Coverlet.svg?color=004880&logo=nuget&style=flat-square "NuGet Version"
[nuget-downloads-2jdbmqdcrhfg-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.Extensions.Testing.Coverlet.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads"
Expand Down
46 changes: 46 additions & 0 deletions Testing.sln
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".vscode", ".vscode", "{2E4E
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.Extensions.Testing.SourceGenerators", "src\Testing.SourceGenerators\Rocket.Surgery.Extensions.Testing.SourceGenerators.csproj", "{14E1380D-30CE-4EA6-8392-C9744B3548CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.Extensions.Testing.AutoFixtures.Tests", "test\Testing.AutoFixtures.Tests\Rocket.Surgery.Extensions.Testing.AutoFixtures.Tests.csproj", "{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "node_modules", "node_modules", "{23F6FBFB-B51E-4BCC-BAFB-7FE48A105592}"
ProjectSection(SolutionItems) = preProject
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "resolve", "resolve", "{55C6BB1F-E98B-48A8-93F4-1D0C3D6E1E93}"
ProjectSection(SolutionItems) = preProject
node_modules/resolve/.editorconfig = node_modules/resolve/.editorconfig
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "is-arrayish", "is-arrayish", "{82A69EC4-C831-4DAF-AE55-48CD28CE2F99}"
ProjectSection(SolutionItems) = preProject
node_modules/is-arrayish/.editorconfig = node_modules/is-arrayish/.editorconfig
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.Extensions.Testing.AutoFixtures", "src\Testing.AutoFixtures\Rocket.Surgery.Extensions.Testing.AutoFixtures.csproj", "{3F1CF946-4DA3-4B96-8039-54C112BED0DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -258,6 +276,30 @@ Global
{14E1380D-30CE-4EA6-8392-C9744B3548CC}.Release|x64.Build.0 = Release|Any CPU
{14E1380D-30CE-4EA6-8392-C9744B3548CC}.Release|x86.ActiveCfg = Release|Any CPU
{14E1380D-30CE-4EA6-8392-C9744B3548CC}.Release|x86.Build.0 = Release|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Debug|x64.ActiveCfg = Debug|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Debug|x64.Build.0 = Debug|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Debug|x86.ActiveCfg = Debug|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Debug|x86.Build.0 = Debug|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Release|Any CPU.Build.0 = Release|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Release|x64.ActiveCfg = Release|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Release|x64.Build.0 = Release|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Release|x86.ActiveCfg = Release|Any CPU
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8}.Release|x86.Build.0 = Release|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Debug|x64.ActiveCfg = Debug|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Debug|x64.Build.0 = Debug|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Debug|x86.ActiveCfg = Debug|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Debug|x86.Build.0 = Debug|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Release|Any CPU.Build.0 = Release|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Release|x64.ActiveCfg = Release|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Release|x64.Build.0 = Release|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Release|x86.ActiveCfg = Release|Any CPU
{3F1CF946-4DA3-4B96-8039-54C112BED0DE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -280,6 +322,10 @@ Global
{13ED04AE-B6C9-4D28-B768-2740E053BC69} = {A3232EC4-8418-4188-8EB8-DD463C031533}
{2E4EA52F-4835-4D34-A6F5-650042213443} = {A3232EC4-8418-4188-8EB8-DD463C031533}
{14E1380D-30CE-4EA6-8392-C9744B3548CC} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
{5A08F7E7-90C1-4DAA-A732-4CD080AFE2E8} = {DF33E0FB-9790-4654-B60F-8AB22E0CC3D1}
{55C6BB1F-E98B-48A8-93F4-1D0C3D6E1E93} = {23F6FBFB-B51E-4BCC-BAFB-7FE48A105592}
{82A69EC4-C831-4DAF-AE55-48CD28CE2F99} = {23F6FBFB-B51E-4BCC-BAFB-7FE48A105592}
{3F1CF946-4DA3-4B96-8039-54C112BED0DE} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {439897C2-CCBD-44FE-B2DC-A3E4670ADA59}
Expand Down
19 changes: 19 additions & 0 deletions src/Testing.AutoFixtures/AutoFixtureAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Rocket.Surgery.Extensions.Testing.AutoFixtures;

internal static class AutoFixtureAttribute
{
public const string Source = @"using System;
using System.Diagnostics;
namespace Rocket.Surgery.Extensions.Testing.AutoFixture
{
[AttributeUsage(AttributeTargets.Class)]
[Conditional(""CODEGEN"")]
internal class AutoFixtureAttribute : Attribute
{
public AutoFixtureAttribute(Type type) => Type = type;
public Type Type { get; }
}
}";
}
Loading

0 comments on commit 2883969

Please sign in to comment.