diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3e272de --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,143 @@ +name: Build +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + release: + types: [published] + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + NuGetDirectory: ${{ github.workspace}}/nuget + +jobs: + build: + name: Build and analyze + runs-on: windows-latest + steps: + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'zulu' # Alternative distribution options are available. + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Cache SonarQube Cloud packages + uses: actions/cache@v4 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache SonarQube Cloud scanner + id: cache-sonar-scanner + uses: actions/cache@v4 + with: + path: .\.sonar\scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + - name: Cache .Net Tools + id: cache-dotnet-tools + uses: actions/cache@v4 + with: + path: ~\.dotnet\tools + key: ${{ runner.os }}-dotnet + restore-keys: ${{ runner.os }}-dotnet + - name: Install dotnet-coverage + shell: powershell + run: dotnet tool install --global dotnet-coverage + - name: Install SonarQube Cloud scanner + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' + shell: powershell + run: | + New-Item -Path .\.sonar\scanner -ItemType Directory + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + - name: Build and analyze + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + shell: powershell + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"retroandchill_SourceGenerators" /o:"fcorso2016" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.exclusions="**/example/**/*,**/examples/**/*" + dotnet build + dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml" + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + + create_nuget: + name: Create Nuget Package + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + + - name: Package Nuget Package + run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} + + - uses: actions/upload-artifact@v4 + with: + name: nuget + if-no-files-found: error + retention-days: 7 + path: ${{ env.NuGetDirectory }}/*.nupkg + + validate_nuget: + name: Validate Nuget Package + runs-on: windows-latest + needs: [ create_nuget ] + steps: + # Install the .NET SDK indicated in the global.json file + - name: Setup .NET + uses: actions/setup-dotnet@v4 + + # Download the NuGet package created in the previous job + - uses: actions/download-artifact@v4 + with: + name: nuget + path: ${{ env.NuGetDirectory }} + + - name: Install nuget validator + run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global + + # Validate metadata and content of the NuGet package + # https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab + # If some rules are not applicable, you can disable them + # using the --excluded-rules or --excluded-rule-ids option + - name: Validate package + run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg") + + deploy: + name: Publish Nuget Package + # Publish only when creating a GitHub Release + # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository + # You can update this logic if you want to manage releases differently + if: github.event_name == 'release' + runs-on: windows-latest + needs: [ validate_nuget, build ] + steps: + # Download the NuGet package created in the previous job + - uses: actions/download-artifact@v4 + with: + name: nuget + path: ${{ env.NuGetDirectory }} + + # Install the .NET SDK indicated in the global.json file + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + + # Publish all NuGet packages to NuGet.org + # Use --skip-duplicate to prevent errors if a package with the same version already exists. + # If you retry a failed workflow, already published packages will be skipped without error. + - name: Publish NuGet package + run: | + foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) { + dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + } \ No newline at end of file diff --git a/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Commands/CommandContext.cs b/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Commands/CommandContext.cs index a509174..974f227 100644 --- a/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Commands/CommandContext.cs +++ b/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Commands/CommandContext.cs @@ -1,5 +1,5 @@ using System; -using Retro.AutoCommandLine.Core.Attributes; +using Retro.AutoCommandLine.Attributes; using Retro.AutoCommandLine.Core.Handlers; namespace Retro.AutoCommandLine.Sample.Commands; diff --git a/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Commands/ProgramRootCommand.cs b/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Commands/ProgramRootCommand.cs index d706411..799e2b8 100644 --- a/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Commands/ProgramRootCommand.cs +++ b/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Commands/ProgramRootCommand.cs @@ -1,9 +1,7 @@ using System; using System.Threading; using System.Threading.Tasks; -using Retro.AutoCommandLine.Core; -using Retro.AutoCommandLine.Core.Attributes; -using Retro.AutoCommandLine.Core.Handlers; +using Retro.AutoCommandLine.Attributes; namespace Retro.AutoCommandLine.Sample.Commands; /// diff --git a/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Retro.AutoCommandLine.Sample.csproj b/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Retro.AutoCommandLine.Sample.csproj index df0f172..24d1d0d 100644 --- a/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Retro.AutoCommandLine.Sample.csproj +++ b/AutoCommandLine/examples/Retro.AutoCommandLine.Sample/Retro.AutoCommandLine.Sample.csproj @@ -5,6 +5,7 @@ enable Retro.AutoCommandLine.Sample Exe + false diff --git a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/ArgumentAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/ArgumentAttribute.cs deleted file mode 100644 index 5224a20..0000000 --- a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/ArgumentAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -namespace Retro.AutoCommandLine.Core.Attributes; - -[AttributeUsage(AttributeTargets.Property)] -public class ArgumentAttribute(string? name = null) : CliParameterAttribute { - - public string? Name { get; } = name; - -} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CliParameterAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CliParameterAttribute.cs deleted file mode 100644 index ab9584f..0000000 --- a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CliParameterAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Collections.Immutable; -namespace Retro.AutoCommandLine.Core.Attributes; - -public abstract class CliParameterAttribute : Attribute { - - public string? Description { get; init; } - -} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CommandHandlerAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CommandHandlerAttribute.cs deleted file mode 100644 index 0828ca5..0000000 --- a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CommandHandlerAttribute.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System; -namespace Retro.AutoCommandLine.Core.Attributes; - -[AttributeUsage(AttributeTargets.Method)] -public class CommandHandlerAttribute : Attribute; \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CommandLineContextAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CommandLineContextAttribute.cs deleted file mode 100644 index a6f1ec1..0000000 --- a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CommandLineContextAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -namespace Retro.AutoCommandLine.Core.Attributes; - -[AttributeUsage(AttributeTargets.Class)] -public class CommandLineContextAttribute(Type rootCommand) : Attribute { - - public Type RootCommand { get; } = rootCommand; - -} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/OptionAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/OptionAttribute.cs deleted file mode 100644 index 729f4a5..0000000 --- a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/OptionAttribute.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Immutable; -namespace Retro.AutoCommandLine.Core.Attributes; - -[AttributeUsage(AttributeTargets.Property)] -public class OptionAttribute(params string[] aliases) : CliParameterAttribute { - - public ImmutableArray Aliases { get; } = aliases.ToImmutableArray(); - -} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Retro.AutoCommandLine.Core.csproj b/AutoCommandLine/src/Retro.AutoCommandLine.Core/Retro.AutoCommandLine.Core.csproj index d78bbc6..3e80a7b 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Retro.AutoCommandLine.Core.csproj +++ b/AutoCommandLine/src/Retro.AutoCommandLine.Core/Retro.AutoCommandLine.Core.csproj @@ -4,6 +4,7 @@ netstandard2.0 latest enable + false @@ -20,4 +21,8 @@ + + + + diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/ArgumentAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/ArgumentAttribute.cs new file mode 100644 index 0000000..42f46b2 --- /dev/null +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/ArgumentAttribute.cs @@ -0,0 +1,16 @@ +using System; +#if AUTO_COMMAND_LINE_GENERATOR +using RhoMicro.CodeAnalysis; +#endif + +namespace Retro.AutoCommandLine.Attributes; + +[AttributeUsage(AttributeTargets.Property)] +#if AUTO_COMMAND_LINE_GENERATOR +[IncludeFile] +#endif +internal class ArgumentAttribute(string? name = null) : CliParameterAttribute { + + public string? Name { get; } = name; + +} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CliParameterAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CliParameterAttribute.cs new file mode 100644 index 0000000..e12149f --- /dev/null +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CliParameterAttribute.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Immutable; +#if AUTO_COMMAND_LINE_GENERATOR +using RhoMicro.CodeAnalysis; +#endif + +namespace Retro.AutoCommandLine.Attributes; + +#if AUTO_COMMAND_LINE_GENERATOR +[IncludeFile] +#endif +internal abstract class CliParameterAttribute : Attribute { + + public string? Description { get; init; } + +} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CommandAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CommandAttribute.cs similarity index 52% rename from AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CommandAttribute.cs rename to AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CommandAttribute.cs index 20c64c6..59816ef 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine.Core/Attributes/CommandAttribute.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CommandAttribute.cs @@ -1,8 +1,15 @@ using System; -namespace Retro.AutoCommandLine.Core.Attributes; +#if AUTO_COMMAND_LINE_GENERATOR +using RhoMicro.CodeAnalysis; +#endif + +namespace Retro.AutoCommandLine.Attributes; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)] -public class CommandAttribute(string? name = null) : Attribute { +#if AUTO_COMMAND_LINE_GENERATOR +[IncludeFile] +#endif +internal class CommandAttribute(string? name = null) : Attribute { public string? Name { get; } = name; public string? Description { get; init; } diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CommandHandlerAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CommandHandlerAttribute.cs new file mode 100644 index 0000000..bf3af61 --- /dev/null +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CommandHandlerAttribute.cs @@ -0,0 +1,12 @@ +using System; +#if AUTO_COMMAND_LINE_GENERATOR +using RhoMicro.CodeAnalysis; +#endif + +namespace Retro.AutoCommandLine.Attributes; + +[AttributeUsage(AttributeTargets.Method)] +#if AUTO_COMMAND_LINE_GENERATOR +[IncludeFile] +#endif +internal class CommandHandlerAttribute : Attribute; \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CommandLineContextAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CommandLineContextAttribute.cs new file mode 100644 index 0000000..db5b71b --- /dev/null +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/CommandLineContextAttribute.cs @@ -0,0 +1,16 @@ +using System; +#if AUTO_COMMAND_LINE_GENERATOR +using RhoMicro.CodeAnalysis; +#endif + +namespace Retro.AutoCommandLine.Attributes; + +[AttributeUsage(AttributeTargets.Class)] +#if AUTO_COMMAND_LINE_GENERATOR +[IncludeFile] +#endif +internal class CommandLineContextAttribute(Type rootCommand) : Attribute { + + public Type RootCommand { get; } = rootCommand; + +} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/OptionAttribute.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/OptionAttribute.cs new file mode 100644 index 0000000..1e8ef85 --- /dev/null +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Attributes/OptionAttribute.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Immutable; +#if AUTO_COMMAND_LINE_GENERATOR +using RhoMicro.CodeAnalysis; +#endif + +namespace Retro.AutoCommandLine.Attributes; + +[AttributeUsage(AttributeTargets.Property)] +#if AUTO_COMMAND_LINE_GENERATOR +[IncludeFile] +#endif +internal class OptionAttribute(params string[] aliases) : CliParameterAttribute { + + public ImmutableArray Aliases { get; } = [..aliases]; + +} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Generators/CommandBinderGenerator.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Generators/CommandBinderGenerator.cs index 8cbad3b..3600814 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Generators/CommandBinderGenerator.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Generators/CommandBinderGenerator.cs @@ -4,11 +4,12 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Retro.AutoCommandLine.Core.Attributes; -using Retro.AutoCommandLine.Model; +using Retro.AutoCommandLine.Attributes; using Retro.AutoCommandLine.Model.Attributes; +using Retro.AutoCommandLine.Model.Commands; using Retro.AutoCommandLine.Properties; using Retro.AutoCommandLine.Utils; +using Retro.SourceGeneratorUtilities.Utilities; namespace Retro.AutoCommandLine.Generators; [Generator] diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Generators/CopyFileGenerator.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Generators/CopyFileGenerator.cs new file mode 100644 index 0000000..87d20d2 --- /dev/null +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Generators/CopyFileGenerator.cs @@ -0,0 +1,15 @@ +using Microsoft.CodeAnalysis; +using RhoMicro.CodeAnalysis.Generated; +namespace Retro.AutoCommandLine.Generators; + +/// +/// Represents a source generator that facilitates copying files for use in code generation tasks. +/// +[Generator] +internal class CopyFilesGenerator : IIncrementalGenerator { + + /// + public void Initialize(IncrementalGeneratorInitializationContext context) { + IncludedFileSources.RegisterToContext(context); + } +} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/ArgumentInfo.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/ArgumentInfo.cs index cfa073c..126bf48 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/ArgumentInfo.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/ArgumentInfo.cs @@ -1,5 +1,5 @@ using System.Collections.Immutable; -using Retro.AutoCommandLine.Core.Attributes; +using Retro.AutoCommandLine.Attributes; using Retro.SourceGeneratorUtilities.Utilities.Attributes; namespace Retro.AutoCommandLine.Model.Attributes; diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/CliParameterInfo.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/CliParameterInfo.cs index 31633f4..ea22442 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/CliParameterInfo.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/CliParameterInfo.cs @@ -1,5 +1,5 @@ using System.Collections.Immutable; -using Retro.AutoCommandLine.Core.Attributes; +using Retro.AutoCommandLine.Attributes; using Retro.SourceGeneratorUtilities.Utilities.Attributes; namespace Retro.AutoCommandLine.Model.Attributes; diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/CommandInfo.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/CommandInfo.cs index c339a49..25dd68b 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/CommandInfo.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/CommandInfo.cs @@ -1,4 +1,4 @@ -using Retro.AutoCommandLine.Core.Attributes; +using Retro.AutoCommandLine.Attributes; using Retro.SourceGeneratorUtilities.Utilities.Attributes; namespace Retro.AutoCommandLine.Model.Attributes; diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/OptionInfo.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/OptionInfo.cs index 2656215..f91be4c 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/OptionInfo.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Attributes/OptionInfo.cs @@ -1,5 +1,5 @@ using System.Collections.Immutable; -using Retro.AutoCommandLine.Core.Attributes; +using Retro.AutoCommandLine.Attributes; using Retro.SourceGeneratorUtilities.Utilities.Attributes; namespace Retro.AutoCommandLine.Model.Attributes; diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Model/HandlerMethodInfo.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/HandlerMethodInfo.cs similarity index 88% rename from AutoCommandLine/src/Retro.AutoCommandLine/Model/HandlerMethodInfo.cs rename to AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/HandlerMethodInfo.cs index 392c966..6443dff 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Model/HandlerMethodInfo.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/HandlerMethodInfo.cs @@ -1,4 +1,4 @@ -namespace Retro.AutoCommandLine.Model; +namespace Retro.AutoCommandLine.Model.Commands; public record HandlerMethodInfo { public required string Name { get; init; } diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Model/HandlerReturnType.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/HandlerReturnType.cs similarity index 57% rename from AutoCommandLine/src/Retro.AutoCommandLine/Model/HandlerReturnType.cs rename to AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/HandlerReturnType.cs index bd62581..a348aec 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Model/HandlerReturnType.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/HandlerReturnType.cs @@ -1,4 +1,4 @@ -namespace Retro.AutoCommandLine.Model; +namespace Retro.AutoCommandLine.Model.Commands; public enum HandlerReturnType { Void, diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Model/OptionAlias.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/OptionAlias.cs similarity index 71% rename from AutoCommandLine/src/Retro.AutoCommandLine/Model/OptionAlias.cs rename to AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/OptionAlias.cs index 4717d85..efe717d 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Model/OptionAlias.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/OptionAlias.cs @@ -1,4 +1,4 @@ -namespace Retro.AutoCommandLine.Model; +namespace Retro.AutoCommandLine.Model.Commands; public record struct OptionAlias { public required string Name { get; init; } diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Model/OptionBinding.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/OptionBinding.cs similarity index 83% rename from AutoCommandLine/src/Retro.AutoCommandLine/Model/OptionBinding.cs rename to AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/OptionBinding.cs index f29eee3..b56da67 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Model/OptionBinding.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/OptionBinding.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using Microsoft.CodeAnalysis.Options; -namespace Retro.AutoCommandLine.Model; +namespace Retro.AutoCommandLine.Model.Commands; public record OptionBinding { public required OptionType Wrapper { get; init; } diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Model/OptionType.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/OptionType.cs similarity index 64% rename from AutoCommandLine/src/Retro.AutoCommandLine/Model/OptionType.cs rename to AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/OptionType.cs index ac905c4..8dc6852 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Model/OptionType.cs +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Model/Commands/OptionType.cs @@ -1,6 +1,6 @@ using BetterEnumsGen; -namespace Retro.AutoCommandLine.Model; +namespace Retro.AutoCommandLine.Model.Commands; [BetterEnum] public enum OptionType { diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Retro.AutoCommandLine.csproj b/AutoCommandLine/src/Retro.AutoCommandLine/Retro.AutoCommandLine.csproj index 3f0a59c..63a9b50 100644 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Retro.AutoCommandLine.csproj +++ b/AutoCommandLine/src/Retro.AutoCommandLine/Retro.AutoCommandLine.csproj @@ -5,7 +5,9 @@ false enable latest - true + enable + true + $(DefineConstants);AUTO_COMMAND_LINE_GENERATOR true true @@ -28,11 +30,14 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - @@ -43,8 +48,6 @@ - @@ -54,11 +57,6 @@ - - - - - diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Utils/TypeUtils.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Utils/TypeUtils.cs deleted file mode 100644 index e14812c..0000000 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Utils/TypeUtils.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Microsoft.CodeAnalysis; -namespace Retro.AutoCommandLine.Utils; - -public static class TypeUtils { - public static string GetMetadataName(this ITypeSymbol typeSymbol) { - return $"{typeSymbol.ContainingNamespace}.{typeSymbol.MetadataName}"; - } -} \ No newline at end of file diff --git a/AutoCommandLine/src/Retro.AutoCommandLine/Utils/XmlCommentUtils.cs b/AutoCommandLine/src/Retro.AutoCommandLine/Utils/XmlCommentUtils.cs deleted file mode 100644 index 225aa13..0000000 --- a/AutoCommandLine/src/Retro.AutoCommandLine/Utils/XmlCommentUtils.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Linq; -using System.Text.RegularExpressions; -using System.Xml; -namespace Retro.AutoCommandLine.Utils; - -public static class XmlCommentUtils { - - private static readonly Regex Trimmer = new(@"\s\s+"); - - public static string? GetSummaryTag(this string? xmlComment) { - if (string.IsNullOrWhiteSpace(xmlComment)) { - return null; - } - - var doc = new XmlDocument(); - doc.LoadXml(xmlComment); - - if (doc.DocumentElement is null) { - return null; - } - - if (doc.DocumentElement.FirstChild.NodeType == XmlNodeType.Text) { - return Trimmer.Replace(doc.DocumentElement.InnerText.Trim(), " "); - } - - var summaryElements = doc.DocumentElement.GetElementsByTagName("summary"); - return summaryElements.Count > 0 ? Trimmer.Replace(summaryElements[0].InnerText.Trim(), " ") : null; - } - -} \ No newline at end of file diff --git a/AutoExceptionHandler/examples/AutoExceptionHandler.Sample/AutoExceptionHandler.Sample.csproj b/AutoExceptionHandler/examples/AutoExceptionHandler.Sample/AutoExceptionHandler.Sample.csproj index 735409e..ebd96fa 100644 --- a/AutoExceptionHandler/examples/AutoExceptionHandler.Sample/AutoExceptionHandler.Sample.csproj +++ b/AutoExceptionHandler/examples/AutoExceptionHandler.Sample/AutoExceptionHandler.Sample.csproj @@ -10,7 +10,6 @@ - diff --git a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/AutoExceptionHandler.Annotations.csproj b/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/AutoExceptionHandler.Annotations.csproj deleted file mode 100644 index 88aec17..0000000 --- a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/AutoExceptionHandler.Annotations.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - netstandard2.0 - 13 - enable - - AutoExceptionHandler.Annotations - AutoExceptionHandler.Annotations - 1.0.0 - false - - true - snupkg - - true - True - true - - - - bin\Debug\AutoExceptionHandler.Annotations.xml - portable - - - - bin\Release\AutoExceptionHandler.Annotations.xml - true - portable - - - diff --git a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/ExceptionHandlerAttribute.cs b/AutoExceptionHandler/src/AutoExceptionHandler/Annotations/ExceptionHandlerAttribute.cs similarity index 78% rename from AutoExceptionHandler/src/AutoExceptionHandler.Annotations/ExceptionHandlerAttribute.cs rename to AutoExceptionHandler/src/AutoExceptionHandler/Annotations/ExceptionHandlerAttribute.cs index 2aabba6..6226b65 100644 --- a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/ExceptionHandlerAttribute.cs +++ b/AutoExceptionHandler/src/AutoExceptionHandler/Annotations/ExceptionHandlerAttribute.cs @@ -1,5 +1,8 @@ using System; using System.Diagnostics; +#if AUTO_EXCEPTION_HANDLER_GENERATOR +using RhoMicro.CodeAnalysis; +#endif namespace AutoExceptionHandler.Annotations; @@ -15,4 +18,7 @@ namespace AutoExceptionHandler.Annotations; /// [AttributeUsage(AttributeTargets.Class)] [Conditional("AUTO_EXCEPTION_HANDLER_SCOPE_RUNTIME")] -public class ExceptionHandlerAttribute : Attribute; \ No newline at end of file +#if AUTO_EXCEPTION_HANDLER_GENERATOR +[IncludeFile] +#endif +internal class ExceptionHandlerAttribute : Attribute; \ No newline at end of file diff --git a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/FallbackExceptionHandlerAttribute.cs b/AutoExceptionHandler/src/AutoExceptionHandler/Annotations/FallbackExceptionHandlerAttribute.cs similarity index 82% rename from AutoExceptionHandler/src/AutoExceptionHandler.Annotations/FallbackExceptionHandlerAttribute.cs rename to AutoExceptionHandler/src/AutoExceptionHandler/Annotations/FallbackExceptionHandlerAttribute.cs index d3cde93..c6bbb2e 100644 --- a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/FallbackExceptionHandlerAttribute.cs +++ b/AutoExceptionHandler/src/AutoExceptionHandler/Annotations/FallbackExceptionHandlerAttribute.cs @@ -1,5 +1,8 @@ using System; using System.Diagnostics; +#if AUTO_EXCEPTION_HANDLER_GENERATOR +using RhoMicro.CodeAnalysis; +#endif namespace AutoExceptionHandler.Annotations; @@ -18,4 +21,7 @@ namespace AutoExceptionHandler.Annotations; /// [AttributeUsage(AttributeTargets.Method)] [Conditional("AUTO_EXCEPTION_HANDLER_SCOPE_RUNTIME")] -public class FallbackExceptionHandlerAttribute : Attribute; \ No newline at end of file +#if AUTO_EXCEPTION_HANDLER_GENERATOR +[IncludeFile] +#endif +internal class FallbackExceptionHandlerAttribute : Attribute; \ No newline at end of file diff --git a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/GeneralExceptionHandlerAttribute.cs b/AutoExceptionHandler/src/AutoExceptionHandler/Annotations/GeneralExceptionHandlerAttribute.cs similarity index 81% rename from AutoExceptionHandler/src/AutoExceptionHandler.Annotations/GeneralExceptionHandlerAttribute.cs rename to AutoExceptionHandler/src/AutoExceptionHandler/Annotations/GeneralExceptionHandlerAttribute.cs index b89ee6a..74fba1d 100644 --- a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/GeneralExceptionHandlerAttribute.cs +++ b/AutoExceptionHandler/src/AutoExceptionHandler/Annotations/GeneralExceptionHandlerAttribute.cs @@ -1,5 +1,8 @@ using System; using System.Diagnostics; +#if AUTO_EXCEPTION_HANDLER_GENERATOR +using RhoMicro.CodeAnalysis; +#endif namespace AutoExceptionHandler.Annotations; @@ -18,4 +21,7 @@ namespace AutoExceptionHandler.Annotations; /// [AttributeUsage(AttributeTargets.Method)] [Conditional("AUTO_EXCEPTION_HANDLER_SCOPE_RUNTIME")] -public class GeneralExceptionHandlerAttribute : Attribute; \ No newline at end of file +#if AUTO_EXCEPTION_HANDLER_GENERATOR +[IncludeFile] +#endif +internal class GeneralExceptionHandlerAttribute : Attribute; \ No newline at end of file diff --git a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/HandlesExceptionAttribute.cs b/AutoExceptionHandler/src/AutoExceptionHandler/Annotations/HandlesExceptionAttribute.cs similarity index 87% rename from AutoExceptionHandler/src/AutoExceptionHandler.Annotations/HandlesExceptionAttribute.cs rename to AutoExceptionHandler/src/AutoExceptionHandler/Annotations/HandlesExceptionAttribute.cs index b54a0a0..3b5dbc5 100644 --- a/AutoExceptionHandler/src/AutoExceptionHandler.Annotations/HandlesExceptionAttribute.cs +++ b/AutoExceptionHandler/src/AutoExceptionHandler/Annotations/HandlesExceptionAttribute.cs @@ -1,5 +1,8 @@ using System; using System.Diagnostics; +#if AUTO_EXCEPTION_HANDLER_GENERATOR +using RhoMicro.CodeAnalysis; +#endif namespace AutoExceptionHandler.Annotations; @@ -27,6 +30,9 @@ namespace AutoExceptionHandler.Annotations; /// [AttributeUsage(AttributeTargets.Method)] [Conditional("AUTO_EXCEPTION_HANDLER_SCOPE_RUNTIME")] -public class HandlesExceptionAttribute(params Type[] exceptionTypes) : Attribute; +#if AUTO_EXCEPTION_HANDLER_GENERATOR +[IncludeFile] +#endif +internal class HandlesExceptionAttribute(params Type[] exceptionTypes) : Attribute; #pragma warning restore 9113 \ No newline at end of file diff --git a/AutoExceptionHandler/src/AutoExceptionHandler/AutoExceptionHandler.csproj b/AutoExceptionHandler/src/AutoExceptionHandler/AutoExceptionHandler.csproj index eaa7f3a..f33d0ab 100644 --- a/AutoExceptionHandler/src/AutoExceptionHandler/AutoExceptionHandler.csproj +++ b/AutoExceptionHandler/src/AutoExceptionHandler/AutoExceptionHandler.csproj @@ -4,6 +4,9 @@ netstandard2.0 enable latest + enable + true + $(DefineConstants);AUTO_EXCEPTION_HANDLER_GENERATOR true true @@ -38,16 +41,23 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + @@ -83,8 +93,6 @@ - @@ -98,15 +106,10 @@ - - - - - True - + diff --git a/AutoExceptionHandler/src/AutoExceptionHandler/Generator/CopyFilesGenerator.cs b/AutoExceptionHandler/src/AutoExceptionHandler/Generator/CopyFilesGenerator.cs new file mode 100644 index 0000000..5060f4a --- /dev/null +++ b/AutoExceptionHandler/src/AutoExceptionHandler/Generator/CopyFilesGenerator.cs @@ -0,0 +1,15 @@ +using Microsoft.CodeAnalysis; +using RhoMicro.CodeAnalysis.Generated; +namespace AutoExceptionHandler.Generator; + +/// +/// Represents a source generator that facilitates copying files for use in code generation tasks. +/// +[Generator] +internal class CopyFilesGenerator : IIncrementalGenerator { + + /// + public void Initialize(IncrementalGeneratorInitializationContext context) { + IncludedFileSources.RegisterToContext(context); + } +} \ No newline at end of file diff --git a/AutoExceptionHandler/src/AutoExceptionHandler/Generator/ExceptionHandlerGenerator.cs b/AutoExceptionHandler/src/AutoExceptionHandler/Generator/ExceptionHandlerGenerator.cs index ec1b3df..b7e198b 100644 --- a/AutoExceptionHandler/src/AutoExceptionHandler/Generator/ExceptionHandlerGenerator.cs +++ b/AutoExceptionHandler/src/AutoExceptionHandler/Generator/ExceptionHandlerGenerator.cs @@ -1,13 +1,16 @@ using System; using System.Collections.Generic; -using System.Linq; +using System.Collections.Immutable; using AutoExceptionHandler.Annotations; +using AutoExceptionHandler.Model; using AutoExceptionHandler.Properties; -using AutoExceptionHandler.Utilities; using HandlebarsDotNet; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Retro.SourceGeneratorUtilities.Utilities.Attributes; +using Retro.SourceGeneratorUtilities.Utilities.Members; +using Retro.SourceGeneratorUtilities.Utilities.Types; namespace AutoExceptionHandler.Generator; @@ -60,10 +63,8 @@ private static void Execute(ClassDeclarationSyntax handlerClass, if (classSymbol is null) { throw new ArgumentNullException(nameof(handlerClass)); } - var attributeData = classSymbol - .GetAttributes() - .FirstOrDefault(x => x.IsOfAttributeType()); - if (attributeData is null) { + + if (!classSymbol.HasAttribute()) { return; } @@ -119,10 +120,10 @@ private static void Execute(ClassDeclarationSyntax handlerClass, ExceptionTypes = exceptionTypes .Select((t, j) => new { ExceptionName = t.ToDisplayString(), - Comma = j != exceptionTypes.Count - 1 + Comma = j != exceptionTypes.Length - 1 }) .ToList(), - SingleException = exceptionTypes.Count == 1, + SingleException = exceptionTypes.Length == 1, Index = i, MethodName = y.Symbol.Name, ExceptionType = y.Symbol.Parameters[0].Type.ToDisplayString(), @@ -167,18 +168,18 @@ private static bool IsGeneralExceptionHandlerMethod(IMethodSymbol methodSymbol) return false; } - var attribute = methodSymbol.GetAttribute(); - return attribute is not null && methodSymbol.Parameters.Length > 0 && methodSymbol.Parameters[0].Type.IsExceptionType(); + return methodSymbol.HasAttribute() && methodSymbol.Parameters.Length > 0 + && methodSymbol.Parameters[0].Type.IsAssignableTo(); } private static bool IsFallbackHandler(IMethodSymbol methodSymbol) { - var attribute = methodSymbol.GetAttribute(); - return attribute is not null && methodSymbol.Parameters.Length > 0 && methodSymbol.Parameters[0].Type.IsExceptionType(); + return methodSymbol.HasAttribute() && methodSymbol.Parameters.Length > 0 + && methodSymbol.Parameters[0].Type.IsAssignableTo(); } private static bool IsSpecificHandler(IMethodSymbol methodSymbol) { - var attribute = methodSymbol.GetAttribute(); - return attribute is not null && methodSymbol.Parameters.Length > 0 && methodSymbol.Parameters[0].Type.IsExceptionType(); + return methodSymbol.HasAttribute() && methodSymbol.Parameters.Length > 0 + && methodSymbol.Parameters[0].Type.IsAssignableTo(); } private static bool IsValidHandler(IMethodSymbol parent, IMethodSymbol child) { @@ -186,12 +187,12 @@ private static bool IsValidHandler(IMethodSymbol parent, IMethodSymbol child) { return false; } - if (!GetExceptionTypes(child).All(x => x!.ConvertableTo(parent.Parameters[0].Type))) { + if (!GetExceptionTypes(child).All(x => x!.IsAssignableTo(parent.Parameters[0].Type))) { return false; } for (var i = 1; i < child.Parameters.Length; i++) { - if (!parent.Parameters[i].Type.ConvertableTo(child.Parameters[i].Type)) { + if (!parent.Parameters[i].Type.IsAssignableTo(child.Parameters[i].Type)) { return false; } } @@ -204,22 +205,16 @@ private static bool IsValidFallback(IMethodSymbol parent, IMethodSymbol child) { return false; } - return !child.Parameters.Where((t, i) => !parent.Parameters[i].Type.ConvertableTo(t.Type)).Any(); + return !child.Parameters.Where((t, i) => !parent.Parameters[i].Type.IsAssignableTo(t.Type)).Any(); } - private static List GetExceptionTypes(IMethodSymbol method) { - var parameterPack = method.GetAttribute()!.ConstructorArguments.FirstOrDefault(); - var exceptionTypes = parameterPack.Values - .Where(a => a.Kind == TypedConstantKind.Type) - .Select(a => a.Value as ITypeSymbol) - .Where(a => a is not null) - .ToList(); + private static ImmutableArray GetExceptionTypes(IMethodSymbol method) { + var exceptionTypes = method.GetAttributes().GetHandlesExceptionInfos() + .Select(x => x.ExceptionTypes) + .Single(); + + return exceptionTypes.Length == 0 ? [method.Parameters[0].Type] : exceptionTypes; - if (exceptionTypes.Count == 0) { - exceptionTypes.Add(method.Parameters[0].Type); - } - - return exceptionTypes!; } } \ No newline at end of file diff --git a/AutoExceptionHandler/src/AutoExceptionHandler/Model/HandlesExceptionInfo.cs b/AutoExceptionHandler/src/AutoExceptionHandler/Model/HandlesExceptionInfo.cs new file mode 100644 index 0000000..ed78c2d --- /dev/null +++ b/AutoExceptionHandler/src/AutoExceptionHandler/Model/HandlesExceptionInfo.cs @@ -0,0 +1,37 @@ +using System.Collections.Immutable; +using AutoExceptionHandler.Annotations; +using Microsoft.CodeAnalysis; +using Retro.SourceGeneratorUtilities.Utilities.Attributes; +namespace AutoExceptionHandler.Model; + +/// +/// Represents information about exceptions that are handled by methods +/// annotated with the . +/// +[AttributeInfoType] +public record struct HandlesExceptionInfo { + + /// + /// Gets the collection of exception types associated with the + /// structure. These exception types + /// represent the exceptions handled by methods annotated with the + /// . + /// + public ImmutableArray ExceptionTypes { get; } + + /// + /// Represents the information required for identifying exceptions + /// that are handled by methods annotated with the . + /// + /// + /// This struct provides the ability to store and manage the types of exceptions + /// that are explicitly handled within a given context. + /// The annotation is used to mark + /// methods handling specific exceptions. + /// + /// The types of exceptions that are take in. + public HandlesExceptionInfo(params ITypeSymbol[] exceptionTypes) { + ExceptionTypes = [..exceptionTypes]; + } + +} \ No newline at end of file diff --git a/AutoExceptionHandler/src/AutoExceptionHandler/Utilities/AttributeExtensions.cs b/AutoExceptionHandler/src/AutoExceptionHandler/Utilities/AttributeExtensions.cs deleted file mode 100644 index 974b2c8..0000000 --- a/AutoExceptionHandler/src/AutoExceptionHandler/Utilities/AttributeExtensions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Linq; -using Microsoft.CodeAnalysis; - -namespace AutoExceptionHandler.Utilities; - -/// -/// Provides extension methods for handling attributes in .NET code analysis. -/// -internal static class AttributeExtensions { - - /// - /// Determines whether the specified attribute is of the given attribute type. - /// - /// The type of the attribute to check. Must inherit from . - /// The attribute data to inspect. - /// - /// true if the attribute is of the specified type; otherwise, false. - /// - public static bool IsOfAttributeType(this AttributeData attribute) where T : Attribute { - return attribute.AttributeClass?.IsOfType() ?? false; - } - - /// - /// Retrieves the attribute of the specified type applied to the given symbol, if any. - /// - /// The type of the attribute to retrieve. Must inherit from . - /// The symbol to inspect for the attribute. - /// - /// The attribute of type if found, otherwise null. - /// - public static AttributeData? GetAttribute(this ISymbol symbol) where T : Attribute { - return symbol.GetAttributes() - .FirstOrDefault(a => a.IsOfAttributeType()); - } - -} \ No newline at end of file diff --git a/AutoExceptionHandler/src/AutoExceptionHandler/Utilities/TypeExtensions.cs b/AutoExceptionHandler/src/AutoExceptionHandler/Utilities/TypeExtensions.cs deleted file mode 100644 index 8e59cae..0000000 --- a/AutoExceptionHandler/src/AutoExceptionHandler/Utilities/TypeExtensions.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Linq; -using Microsoft.CodeAnalysis; - -namespace AutoExceptionHandler.Utilities; - -/// -/// Provides extension methods for working with types represented as . -/// -internal static class TypeExtensions { - - /// - /// Checks if the type represented by the current is of type . - /// - /// The current type symbol to check. - /// - /// True if the current type symbol is of type ; otherwise, false. - /// - public static bool IsExceptionType(this ITypeSymbol type) { - return type.IsOfType(); - } - - /// - /// Checks if the type represented by the current is of the specified type . - /// - /// The type to compare against. - /// The current type symbol to check. - /// - /// True if the current type symbol is of the specified type; otherwise, false. - /// - public static bool IsOfType(this ITypeSymbol type) { - if (type.ToString() == typeof(T).FullName) { - return true; - } - - if (typeof(T).IsClass && type is { TypeKind: TypeKind.Class, BaseType: not null }) { - return type.BaseType.IsOfType(); - } - - if (typeof(T).IsInterface && type.TypeKind is TypeKind.Interface or TypeKind.Class) { - return type.Interfaces - .Any(i => i.IsOfType()); - } - - return false; - } - - /// - /// Checks if the type represented by the current is of the specified type represented by another . - /// - /// The current type symbol to check. - /// The type symbol to compare against. - /// - /// True if the current type symbol is of the specified type; otherwise, false. - /// - public static bool IsOfType(this ITypeSymbol type, ITypeSymbol other) { - if (SymbolEqualityComparer.Default.Equals(type, other)) { - return true; - } - - return other.TypeKind switch { - TypeKind.Class when type is { TypeKind: TypeKind.Class, BaseType: not null } => type.BaseType.IsOfType(other), - TypeKind.Interface when type.TypeKind is TypeKind.Interface or TypeKind.Class => type.Interfaces - .Any(i => i.IsOfType(other)), - _ => false - }; - - } - - /// - /// Determines whether the type represented by the current can be converted to the specified type represented by another . - /// - /// The current type symbol to check for convertibility. - /// The target type symbol to check against. - /// - /// True if the current type symbol can be converted to the specified type; otherwise, false. - /// - public static bool ConvertableTo(this ITypeSymbol type, ITypeSymbol other) { - if (type.IsOfType(other)) { - return true; - } - - return false; - } - -} \ No newline at end of file diff --git a/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/AutoExceptionHandler.Tests.csproj b/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/AutoExceptionHandler.Tests.csproj index cded6d1..35ff73a 100644 --- a/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/AutoExceptionHandler.Tests.csproj +++ b/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/AutoExceptionHandler.Tests.csproj @@ -11,17 +11,16 @@ - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - diff --git a/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/ExceptionHandlerGeneratorTest.cs b/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/ExceptionHandlerGeneratorTest.cs index 81f89a4..eeffcbb 100644 --- a/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/ExceptionHandlerGeneratorTest.cs +++ b/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/ExceptionHandlerGeneratorTest.cs @@ -2,7 +2,8 @@ using AutoExceptionHandler.Annotations; using AutoExceptionHandler.Generator; using Microsoft.CodeAnalysis.CSharp; -using Xunit; +using NUnit.Framework; + using static AutoExceptionHandler.Tests.Utils.GeneratorTestHelpers; namespace AutoExceptionHandler.Tests; @@ -62,7 +63,7 @@ string message } """; - [Fact] + [Test] public void GenerateReportMethod() { // Create an instance of the source generator. var generator = new ExceptionHandlerGenerator(); @@ -80,7 +81,6 @@ public void GenerateReportMethod() { var generatedFileSyntax = runResult.GeneratedTrees.Single(t => t.FilePath.EndsWith("ExampleHandler.g.cs")); // Complex generators should be tested using text comparison. - Assert.Equal(ExpectedGeneratedClassText, generatedFileSyntax.GetText().ToString(), - ignoreLineEndingDifferences: true); + Assert.That(generatedFileSyntax.GetText().ToString(), Is.EqualTo(ExpectedGeneratedClassText)); } } \ No newline at end of file diff --git a/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/Utils/GeneratorTestHelpers.cs b/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/Utils/GeneratorTestHelpers.cs index 55b4c66..ca315a0 100644 --- a/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/Utils/GeneratorTestHelpers.cs +++ b/AutoExceptionHandler/tests/AutoExceptionHandler.Tests/Utils/GeneratorTestHelpers.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using AutoExceptionHandler.Generator; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -12,9 +13,15 @@ public static Compilation CreateCompilation(string source, params Type[] additio .Select(a => a.Location) .Where(a => !string.IsNullOrEmpty(a)) .Select(l => MetadataReference.CreateFromFile(l)); - return CSharpCompilation.Create("compilation", + var baseCompilation = CSharpCompilation.Create("compilation", [CSharpSyntaxTree.ParseText(source)], assemblies, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); + + var generator = new CopyFilesGenerator(); + var driver = CSharpGeneratorDriver.Create(generator); + driver.RunGeneratorsAndUpdateCompilation(baseCompilation, out var outputCompilation, out _); + + return outputCompilation; } } \ No newline at end of file diff --git a/FastInject/examples/Retro.FastInject.Sample.Cli/Retro.FastInject.Sample.Cli.csproj b/FastInject/examples/Retro.FastInject.Sample.Cli/Retro.FastInject.Sample.Cli.csproj index 80ebd4e..b4c495a 100644 --- a/FastInject/examples/Retro.FastInject.Sample.Cli/Retro.FastInject.Sample.Cli.csproj +++ b/FastInject/examples/Retro.FastInject.Sample.Cli/Retro.FastInject.Sample.Cli.csproj @@ -5,12 +5,11 @@ net9.0 enable enable + false - - diff --git a/FastInject/examples/Retro.FastInject.Sample.WebApi/Retro.FastInject.Sample.WebApi.csproj b/FastInject/examples/Retro.FastInject.Sample.WebApi/Retro.FastInject.Sample.WebApi.csproj index c051eea..9d7b472 100644 --- a/FastInject/examples/Retro.FastInject.Sample.WebApi/Retro.FastInject.Sample.WebApi.csproj +++ b/FastInject/examples/Retro.FastInject.Sample.WebApi/Retro.FastInject.Sample.WebApi.csproj @@ -11,9 +11,7 @@ - - - + diff --git a/FastInject/examples/Retro.FastInject.Sample/Retro.FastInject.Sample.csproj b/FastInject/examples/Retro.FastInject.Sample/Retro.FastInject.Sample.csproj index 2fdbdfe..45fbba7 100644 --- a/FastInject/examples/Retro.FastInject.Sample/Retro.FastInject.Sample.csproj +++ b/FastInject/examples/Retro.FastInject.Sample/Retro.FastInject.Sample.csproj @@ -5,10 +5,10 @@ enable Retro.FastInject.Sample Exe + false - diff --git a/FastInject/src/Retro.FastInject.Annotations/FactoryAttribute.cs b/FastInject/src/Retro.FastInject.Annotations/FactoryAttribute.cs deleted file mode 100644 index e891339..0000000 --- a/FastInject/src/Retro.FastInject.Annotations/FactoryAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Retro.FastInject.Annotations; - -[AttributeUsage(AttributeTargets.Method)] -public class FactoryAttribute(ServiceScope scope = ServiceScope.Singleton) : Attribute { - - public ServiceScope Scope { get; } = scope; - - public string? Key { get; init; } - -} \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject.Annotations/Retro.FastInject.Annotations.csproj b/FastInject/src/Retro.FastInject.Annotations/Retro.FastInject.Annotations.csproj deleted file mode 100644 index 053df57..0000000 --- a/FastInject/src/Retro.FastInject.Annotations/Retro.FastInject.Annotations.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - netstandard2.0 - latest - enable - - - - bin\Debug\Retro.FastInject.Annotations.xml - - - - true - bin\Release\Retro.FastInject.Annotations.xml - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - diff --git a/FastInject/src/Retro.FastInject.Core/Retro.FastInject.Core.csproj b/FastInject/src/Retro.FastInject.Core/Retro.FastInject.Core.csproj index 594ea28..e3c0ed9 100644 --- a/FastInject/src/Retro.FastInject.Core/Retro.FastInject.Core.csproj +++ b/FastInject/src/Retro.FastInject.Core/Retro.FastInject.Core.csproj @@ -4,6 +4,7 @@ net9.0 enable enable + false @@ -20,7 +21,6 @@ - diff --git a/FastInject/src/Retro.FastInject.Dynamic/Retro.FastInject.Dynamic.csproj b/FastInject/src/Retro.FastInject.Dynamic/Retro.FastInject.Dynamic.csproj index 9361371..4302d8f 100644 --- a/FastInject/src/Retro.FastInject.Dynamic/Retro.FastInject.Dynamic.csproj +++ b/FastInject/src/Retro.FastInject.Dynamic/Retro.FastInject.Dynamic.csproj @@ -4,6 +4,7 @@ net9.0 latest enable + false @@ -19,6 +20,7 @@ + diff --git a/FastInject/src/Retro.FastInject.Annotations/AllowDynamicAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/AllowDynamicAttribute.cs similarity index 78% rename from FastInject/src/Retro.FastInject.Annotations/AllowDynamicAttribute.cs rename to FastInject/src/Retro.FastInject/Annotations/AllowDynamicAttribute.cs index 85b0d0a..a94a2ee 100644 --- a/FastInject/src/Retro.FastInject.Annotations/AllowDynamicAttribute.cs +++ b/FastInject/src/Retro.FastInject/Annotations/AllowDynamicAttribute.cs @@ -1,4 +1,9 @@ -using System; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + namespace Retro.FastInject.Annotations; /// @@ -14,4 +19,7 @@ namespace Retro.FastInject.Annotations; /// service is determined at runtime, such as resolving services from key-based factories or dynamic providers. /// [AttributeUsage(AttributeTargets.Parameter)] -public class AllowDynamicAttribute : Attribute; \ No newline at end of file +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class AllowDynamicAttribute : Attribute; \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject.Annotations/DependencyAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/DependencyAttribute.cs similarity index 91% rename from FastInject/src/Retro.FastInject.Annotations/DependencyAttribute.cs rename to FastInject/src/Retro.FastInject/Annotations/DependencyAttribute.cs index ac5cad5..6e1441e 100644 --- a/FastInject/src/Retro.FastInject.Annotations/DependencyAttribute.cs +++ b/FastInject/src/Retro.FastInject/Annotations/DependencyAttribute.cs @@ -1,4 +1,9 @@ -using System; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + namespace Retro.FastInject.Annotations; /// @@ -9,7 +14,10 @@ namespace Retro.FastInject.Annotations; /// It can be used multiple times on the same type to register it for different services or configurations. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = true)] -public class DependencyAttribute(Type type, ServiceScope scope) : Attribute { +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class DependencyAttribute(Type type, ServiceScope scope) : Attribute { /// /// Gets the type that represents the service or implementation being registered in a dependency injection container. diff --git a/FastInject/src/Retro.FastInject/Annotations/FactoryAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/FactoryAttribute.cs new file mode 100644 index 0000000..43f8ad6 --- /dev/null +++ b/FastInject/src/Retro.FastInject/Annotations/FactoryAttribute.cs @@ -0,0 +1,19 @@ +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + +namespace Retro.FastInject.Annotations; + +[AttributeUsage(AttributeTargets.Method)] +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class FactoryAttribute(ServiceScope scope = ServiceScope.Singleton) : Attribute { + + public ServiceScope Scope { get; } = scope; + + public string? Key { get; init; } + +} \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject.Annotations/ImportAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/ImportAttribute.cs similarity index 87% rename from FastInject/src/Retro.FastInject.Annotations/ImportAttribute.cs rename to FastInject/src/Retro.FastInject/Annotations/ImportAttribute.cs index 8797a36..7f121bc 100644 --- a/FastInject/src/Retro.FastInject.Annotations/ImportAttribute.cs +++ b/FastInject/src/Retro.FastInject/Annotations/ImportAttribute.cs @@ -1,6 +1,12 @@ -using System; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + namespace Retro.FastInject.Annotations; + /// /// Specifies that a class or struct requires the import of another type for dependency injection purposes. /// @@ -9,7 +15,10 @@ namespace Retro.FastInject.Annotations; /// and should import its services and dependencies. The attribute supports optional dynamic registration of dependencies. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)] -public class ImportAttribute(Type moduleType) : Attribute { +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class ImportAttribute(Type moduleType) : Attribute { /// /// Represents the type of the module that is required to be imported by the annotated class or struct @@ -37,4 +46,4 @@ public class ImportAttribute(Type moduleType) : Attribute { /// it supports configurable dynamic registration to facilitate more flexible dependency management. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)] -public class ImportAttribute() : ImportAttribute(typeof(TModule)); +internal class ImportAttribute() : ImportAttribute(typeof(TModule)); diff --git a/FastInject/src/Retro.FastInject.Annotations/InstanceAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/InstanceAttribute.cs similarity index 88% rename from FastInject/src/Retro.FastInject.Annotations/InstanceAttribute.cs rename to FastInject/src/Retro.FastInject/Annotations/InstanceAttribute.cs index 5c72121..90474e6 100644 --- a/FastInject/src/Retro.FastInject.Annotations/InstanceAttribute.cs +++ b/FastInject/src/Retro.FastInject/Annotations/InstanceAttribute.cs @@ -1,4 +1,8 @@ -using System; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif namespace Retro.FastInject.Annotations; @@ -18,7 +22,10 @@ namespace Retro.FastInject.Annotations; /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] -public class InstanceAttribute : Attribute { +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class InstanceAttribute : Attribute { /// /// Gets or initializes the unique identifier associated with the instance dependency. diff --git a/FastInject/src/Retro.FastInject.Annotations/RequireNonEmptyAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/RequireNonEmptyAttribute.cs similarity index 80% rename from FastInject/src/Retro.FastInject.Annotations/RequireNonEmptyAttribute.cs rename to FastInject/src/Retro.FastInject/Annotations/RequireNonEmptyAttribute.cs index 686eec5..9d1f3a1 100644 --- a/FastInject/src/Retro.FastInject.Annotations/RequireNonEmptyAttribute.cs +++ b/FastInject/src/Retro.FastInject/Annotations/RequireNonEmptyAttribute.cs @@ -1,4 +1,9 @@ -using System; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + namespace Retro.FastInject.Annotations; /// @@ -15,4 +20,7 @@ namespace Retro.FastInject.Annotations; /// that services of a specific type are available and non-empty. /// [AttributeUsage(AttributeTargets.Parameter)] -public class RequireNonEmptyAttribute : Attribute; \ No newline at end of file +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class RequireNonEmptyAttribute : Attribute; \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject.Annotations/ScopedAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/ScopedAttribute.cs similarity index 79% rename from FastInject/src/Retro.FastInject.Annotations/ScopedAttribute.cs rename to FastInject/src/Retro.FastInject/Annotations/ScopedAttribute.cs index cbf4fe9..7cc3d4e 100644 --- a/FastInject/src/Retro.FastInject.Annotations/ScopedAttribute.cs +++ b/FastInject/src/Retro.FastInject/Annotations/ScopedAttribute.cs @@ -1,4 +1,9 @@ -using System; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + namespace Retro.FastInject.Annotations; /// @@ -10,7 +15,10 @@ namespace Retro.FastInject.Annotations; /// This attribute can be applied multiple times to allow registration for different service types. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = true)] -public class ScopedAttribute(Type serviceType) : DependencyAttribute(serviceType, ServiceScope.Scoped); +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class ScopedAttribute(Type serviceType) : DependencyAttribute(serviceType, ServiceScope.Scoped); /// /// Attribute specifying that the decorated type is registered with a scoped lifecycle in a dependency injection container. @@ -21,4 +29,4 @@ public class ScopedAttribute(Type serviceType) : DependencyAttribute(serviceType /// Can be applied multiple times to facilitate registration for different service types. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = true)] -public class ScopedAttribute() : ScopedAttribute(typeof(TService)); \ No newline at end of file +internal class ScopedAttribute() : ScopedAttribute(typeof(TService)); \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject.Annotations/ServiceProviderAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/ServiceProviderAttribute.cs similarity index 87% rename from FastInject/src/Retro.FastInject.Annotations/ServiceProviderAttribute.cs rename to FastInject/src/Retro.FastInject/Annotations/ServiceProviderAttribute.cs index 88c2b73..2cd390a 100644 --- a/FastInject/src/Retro.FastInject.Annotations/ServiceProviderAttribute.cs +++ b/FastInject/src/Retro.FastInject/Annotations/ServiceProviderAttribute.cs @@ -1,4 +1,9 @@ -using System; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + namespace Retro.FastInject.Annotations; /// @@ -17,7 +22,10 @@ namespace Retro.FastInject.Annotations; /// as SingletonAttribute can be used to specify service lifetimes. /// [AttributeUsage(AttributeTargets.Class)] -public class ServiceProviderAttribute : Attribute { +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class ServiceProviderAttribute : Attribute { /// /// Specifies whether dynamic registrations are allowed for the associated property or field. diff --git a/FastInject/src/Retro.FastInject.Annotations/ServiceScope.cs b/FastInject/src/Retro.FastInject/Annotations/ServiceScope.cs similarity index 80% rename from FastInject/src/Retro.FastInject.Annotations/ServiceScope.cs rename to FastInject/src/Retro.FastInject/Annotations/ServiceScope.cs index 1388b04..2318e51 100644 --- a/FastInject/src/Retro.FastInject.Annotations/ServiceScope.cs +++ b/FastInject/src/Retro.FastInject/Annotations/ServiceScope.cs @@ -1,4 +1,10 @@ -namespace Retro.FastInject.Annotations; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + +namespace Retro.FastInject.Annotations; /// /// Specifies that the service has a singleton lifecycle in a dependency injection container. @@ -8,7 +14,10 @@ /// throughout the lifetime of the application. All requests for the service resolve to the /// same, single instance. /// -public enum ServiceScope { +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal enum ServiceScope { /// /// A singleton service, meaning only one instance is created and shared throughout the lifetime of the application. /// diff --git a/FastInject/src/Retro.FastInject.Annotations/SingletonAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/SingletonAttribute.cs similarity index 75% rename from FastInject/src/Retro.FastInject.Annotations/SingletonAttribute.cs rename to FastInject/src/Retro.FastInject/Annotations/SingletonAttribute.cs index de207a7..a012c11 100644 --- a/FastInject/src/Retro.FastInject.Annotations/SingletonAttribute.cs +++ b/FastInject/src/Retro.FastInject/Annotations/SingletonAttribute.cs @@ -1,4 +1,9 @@ -using System; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + namespace Retro.FastInject.Annotations; /// @@ -9,7 +14,10 @@ namespace Retro.FastInject.Annotations; /// Services marked with this attribute are instantiated once and shared throughout the application lifetime. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = true)] -public class SingletonAttribute(Type serviceType) : DependencyAttribute(serviceType, ServiceScope.Singleton); +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class SingletonAttribute(Type serviceType) : DependencyAttribute(serviceType, ServiceScope.Singleton); /// /// Defines an attribute to indicate that the attributed class, struct, or interface should be registered as a singleton @@ -20,4 +28,4 @@ public class SingletonAttribute(Type serviceType) : DependencyAttribute(serviceT /// the lifetime of the application. It enables dependency injection systems to manage singleton lifetimes. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = true)] -public class SingletonAttribute() : SingletonAttribute(typeof(TService)); \ No newline at end of file +internal class SingletonAttribute() : SingletonAttribute(typeof(TService)); \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject.Annotations/TransientAttribute.cs b/FastInject/src/Retro.FastInject/Annotations/TransientAttribute.cs similarity index 77% rename from FastInject/src/Retro.FastInject.Annotations/TransientAttribute.cs rename to FastInject/src/Retro.FastInject/Annotations/TransientAttribute.cs index 94da786..3e7d0c2 100644 --- a/FastInject/src/Retro.FastInject.Annotations/TransientAttribute.cs +++ b/FastInject/src/Retro.FastInject/Annotations/TransientAttribute.cs @@ -1,4 +1,9 @@ -using System; +#if FAST_INJECT_GENERATOR +using RhoMicro.CodeAnalysis; +#else +using System; +#endif + namespace Retro.FastInject.Annotations; /// @@ -9,7 +14,10 @@ namespace Retro.FastInject.Annotations; /// A transient service is created each time it is requested, ensuring a new instance is provided for each dependency resolution. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = true)] -public class TransientAttribute(Type serviceType) : DependencyAttribute(serviceType, ServiceScope.Transient); +#if FAST_INJECT_GENERATOR +[IncludeFile] +#endif +internal class TransientAttribute(Type serviceType) : DependencyAttribute(serviceType, ServiceScope.Transient); /// /// Marks the annotated type to be registered with a transient lifecycle in the dependency injection container. @@ -19,4 +27,4 @@ public class TransientAttribute(Type serviceType) : DependencyAttribute(serviceT /// It is particularly useful for stateless or short-lived services where shared state is unnecessary. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = true)] -public class TransientAttribute() : TransientAttribute(typeof(TService)); \ No newline at end of file +internal class TransientAttribute() : TransientAttribute(typeof(TService)); \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject/CopyFilesGenerator.cs b/FastInject/src/Retro.FastInject/CopyFilesGenerator.cs new file mode 100644 index 0000000..7a6660f --- /dev/null +++ b/FastInject/src/Retro.FastInject/CopyFilesGenerator.cs @@ -0,0 +1,16 @@ +using Microsoft.CodeAnalysis; +using RhoMicro.CodeAnalysis.Generated; + +namespace Retro.FastInject; + +/// +/// Represents a source generator that facilitates copying files for use in code generation tasks. +/// +[Generator] +internal class CopyFilesGenerator : IIncrementalGenerator { + + /// + public void Initialize(IncrementalGeneratorInitializationContext context) { + IncludedFileSources.RegisterToContext(context); + } +} \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject/Generation/DependencyExtensions.cs b/FastInject/src/Retro.FastInject/Generation/DependencyExtensions.cs index 5abbb8d..51197b0 100644 --- a/FastInject/src/Retro.FastInject/Generation/DependencyExtensions.cs +++ b/FastInject/src/Retro.FastInject/Generation/DependencyExtensions.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis; @@ -7,8 +6,7 @@ using Retro.FastInject.Comparers; using Retro.FastInject.Model.Attributes; using Retro.FastInject.Model.Detection; -using Retro.FastInject.Model.Manifest; -using Retro.FastInject.Utils; +using Retro.SourceGeneratorUtilities.Utilities.Types; namespace Retro.FastInject.Generation; @@ -16,7 +14,7 @@ namespace Retro.FastInject.Generation; /// Provides extension methods for analyzing and retrieving dependency injection service details /// from Roslyn `ITypeSymbol` representations of classes or types. /// -public static class DependencyExtensions { +internal static class DependencyExtensions { /// /// Retrieves a collection of services injected into the specified class using attributes, /// factory methods, or instance members. This method analyzes the class for services that diff --git a/FastInject/src/Retro.FastInject/Generation/ResolutionExtensions.cs b/FastInject/src/Retro.FastInject/Generation/ResolutionExtensions.cs index 166026f..cf2edd6 100644 --- a/FastInject/src/Retro.FastInject/Generation/ResolutionExtensions.cs +++ b/FastInject/src/Retro.FastInject/Generation/ResolutionExtensions.cs @@ -1,17 +1,15 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; using Retro.FastInject.Model.Manifest; -using System.Linq; using System.Text; -using Microsoft.Extensions.DependencyInjection; using Retro.FastInject.Annotations; using Retro.FastInject.Comparers; using Retro.FastInject.Model.Attributes; -using Retro.FastInject.Utils; using Retro.SourceGeneratorUtilities.Utilities.Attributes; +using Retro.SourceGeneratorUtilities.Utilities.Members; +using Retro.SourceGeneratorUtilities.Utilities.Types; namespace Retro.FastInject.Generation; @@ -19,7 +17,7 @@ namespace Retro.FastInject.Generation; /// Provides extension methods for resolving and manipulating parameter resolution details /// used in the dependency injection service hierarchy. /// -public static class ResolutionExtensions { +internal static class ResolutionExtensions { /// /// Checks if all dependencies in the constructor of the specified service registration can be resolved and records the resolution. /// diff --git a/FastInject/src/Retro.FastInject/Generation/ServiceManifestGenerator.cs b/FastInject/src/Retro.FastInject/Generation/ServiceManifestGenerator.cs index 6790cb9..696f3e3 100644 --- a/FastInject/src/Retro.FastInject/Generation/ServiceManifestGenerator.cs +++ b/FastInject/src/Retro.FastInject/Generation/ServiceManifestGenerator.cs @@ -9,7 +9,7 @@ namespace Retro.FastInject.Generation; /// Responsible for generating a service manifest that organizes and maps services, their implementations, /// lifetimes, base types, and indirect relationships within a dependency injection framework. /// -public static class ServiceManifestGenerator { +internal static class ServiceManifestGenerator { /// /// Generates a manifest that maps services to their implementations, lifetimes, base types, and indirect relationships. /// diff --git a/FastInject/src/Retro.FastInject/Generation/ValidationExtensions.cs b/FastInject/src/Retro.FastInject/Generation/ValidationExtensions.cs index 33ba70e..ed3d52a 100644 --- a/FastInject/src/Retro.FastInject/Generation/ValidationExtensions.cs +++ b/FastInject/src/Retro.FastInject/Generation/ValidationExtensions.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.CodeAnalysis; @@ -14,7 +13,7 @@ namespace Retro.FastInject.Generation; /// Useful for ensuring proper dependency management and detecting issues such as circular dependencies /// within the dependency injection process. /// -public static class ValidationExtensions { +internal static class ValidationExtensions { /// /// Validates the entire dependency graph for circular dependencies. diff --git a/FastInject/src/Retro.FastInject/Model/Attributes/DependencyOverview.cs b/FastInject/src/Retro.FastInject/Model/Attributes/DependencyOverview.cs index 0a6ac6e..f3157fe 100644 --- a/FastInject/src/Retro.FastInject/Model/Attributes/DependencyOverview.cs +++ b/FastInject/src/Retro.FastInject/Model/Attributes/DependencyOverview.cs @@ -14,7 +14,7 @@ namespace Retro.FastInject.Model.Attributes; /// The service scope that determines the lifetime of the dependency (e.g., Singleton, Scoped, Transient). /// [AttributeInfoType] -public record DependencyOverview(ITypeSymbol Type, ServiceScope Scope) { +internal record DependencyOverview(ITypeSymbol Type, ServiceScope Scope) { /// /// Gets or initializes the key associated with the dependency overview. /// This key can be utilized to uniquely identify a dependency diff --git a/FastInject/src/Retro.FastInject/Model/Attributes/FactoryOverview.cs b/FastInject/src/Retro.FastInject/Model/Attributes/FactoryOverview.cs index 14d80c6..68d274c 100644 --- a/FastInject/src/Retro.FastInject/Model/Attributes/FactoryOverview.cs +++ b/FastInject/src/Retro.FastInject/Model/Attributes/FactoryOverview.cs @@ -14,7 +14,7 @@ namespace Retro.FastInject.Model.Attributes; /// Specifies the lifecycle scope of the service within the dependency injection container. /// [AttributeInfoType] -public record FactoryOverview(ServiceScope Scope) { +internal record FactoryOverview(ServiceScope Scope) { /// /// Gets or initializes the configuration key associated with this factory overview. diff --git a/FastInject/src/Retro.FastInject/Model/Attributes/FromKeyedServicesOverview.cs b/FastInject/src/Retro.FastInject/Model/Attributes/FromKeyedServicesOverview.cs index b45d4df..50da965 100644 --- a/FastInject/src/Retro.FastInject/Model/Attributes/FromKeyedServicesOverview.cs +++ b/FastInject/src/Retro.FastInject/Model/Attributes/FromKeyedServicesOverview.cs @@ -10,7 +10,7 @@ namespace Retro.FastInject.Model.Attributes; /// It provides functionality to initialize and retrieve the key associated with the service. /// [AttributeInfoType] -public record FromKeyedServicesOverview { +internal record FromKeyedServicesOverview { /// /// Represents the key associated with a keyed service in dependency injection. diff --git a/FastInject/src/Retro.FastInject/Model/Attributes/ImportOverview.cs b/FastInject/src/Retro.FastInject/Model/Attributes/ImportOverview.cs index dc37bb8..3df2b09 100644 --- a/FastInject/src/Retro.FastInject/Model/Attributes/ImportOverview.cs +++ b/FastInject/src/Retro.FastInject/Model/Attributes/ImportOverview.cs @@ -10,7 +10,7 @@ namespace Retro.FastInject.Model.Attributes; /// The symbol representing the type of the module to be imported. /// [AttributeInfoType] -public record ImportOverview(ITypeSymbol ModuleType) { +internal record ImportOverview(ITypeSymbol ModuleType) { /// /// Gets or sets a value indicating whether dynamic registrations are allowed @@ -30,4 +30,4 @@ public record ImportOverview(ITypeSymbol ModuleType) { /// The symbol representing the type of the module to be imported. /// [AttributeInfoType(typeof(ImportAttribute<>))] -public record ImportOneParamOverview(ITypeSymbol ModuleType) : ImportOverview(ModuleType); \ No newline at end of file +internal record ImportOneParamOverview(ITypeSymbol ModuleType) : ImportOverview(ModuleType); \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject/Model/Attributes/InstanceOverview.cs b/FastInject/src/Retro.FastInject/Model/Attributes/InstanceOverview.cs index ef2fba6..cd55d62 100644 --- a/FastInject/src/Retro.FastInject/Model/Attributes/InstanceOverview.cs +++ b/FastInject/src/Retro.FastInject/Model/Attributes/InstanceOverview.cs @@ -13,7 +13,7 @@ namespace Retro.FastInject.Model.Attributes; /// operate with uniquely identified dependency instances. /// [AttributeInfoType] -public record InstanceOverview { +internal record InstanceOverview { /// /// Gets the unique identifier or key associated with the instance. diff --git a/FastInject/src/Retro.FastInject/Model/Attributes/ScopedOverview.cs b/FastInject/src/Retro.FastInject/Model/Attributes/ScopedOverview.cs index 162da61..bf49921 100644 --- a/FastInject/src/Retro.FastInject/Model/Attributes/ScopedOverview.cs +++ b/FastInject/src/Retro.FastInject/Model/Attributes/ScopedOverview.cs @@ -15,7 +15,7 @@ namespace Retro.FastInject.Model.Attributes; /// This indicates the interface or class registered with a scoped lifetime. /// [AttributeInfoType] -public record ScopedOverview(ITypeSymbol Type) : DependencyOverview(Type, ServiceScope.Scoped); +internal record ScopedOverview(ITypeSymbol Type) : DependencyOverview(Type, ServiceScope.Scoped); /// /// Represents an overview model specifically tailored for scoped services with a single generic parameter in dependency injection frameworks. @@ -30,4 +30,4 @@ public record ScopedOverview(ITypeSymbol Type) : DependencyOverview(Type, Servic /// This indicates the generic service type registered with a scoped lifetime. /// [AttributeInfoType(typeof(ScopedAttribute<>))] -public record ScopedOneParamOverview(ITypeSymbol Type) : ScopedOverview(Type); \ No newline at end of file +internal record ScopedOneParamOverview(ITypeSymbol Type) : ScopedOverview(Type); \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject/Model/Attributes/ServiceProviderOverview.cs b/FastInject/src/Retro.FastInject/Model/Attributes/ServiceProviderOverview.cs index 5540bea..d33479d 100644 --- a/FastInject/src/Retro.FastInject/Model/Attributes/ServiceProviderOverview.cs +++ b/FastInject/src/Retro.FastInject/Model/Attributes/ServiceProviderOverview.cs @@ -12,7 +12,7 @@ namespace Retro.FastInject.Model.Attributes; /// Retro.FastInject framework. /// [AttributeInfoType] -public record ServiceProviderOverview { +internal record ServiceProviderOverview { /// /// Determines whether the service provider allows dynamic registrations diff --git a/FastInject/src/Retro.FastInject/Model/Attributes/SingletonOverview.cs b/FastInject/src/Retro.FastInject/Model/Attributes/SingletonOverview.cs index 33fa893..7670282 100644 --- a/FastInject/src/Retro.FastInject/Model/Attributes/SingletonOverview.cs +++ b/FastInject/src/Retro.FastInject/Model/Attributes/SingletonOverview.cs @@ -18,7 +18,7 @@ namespace Retro.FastInject.Model.Attributes; /// The symbol representation of the type being registered as a singleton. /// [AttributeInfoType] -public record SingletonOverview(ITypeSymbol Type) : DependencyOverview(Type, ServiceScope.Singleton); +internal record SingletonOverview(ITypeSymbol Type) : DependencyOverview(Type, ServiceScope.Singleton); /// /// Represents an overview of a dependency that is registered with a singleton lifetime scope, @@ -35,4 +35,4 @@ public record SingletonOverview(ITypeSymbol Type) : DependencyOverview(Type, Ser /// The symbol representation of the one-parameter generic type being registered as a singleton. /// [AttributeInfoType(typeof(SingletonAttribute<>))] -public record SingletonOneParamOverview(ITypeSymbol Type) : SingletonOverview(Type); \ No newline at end of file +internal record SingletonOneParamOverview(ITypeSymbol Type) : SingletonOverview(Type); \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject/Model/Attributes/TransientOverview.cs b/FastInject/src/Retro.FastInject/Model/Attributes/TransientOverview.cs index 7c0fb25..31835a5 100644 --- a/FastInject/src/Retro.FastInject/Model/Attributes/TransientOverview.cs +++ b/FastInject/src/Retro.FastInject/Model/Attributes/TransientOverview.cs @@ -14,7 +14,7 @@ namespace Retro.FastInject.Model.Attributes; /// The type symbol representing the service type associated with the transient dependency. /// [AttributeInfoType] -public record TransientOverview(ITypeSymbol Type) : DependencyOverview(Type, ServiceScope.Transient); +internal record TransientOverview(ITypeSymbol Type) : DependencyOverview(Type, ServiceScope.Transient); /// /// Represents an overview of a transient dependency with one generic parameter within the dependency injection system. @@ -27,4 +27,4 @@ public record TransientOverview(ITypeSymbol Type) : DependencyOverview(Type, Ser /// The type symbol representing the service type associated with the generic transient dependency. /// [AttributeInfoType(typeof(TransientAttribute<>))] -public record TransientOneParamOverview(ITypeSymbol Type) : TransientOverview(Type); \ No newline at end of file +internal record TransientOneParamOverview(ITypeSymbol Type) : TransientOverview(Type); \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject/Model/Detection/ServiceDeclaration.cs b/FastInject/src/Retro.FastInject/Model/Detection/ServiceDeclaration.cs index afce790..0f0ae1c 100644 --- a/FastInject/src/Retro.FastInject/Model/Detection/ServiceDeclaration.cs +++ b/FastInject/src/Retro.FastInject/Model/Detection/ServiceDeclaration.cs @@ -8,7 +8,7 @@ namespace Retro.FastInject.Model.Detection; /// This encapsulates metadata associated with a specific service type, its lifetime scope, /// an optional key for uniquely identifying instances, and potentially an associated symbol. /// -public record ServiceDeclaration( +internal record ServiceDeclaration( ITypeSymbol Type, ServiceScope Lifetime, string? Key, diff --git a/FastInject/src/Retro.FastInject/Model/Detection/ServiceDeclarationCollection.cs b/FastInject/src/Retro.FastInject/Model/Detection/ServiceDeclarationCollection.cs index 7788bfc..fcc3060 100644 --- a/FastInject/src/Retro.FastInject/Model/Detection/ServiceDeclarationCollection.cs +++ b/FastInject/src/Retro.FastInject/Model/Detection/ServiceDeclarationCollection.cs @@ -16,9 +16,9 @@ namespace Retro.FastInject.Model.Detection; /// The named type symbol representing the container type. /// An immutable array of service declarations associated with the container. /// A flag indicating whether dynamic service resolution is allowed. -public readonly struct ServiceDeclarationCollection(INamedTypeSymbol containerType, - [ReadOnly] ImmutableArray serviceDeclarations, - bool allowDynamicServices) : IReadOnlyList { +internal readonly struct ServiceDeclarationCollection(INamedTypeSymbol containerType, + [ReadOnly] ImmutableArray serviceDeclarations, + bool allowDynamicServices) : IReadOnlyList { /// /// Gets the named type symbol representing the container type for these service declarations. diff --git a/FastInject/src/Retro.FastInject/Model/Manifest/ConstructorResolution.cs b/FastInject/src/Retro.FastInject/Model/Manifest/ConstructorResolution.cs index ceec3ab..3e6831c 100644 --- a/FastInject/src/Retro.FastInject/Model/Manifest/ConstructorResolution.cs +++ b/FastInject/src/Retro.FastInject/Model/Manifest/ConstructorResolution.cs @@ -6,7 +6,7 @@ namespace Retro.FastInject.Model.Manifest; /// /// Records all service resolutions for a constructor. /// -public class ConstructorResolution { +internal class ConstructorResolution { /// /// The constructor that was resolved /// diff --git a/FastInject/src/Retro.FastInject/Model/Manifest/ParameterResolution.cs b/FastInject/src/Retro.FastInject/Model/Manifest/ParameterResolution.cs index 4d2fd12..243854a 100644 --- a/FastInject/src/Retro.FastInject/Model/Manifest/ParameterResolution.cs +++ b/FastInject/src/Retro.FastInject/Model/Manifest/ParameterResolution.cs @@ -5,7 +5,7 @@ namespace Retro.FastInject.Model.Manifest; /// /// Records a service resolution for a constructor parameter. /// -public record ParameterResolution { +internal record ParameterResolution { /// /// The parameter symbol /// diff --git a/FastInject/src/Retro.FastInject/Model/Manifest/ResolvedDependencyArguments.cs b/FastInject/src/Retro.FastInject/Model/Manifest/ResolvedDependencyArguments.cs index 70bd0b9..b180bff 100644 --- a/FastInject/src/Retro.FastInject/Model/Manifest/ResolvedDependencyArguments.cs +++ b/FastInject/src/Retro.FastInject/Model/Manifest/ResolvedDependencyArguments.cs @@ -10,4 +10,4 @@ namespace Retro.FastInject.Model.Manifest; /// This struct encapsulates the type information and service scope associated with a resolved dependency. /// It is primarily used to define how a specific dependency is resolved within a service hierarchy. /// -public record struct ResolvedDependencyArguments(ITypeSymbol Type, ServiceScope Scope); \ No newline at end of file +internal record struct ResolvedDependencyArguments(ITypeSymbol Type, ServiceScope Scope); \ No newline at end of file diff --git a/FastInject/src/Retro.FastInject/Model/Manifest/ServiceManifest.cs b/FastInject/src/Retro.FastInject/Model/Manifest/ServiceManifest.cs index e9bc293..124ce9f 100644 --- a/FastInject/src/Retro.FastInject/Model/Manifest/ServiceManifest.cs +++ b/FastInject/src/Retro.FastInject/Model/Manifest/ServiceManifest.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; +using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; using Retro.FastInject.Annotations; using Retro.FastInject.Comparers; -using Retro.FastInject.Utils; using Retro.SourceGeneratorUtilities.Utilities.Types; namespace Retro.FastInject.Model.Manifest; @@ -15,7 +11,7 @@ namespace Retro.FastInject.Model.Manifest; /// Provides functionalities to track and retrieve services based on different parameters such as /// lifetime, associated keys, and constructor dependencies. /// -public class ServiceManifest { +internal class ServiceManifest { private readonly Dictionary> _services = new(TypeSymbolEqualityComparer.Instance); diff --git a/FastInject/src/Retro.FastInject/Model/Manifest/ServiceRegistration.cs b/FastInject/src/Retro.FastInject/Model/Manifest/ServiceRegistration.cs index 1c41f3f..6eaf47f 100644 --- a/FastInject/src/Retro.FastInject/Model/Manifest/ServiceRegistration.cs +++ b/FastInject/src/Retro.FastInject/Model/Manifest/ServiceRegistration.cs @@ -1,7 +1,6 @@ -using System.Collections.Generic; -using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis; using Retro.FastInject.Annotations; -using Retro.FastInject.Utils; +using Retro.SourceGeneratorUtilities.Utilities.Types; namespace Retro.FastInject.Model.Manifest; @@ -13,7 +12,7 @@ namespace Retro.FastInject.Model.Manifest; /// optional implementation type, keys for distinguishing registrations, and associated /// metadata for resolving dependencies during runtime. /// -public record ServiceRegistration { +internal record ServiceRegistration { /// Represents the type of the service being registered. /// This property is required and is used to define the type of the service /// in the dependency injection container. diff --git a/FastInject/src/Retro.FastInject/Model/Template/CollectedService.cs b/FastInject/src/Retro.FastInject/Model/Template/CollectedService.cs index 71ea3b9..d40676c 100644 --- a/FastInject/src/Retro.FastInject/Model/Template/CollectedService.cs +++ b/FastInject/src/Retro.FastInject/Model/Template/CollectedService.cs @@ -9,7 +9,7 @@ namespace Retro.FastInject.Model.Template; /// This class encapsulates the data of a specific service registration, including its type, /// index, and its status as primary or the last registration in a sequence. /// -public class CollectedService(ServiceRegistration registration, bool isLast) { +internal class CollectedService(ServiceRegistration registration, bool isLast) { /// /// Gets the fully qualified type name of the service associated with this registration. /// diff --git a/FastInject/src/Retro.FastInject/Model/Template/ParameterInjection.cs b/FastInject/src/Retro.FastInject/Model/Template/ParameterInjection.cs index 3f57558..bed4578 100644 --- a/FastInject/src/Retro.FastInject/Model/Template/ParameterInjection.cs +++ b/FastInject/src/Retro.FastInject/Model/Template/ParameterInjection.cs @@ -8,7 +8,7 @@ namespace Retro.FastInject.Model.Template; /// Represents a parameter resolution for dependency injection, containing information /// about a parameter and how it should be resolved. /// -public record ParameterInjection { +internal record ParameterInjection { /// /// Gets or sets the type of the parameter. /// diff --git a/FastInject/src/Retro.FastInject/Model/Template/ResolvedInjection.cs b/FastInject/src/Retro.FastInject/Model/Template/ResolvedInjection.cs index d2f4c69..ecf4e92 100644 --- a/FastInject/src/Retro.FastInject/Model/Template/ResolvedInjection.cs +++ b/FastInject/src/Retro.FastInject/Model/Template/ResolvedInjection.cs @@ -1,14 +1,15 @@ using Microsoft.CodeAnalysis; using Retro.FastInject.Generation; using Retro.FastInject.Model.Manifest; -using Retro.FastInject.Utils; +using Retro.SourceGeneratorUtilities.Utilities.Types; + namespace Retro.FastInject.Model.Template; /// /// Represents a resolved injection for a service, containing the service name, type, /// and an optional index when applicable. /// -public record ResolvedInjection { +internal record ResolvedInjection { /// /// Gets the name of the service associated with the resolved injection. /// This property identifies the specific service within the dependency injection context. diff --git a/FastInject/src/Retro.FastInject/Model/Template/ServiceInjection.cs b/FastInject/src/Retro.FastInject/Model/Template/ServiceInjection.cs index 245ef81..b32f067 100644 --- a/FastInject/src/Retro.FastInject/Model/Template/ServiceInjection.cs +++ b/FastInject/src/Retro.FastInject/Model/Template/ServiceInjection.cs @@ -1,10 +1,8 @@ -using System.Collections.Generic; -using System.Linq; -using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis; using Retro.FastInject.Annotations; using Retro.FastInject.Generation; using Retro.FastInject.Model.Manifest; -using Retro.FastInject.Utils; +using Retro.SourceGeneratorUtilities.Utilities.Types; namespace Retro.FastInject.Model.Template; @@ -12,7 +10,7 @@ namespace Retro.FastInject.Model.Template; /// Represents a service injection that is used to hold details about a service /// registration and its associated parameters, used during dependency injection. /// -public record ServiceInjection { +internal record ServiceInjection { /// /// Gets the display string representing the type of the service associated with this injection. diff --git a/FastInject/src/Retro.FastInject/Properties/SourceTemplates.Designer.cs b/FastInject/src/Retro.FastInject/Properties/SourceTemplates.Designer.cs index 6d3a532..f126ffb 100644 --- a/FastInject/src/Retro.FastInject/Properties/SourceTemplates.Designer.cs +++ b/FastInject/src/Retro.FastInject/Properties/SourceTemplates.Designer.cs @@ -8,10 +8,9 @@ //------------------------------------------------------------------------------ namespace Retro.FastInject { - using System; - - - /// + + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder diff --git a/FastInject/src/Retro.FastInject/Retro.FastInject.csproj b/FastInject/src/Retro.FastInject/Retro.FastInject.csproj index 04df064..cbf7586 100644 --- a/FastInject/src/Retro.FastInject/Retro.FastInject.csproj +++ b/FastInject/src/Retro.FastInject/Retro.FastInject.csproj @@ -5,7 +5,9 @@ false enable latest - true + enable + true + $(DefineConstants);FAST_INJECT_GENERATOR true true @@ -31,13 +33,15 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - - @@ -57,8 +61,6 @@ - @@ -68,11 +70,6 @@ - - - - - @@ -90,4 +87,8 @@ SourceTemplates.resx + + + + diff --git a/FastInject/src/Retro.FastInject/ServiceProviderGenerator.cs b/FastInject/src/Retro.FastInject/ServiceProviderGenerator.cs index 4681d7c..41b3ca4 100644 --- a/FastInject/src/Retro.FastInject/ServiceProviderGenerator.cs +++ b/FastInject/src/Retro.FastInject/ServiceProviderGenerator.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using HandlebarsDotNet; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/FastInject/src/Retro.FastInject/Utils/TypeExtensions.cs b/FastInject/src/Retro.FastInject/Utils/TypeExtensions.cs deleted file mode 100644 index 2e007b1..0000000 --- a/FastInject/src/Retro.FastInject/Utils/TypeExtensions.cs +++ /dev/null @@ -1,253 +0,0 @@ -using System; -using System.Collections.Immutable; -using System.Linq; -using Microsoft.CodeAnalysis; - -namespace Retro.FastInject.Utils; - -/// -/// Provides extension methods for working with types represented as . -/// -public static class TypeExtensions { - /// - /// Determines whether the specified interface type is valid for use as a type argument in the current context. - /// - /// The interface type represented as an to validate. - /// - /// True if the interface type is valid for use as a type argument; otherwise, false. - /// - public static bool IsValidForTypeArgument(this ITypeSymbol interfaceType) { - if (interfaceType is not INamedTypeSymbol namedType) return true; - - if (IsProblematicInterface(namedType)) { - return false; - } - - // Check if the interface has any static members - var staticMembers = namedType.GetMembers().Where(m => m.IsStatic).ToList(); - if (!staticMembers.Any()) return true; - - foreach (var member in staticMembers) { - // Check for unimplemented static members - if (!HasSpecificImplementation(member)) return false; - - // Check for ambiguous implementations in generic interfaces - if (namedType.IsGenericType && MightHaveAmbiguousImplementation(member)) { - return false; - } - } - - return true; - } - - private static bool MightHaveAmbiguousImplementation(ISymbol member) { - switch (member) { - case IMethodSymbol methodSymbol: - // Check if the method uses type parameters in its signature - return HasTypeParametersInSignature(methodSymbol); - - case IPropertySymbol propertySymbol: - // Check if the property type involves type parameters - return HasTypeParametersInProperty(propertySymbol); - - default: - return false; - } - } - - private static bool HasTypeParametersInSignature(IMethodSymbol method) { - // Check return type - return ContainsTypeParameters(method.ReturnType) || - // Check parameters - method.Parameters.Any(p => ContainsTypeParameters(p.Type)); - } - - private static bool HasTypeParametersInProperty(IPropertySymbol property) { - return ContainsTypeParameters(property.Type); - } - - private static bool ContainsTypeParameters(ITypeSymbol type) { - return type switch { - ITypeParameterSymbol => true, - INamedTypeSymbol namedType => namedType.TypeArguments.Any(ContainsTypeParameters), - _ => false - }; - } - - private static bool HasSpecificImplementation(ISymbol member) { - // For properties - if (member is IPropertySymbol propertySymbol) { - return !propertySymbol.IsAbstract; - } - - // For methods - if (member is IMethodSymbol methodSymbol) { - return !methodSymbol.IsAbstract; - } - - return true; - } - - - private static bool IsProblematicInterface(INamedTypeSymbol type) { - var fullName = type.ToDisplayString(); - - // System.Numerics interfaces - var numericInterfaces = new[] { - "System.Numerics.INumber<", - "System.Numerics.IBinaryFloatingPointIeee754<", - "System.Numerics.IBinaryNumber<", - "System.Numerics.ISignedNumber<", - "System.Numerics.IFloatingPoint<", - "System.Numerics.IFloatingPointIeee754<", - "System.Numerics.IExponentalFunctions<", - "System.Numerics.IPowerFunctions<", - "System.Numerics.ILogarithmicFunctions<", - "System.Numerics.ITrigonometricFunctions<", - "System.Numerics.IHyperbolicFunctions<", - "System.Numerics.IRootFunctions<", - "System.Numerics.IModulusOperators<", - "System.Numerics.IUnaryPlusOperators<", - "System.Numerics.IUnaryNegationOperators<", - "System.Numerics.IIncrementOperators<", - "System.Numerics.IDecrementOperators<" - }; - - // Basic BCL interfaces - var bclInterfaces = new[] { - "System.ISpanFormattable", - "System.IFormattable", - "System.IUtf8SpanFormattable", - "System.IComparable", - "System.IComparable<", - "System.IConvertible", - "System.IEquatable<", - "System.ISpanParsable<", - "System.IParsable<", - "System.IUtf8SpanParsable<", - - // Collections and related - "System.Collections.Generic.IEnumerable<", - "System.Collections.Generic.IAsyncEnumerable<", - "System.Collections.Generic.ICollection<", - "System.Collections.Generic.IList<", - "System.Collections.Generic.ISet<", - "System.Collections.Generic.IDictionary<", - "System.Collections.Generic.IReadOnlyCollection<", - "System.Collections.Generic.IReadOnlyList<", - "System.Collections.Generic.IReadOnlySet<", - "System.Collections.Generic.IReadOnlyDictionary<", - - // Additional common interfaces - "System.IObservable<", - "System.IObserver<", - "System.IProgress<", - "System.IDisposable", - "System.IAsyncDisposable", - "System.ICloneable", - - // Comparison interfaces - "System.IComparer<", - "System.Collections.Generic.IEqualityComparer<", - - // Additional numeric interfaces - "System.IAdditionOperators<", - "System.ISubtractionOperators<", - "System.IMultiplyOperators<", - "System.IDivisionOperators<", - "System.IAdditionOperators<", - "System.IAdditiveIdentity<", - "System.IMultiplicativeIdentity<", - - // Pattern interfaces - "System.IAsyncPattern", - "System.IValueTaskSource<", - "System.IValueTaskSource" - }; - - return numericInterfaces.Concat(bclInterfaces) - .Any(pi => fullName.StartsWith(pi, StringComparison.Ordinal)); - } - - /// - /// Determines whether the specified represents a nullable type - /// and provides information about its underlying type. - /// - /// The type symbol to check for nullability. - /// - /// A instance containing information about the nullability - /// of the type and its underlying type, if applicable. - /// - public static NullableData CheckIfNullable(this ITypeSymbol type) { - if (type is INamedTypeSymbol { ConstructedFrom.SpecialType: SpecialType.System_Nullable_T } namedType) { - return new NullableData(true, namedType.TypeArguments[0]); - } - - return type.NullableAnnotation == NullableAnnotation.Annotated ? new NullableData(true, type.WithNullableAnnotation(NullableAnnotation.None)) : new NullableData(false, type); - } - - /// - /// Constructs a generic type by instantiating it with the specified . - /// - /// The types to be used as the generic type argument for the constructed type. - /// The current Roslyn instance used to access type metadata. - /// The generic type definition to be instantiated, provided as a . - /// - /// An representing the constructed generic type. - /// - /// - /// Thrown if the does not have a or if the metadata for the specified type cannot be found in the . - /// - public static INamedTypeSymbol GetInstantiatedGeneric(this Type type, Compilation compilation, params ITypeSymbol[] elementTypes) { - // Get the ImmutableArray generic type definition from the compilation - if (type.FullName is null) { - throw new InvalidOperationException("Cannot operate on anonymous types."); - } - - var genericType = compilation.GetTypeByMetadataName(type.FullName); - - if (genericType == null) - throw new InvalidOperationException($"Could not find {type.FullName} type"); - - // Construct the generic type with the provided element type(s) - return genericType.Construct(elementTypes); - } - - /// - /// Constructs an instantiated generic type from the provided unbound generic type and type arguments. - /// - /// The unbound generic type represented by an . - /// An array of representing the generic type arguments. - /// - /// An representing the constructed generic type with the provided type arguments. - /// - /// - /// Thrown if the provided type is not an unbound generic type or if the type cannot be constructed with the provided type arguments. - /// - public static INamedTypeSymbol GetInstantiatedGeneric(this ITypeSymbol type, params ITypeSymbol[] elementTypes) { - if (type is not INamedTypeSymbol namedType) { - throw new InvalidOperationException($"Type '{type.ToDisplayString()}' is not an unbound generic."); - } - - // Construct the generic type with the provided element type(s) - return namedType.Construct(elementTypes); - } - - /// - /// Generates a sanitized string representation of the given . - /// For generic types, the result includes a concatenated format of the type's name and its type arguments. - /// - /// The to generate a sanitized name for. - /// - /// A sanitized string representation of the type, formatted as the type name. For generic types, - /// the type arguments are included as an underscore-separated list. - /// - public static string GetSanitizedTypeName(this ITypeSymbol type) { - return type is not INamedTypeSymbol { IsGenericType: true } namedType ? type.Name - : $"{type.Name}_{namedType.TypeArguments - .Select(x => x.GetSanitizedTypeName()) - .Joining("_")}"; - - } - -} \ No newline at end of file diff --git a/FastInject/test/Retro.FastInject.Core.Tests/BasicFunctionalityTests.cs b/FastInject/test/Retro.FastInject.Core.Tests/BasicFunctionalityTests.cs index f8ea49c..3cb36d3 100644 --- a/FastInject/test/Retro.FastInject.Core.Tests/BasicFunctionalityTests.cs +++ b/FastInject/test/Retro.FastInject.Core.Tests/BasicFunctionalityTests.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; using Retro.FastInject.Annotations; diff --git a/FastInject/test/Retro.FastInject.Core.Tests/DisposableServiceTests.cs b/FastInject/test/Retro.FastInject.Core.Tests/DisposableServiceTests.cs index 8429628..ffa8f9f 100644 --- a/FastInject/test/Retro.FastInject.Core.Tests/DisposableServiceTests.cs +++ b/FastInject/test/Retro.FastInject.Core.Tests/DisposableServiceTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; using Retro.FastInject.Annotations; diff --git a/FastInject/test/Retro.FastInject.Core.Tests/Retro.FastInject.Core.Tests.csproj b/FastInject/test/Retro.FastInject.Core.Tests/Retro.FastInject.Core.Tests.csproj index 202fcbe..37b93dc 100644 --- a/FastInject/test/Retro.FastInject.Core.Tests/Retro.FastInject.Core.Tests.csproj +++ b/FastInject/test/Retro.FastInject.Core.Tests/Retro.FastInject.Core.Tests.csproj @@ -21,7 +21,6 @@ - diff --git a/FastInject/test/Retro.FastInject.Dynamic.Tests/ComplexDependencyResolutionTests.cs b/FastInject/test/Retro.FastInject.Dynamic.Tests/ComplexDependencyResolutionTests.cs index d8c5147..ec4e357 100644 --- a/FastInject/test/Retro.FastInject.Dynamic.Tests/ComplexDependencyResolutionTests.cs +++ b/FastInject/test/Retro.FastInject.Dynamic.Tests/ComplexDependencyResolutionTests.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; using Retro.FastInject.Annotations; diff --git a/FastInject/test/Retro.FastInject.Dynamic.Tests/DynamicDisposableServiceTests.cs b/FastInject/test/Retro.FastInject.Dynamic.Tests/DynamicDisposableServiceTests.cs index 4c5936b..f6a290b 100644 --- a/FastInject/test/Retro.FastInject.Dynamic.Tests/DynamicDisposableServiceTests.cs +++ b/FastInject/test/Retro.FastInject.Dynamic.Tests/DynamicDisposableServiceTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; using Retro.FastInject.Annotations; diff --git a/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridLazyInjectionTests.cs b/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridLazyInjectionTests.cs index a8dc91c..1fae163 100644 --- a/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridLazyInjectionTests.cs +++ b/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridLazyInjectionTests.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; using Retro.FastInject.Annotations; using Retro.FastInject.Core.Tests; diff --git a/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridServiceProviderCoverageTests.cs b/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridServiceProviderCoverageTests.cs index 722c428..33ec924 100644 --- a/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridServiceProviderCoverageTests.cs +++ b/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridServiceProviderCoverageTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; using Retro.FastInject.Annotations; diff --git a/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridServiceProviderTests.cs b/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridServiceProviderTests.cs index a18d676..d7f349a 100644 --- a/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridServiceProviderTests.cs +++ b/FastInject/test/Retro.FastInject.Dynamic.Tests/HybridServiceProviderTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; using Retro.FastInject.Annotations; diff --git a/FastInject/test/Retro.FastInject.Dynamic.Tests/KeyedServiceTests.cs b/FastInject/test/Retro.FastInject.Dynamic.Tests/KeyedServiceTests.cs index 7579fd9..982085f 100644 --- a/FastInject/test/Retro.FastInject.Dynamic.Tests/KeyedServiceTests.cs +++ b/FastInject/test/Retro.FastInject.Dynamic.Tests/KeyedServiceTests.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; using Retro.FastInject.Annotations; diff --git a/FastInject/test/Retro.FastInject.Dynamic.Tests/Retro.FastInject.Dynamic.Tests.csproj b/FastInject/test/Retro.FastInject.Dynamic.Tests/Retro.FastInject.Dynamic.Tests.csproj index 24e272e..0986b04 100644 --- a/FastInject/test/Retro.FastInject.Dynamic.Tests/Retro.FastInject.Dynamic.Tests.csproj +++ b/FastInject/test/Retro.FastInject.Dynamic.Tests/Retro.FastInject.Dynamic.Tests.csproj @@ -21,7 +21,6 @@ - diff --git a/FastInject/test/Retro.FastInject.Tests/Retro.FastInject.Tests.csproj b/FastInject/test/Retro.FastInject.Tests/Retro.FastInject.Tests.csproj index 7428200..5aa6b39 100644 --- a/FastInject/test/Retro.FastInject.Tests/Retro.FastInject.Tests.csproj +++ b/FastInject/test/Retro.FastInject.Tests/Retro.FastInject.Tests.csproj @@ -25,7 +25,6 @@ - diff --git a/FastInject/test/Retro.FastInject.Tests/ServiceHierarchy/DependencyExtensionsTest.cs b/FastInject/test/Retro.FastInject.Tests/ServiceHierarchy/DependencyExtensionsTest.cs index 120d9bd..a916584 100644 --- a/FastInject/test/Retro.FastInject.Tests/ServiceHierarchy/DependencyExtensionsTest.cs +++ b/FastInject/test/Retro.FastInject.Tests/ServiceHierarchy/DependencyExtensionsTest.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using Microsoft.CodeAnalysis; using NUnit.Framework; using Retro.FastInject.Annotations; diff --git a/FastInject/test/Retro.FastInject.Tests/ServiceHierarchy/ServiceManifestTest.cs b/FastInject/test/Retro.FastInject.Tests/ServiceHierarchy/ServiceManifestTest.cs index f76a3cc..98f4bae 100644 --- a/FastInject/test/Retro.FastInject.Tests/ServiceHierarchy/ServiceManifestTest.cs +++ b/FastInject/test/Retro.FastInject.Tests/ServiceHierarchy/ServiceManifestTest.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Immutable; +using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.Extensions.DependencyInjection; @@ -9,7 +8,7 @@ using Retro.FastInject.Generation; using Retro.FastInject.Model.Manifest; using Retro.FastInject.Tests.Utils; -using Retro.FastInject.Utils; +using Retro.SourceGeneratorUtilities.Utilities.Types; namespace Retro.FastInject.Tests.ServiceHierarchy; diff --git a/FastInject/test/Retro.FastInject.Tests/Utils/GeneratorTestHelpers.cs b/FastInject/test/Retro.FastInject.Tests/Utils/GeneratorTestHelpers.cs index 258f56e..21dbbb7 100644 --- a/FastInject/test/Retro.FastInject.Tests/Utils/GeneratorTestHelpers.cs +++ b/FastInject/test/Retro.FastInject.Tests/Utils/GeneratorTestHelpers.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -14,10 +13,17 @@ public static Compilation CreateCompilation(string source, params IEnumerable a.Location) .Where(a => !string.IsNullOrEmpty(a)) .Select(l => MetadataReference.CreateFromFile(l)); - return CSharpCompilation.Create("compilation", - [CSharpSyntaxTree.ParseText(source)], - assemblies, - new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); + + var baseCompilation = CSharpCompilation.Create("compilation", + [CSharpSyntaxTree.ParseText(source)], + assemblies, + new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); + + var generator = new CopyFilesGenerator(); + var driver = CSharpGeneratorDriver.Create(generator); + driver.RunGeneratorsAndUpdateCompilation(baseCompilation, out var outputCompilation, out _); + + return outputCompilation; } public static ITypeSymbol GetTypeSymbol(this Compilation compilation, string typeName) { diff --git a/FastInject/test/Retro.FastInject.Tests/Utils/ParameterExtensionsTest.cs b/FastInject/test/Retro.FastInject.Tests/Utils/ParameterExtensionsTest.cs index 6ec8e10..840a7f4 100644 --- a/FastInject/test/Retro.FastInject.Tests/Utils/ParameterExtensionsTest.cs +++ b/FastInject/test/Retro.FastInject.Tests/Utils/ParameterExtensionsTest.cs @@ -1,10 +1,8 @@ using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.Globalization; -using System.Threading; using Microsoft.CodeAnalysis; using NUnit.Framework; -using Retro.FastInject.Utils; +using Retro.SourceGeneratorUtilities.Utilities.Members; using static Retro.FastInject.Tests.Utils.GeneratorTestHelpers; namespace Retro.FastInject.Tests.Utils; @@ -295,7 +293,7 @@ public ImmutableArray ToMinimalDisplayParts(SemanticModel sem return original.ToMinimalDisplayParts(semanticModel, position, format); } - public bool Equals([NotNullWhen(true)] ISymbol? other, SymbolEqualityComparer equalityComparer) { + public bool Equals(ISymbol? other, SymbolEqualityComparer equalityComparer) { return original.Equals(other, equalityComparer); } diff --git a/ReadOnlyParams/src/Retro.ReadOnlyParams.Annotations/Retro.ReadOnlyParams.Annotations.csproj b/ReadOnlyParams/src/Retro.ReadOnlyParams.Annotations/Retro.ReadOnlyParams.Annotations.csproj deleted file mode 100644 index a362fad..0000000 --- a/ReadOnlyParams/src/Retro.ReadOnlyParams.Annotations/Retro.ReadOnlyParams.Annotations.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - netstandard2.0 - 13 - enable - - Retro.ReadOnlyParams.Annotations - Retro.ReadOnlyParams.Annotations - 1.0.0 - false - - true - snupkg - - true - True - true - - - - bin\Debug\Retro.ReadOnlyParams.Annotations.xml - - - - bin\Release\Retro.ReadOnlyParams.Annotations.xml - true - - - diff --git a/ReadOnlyParams/src/Retro.ReadOnlyParams.Annotations/ReadOnlyAttribute.cs b/ReadOnlyParams/src/Retro.ReadOnlyParams/Annotations/ReadOnlyAttribute.cs similarity index 75% rename from ReadOnlyParams/src/Retro.ReadOnlyParams.Annotations/ReadOnlyAttribute.cs rename to ReadOnlyParams/src/Retro.ReadOnlyParams/Annotations/ReadOnlyAttribute.cs index 9a5f3b1..181bb18 100644 --- a/ReadOnlyParams/src/Retro.ReadOnlyParams.Annotations/ReadOnlyAttribute.cs +++ b/ReadOnlyParams/src/Retro.ReadOnlyParams/Annotations/ReadOnlyAttribute.cs @@ -1,4 +1,7 @@ using System; +#if READONLYPARAMS_GENERATOR +using RhoMicro.CodeAnalysis; +#endif namespace Retro.ReadOnlyParams.Annotations; @@ -12,4 +15,7 @@ namespace Retro.ReadOnlyParams.Annotations; /// /// [AttributeUsage(AttributeTargets.Parameter)] -public class ReadOnlyAttribute : Attribute; \ No newline at end of file +#if READONLYPARAMS_GENERATOR +[IncludeFile] +#endif +internal class ReadOnlyAttribute : Attribute; \ No newline at end of file diff --git a/ReadOnlyParams/src/Retro.ReadOnlyParams/CopyFilesGenerator.cs b/ReadOnlyParams/src/Retro.ReadOnlyParams/CopyFilesGenerator.cs new file mode 100644 index 0000000..2cea232 --- /dev/null +++ b/ReadOnlyParams/src/Retro.ReadOnlyParams/CopyFilesGenerator.cs @@ -0,0 +1,16 @@ +using Microsoft.CodeAnalysis; +using RhoMicro.CodeAnalysis.Generated; + +namespace Retro.ReadOnlyParams; + +/// +/// Represents a source generator that facilitates copying files for use in code generation tasks. +/// +[Generator] +internal class CopyFilesGenerator : IIncrementalGenerator { + + /// + public void Initialize(IncrementalGeneratorInitializationContext context) { + IncludedFileSources.RegisterToContext(context); + } +} \ No newline at end of file diff --git a/ReadOnlyParams/src/Retro.ReadOnlyParams/Retro.ReadOnlyParams.csproj b/ReadOnlyParams/src/Retro.ReadOnlyParams/Retro.ReadOnlyParams.csproj index b0a463d..9881adc 100644 --- a/ReadOnlyParams/src/Retro.ReadOnlyParams/Retro.ReadOnlyParams.csproj +++ b/ReadOnlyParams/src/Retro.ReadOnlyParams/Retro.ReadOnlyParams.csproj @@ -5,10 +5,13 @@ true enable latest + enable + true true true false + $(DefineConstants);READONLYPARAMS_GENERATOR Retro.ReadOnlyParams @@ -40,16 +43,19 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -67,8 +73,6 @@ - @@ -77,15 +81,13 @@ - - - - - True - + + + + diff --git a/ReadOnlyParams/test/Retro.ReadOnlyParams.Tests/ReadonlyParameterSemanticAnalyzerTests.cs b/ReadOnlyParams/test/Retro.ReadOnlyParams.Tests/ReadonlyParameterSemanticAnalyzerTests.cs index 0d31b03..75cf9d3 100644 --- a/ReadOnlyParams/test/Retro.ReadOnlyParams.Tests/ReadonlyParameterSemanticAnalyzerTests.cs +++ b/ReadOnlyParams/test/Retro.ReadOnlyParams.Tests/ReadonlyParameterSemanticAnalyzerTests.cs @@ -172,13 +172,23 @@ await VerifyAnalyzerAsync(test, } private static Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) { + const string attributeDefinition = """ + namespace Retro.ReadOnlyParams.Annotations + { + [System.AttributeUsage(System.AttributeTargets.Parameter)] + public class ReadOnlyAttribute : System.Attribute { } + } + """; + + var test = new CSharpAnalyzerTest { TestCode = source, ReferenceAssemblies = ReferenceAssemblies.Net.Net60, TestState = { AdditionalReferences = { MetadataReference.CreateFromFile(typeof(ReadOnlyAttribute).Assembly.Location) - } + }, + Sources = { attributeDefinition } } }; test.ExpectedDiagnostics.AddRange(expected); diff --git a/ReadOnlyParams/test/Retro.ReadOnlyParams.Tests/Retro.ReadOnlyParams.Tests.csproj b/ReadOnlyParams/test/Retro.ReadOnlyParams.Tests/Retro.ReadOnlyParams.Tests.csproj index 303e26d..7fb58a4 100644 --- a/ReadOnlyParams/test/Retro.ReadOnlyParams.Tests/Retro.ReadOnlyParams.Tests.csproj +++ b/ReadOnlyParams/test/Retro.ReadOnlyParams.Tests/Retro.ReadOnlyParams.Tests.csproj @@ -22,7 +22,6 @@ - diff --git a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Retro.SourceGeneratorUtilities.csproj b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Retro.SourceGeneratorUtilities.csproj index df24071..af40bbd 100644 --- a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Retro.SourceGeneratorUtilities.csproj +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Retro.SourceGeneratorUtilities.csproj @@ -107,10 +107,6 @@ - - - - diff --git a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Templates/AttributeInfoTemplate.mustache b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Templates/AttributeInfoTemplate.mustache index f751b32..d7674d7 100644 --- a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Templates/AttributeInfoTemplate.mustache +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Templates/AttributeInfoTemplate.mustache @@ -9,7 +9,7 @@ using Retro.SourceGeneratorUtilities.Utilities.Types; namespace {{Namespace}}; -public static class {{Name}}Extensions { +internal static class {{Name}}Extensions { public static {{Name}} Get{{Name}}(this AttributeData data) { return data.TryGet{{Name}}(out var info) ? info : throw new InvalidOperationException("Cannot create {{AttributeName}}Info"); diff --git a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Attributes/AttributeInfoTypeExtensions.cs b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Attributes/AttributeInfoTypeExtensions.cs index 1e24a10..46fae1a 100644 --- a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Attributes/AttributeInfoTypeExtensions.cs +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Attributes/AttributeInfoTypeExtensions.cs @@ -183,6 +183,12 @@ private static bool MatchConstructorParameters(IMethodSymbol targetConstructor, return false; } + if (targetParameter.Type.IsSameType()) { + if (modelParameter.Type.IsSameType()) continue; + + return false; + } + if (targetParameter.Type.Equals(modelParameter.Type, SymbolEqualityComparer.Default)) continue; return false; diff --git a/AutoExceptionHandler/src/AutoExceptionHandler/Utilities/MethodExtensions.cs b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Members/MethodExtensions.cs similarity index 80% rename from AutoExceptionHandler/src/AutoExceptionHandler/Utilities/MethodExtensions.cs rename to SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Members/MethodExtensions.cs index c42f318..58a5849 100644 --- a/AutoExceptionHandler/src/AutoExceptionHandler/Utilities/MethodExtensions.cs +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Members/MethodExtensions.cs @@ -1,10 +1,17 @@ using Microsoft.CodeAnalysis; +using Retro.SourceGeneratorUtilities.Utilities.Types; +#if SOURCE_UTILS_GENERATOR +using RhoMicro.CodeAnalysis; +#endif -namespace AutoExceptionHandler.Utilities; +namespace Retro.SourceGeneratorUtilities.Utilities.Members; /// /// Provides extension methods for working with methods represented as . /// +#if SOURCE_UTILS_GENERATOR +[IncludeFile] +#endif internal static class MethodExtensions { /// @@ -20,7 +27,7 @@ public static bool HasCommonReturnType(this IMethodSymbol method, IMethodSymbol return true; } - return !otherMethod.ReturnsVoid && otherMethod.ReturnType.ConvertableTo(method.ReturnType); + return !otherMethod.ReturnsVoid && otherMethod.ReturnType.IsAssignableTo(method.ReturnType); } /// diff --git a/FastInject/src/Retro.FastInject/Utils/ParameterExtensions.cs b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Members/ParameterExtensions.cs similarity index 89% rename from FastInject/src/Retro.FastInject/Utils/ParameterExtensions.cs rename to SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Members/ParameterExtensions.cs index ff9d488..586a592 100644 --- a/FastInject/src/Retro.FastInject/Utils/ParameterExtensions.cs +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Members/ParameterExtensions.cs @@ -1,13 +1,17 @@ -using System; -using System.Linq; -using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis; +#if SOURCE_UTILS_GENERATOR +using RhoMicro.CodeAnalysis; +#endif -namespace Retro.FastInject.Utils; +namespace Retro.SourceGeneratorUtilities.Utilities.Members; /// /// Provides extension methods for objects. /// -public static class ParameterExtensions { +#if SOURCE_UTILS_GENERATOR +[IncludeFile] +#endif +internal static class ParameterExtensions { /// /// Retrieves the default value of the parameter as a string representation. /// diff --git a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Model/Attributes/AttributeInfoConstructorParamOverview.cs b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Model/Attributes/AttributeInfoConstructorParamOverview.cs index ed443c3..8c8d3d6 100644 --- a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Model/Attributes/AttributeInfoConstructorParamOverview.cs +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Model/Attributes/AttributeInfoConstructorParamOverview.cs @@ -30,8 +30,16 @@ public record struct AttributeInfoConstructorParamOverview(IParameterSymbol Symb /// set to . It provides a type representation that is explicitly /// non-nullable, regardless of the original nullable annotation of the parameter type. /// - public string NonNullableType => Type.IsSameType() ? typeof(Type).FullName! : - Type.WithNullableAnnotation(NullableAnnotation.NotAnnotated).ToDisplayString(); + public string NonNullableType { + get { + if (Type.IsSameType()) { + return $"{typeof(Type).FullName}[]"; + } + + return Type.IsSameType() ? typeof(Type).FullName! : + Type.WithNullableAnnotation(NullableAnnotation.NotAnnotated).ToDisplayString(); + } + } /// /// Gets the name of the constructor parameter. diff --git a/FastInject/src/Retro.FastInject/Utils/StringUtils.cs b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/StringUtils.cs similarity index 76% rename from FastInject/src/Retro.FastInject/Utils/StringUtils.cs rename to SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/StringUtils.cs index 9f84d9c..92727bc 100644 --- a/FastInject/src/Retro.FastInject/Utils/StringUtils.cs +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/StringUtils.cs @@ -1,11 +1,16 @@ -using System.Collections.Generic; +#if SOURCE_UTILS_GENERATOR +using RhoMicro.CodeAnalysis; +#endif -namespace Retro.FastInject.Utils; +namespace Retro.SourceGeneratorUtilities.Utilities; /// /// Provides utility methods for string manipulation and operations. /// -public static class StringUtils { +#if SOURCE_UTILS_GENERATOR +[IncludeFile] +#endif +internal static class StringUtils { /// /// Concatenates the elements of a sequence of strings, using the specified separator between each element. /// diff --git a/FastInject/src/Retro.FastInject/Utils/NullableData.cs b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Types/NullableData.cs similarity index 55% rename from FastInject/src/Retro.FastInject/Utils/NullableData.cs rename to SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Types/NullableData.cs index 43b5896..fafc9ab 100644 --- a/FastInject/src/Retro.FastInject/Utils/NullableData.cs +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Types/NullableData.cs @@ -1,6 +1,9 @@ using Microsoft.CodeAnalysis; +#if SOURCE_UTILS_GENERATOR +using RhoMicro.CodeAnalysis; +#endif -namespace Retro.FastInject.Utils; +namespace Retro.SourceGeneratorUtilities.Utilities.Types; /// /// Represents metadata about the nullability of a type and its underlying type. @@ -9,4 +12,7 @@ namespace Retro.FastInject.Utils; /// This struct is used to encapsulate the nullability state of a type and provide /// information about the underlying type if it is nullable. /// -public readonly record struct NullableData(bool IsNullable, ITypeSymbol UnderlyingType); \ No newline at end of file +#if SOURCE_UTILS_GENERATOR +[IncludeFile] +#endif +internal readonly record struct NullableData(bool IsNullable, ITypeSymbol UnderlyingType); \ No newline at end of file diff --git a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Types/TypeExtensions.cs b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Types/TypeExtensions.cs index 676d366..2335d4d 100644 --- a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Types/TypeExtensions.cs +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/Types/TypeExtensions.cs @@ -447,4 +447,245 @@ public static string GetTypeofName(this INamedTypeSymbol type) { var genericArguments = string.Concat(Enumerable.Repeat(",", type.TypeArguments.Length - 1)); return $"{baseName}<{genericArguments}>"; } + + /// + /// Determines whether the specified interface type is valid for use as a type argument in the current context. + /// + /// The interface type represented as an to validate. + /// + /// True if the interface type is valid for use as a type argument; otherwise, false. + /// + public static bool IsValidForTypeArgument(this ITypeSymbol interfaceType) { + if (interfaceType is not INamedTypeSymbol namedType) return true; + + if (IsProblematicInterface(namedType)) { + return false; + } + + // Check if the interface has any static members + var staticMembers = namedType.GetMembers().Where(m => m.IsStatic).ToList(); + if (!staticMembers.Any()) return true; + + foreach (var member in staticMembers) { + // Check for unimplemented static members + if (!HasSpecificImplementation(member)) return false; + + // Check for ambiguous implementations in generic interfaces + if (namedType.IsGenericType && MightHaveAmbiguousImplementation(member)) { + return false; + } + } + + return true; + } + + private static bool MightHaveAmbiguousImplementation(ISymbol member) { + switch (member) { + case IMethodSymbol methodSymbol: + // Check if the method uses type parameters in its signature + return HasTypeParametersInSignature(methodSymbol); + + case IPropertySymbol propertySymbol: + // Check if the property type involves type parameters + return HasTypeParametersInProperty(propertySymbol); + + default: + return false; + } + } + + private static bool HasTypeParametersInSignature(IMethodSymbol method) { + // Check return type + return ContainsTypeParameters(method.ReturnType) || + // Check parameters + method.Parameters.Any(p => ContainsTypeParameters(p.Type)); + } + + private static bool HasTypeParametersInProperty(IPropertySymbol property) { + return ContainsTypeParameters(property.Type); + } + + private static bool ContainsTypeParameters(ITypeSymbol type) { + return type switch { + ITypeParameterSymbol => true, + INamedTypeSymbol namedType => namedType.TypeArguments.Any(ContainsTypeParameters), + _ => false + }; + } + + private static bool HasSpecificImplementation(ISymbol member) { + // For properties + if (member is IPropertySymbol propertySymbol) { + return !propertySymbol.IsAbstract; + } + + // For methods + if (member is IMethodSymbol methodSymbol) { + return !methodSymbol.IsAbstract; + } + + return true; + } + + + private static bool IsProblematicInterface(INamedTypeSymbol type) { + var fullName = type.ToDisplayString(); + + // System.Numerics interfaces + var numericInterfaces = new[] { + "System.Numerics.INumber<", + "System.Numerics.IBinaryFloatingPointIeee754<", + "System.Numerics.IBinaryNumber<", + "System.Numerics.ISignedNumber<", + "System.Numerics.IFloatingPoint<", + "System.Numerics.IFloatingPointIeee754<", + "System.Numerics.IExponentalFunctions<", + "System.Numerics.IPowerFunctions<", + "System.Numerics.ILogarithmicFunctions<", + "System.Numerics.ITrigonometricFunctions<", + "System.Numerics.IHyperbolicFunctions<", + "System.Numerics.IRootFunctions<", + "System.Numerics.IModulusOperators<", + "System.Numerics.IUnaryPlusOperators<", + "System.Numerics.IUnaryNegationOperators<", + "System.Numerics.IIncrementOperators<", + "System.Numerics.IDecrementOperators<" + }; + + // Basic BCL interfaces + var bclInterfaces = new[] { + "System.ISpanFormattable", + "System.IFormattable", + "System.IUtf8SpanFormattable", + "System.IComparable", + "System.IComparable<", + "System.IConvertible", + "System.IEquatable<", + "System.ISpanParsable<", + "System.IParsable<", + "System.IUtf8SpanParsable<", + + // Collections and related + "System.Collections.Generic.IEnumerable<", + "System.Collections.Generic.IAsyncEnumerable<", + "System.Collections.Generic.ICollection<", + "System.Collections.Generic.IList<", + "System.Collections.Generic.ISet<", + "System.Collections.Generic.IDictionary<", + "System.Collections.Generic.IReadOnlyCollection<", + "System.Collections.Generic.IReadOnlyList<", + "System.Collections.Generic.IReadOnlySet<", + "System.Collections.Generic.IReadOnlyDictionary<", + + // Additional common interfaces + "System.IObservable<", + "System.IObserver<", + "System.IProgress<", + "System.IDisposable", + "System.IAsyncDisposable", + "System.ICloneable", + + // Comparison interfaces + "System.IComparer<", + "System.Collections.Generic.IEqualityComparer<", + + // Additional numeric interfaces + "System.IAdditionOperators<", + "System.ISubtractionOperators<", + "System.IMultiplyOperators<", + "System.IDivisionOperators<", + "System.IAdditionOperators<", + "System.IAdditiveIdentity<", + "System.IMultiplicativeIdentity<", + + // Pattern interfaces + "System.IAsyncPattern", + "System.IValueTaskSource<", + "System.IValueTaskSource" + }; + + return numericInterfaces.Concat(bclInterfaces) + .Any(pi => fullName.StartsWith(pi, StringComparison.Ordinal)); + } + + /// + /// Determines whether the specified represents a nullable type + /// and provides information about its underlying type. + /// + /// The type symbol to check for nullability. + /// + /// A instance containing information about the nullability + /// of the type and its underlying type, if applicable. + /// + public static NullableData CheckIfNullable(this ITypeSymbol type) { + if (type is INamedTypeSymbol { ConstructedFrom.SpecialType: SpecialType.System_Nullable_T } namedType) { + return new NullableData(true, namedType.TypeArguments[0]); + } + + return type.NullableAnnotation == NullableAnnotation.Annotated ? new NullableData(true, type.WithNullableAnnotation(NullableAnnotation.None)) : new NullableData(false, type); + } + + /// + /// Constructs a generic type by instantiating it with the specified . + /// + /// The types to be used as the generic type argument for the constructed type. + /// The current Roslyn instance used to access type metadata. + /// The generic type definition to be instantiated, provided as a . + /// + /// An representing the constructed generic type. + /// + /// + /// Thrown if the does not have a or if the metadata for the specified type cannot be found in the . + /// + public static INamedTypeSymbol GetInstantiatedGeneric(this Type type, Compilation compilation, params ITypeSymbol[] elementTypes) { + // Get the ImmutableArray generic type definition from the compilation + if (type.FullName is null) { + throw new InvalidOperationException("Cannot operate on anonymous types."); + } + + var genericType = compilation.GetTypeByMetadataName(type.FullName); + + if (genericType == null) + throw new InvalidOperationException($"Could not find {type.FullName} type"); + + // Construct the generic type with the provided element type(s) + return genericType.Construct(elementTypes); + } + + /// + /// Constructs an instantiated generic type from the provided unbound generic type and type arguments. + /// + /// The unbound generic type represented by an . + /// An array of representing the generic type arguments. + /// + /// An representing the constructed generic type with the provided type arguments. + /// + /// + /// Thrown if the provided type is not an unbound generic type or if the type cannot be constructed with the provided type arguments. + /// + public static INamedTypeSymbol GetInstantiatedGeneric(this ITypeSymbol type, params ITypeSymbol[] elementTypes) { + if (type is not INamedTypeSymbol namedType) { + throw new InvalidOperationException($"Type '{type.ToDisplayString()}' is not an unbound generic."); + } + + // Construct the generic type with the provided element type(s) + return namedType.Construct(elementTypes); + } + + /// + /// Generates a sanitized string representation of the given . + /// For generic types, the result includes a concatenated format of the type's name and its type arguments. + /// + /// The to generate a sanitized name for. + /// + /// A sanitized string representation of the type, formatted as the type name. For generic types, + /// the type arguments are included as an underscore-separated list. + /// + public static string GetSanitizedTypeName(this ITypeSymbol type) { + return type is not INamedTypeSymbol { IsGenericType: true } namedType ? type.Name + : $"{type.Name}_{namedType.TypeArguments + .Select(x => x.GetSanitizedTypeName()) + .Joining("_")}"; + + } } \ No newline at end of file diff --git a/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/XmlCommentUtils.cs b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/XmlCommentUtils.cs new file mode 100644 index 0000000..4a4f3ef --- /dev/null +++ b/SourceGeneratorUtilities/src/Retro.SourceGeneratorUtilities/Utilities/XmlCommentUtils.cs @@ -0,0 +1,48 @@ +using System.Text.RegularExpressions; +using System.Xml; +#if SOURCE_UTILS_GENERATOR +using RhoMicro.CodeAnalysis; +#endif + +namespace Retro.SourceGeneratorUtilities.Utilities; + +/// +/// Provides utility methods for processing and extracting data from XML-based documentation comments. +/// +#if SOURCE_UTILS_GENERATOR +[IncludeFile] +#endif +internal static class XmlCommentUtils { + + private static readonly Regex Trimmer = new(@"\s\s+", RegexOptions.None, TimeSpan.FromSeconds(1)); + + /// + /// Extracts and trims the content of the <summary> tag from an XML comment string. + /// The method removes excessive whitespace, normalizing it to single spaces. + /// + /// The XML comment as a string. Can be null, empty, or contain whitespace. + /// + /// A string containing the trimmed content of the <summary> tag if it exists; null if the tag is absent, + /// the input is null, only whitespace, or improperly formatted. + /// + public static string? GetSummaryTag(this string? xmlComment) { + if (string.IsNullOrWhiteSpace(xmlComment)) { + return null; + } + + var doc = new XmlDocument(); + doc.LoadXml(xmlComment); + + if (doc.DocumentElement is null) { + return null; + } + + if (doc.DocumentElement.FirstChild.NodeType == XmlNodeType.Text) { + return Trimmer.Replace(doc.DocumentElement.InnerText.Trim(), " "); + } + + var summaryElements = doc.DocumentElement.GetElementsByTagName("summary"); + return summaryElements.Count > 0 ? Trimmer.Replace(summaryElements[0].InnerText.Trim(), " ") : null; + } + +} \ No newline at end of file diff --git a/SourceGenerators.sln b/SourceGenerators.sln index 95bfdcc..6d9d6a2 100644 --- a/SourceGenerators.sln +++ b/SourceGenerators.sln @@ -16,8 +16,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoExceptionHandler.Sample EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoExceptionHandler", "AutoExceptionHandler\src\AutoExceptionHandler\AutoExceptionHandler.csproj", "{C7659CA5-4CA7-410B-9928-2E01DD61D700}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoExceptionHandler.Annotations", "AutoExceptionHandler\src\AutoExceptionHandler.Annotations\AutoExceptionHandler.Annotations.csproj", "{0EC0233C-AA2A-44A2-AF46-38EC99110D11}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoExceptionHandler.Tests", "AutoExceptionHandler\tests\AutoExceptionHandler.Tests\AutoExceptionHandler.Tests.csproj", "{0EF989A9-9BCF-479F-9F61-97BBD4DF5EEA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FastInject", "FastInject", "{4E364029-1E8D-4C3C-995C-EBBE7C785593}" @@ -36,8 +34,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retro.FastInject.Sample.Web EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retro.FastInject", "FastInject\src\Retro.FastInject\Retro.FastInject.csproj", "{415DBEFC-2BAE-4DD4-ACB8-E2C06A12202A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retro.FastInject.Annotations", "FastInject\src\Retro.FastInject.Annotations\Retro.FastInject.Annotations.csproj", "{C4EAE41E-2E8F-43DB-B4FC-4AD09FCBDCED}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retro.FastInject.Core", "FastInject\src\Retro.FastInject.Core\Retro.FastInject.Core.csproj", "{561ED6AB-A2E9-4163-BA4D-1254BEACACE7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retro.FastInject.Dynamic", "FastInject\src\Retro.FastInject.Dynamic\Retro.FastInject.Dynamic.csproj", "{C3BCF1E2-FF57-46DD-B672-9042FA5ADB7D}" @@ -59,8 +55,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5602D1FC-E EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retro.ReadOnlyParams", "ReadOnlyParams\src\Retro.ReadOnlyParams\Retro.ReadOnlyParams.csproj", "{12E56546-70EB-4540-B9D3-E0C156117993}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retro.ReadOnlyParams.Annotations", "ReadOnlyParams\src\Retro.ReadOnlyParams.Annotations\Retro.ReadOnlyParams.Annotations.csproj", "{B2330339-651D-4F0C-99FB-6FB9C3375BFB}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retro.ReadOnlyParams.Tests", "ReadOnlyParams\test\Retro.ReadOnlyParams.Tests\Retro.ReadOnlyParams.Tests.csproj", "{F161D5D1-AB45-4C5A-88A7-7776D7D2D2C5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SourceGeneratorUtilities", "SourceGeneratorUtilities", "{5C96FEEB-6328-4B2B-98BC-484087AC4E7C}" @@ -105,7 +99,6 @@ Global {4F803CCC-1A71-4C34-A9EA-EA4FDBF8BE99} = {030D3AFB-65F8-49F9-BD3C-D0AFE51B745D} {5E031908-B4B3-4EBA-B5C4-507A4334DFA8} = {BD0A2E83-13F7-446B-A530-190CCDD25B45} {C7659CA5-4CA7-410B-9928-2E01DD61D700} = {CFB926A7-D465-4774-997A-6047E3785915} - {0EC0233C-AA2A-44A2-AF46-38EC99110D11} = {CFB926A7-D465-4774-997A-6047E3785915} {0EF989A9-9BCF-479F-9F61-97BBD4DF5EEA} = {4F803CCC-1A71-4C34-A9EA-EA4FDBF8BE99} {7A3C6402-65AA-4AA1-BFD5-6859A38A48F8} = {4E364029-1E8D-4C3C-995C-EBBE7C785593} {B88CE161-E84C-458A-8506-8E4824A40AE2} = {4E364029-1E8D-4C3C-995C-EBBE7C785593} @@ -114,7 +107,6 @@ Global {5B6F7BB9-23D7-478E-8DA4-E9A516C885C2} = {7A3C6402-65AA-4AA1-BFD5-6859A38A48F8} {36B4F5BE-C96D-41BB-AE96-8BE8CDC6789B} = {7A3C6402-65AA-4AA1-BFD5-6859A38A48F8} {415DBEFC-2BAE-4DD4-ACB8-E2C06A12202A} = {B88CE161-E84C-458A-8506-8E4824A40AE2} - {C4EAE41E-2E8F-43DB-B4FC-4AD09FCBDCED} = {B88CE161-E84C-458A-8506-8E4824A40AE2} {561ED6AB-A2E9-4163-BA4D-1254BEACACE7} = {B88CE161-E84C-458A-8506-8E4824A40AE2} {C3BCF1E2-FF57-46DD-B672-9042FA5ADB7D} = {B88CE161-E84C-458A-8506-8E4824A40AE2} {6391FF55-A489-4D6F-A8B7-8309EB5E5166} = {29C08276-F023-401C-9FF6-4C04B8DFDD51} @@ -123,7 +115,6 @@ Global {4A352B79-A374-4B1D-A17E-91014470211F} = {6BC6D7AD-0451-4324-9F82-D639F1F9F6AB} {5602D1FC-E06C-4FD2-8C7E-52CFCFE1B40E} = {6BC6D7AD-0451-4324-9F82-D639F1F9F6AB} {12E56546-70EB-4540-B9D3-E0C156117993} = {4A352B79-A374-4B1D-A17E-91014470211F} - {B2330339-651D-4F0C-99FB-6FB9C3375BFB} = {4A352B79-A374-4B1D-A17E-91014470211F} {F161D5D1-AB45-4C5A-88A7-7776D7D2D2C5} = {5602D1FC-E06C-4FD2-8C7E-52CFCFE1B40E} {F479FC9E-D253-4B6E-8993-34CB90174F50} = {5C96FEEB-6328-4B2B-98BC-484087AC4E7C} {8E8A763A-0AAA-4E92-A4AD-1964B3826C7E} = {5C96FEEB-6328-4B2B-98BC-484087AC4E7C} @@ -147,10 +138,6 @@ Global {C7659CA5-4CA7-410B-9928-2E01DD61D700}.Debug|Any CPU.Build.0 = Debug|Any CPU {C7659CA5-4CA7-410B-9928-2E01DD61D700}.Release|Any CPU.ActiveCfg = Release|Any CPU {C7659CA5-4CA7-410B-9928-2E01DD61D700}.Release|Any CPU.Build.0 = Release|Any CPU - {0EC0233C-AA2A-44A2-AF46-38EC99110D11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0EC0233C-AA2A-44A2-AF46-38EC99110D11}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0EC0233C-AA2A-44A2-AF46-38EC99110D11}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0EC0233C-AA2A-44A2-AF46-38EC99110D11}.Release|Any CPU.Build.0 = Release|Any CPU {0EF989A9-9BCF-479F-9F61-97BBD4DF5EEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0EF989A9-9BCF-479F-9F61-97BBD4DF5EEA}.Debug|Any CPU.Build.0 = Debug|Any CPU {0EF989A9-9BCF-479F-9F61-97BBD4DF5EEA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -171,10 +158,6 @@ Global {415DBEFC-2BAE-4DD4-ACB8-E2C06A12202A}.Debug|Any CPU.Build.0 = Debug|Any CPU {415DBEFC-2BAE-4DD4-ACB8-E2C06A12202A}.Release|Any CPU.ActiveCfg = Release|Any CPU {415DBEFC-2BAE-4DD4-ACB8-E2C06A12202A}.Release|Any CPU.Build.0 = Release|Any CPU - {C4EAE41E-2E8F-43DB-B4FC-4AD09FCBDCED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C4EAE41E-2E8F-43DB-B4FC-4AD09FCBDCED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C4EAE41E-2E8F-43DB-B4FC-4AD09FCBDCED}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C4EAE41E-2E8F-43DB-B4FC-4AD09FCBDCED}.Release|Any CPU.Build.0 = Release|Any CPU {561ED6AB-A2E9-4163-BA4D-1254BEACACE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {561ED6AB-A2E9-4163-BA4D-1254BEACACE7}.Debug|Any CPU.Build.0 = Debug|Any CPU {561ED6AB-A2E9-4163-BA4D-1254BEACACE7}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -199,10 +182,6 @@ Global {12E56546-70EB-4540-B9D3-E0C156117993}.Debug|Any CPU.Build.0 = Debug|Any CPU {12E56546-70EB-4540-B9D3-E0C156117993}.Release|Any CPU.ActiveCfg = Release|Any CPU {12E56546-70EB-4540-B9D3-E0C156117993}.Release|Any CPU.Build.0 = Release|Any CPU - {B2330339-651D-4F0C-99FB-6FB9C3375BFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B2330339-651D-4F0C-99FB-6FB9C3375BFB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B2330339-651D-4F0C-99FB-6FB9C3375BFB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B2330339-651D-4F0C-99FB-6FB9C3375BFB}.Release|Any CPU.Build.0 = Release|Any CPU {F161D5D1-AB45-4C5A-88A7-7776D7D2D2C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F161D5D1-AB45-4C5A-88A7-7776D7D2D2C5}.Debug|Any CPU.Build.0 = Debug|Any CPU {F161D5D1-AB45-4C5A-88A7-7776D7D2D2C5}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/SourceGenerators.sln.DotSettings.user b/SourceGenerators.sln.DotSettings.user new file mode 100644 index 0000000..cf35216 --- /dev/null +++ b/SourceGenerators.sln.DotSettings.user @@ -0,0 +1,20 @@ + + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + <SessionState ContinuousTestingMode="0" IsActive="True" Name="GenerateReportMethod" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Solution /> +</SessionState> + + \ No newline at end of file