├── README.md
├── Source
├── AsyncGenerator.Tests
│ ├── logging.settings.json
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TaskConflict
│ │ └── Input
│ │ │ ├── Task.cs
│ │ │ └── TestCase.cs
│ ├── Github
│ │ ├── Issue50
│ │ │ ├── Input
│ │ │ │ ├── IInterface.cs
│ │ │ │ ├── Abstract.cs
│ │ │ │ └── TestCase.cs
│ │ │ └── Output
│ │ │ │ ├── IInterface.txt
│ │ │ │ ├── Abstract.txt
│ │ │ │ └── TestCase.txt
│ │ ├── Issue49
│ │ │ └── Input
│ │ │ │ └── TestCase.cs
│ │ ├── Issue51
│ │ │ └── Input
│ │ │ │ └── TestCase.cs
│ │ └── Issue105
│ │ │ ├── Input
│ │ │ ├── TestCase3.cs
│ │ │ └── TestCase.cs
│ │ │ └── Output
│ │ │ └── TestCase.txt
│ ├── Nameof
│ │ ├── Input
│ │ │ ├── SelfReference.cs
│ │ │ ├── ArgumentFunction.cs
│ │ │ ├── Variable.cs
│ │ │ └── Method.cs
│ │ └── Output
│ │ │ ├── SelfReferenceNewType.txt
│ │ │ ├── MethodPartial.txt
│ │ │ ├── ArgumentFunctionNewType.txt
│ │ │ └── Variable.txt
│ ├── IfDirective
│ │ ├── Input
│ │ │ ├── Empty.cs
│ │ │ ├── TryCatch.cs
│ │ │ ├── VoidReturnType.cs
│ │ │ └── TestCase.cs
│ │ └── Output
│ │ │ └── TryCatchForwardCall.txt
│ ├── app.config
│ ├── AsyncMethodFinder
│ │ ├── Input
│ │ │ ├── ExternalExtensionMethods.cs
│ │ │ ├── GenericParameter.cs
│ │ │ ├── Guards.cs
│ │ │ ├── IgnoreSomeAsyncMethods.cs
│ │ │ ├── ExtensionMethods.cs
│ │ │ ├── ActionFunc.cs
│ │ │ ├── CustomLinqExtensions.cs
│ │ │ └── GenericTypeParameter.cs
│ │ └── Output
│ │ │ ├── ExternalExtensionMethods.txt
│ │ │ └── IgnoreSomeAsyncMethods.txt
│ ├── MethodGeneration
│ │ ├── Input
│ │ │ └── TestCase.cs
│ │ └── Output
│ │ │ └── TestCase.txt
│ ├── ParallelFor
│ │ ├── Input
│ │ │ ├── NoLinq.cs
│ │ │ ├── Formatting.cs
│ │ │ └── Variables.cs
│ │ └── Output
│ │ │ └── NoLinq.txt
│ ├── ParallelForEach
│ │ ├── Input
│ │ │ └── NoLinq.cs
│ │ └── Output
│ │ │ └── NoLinq.txt
│ ├── Fields
│ │ ├── Input
│ │ │ └── Argument.cs
│ │ └── Output
│ │ │ └── ArgumentNewType.txt
│ ├── TryCatch
│ │ ├── Input
│ │ │ ├── ExternalProperty.cs
│ │ │ ├── Cast.cs
│ │ │ ├── Invocation.cs
│ │ │ ├── ElementAccess.cs
│ │ │ ├── IfStatement.cs
│ │ │ ├── AnonymousFunction.cs
│ │ │ ├── Precondition.cs
│ │ │ ├── ObjectCreation.cs
│ │ │ ├── AutoProperty.cs
│ │ │ ├── VirtualAutoProperty.cs
│ │ │ ├── CustomProperty.cs
│ │ │ ├── AbstractAutoProperty.cs
│ │ │ └── InterfaceAutoProperty.cs
│ │ └── Output
│ │ │ ├── AnonymousFunction.txt
│ │ │ ├── IfStatement.txt
│ │ │ ├── Precondition.txt
│ │ │ ├── Cast.txt
│ │ │ └── ElementAccess.txt
│ ├── CancellationTokens
│ │ ├── Input
│ │ │ ├── Params.cs
│ │ │ ├── DefaultParameter.cs
│ │ │ ├── AbstractClass.cs
│ │ │ └── ClassWithLocalAsyncMethods.cs
│ │ └── Output
│ │ │ └── Params.txt
│ ├── SearchInheritedTypes
│ │ ├── Input
│ │ │ ├── Interface.cs
│ │ │ ├── AbstractClass.cs
│ │ │ └── MultipleAsyncCounterparts.cs
│ │ └── Output
│ │ │ └── Interface.txt
│ ├── LocalFunctions
│ │ ├── Input
│ │ │ ├── Expression.cs
│ │ │ ├── Simple.cs
│ │ │ ├── TryCatch.cs
│ │ │ ├── SimpleAsync.cs
│ │ │ ├── Nested.cs
│ │ │ ├── NestedCall.cs
│ │ │ └── ExtensionMethod.cs
│ │ └── Output
│ │ │ ├── Expression.txt
│ │ │ ├── Simple.txt
│ │ │ └── SimpleAsync.txt
│ ├── AsyncReturnType
│ │ └── Input
│ │ │ ├── NullCoalescing.cs
│ │ │ └── TestCase.cs
│ ├── Formatting
│ │ ├── Input
│ │ │ ├── ConfigureAwait.cs
│ │ │ ├── Indentation.cs
│ │ │ ├── IndentCondition.cs
│ │ │ ├── MultilineParameters.cs
│ │ │ ├── MethodBodyBraces.cs
│ │ │ ├── MixingIndent.cs
│ │ │ ├── Await.cs
│ │ │ ├── IndentSwitch.cs
│ │ │ └── NestedClasses.cs
│ │ └── Output
│ │ │ └── ConfigureAwait.txt
│ ├── PrivateMethods
│ │ ├── Input
│ │ │ ├── ExplicitInterface.cs
│ │ │ ├── TestCase.cs
│ │ │ └── UsedByNestedFunction.cs
│ │ └── Output
│ │ │ ├── TestCase.txt
│ │ │ └── ExplicitInterface.txt
│ ├── NewTypes
│ │ ├── Input
│ │ │ ├── NonAsync.cs
│ │ │ ├── AlreadyAsync.cs
│ │ │ ├── MethodWithDelegate.cs
│ │ │ ├── DerivedClasses.cs
│ │ │ ├── DerivedAsyncClass.cs
│ │ │ ├── SubNestedClass.cs
│ │ │ └── NestedCopy.cs
│ │ └── Output
│ │ │ └── AlreadyAsync.txt
│ ├── PreserveReturnType
│ │ ├── Input
│ │ │ ├── FunctionArgument.cs
│ │ │ └── LastStatement.cs
│ │ └── Output
│ │ │ └── FunctionArgument.txt
│ ├── SimpleCircularCall
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── AnonymousFunctions
│ │ ├── Input
│ │ │ ├── Variable.cs
│ │ │ ├── TryCatch.cs
│ │ │ ├── VoidTryCatch.cs
│ │ │ ├── ReturnTypeMismatch.cs
│ │ │ ├── MethodWithDelegate.cs
│ │ │ └── ArrayOfDelegates.cs
│ │ └── Output
│ │ │ ├── Variable.txt
│ │ │ ├── ReturnTypeMismatch.txt
│ │ │ └── ArrayOfDelegates.txt
│ ├── ConfigurationOverride
│ │ └── Input
│ │ │ └── PartialCopy.cs
│ ├── NestedTypes
│ │ ├── Input
│ │ │ ├── TestCase.cs
│ │ │ └── MultipleNested.cs
│ │ └── Output
│ │ │ ├── TestCaseOriginal.txt
│ │ │ ├── MultipleNested.txt
│ │ │ └── TestCase.txt
│ ├── CustomReturnType
│ │ └── Input
│ │ │ ├── SameType.cs
│ │ │ └── TestCase.cs
│ ├── NUnit
│ │ ├── Input
│ │ │ ├── DoesNotThrowTryCatch.cs
│ │ │ ├── AssertThatTryCatch.cs
│ │ │ ├── AssertThatNoToken.cs
│ │ │ ├── NestedAssertThat.cs
│ │ │ ├── SimpleFixture.cs
│ │ │ └── AssertMultiple.cs
│ │ └── Output
│ │ │ ├── AssertThatTryCatch.txt
│ │ │ └── DoesNotThrowTryCatch.txt
│ ├── ExceptionHandling
│ │ └── Input
│ │ │ ├── NoCatchMethod.cs
│ │ │ └── CatchProperty.cs
│ ├── PreprocessorDirectives
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── AsyncProperites
│ │ ├── Input
│ │ │ ├── ArrowGetter.cs
│ │ │ ├── Setter.cs
│ │ │ ├── ArrowSetter.cs
│ │ │ ├── Getter.cs
│ │ │ ├── ArgumentGetter.cs
│ │ │ ├── ListGetter.cs
│ │ │ ├── InitSetter.cs
│ │ │ ├── ExternalGetter.cs
│ │ │ ├── GetterWithAsyncPart.cs
│ │ │ ├── GetAccessor.cs
│ │ │ ├── SetAccessor.cs
│ │ │ ├── InterfaceGetter.cs
│ │ │ ├── AbstractGetter.cs
│ │ │ └── AbstractSetter.cs
│ │ └── Output
│ │ │ ├── GetterNoConversion.txt
│ │ │ └── GetAccessor.txt
│ ├── MethodReferences
│ │ └── Input
│ │ │ └── ForwardCall.cs
│ ├── IgnoreAsyncCounterparts
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── Events
│ │ ├── Input
│ │ │ └── AddRemoveEvent.cs
│ │ └── Output
│ │ │ └── AddRemoveEvent.txt
│ ├── Diagnostics
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── SimpleClassInheritance
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── Plugins
│ │ ├── Input
│ │ │ ├── EmptyRegions.cs
│ │ │ └── TransactionScopeAsyncFlow.cs
│ │ └── Output
│ │ │ └── EmptyRegions.txt
│ ├── SimpleReference
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── Dynamic
│ │ └── Input
│ │ │ └── TypeArgument.cs
│ ├── OutsideMethodFunction
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── PrivateFields
│ │ └── Input
│ │ │ └── UsedByNestedFunction.cs
│ ├── OmitAsync
│ │ └── Input
│ │ │ └── UsingAndTryPreserveAwait.cs
│ ├── DocumentationComments
│ │ └── Input
│ │ │ ├── Comments.cs
│ │ │ └── MissingMembers.cs
│ ├── AbstractClass
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── CSharpFeatures
│ │ └── Input
│ │ │ └── InModifier.cs
│ ├── Sleep
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── PartialCompilation
│ │ ├── Input
│ │ │ └── Ctor.cs
│ │ └── Output
│ │ │ └── Ctor.txt
│ ├── CastOmitAsync
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── NestedNamespaces
│ │ └── Input
│ │ │ └── TestCase.cs
│ ├── Preconditions
│ │ └── Input
│ │ │ └── TestCase.cs
│ └── NullableReferences
│ │ └── Output
│ │ └── NullableRestore.txt
├── AsyncGenerator.CommandLine
│ ├── logging.settings.json
│ └── App.config
├── AsyncGenerator
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── app.config
│ ├── Extensions
│ │ └── Internal
│ │ │ ├── MethodKindExtensions.cs
│ │ │ ├── EnumExtensions.cs
│ │ │ └── AssemblyExtensions.cs
│ ├── Internal
│ │ ├── Annotations.cs
│ │ ├── IDataReference.cs
│ │ ├── DiagnosticData.cs
│ │ ├── LockData.cs
│ │ ├── FieldVariableDataReference.cs
│ │ ├── DefaultPreconditionChecker.cs
│ │ ├── ChildFunctionData.cs
│ │ ├── DelegatePreconditionChecker.cs
│ │ └── TypeDataReference.cs
│ ├── Plugins
│ │ └── Internal
│ │ │ └── AbstractPlugin.cs
│ ├── Transformation
│ │ └── Internal
│ │ │ ├── FieldVariableTransformationResult.cs
│ │ │ ├── AnnotatedNode.cs
│ │ │ ├── FunctionReferenceTransformationResult.cs
│ │ │ └── RootTypeTransformationResult.cs
│ └── Configuration
│ │ └── Internal
│ │ └── ProjectPreprocessorDirectivesConfiguration.cs
├── AsyncGenerator.Core
│ ├── AsyncReturnType.cs
│ ├── ExecutionPhase.cs
│ ├── ReferenceConversion.cs
│ ├── Analyzation
│ │ ├── IMemberAnalyzationResult.cs
│ │ ├── IChildFunctionAnalyzationResult.cs
│ │ ├── ITypeReferenceAnalyzationResult.cs
│ │ ├── IProjectAnalyzationResult.cs
│ │ ├── IAccessorAnalyzationResult.cs
│ │ ├── IMethodAnalyzationResult.cs
│ │ ├── IDocumentAnalyzationResult.cs
│ │ ├── ILockAnalyzationResult.cs
│ │ ├── IMethodSymbolInfo.cs
│ │ ├── IFieldVariableDeclaratorResult.cs
│ │ ├── IReferenceAnalyzationResult.cs
│ │ ├── IFunctionReferenceAnalyzationResult.cs
│ │ ├── IFieldAnalyzationResult.cs
│ │ ├── IPropertyAnalyzationResult.cs
│ │ ├── IBodyFunctionReferenceAnalyzation.cs
│ │ ├── IDelegateArgumentAnalyzationResult.cs
│ │ └── IAnalyzationResult.cs
│ ├── Plugins
│ │ ├── IAlwaysAwaitMethodProvider.cs
│ │ ├── ITypeConversionProvider.cs
│ │ ├── IFieldConversionProvider.cs
│ │ ├── IMethodConversionProvider.cs
│ │ ├── IPreserveMethodReturnTypeProvider.cs
│ │ ├── ISearchForMethodReferencesProvider.cs
│ │ ├── IMethodRequiresCancellationTokenProvider.cs
│ │ ├── IProjectConfigurator.cs
│ │ ├── IPreconditionChecker.cs
│ │ ├── IPlugin.cs
│ │ ├── IDocumentTransformer.cs
│ │ ├── IAsyncCounterpartsFinder.cs
│ │ ├── IMethodOrAccessorTransformer.cs
│ │ ├── IMethodExceptionHandler.cs
│ │ ├── IInvocationExpressionAnalyzer.cs
│ │ ├── IBodyFunctionReferencePostAnalyzer.cs
│ │ ├── IFunctionTransformer.cs
│ │ ├── ITypeTransformer.cs
│ │ └── IFunctionReferenceTransformer.cs
│ ├── Configuration
│ │ ├── ISolutionConfiguration.cs
│ │ ├── IProjectCompileConfiguration.cs
│ │ ├── IProjectPreprocessorDirectivesConfiguration.cs
│ │ ├── IProjectCancellationTokenConfiguration.cs
│ │ ├── IProjectExceptionHandlingConfiguration.cs
│ │ ├── IFluentProjectCompileConfiguration.cs
│ │ ├── IProjectTransformConfiguration.cs
│ │ ├── IProjectDiagnosticsConfiguration.cs
│ │ ├── IFileConfigurator.cs
│ │ ├── IFluentProjectPreprocessorDirectivesConfiguration.cs
│ │ ├── IProjectAnalyzeConfiguration.cs
│ │ ├── IFluentProjectDiagnosticsConfiguration.cs
│ │ ├── IFluentProjectParseConfiguration.cs
│ │ ├── IProjectConfiguration.cs
│ │ └── IProjectDocumentationCommentConfiguration.cs
│ ├── Transformation
│ │ ├── ITransformationResult.cs
│ │ ├── IFunctionReferenceTransformationResult.cs
│ │ ├── IMemberTransformationResult.cs
│ │ ├── IProjectTransformationResult.cs
│ │ ├── IFunctionTransformationTrivia.cs
│ │ ├── ILockTransformationResult.cs
│ │ ├── IMethodTransformationResult.cs
│ │ ├── IAccessorTransformationResult.cs
│ │ ├── ITransformationTrivia.cs
│ │ ├── ITypeTransformationResult.cs
│ │ ├── INamespaceTransformationResult.cs
│ │ ├── ITypeTransformationMetadata.cs
│ │ ├── IFunctionTransformationResult.cs
│ │ └── IMethodOrAccessorTransformationResult.cs
│ ├── MethodGeneration.cs
│ ├── PreprocessorDirectives.cs
│ ├── NamespaceConversion.cs
│ ├── PropertyConversion.cs
│ ├── FieldVariableConversion.cs
│ ├── TypeConversion.cs
│ └── AsyncGenerator.Core.csproj
├── AsyncGenerator.TestCases
│ ├── CustomAttribute.cs
│ ├── IFileReader.cs
│ ├── ExternalReader.cs
│ ├── AsyncProperties.cs
│ ├── ExternalReaderWithToken.cs
│ ├── IExternalInterface.cs
│ ├── StringExtensions.cs
│ ├── AsyncGenerator.TestCases.csproj
│ └── AbstractDataReader.cs
├── AsyncGenerator.TestProjects
│ ├── NullableRestore
│ │ ├── TestCase.cs
│ │ └── NullableRestore.csproj
│ ├── MultiTargetFrameworks
│ │ └── MultiTargetFrameworks.csproj
│ └── Localization
│ │ └── Localization.csproj
└── AsyncGenerator.Configuration.Yaml
│ ├── YamlFileConfigurator.cs
│ └── AsyncGenerator.Configuration.Yaml.csproj
├── .gitmodules
├── .config
└── dotnet-tools.json
├── Nuget.config
└── .github
└── workflows
└── publish.yml
/README.md:
--------------------------------------------------------------------------------
1 | # AsyncGenerator
2 | Generating async c# code using Roslyn
3 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/logging.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "LogLevel": {
3 | "Default": "Error"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.CommandLine/logging.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "LogLevel": {
3 | "Default": "Information"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | [assembly:Parallelizable(ParallelScope.Fixtures)]
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | [assembly: InternalsVisibleTo("AsyncGenerator.Tests")]
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "NHibernate"]
2 | path = Source/ExternalProjects/NHibernate
3 | url = https://github.com/nhibernate/nhibernate-core.git
4 | branch = master
5 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/AsyncReturnType.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core
2 | {
3 | public enum AsyncReturnType
4 | {
5 | Task = 0,
6 | ValueTask
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/ExecutionPhase.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core
2 | {
3 | public enum ExecutionPhase
4 | {
5 | Default = 0,
6 | PostProviders = 1
7 | }
8 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/ReferenceConversion.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core
2 | {
3 | public enum ReferenceConversion
4 | {
5 | Unknown,
6 | Ignore,
7 | ToAsync
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IMemberAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core.Analyzation
2 | {
3 | public interface IMemberAnalyzationResult : IAnalyzationResult
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TaskConflict/Input/Task.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Text;
4 |
5 | namespace AsyncGenerator.Tests.TaskConflict.Input
6 | {
7 | public class Task
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue50/Input/IInterface.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | namespace AsyncGenerator.Tests.Github.Issue50.Input
4 | {
5 | public interface IInterface
6 | {
7 | void Read();
8 |
9 | bool Write(string content);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/.config/dotnet-tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "isRoot": true,
4 | "tools": {
5 | "cake.tool": {
6 | "version": "6.0.0",
7 | "commands": [
8 | "dotnet-cake"
9 | ],
10 | "rollForward": false
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IChildFunctionAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core.Analyzation
2 | {
3 | public interface IChildFunctionAnalyzationResult : IFunctionAnalyzationResult
4 | {
5 | IFunctionAnalyzationResult ParentFunction { get; }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IAlwaysAwaitMethodProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Core.Plugins
4 | {
5 | public interface IAlwaysAwaitMethodProvider : IPlugin
6 | {
7 | bool? AlwaysAwait(IMethodSymbol methodSymbol);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/ITypeConversionProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Core.Plugins
4 | {
5 | public interface ITypeConversionProvider : IPlugin
6 | {
7 | TypeConversion? GetConversion(INamedTypeSymbol typeSymbol);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Nameof/Input/SelfReference.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 |
3 | namespace AsyncGenerator.Tests.Nameof.Input
4 | {
5 | public class SelfReference
6 | {
7 | public void Write()
8 | {
9 | SimpleFile.Write(nameof(Write));
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IFieldConversionProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Core.Plugins
4 | {
5 | public interface IFieldConversionProvider : IPlugin
6 | {
7 | FieldVariableConversion? GetFieldConversion(ISymbol fieldSymbol);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IMethodConversionProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Core.Plugins
4 | {
5 | public interface IMethodConversionProvider : IPlugin
6 | {
7 | MethodConversion? GetConversion(IMethodSymbol methodSymbol);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/ISolutionConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core.Configuration
2 | {
3 | public interface ISolutionConfiguration
4 | {
5 | bool ConcurrentRun { get; }
6 |
7 | bool ApplyChanges { get; }
8 |
9 | string TargetFramework { get; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IPreserveMethodReturnTypeProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Core.Plugins
4 | {
5 | public interface IPreserveMethodReturnTypeProvider : IPlugin
6 | {
7 | bool? PreserveReturnType(IMethodSymbol methodSymbol);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestCases/CustomAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.TestCases
8 | {
9 | public class CustomAttribute : Attribute
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/ISearchForMethodReferencesProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Core.Plugins
4 | {
5 | public interface ISearchForMethodReferencesProvider : IPlugin
6 | {
7 | bool? SearchForMethodReferences(IMethodSymbol methodSymbol);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/IfDirective/Input/Empty.cs:
--------------------------------------------------------------------------------
1 | #if TEST
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AsyncGenerator.Tests.IfDirective.Input
9 | {
10 | class Empty
11 | {
12 | }
13 | }
14 | #endif
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IProjectCompileConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core.Configuration
2 | {
3 | public interface IProjectCompileConfiguration
4 | {
5 | string OutputPath { get; }
6 |
7 | string SymbolsPath { get; }
8 |
9 | string XmlDocumentationPath { get; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IMethodRequiresCancellationTokenProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Core.Plugins
4 | {
5 | public interface IMethodRequiresCancellationTokenProvider : IPlugin
6 | {
7 | bool? RequiresCancellationToken(IMethodSymbol methodSymbol);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/ITransformationResult.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core.Transformation
2 | {
3 | public interface ITransformationResult
4 | {
5 | ///
6 | /// The annotation that is applied on the transformed node
7 | ///
8 | string Annotation { get; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IProjectConfigurator.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.Core.Configuration;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Plugins
5 | {
6 | public interface IProjectConfigurator
7 | {
8 | void Configure(Project project, IFluentProjectConfiguration configuration);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Input/ExternalExtensionMethods.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 |
3 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
4 | {
5 | public class ExternalExtensionMethods
6 | {
7 | public void External(IFileReader reader)
8 | {
9 | reader.Read("test");
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/MethodGeneration.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core
2 | {
3 | public enum MethodGeneration
4 | {
5 | ///
6 | /// The method will be generated
7 | ///
8 | Generate = 1,
9 | ///
10 | /// The method won't be generated
11 | ///
12 | Ignore = 2
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/ITypeReferenceAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Core.Analyzation
4 | {
5 | public interface ITypeReferenceAnalyzationResult : IReferenceAnalyzationResult
6 | {
7 | ITypeAnalyzationResult TypeAnalyzationResult { get; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestProjects/NullableRestore/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace NullableRestore
4 | {
5 | public class TestCase
6 | {
7 | public string? ReadFile()
8 | {
9 | var stream = File.OpenRead("");
10 | stream.Read(new byte[] { }, 0, 100);
11 | stream.Dispose();
12 | return null;
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IProjectPreprocessorDirectivesConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Configuration
5 | {
6 | public interface IProjectPreprocessorDirectivesConfiguration
7 | {
8 | Func AddForMethod { get; }
9 | }
10 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IPreconditionChecker.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 | using Microsoft.CodeAnalysis.CSharp.Syntax;
3 |
4 | namespace AsyncGenerator.Core.Plugins
5 | {
6 | public interface IPreconditionChecker : IPlugin
7 | {
8 | bool IsPrecondition(StatementSyntax statement, SemanticModel semanticModel);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestProjects/MultiTargetFrameworks/MultiTargetFrameworks.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1;net461
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/MethodGeneration/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 |
3 | namespace AsyncGenerator.Tests.MethodGeneration.Input
4 | {
5 | public class TestCase
6 | {
7 | public void Read()
8 | {
9 | SimpleFile.Read();
10 | }
11 |
12 | public void Read2()
13 | {
14 | Read();
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestProjects/Localization/Localization.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 |
5 |
6 | true
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/IFunctionReferenceTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.Core.Analyzation;
2 |
3 | namespace AsyncGenerator.Core.Transformation
4 | {
5 | public interface IFunctionReferenceTransformationResult : ITransformationResult
6 | {
7 | IFunctionReferenceAnalyzationResult AnalyzationResult { get; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/ParallelFor/Input/NoLinq.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using AsyncGenerator.TestCases;
3 |
4 | namespace AsyncGenerator.Tests.ParallelFor.Input
5 | {
6 | public class NoLinq
7 | {
8 | public void Read()
9 | {
10 | Parallel.For(1, 100, i =>
11 | {
12 | SimpleFile.Read();
13 | });
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IPlugin.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using AsyncGenerator.Core.Configuration;
3 | using Microsoft.CodeAnalysis;
4 |
5 | namespace AsyncGenerator.Core.Plugins
6 | {
7 | public interface IPlugin
8 | {
9 | Task Initialize(Project project, IProjectConfiguration configuration, Compilation compilation);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue50/Input/Abstract.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 |
3 | namespace AsyncGenerator.Tests.Github.Issue50.Input
4 | {
5 | public abstract class Abstract : IInterface
6 | {
7 | public virtual void Read()
8 | {
9 | SimpleFile.Read();
10 | }
11 |
12 | public abstract bool Write(string content);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IProjectAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Analyzation
5 | {
6 | public interface IProjectAnalyzationResult
7 | {
8 | Project Project { get; }
9 |
10 | IReadOnlyList Documents { get; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IDocumentTransformer.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.Core.Transformation;
2 | using Microsoft.CodeAnalysis.CSharp.Syntax;
3 |
4 | namespace AsyncGenerator.Core.Plugins
5 | {
6 | public interface IDocumentTransformer: IPlugin
7 | {
8 | CompilationUnitSyntax Transform(IDocumentTransformationResult transformationResult);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/IMemberTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.Core.Analyzation;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Transformation
5 | {
6 | public interface IMemberTransformationResult : ITransformationResult, ITransformationTrivia
7 | {
8 | IMemberAnalyzationResult GetAnalyzationResult();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/ParallelForEach/Input/NoLinq.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using AsyncGenerator.TestCases;
3 |
4 | namespace AsyncGenerator.Tests.ParallelForEach.Input
5 | {
6 | public class NoLinq
7 | {
8 | public void Read()
9 | {
10 | Parallel.ForEach(new []{ "" }, i =>
11 | {
12 | SimpleFile.Read();
13 | });
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/IProjectTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Transformation
5 | {
6 | public interface IProjectTransformationResult
7 | {
8 | Project Project { get; }
9 |
10 | IReadOnlyList Documents { get; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Fields/Input/Argument.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using AsyncGenerator.TestCases;
4 |
5 | namespace AsyncGenerator.Tests.Fields.Input
6 | {
7 | public class Argument
8 | {
9 | private readonly string _test = "test";
10 |
11 | public void Write()
12 | {
13 | var result = SimpleFile.Write(_test);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Extensions/Internal/MethodKindExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Extensions.Internal
4 | {
5 | internal static class MethodKindExtensions
6 | {
7 | public static bool IsPropertyAccessor(this MethodKind kind)
8 | {
9 | return kind == MethodKind.PropertyGet || kind == MethodKind.PropertySet;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.CommandLine/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/ExternalProperty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Tests.TryCatch.Input
8 | {
9 | public class ExternalProperty
10 | {
11 | public string Test()
12 | {
13 | return typeof(AutoProperty).FullName;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue50/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 |
3 | namespace AsyncGenerator.Tests.Github.Issue50.Input
4 | {
5 | public class TestCase : Abstract
6 | {
7 | public override void Read()
8 | {
9 | SimpleFile.Read();
10 | }
11 |
12 | public override bool Write(string content)
13 | {
14 | return SimpleFile.Write(content);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IAsyncCounterpartsFinder.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Plugins
5 | {
6 | public interface IAsyncCounterpartsFinder : IPlugin
7 | {
8 | IEnumerable FindAsyncCounterparts(IMethodSymbol syncMethodSymbol, ITypeSymbol invokedFromType, AsyncCounterpartsSearchOptions options);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/Cast.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Tests.TryCatch.Input
8 | {
9 | public class Cast
10 | {
11 | private readonly long _maxLong = long.MaxValue;
12 |
13 | public int Test()
14 | {
15 | return (int)_maxLong;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/Invocation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 | using AsyncGenerator.TestCases;
5 |
6 | namespace AsyncGenerator.Tests.TryCatch.Input
7 | {
8 | public class Invocation
9 | {
10 | public void Test()
11 | {
12 | SimpleFile.Clear();
13 | }
14 |
15 | public bool Test2()
16 | {
17 | return SimpleFile.IsBusy();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IAccessorAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 |
8 | namespace AsyncGenerator.Core.Analyzation
9 | {
10 | public interface IAccessorAnalyzationResult : IMethodOrAccessorAnalyzationResult
11 | {
12 | SyntaxNode Node { get; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IMethodAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Runtime.CompilerServices;
3 | using Microsoft.CodeAnalysis;
4 | using Microsoft.CodeAnalysis.CSharp.Syntax;
5 |
6 | namespace AsyncGenerator.Core.Analyzation
7 | {
8 | public interface IMethodAnalyzationResult : IMethodOrAccessorAnalyzationResult
9 | {
10 | MethodDeclarationSyntax Node { get; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IProjectCancellationTokenConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using AsyncGenerator.Core.Analyzation;
3 | using Microsoft.CodeAnalysis;
4 |
5 | namespace AsyncGenerator.Core.Configuration
6 | {
7 | public interface IProjectCancellationTokenConfiguration
8 | {
9 | bool Guards { get; }
10 |
11 | Func MethodGeneration { get; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/PreprocessorDirectives.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core
2 | {
3 | public class PreprocessorDirectives
4 | {
5 | public PreprocessorDirectives(string startDirective, string endDirective = null)
6 | {
7 | StartDirective = startDirective;
8 | EndDirective = endDirective;
9 | }
10 |
11 | public string StartDirective { get; }
12 |
13 | public string EndDirective { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Internal/Annotations.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Internal
8 | {
9 | internal static class Annotations
10 | {
11 | public const string TaskReturned = "TaskReturned";
12 | public const string AsyncCallWithTokenOrGuard = "AsyncCallWithTokenOrGuard";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/CancellationTokens/Input/Params.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.CancellationTokens.Input
9 | {
10 | public class Params
11 | {
12 | public void Read(params string[] param)
13 | {
14 | SimpleFile.Read();
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Input/GenericParameter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
9 | {
10 | public class GenericParameter
11 | {
12 | public void Test()
13 | {
14 | SimpleFile.Write(false, "");
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/SearchInheritedTypes/Input/Interface.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.SearchInheritedTypes.Input
9 | {
10 | public class Interface
11 | {
12 | public void Test(IDatabase database)
13 | {
14 | database.Save();
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IMethodOrAccessorTransformer.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.Core.Transformation;
2 |
3 | namespace AsyncGenerator.Core.Plugins
4 | {
5 | public interface IMethodOrAccessorTransformer : IPlugin
6 | {
7 | MethodTransformerResult Transform(IMethodOrAccessorTransformationResult methodTransformResult,
8 | ITypeTransformationMetadata typeMetadata, INamespaceTransformationMetadata namespaceMetadata);
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Input/Guards.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
9 | {
10 | public class Guards
11 | {
12 | public void Test()
13 | {
14 | SimpleFile.Write("");
15 | SimpleFile.Write("");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Input/Expression.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AsyncGenerator.Tests.LocalFunctions.Input
9 | {
10 | public class Expression
11 | {
12 | public void Test()
13 | {
14 | void Read() => SimpleFile.Read();
15 | Read();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TaskConflict/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 |
3 | namespace AsyncGenerator.Tests.TaskConflict.Input
4 | {
5 | public class TestCase
6 | {
7 | public void Method()
8 | {
9 | SimpleFile.Read();
10 | }
11 |
12 | public void WriteLine()
13 | {
14 | System.Console.WriteLine();
15 | }
16 |
17 | public int Read()
18 | {
19 | return System.Console.Read();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IMethodExceptionHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 |
8 | namespace AsyncGenerator.Core.Plugins
9 | {
10 | public interface IMethodExceptionHandler : IPlugin
11 | {
12 | bool? CatchMethodBody(IMethodSymbol methodSymbol, IMethodSymbol argumentOfMethodSymbol);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/IFunctionTransformationTrivia.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 |
8 | namespace AsyncGenerator.Core.Transformation
9 | {
10 | public interface IFunctionTransformationTrivia : ITransformationTrivia
11 | {
12 | SyntaxTrivia BodyLeadingWhitespaceTrivia { get; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/ILockTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Analyzation;
7 |
8 | namespace AsyncGenerator.Core.Transformation
9 | {
10 | public interface ILockTransformationResult : ITransformationResult
11 | {
12 | ILockAnalyzationResult AnalyzationResult { get; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/ElementAccess.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Tests.TryCatch.Input
8 | {
9 | public class ElementAccess
10 | {
11 | private readonly List _list = new List {"Test"};
12 |
13 | public string Test()
14 | {
15 | return _list[10];
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/NamespaceConversion.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core
2 | {
3 | public enum NamespaceConversion
4 | {
5 | ///
6 | /// The conversion will be decided by the analyzer
7 | ///
8 | Unknown = 0,
9 | ///
10 | /// The namespace will not get generated
11 | ///
12 | Ignore,
13 | ///
14 | /// The namespace will be generated
15 | ///
16 | Generate
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/IfStatement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.TryCatch.Input
9 | {
10 | public class IfStatement
11 | {
12 | public bool Success;
13 |
14 | public void Test()
15 | {
16 | if (Success)
17 | SimpleFile.Read();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/IMethodTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using AsyncGenerator.Core.Analyzation;
3 | using Microsoft.CodeAnalysis;
4 | using Microsoft.CodeAnalysis.CSharp.Syntax;
5 |
6 | namespace AsyncGenerator.Core.Transformation
7 | {
8 | public interface IMethodTransformationResult : IMethodOrAccessorTransformationResult
9 | {
10 | new IMethodAnalyzationResult AnalyzationResult { get; }
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncReturnType/Input/NullCoalescing.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Common;
2 |
3 | namespace AsyncGenerator.Tests.AsyncReturnType.Input
4 | {
5 | public class NullCoalescing
6 | {
7 | public void Variables()
8 | {
9 | var connection = GetConnection();
10 | var trx = connection?.BeginTransaction();
11 | trx?.Dispose();
12 | }
13 |
14 | private DbConnection GetConnection()
15 | {
16 | return default;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Input/Simple.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AsyncGenerator.Tests.LocalFunctions.Input
9 | {
10 | public class Simple
11 | {
12 | public void Test()
13 | {
14 | void Read()
15 | {
16 | SimpleFile.Read();
17 | }
18 | Read();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Input/IgnoreSomeAsyncMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
9 | {
10 | public class IgnoreSomeAsyncMethods
11 | {
12 | public void Read()
13 | {
14 | SimpleFile.Read();
15 | SimpleFile.Write("");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Input/ConfigureAwait.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.Formatting.Input
9 | {
10 | public class ConfigureAwait
11 | {
12 | public void Test()
13 | {
14 | var obj = new
15 | {
16 | test = SimpleFile.Write("")
17 | };
18 |
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PrivateMethods/Input/ExplicitInterface.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq.Expressions;
4 | using AsyncGenerator.TestCases;
5 |
6 | namespace AsyncGenerator.Tests.PrivateMethods.Input
7 | {
8 | public interface IInterface
9 | {
10 | void Read();
11 | }
12 |
13 | public class ExplicitInterface : IInterface
14 | {
15 | void IInterface.Read()
16 | {
17 | SimpleFile.Read();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Internal/IDataReference.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Analyzation;
7 | using Microsoft.CodeAnalysis;
8 |
9 | namespace AsyncGenerator.Internal
10 | {
11 | internal interface IDataReference : IReferenceAnalyzationResult
12 | {
13 | AbstractData Data { get; }
14 |
15 | AbstractData ReferenceData { get; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NewTypes/Input/NonAsync.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NewTypes.Input
9 | {
10 | public class NonAsync : IDisposable
11 | {
12 | public void Read()
13 | {
14 |
15 | }
16 |
17 |
18 | public void Dispose()
19 | {
20 | SimpleFile.Read();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PreserveReturnType/Input/FunctionArgument.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 | using NUnit.Framework;
8 |
9 | namespace AsyncGenerator.Tests.PreserveReturnType.Input
10 | {
11 | public class FunctionArgument
12 | {
13 | public void Test()
14 | {
15 | Assert.DoesNotThrow(SimpleFile.Read);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/IAccessorTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Analyzation;
7 |
8 | namespace AsyncGenerator.Core.Transformation
9 | {
10 | public interface IAccessorTransformationResult : IMethodOrAccessorTransformationResult
11 | {
12 | new IAccessorAnalyzationResult AnalyzationResult { get; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestCases/IFileReader.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace AsyncGenerator.TestCases
4 | {
5 | public class FileResult
6 | {
7 |
8 | }
9 |
10 | public interface IFileReader
11 | {
12 | FileResult Read(string path);
13 | }
14 |
15 | public static class FileReaderExtensions
16 | {
17 | public static Task ReadAsync(this IFileReader reader, string path)
18 | {
19 | return Task.FromResult(new FileResult());
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Input/Indentation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.Formatting.Input
9 | {
10 | public class Indentation
11 | {
12 | public void Test()
13 | {
14 | SimpleFile.Read();
15 | }
16 |
17 | public void Test2()
18 | {
19 | SimpleFile.Read();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IInvocationExpressionAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.Core.Analyzation;
2 | using Microsoft.CodeAnalysis;
3 | using Microsoft.CodeAnalysis.CSharp.Syntax;
4 |
5 | namespace AsyncGenerator.Core.Plugins
6 | {
7 | public interface IInvocationExpressionAnalyzer : IPlugin
8 | {
9 | void AnalyzeInvocationExpression(InvocationExpressionSyntax invocation, IBodyFunctionReferenceAnalyzation functionReferenceAnalyzation, SemanticModel semanticModel);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/SimpleCircularCall/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 |
3 | namespace AsyncGenerator.Tests.SimpleCircularCall.Input
4 | {
5 | public class TestCase
6 | {
7 | public void Method1()
8 | {
9 | Method2();
10 | }
11 |
12 | public void Method2()
13 | {
14 | if (!ReadFile())
15 | {
16 | Method1();
17 | }
18 | }
19 |
20 | public bool ReadFile()
21 | {
22 | SimpleFile.Read();
23 | return true;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IBodyFunctionReferencePostAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Analyzation;
7 |
8 | namespace AsyncGenerator.Core.Plugins
9 | {
10 | public interface IBodyFunctionReferencePostAnalyzer : IPlugin
11 | {
12 | void PostAnalyzeBodyFunctionReference(IBodyFunctionReferenceAnalyzation functionReferenceAnalyzation);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestProjects/NullableRestore/NullableRestore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | 8.0
5 | enable
6 | enable
7 |
8 |
9 | true
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AnonymousFunctions/Input/Variable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AnonymousFunctions.Input
9 | {
10 | public class Variable
11 | {
12 | public void Test()
13 | {
14 | SimpleFile.Read();
15 | Action action = () =>
16 | {
17 | SimpleFile.Read();
18 | };
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue49/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq.Expressions;
4 | using AsyncGenerator.TestCases;
5 |
6 | namespace AsyncGenerator.Tests.Github.Issue49.Input
7 | {
8 | public class TestCase
9 | {
10 | private const string Content = "test";
11 |
12 | public void Write()
13 | {
14 | SimpleFile.Write(GetContent());
15 | }
16 |
17 | private static string GetContent() => $"_{Content}_";
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Input/TryCatch.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AsyncGenerator.Tests.LocalFunctions.Input
9 | {
10 | public class TryCatch
11 | {
12 | public void Test()
13 | {
14 | void Read()
15 | {
16 | SimpleFile.Clear();
17 | SimpleFile.Read();
18 | }
19 | Read();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Input/SimpleAsync.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AsyncGenerator.Tests.LocalFunctions.Input
9 | {
10 | public class SimpleAsync
11 | {
12 | public void Test()
13 | {
14 | void Read()
15 | {
16 | SimpleFile.Read();
17 | SimpleFile.Read();
18 | }
19 | Read();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/ConfigurationOverride/Input/PartialCopy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.ConfigurationOverride.Input
9 | {
10 | public class PartialCopy
11 | {
12 | public void Read()
13 | {
14 | Copy();
15 | SimpleFile.Read();
16 | }
17 |
18 | public void Copy()
19 | {
20 |
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AnonymousFunctions/Input/TryCatch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AnonymousFunctions.Input
9 | {
10 | public class TryCatch
11 | {
12 | public void Test()
13 | {
14 | Runner.RunGeneric(() =>
15 | {
16 | SimpleFile.Clear();
17 | return SimpleFile.Write("");
18 | });
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AnonymousFunctions/Input/VoidTryCatch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AnonymousFunctions.Input
9 | {
10 | public class VoidTryCatch
11 | {
12 | public void Test()
13 | {
14 | Runner.RunVoid(() =>
15 | {
16 | SimpleFile.Clear();
17 | SimpleFile.Write("");
18 | });
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/IfDirective/Input/TryCatch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Tests.IfDirective.Input
8 | {
9 | public class TryCatch
10 | {
11 | public int Test()
12 | {
13 | #if TEST
14 | var result = new Random();
15 | return result.Next() + 1;
16 | #else
17 | var result = new Random();
18 | return result.Next();
19 | #endif
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Nameof/Input/ArgumentFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.Nameof.Input
10 | {
11 | public class ArgumentFunction
12 | {
13 | public Thread Test()
14 | {
15 | return new Thread(() =>
16 | {
17 | SimpleFile.Write(nameof(Test));
18 | });
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestCases/ExternalReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.TestCases
8 | {
9 | public class ExternalReader
10 | {
11 | public virtual bool Read()
12 | {
13 | SimpleFile.Read();
14 | return true;
15 | }
16 |
17 | public virtual async Task ReadAsync()
18 | {
19 | await SimpleFile.ReadAsync();
20 | return true;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AnonymousFunctions/Input/ReturnTypeMismatch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AnonymousFunctions.Input
9 | {
10 | public class ReturnTypeMismatch
11 | {
12 | public void Test()
13 | {
14 | Runner.Run(s =>
15 | {
16 | SimpleFile.Clear();
17 | SimpleFile.Write("");
18 | });
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NestedTypes/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NestedTypes.Input
9 | {
10 | public class TestCase
11 | {
12 | public class Child
13 | {
14 | public void Read()
15 | {
16 | SimpleFile.Read();
17 | }
18 | }
19 |
20 | public void VoidMethod()
21 | {
22 |
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/AnonymousFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.TryCatch.Input
9 | {
10 | public class AnonymousFunction
11 | {
12 | public virtual bool Success { get; set; }
13 |
14 | public void Test()
15 | {
16 | Runner.Run(s =>
17 | {
18 | Success = true;
19 | });
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IProjectExceptionHandlingConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 |
8 | namespace AsyncGenerator.Core.Configuration
9 | {
10 | public interface IProjectExceptionHandlingConfiguration
11 | {
12 | Predicate CatchPropertyGetterCalls { get; }
13 |
14 | Func CatchFunctionBody { get; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/ITransformationTrivia.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 |
8 | namespace AsyncGenerator.Core.Transformation
9 | {
10 | public interface ITransformationTrivia
11 | {
12 | SyntaxTrivia LeadingWhitespaceTrivia { get; set; }
13 |
14 | SyntaxTrivia EndOfLineTrivia { get; set; }
15 |
16 | SyntaxTrivia IndentTrivia { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/Precondition.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.TryCatch.Input
9 | {
10 | public class Precondition
11 | {
12 | public virtual bool Success { get; set; }
13 |
14 | public void Test()
15 | {
16 | if (Success)
17 | {
18 | throw new NotSupportedException();
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/CustomReturnType/Input/SameType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.CustomReturnType.Input
9 | {
10 | public class SameType
11 | {
12 | public void Read()
13 | {
14 | SimpleFile.Read();
15 | }
16 |
17 | public void ReadAsync()
18 | {
19 | SimpleFile.ReadAsync().GetAwaiter().GetResult();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NUnit/Input/DoesNotThrowTryCatch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 | using NUnit.Framework;
8 |
9 | namespace AsyncGenerator.Tests.NUnit.Input
10 | {
11 | public class DoesNotThrowTryCatch
12 | {
13 | public void Test()
14 | {
15 | Assert.DoesNotThrow(() =>
16 | {
17 | SimpleFile.Clear();
18 | SimpleFile.Read();
19 | });
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/ParallelFor/Input/Formatting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.ParallelFor.Input
9 | {
10 | public class Formatting
11 | {
12 | public void Test()
13 | {
14 | Parallel
15 | .For
16 | (
17 | 1,
18 | 12,
19 | i =>
20 | {
21 | SimpleFile.Read();
22 | }
23 | );
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/ITypeTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using AsyncGenerator.Core.Analyzation;
3 |
4 | namespace AsyncGenerator.Core.Transformation
5 | {
6 | public interface ITypeTransformationResult : IMemberTransformationResult
7 | {
8 | ITypeAnalyzationResult AnalyzationResult { get; }
9 |
10 | ///
11 | /// All transformed methods inside this type
12 | ///
13 | IReadOnlyList TransformedMethods { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Input/Nested.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AsyncGenerator.Tests.LocalFunctions.Input
9 | {
10 | public class Nested
11 | {
12 | public void Test()
13 | {
14 | void Read()
15 | {
16 | void ReadNested()
17 | {
18 | SimpleFile.Read();
19 | }
20 | ReadNested();
21 | }
22 | Read();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Nameof/Input/Variable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 | using AsyncGenerator.TestCases;
9 | using NUnit.Framework;
10 |
11 | namespace AsyncGenerator.Tests.Nameof.Input
12 | {
13 | public class Variable
14 | {
15 | public void Test()
16 | {
17 | var region = nameof(Test);
18 | SimpleFile.Write(region);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NewTypes/Input/AlreadyAsync.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using AsyncGenerator.TestCases;
3 |
4 | namespace AsyncGenerator.Tests.NewTypes.Input
5 | {
6 | public class AlreadyAsync
7 | {
8 | public void Read()
9 | {
10 | SimpleFile.Read();
11 | }
12 |
13 | public void Read2()
14 | {
15 | }
16 |
17 | public Task Read2Async()
18 | {
19 | return SimpleFile.ReadAsync();
20 | }
21 |
22 | public Task Read3Async()
23 | {
24 | return SimpleFile.ReadAsync();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NewTypes/Input/MethodWithDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NewTypes.Input
9 | {
10 | public class MethodWithDelegate
11 | {
12 | public void Test()
13 | {
14 | Read(() => SimpleFile.Read());
15 | }
16 |
17 | public void Read(Action action)
18 | {
19 | action();
20 | SimpleFile.Read();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Plugins/Internal/AbstractPlugin.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using AsyncGenerator.Configuration;
3 | using AsyncGenerator.Core.Configuration;
4 | using AsyncGenerator.Core.Plugins;
5 | using Microsoft.CodeAnalysis;
6 |
7 | namespace AsyncGenerator.Plugins.Internal
8 | {
9 | internal abstract class AbstractPlugin : IPlugin
10 | {
11 | public virtual Task Initialize(Project project, IProjectConfiguration configuration, Compilation compilation)
12 | {
13 | return Task.CompletedTask;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Input/NestedCall.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AsyncGenerator.Tests.LocalFunctions.Input
9 | {
10 | public class NestedCall
11 | {
12 | public void Test()
13 | {
14 | LocalRead();
15 | void LocalRead()
16 | {
17 | Read();
18 | }
19 | }
20 |
21 | public void Read()
22 | {
23 | SimpleFile.Read();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NUnit/Input/AssertThatTryCatch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 | using NUnit.Framework;
8 |
9 | namespace AsyncGenerator.Tests.NUnit.Input
10 | {
11 | public class AssertThatTryCatch
12 | {
13 | public void Test()
14 | {
15 | Assert.That(() =>
16 | {
17 | SimpleFile.Clear();
18 | return SimpleFile.Write("");
19 | }, Throws.Nothing);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NestedTypes/Output/TestCaseOriginal.txt:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NestedTypes.Input
9 | {
10 | public partial class TestCase
11 | {
12 | public partial class Child
13 | {
14 | public void Read()
15 | {
16 | SimpleFile.Read();
17 | }
18 | }
19 |
20 | public void VoidMethod()
21 | {
22 |
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/INamespaceTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using AsyncGenerator.Core.Analyzation;
3 |
4 | namespace AsyncGenerator.Core.Transformation
5 | {
6 | public interface INamespaceTransformationResult : IMemberTransformationResult
7 | {
8 | INamespaceAnalyzationResult AnalyzationResult { get; }
9 |
10 | ///
11 | /// All transformed types inside this namespace
12 | ///
13 | IReadOnlyList TransformedTypes { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/SearchInheritedTypes/Input/AbstractClass.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Data.Common;
5 | using System.Data.SqlClient;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using AsyncGenerator.TestCases;
10 |
11 | namespace AsyncGenerator.Tests.SearchInheritedTypes.Input
12 | {
13 | public class AbstractClass
14 | {
15 | public int Test(SqlCommand command)
16 | {
17 | return command.ExecuteNonQuery();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IFluentProjectCompileConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core.Configuration
2 | {
3 | public interface IFluentProjectCompileConfiguration
4 | {
5 | ///
6 | /// Set the path where the symbols will be placed
7 | ///
8 | IFluentProjectCompileConfiguration SymbolsPath(string path);
9 |
10 | ///
11 | /// Set the path where the xml documentation will be placed
12 | ///
13 | IFluentProjectCompileConfiguration XmlDocumentationPath(string path);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/CustomReturnType/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using AsyncGenerator.TestCases;
4 |
5 | namespace AsyncGenerator.Tests.CustomReturnType.Input
6 | {
7 | public class TestCase
8 | {
9 | public IEnumerable GetData()
10 | {
11 | SimpleFile.Read();
12 | return Enumerable.Empty();
13 | }
14 |
15 | public IAsyncEnumerable GetDataAsync()
16 | {
17 | SimpleFile.ReadAsync();
18 | return AsyncEnumerable.Empty();
19 | }
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/ExceptionHandling/Input/NoCatchMethod.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.ExceptionHandling.Input
9 | {
10 | public class NoCatchMethod
11 | {
12 | public void Test()
13 | {
14 | SimpleFile.Clear();
15 | SimpleFile.Read();
16 | }
17 |
18 | public void Test2()
19 | {
20 | SimpleFile.Clear();
21 | SimpleFile.Read();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Input/IndentCondition.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using AsyncGenerator.TestCases;
3 |
4 | namespace AsyncGenerator.Tests.Formatting.Input
5 | {
6 | public class IndentCondition
7 | {
8 | public void Test(string value)
9 | {
10 | if (value == null)
11 | throw new ArgumentNullException(nameof(value));
12 |
13 | SimpleFile.Read();
14 | value = value == "null" ? "test" : value;
15 | value = value != "test"
16 | ? "val" : value;
17 | value = value != "test"
18 | ? "val"
19 | : value;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncReturnType/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | #if NETCOREAPP2_1_OR_GREATER
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.AsyncReturnType.Input
10 | {
11 | public class TestCase
12 | {
13 | public void Read()
14 | {
15 | SimpleFile.ReadValue();
16 | }
17 |
18 | public bool Write(string content)
19 | {
20 | return SimpleFile.WriteValue(content);
21 | }
22 | }
23 | }
24 | #endif
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IProjectTransformConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core.Configuration
2 | {
3 | public interface IProjectTransformConfiguration
4 | {
5 | string AsyncFolder { get; }
6 |
7 | bool LocalFunctions { get; }
8 |
9 | string AsyncLockFullTypeName { get; }
10 |
11 | string AsyncLockMethodName { get; }
12 |
13 | bool ConcurrentRun { get; }
14 |
15 | IProjectDocumentationCommentConfiguration DocumentationComments { get; }
16 |
17 | IProjectPreprocessorDirectivesConfiguration PreprocessorDirectives { get; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Input/ExtensionMethod.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace AsyncGenerator.Tests.LocalFunctions.Input
5 | {
6 | public class ExtensionMethod
7 | {
8 | public void Test()
9 | {
10 | TType GetFirstOrDefault(TType item) where TType : class
11 | {
12 | return (from e in new EnumerableQuery(new List())
13 | where e.Equals(item)
14 | select e
15 | ).FirstOrDefault();
16 |
17 | }
18 | var result = GetFirstOrDefault("test");
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/SearchInheritedTypes/Input/MultipleAsyncCounterparts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Data.Common;
5 | using System.Data.SqlClient;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using AsyncGenerator.TestCases;
10 |
11 | namespace AsyncGenerator.Tests.SearchInheritedTypes.Input
12 | {
13 | public class MultipleAsyncCounterparts
14 | {
15 | public bool Test(AbstractDataReader reader)
16 | {
17 | return reader.NextResult();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IFunctionTransformer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Transformation;
7 | using Microsoft.CodeAnalysis;
8 |
9 | namespace AsyncGenerator.Core.Plugins
10 | {
11 | public interface IFunctionTransformer : IPlugin
12 | {
13 | SyntaxNode Transform(IFunctionTransformationResult functionTransformResult,
14 | ITypeTransformationMetadata typeMetadata, INamespaceTransformationMetadata namespaceMetadata);
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IDocumentAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Microsoft.CodeAnalysis;
3 | using Microsoft.CodeAnalysis.CSharp.Syntax;
4 |
5 | namespace AsyncGenerator.Core.Analyzation
6 | {
7 | public interface IDocumentAnalyzationResult
8 | {
9 | Document Document { get; }
10 |
11 | CompilationUnitSyntax Node { get; }
12 |
13 | INamespaceAnalyzationResult GlobalNamespace { get; }
14 |
15 | IEnumerable AllTypes { get; }
16 |
17 | IEnumerable AllNamespaces { get; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IProjectDiagnosticsConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 |
8 | namespace AsyncGenerator.Core.Configuration
9 | {
10 | public interface IProjectDiagnosticsConfiguration
11 | {
12 | bool Enabled { get; }
13 |
14 | Predicate CanDiagnoseDocument { get; }
15 |
16 | Predicate CanDiagnoseType { get; }
17 |
18 | Predicate CanDiagnoseMethod { get;}
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Nameof/Input/Method.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using AsyncGenerator.TestCases;
3 |
4 | namespace AsyncGenerator.Tests.Nameof.Input
5 | {
6 | public class Method
7 | {
8 | [DefaultValue(nameof(Write))]
9 | public void Write()
10 | {
11 | SimpleFile.Write(nameof(DoSomething));
12 | }
13 |
14 | private void DoSomething()
15 | {
16 |
17 | }
18 |
19 | [DefaultValue(nameof(DoSomething2))]
20 | public void Read()
21 | {
22 | SimpleFile.Read();
23 | }
24 |
25 | private void DoSomething2()
26 | {
27 |
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PreprocessorDirectives/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 |
3 | namespace AsyncGenerator.Tests.PreprocessorDirectives.Input
4 | {
5 | public class TestCase
6 | {
7 | ///
8 | /// Test
9 | ///
10 | public void Read()
11 | {
12 | SimpleFile.Read();
13 | }
14 |
15 | public void Read2()
16 | {
17 | SimpleFile.Read();
18 | }
19 |
20 | #region MyRegion
21 | #endregion
22 |
23 | public void Read3()
24 | {
25 | SimpleFile.Read();
26 | }
27 |
28 | #region MyRegion2
29 | #endregion
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/ObjectCreation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 |
5 | namespace AsyncGenerator.Tests.TryCatch.Input
6 | {
7 | public class ObjectCreation
8 | {
9 | public MemoryStream Test(byte[] buffer)
10 | {
11 | var test = new MemoryStream(buffer);
12 | return test;
13 | }
14 |
15 | public StringBuilder Test2()
16 | {
17 | var test = new StringBuilder();
18 | return test;
19 | }
20 |
21 | public StringBuilder Test3()
22 | {
23 | var test = new StringBuilder{};
24 | return test;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestCases/AsyncProperties.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.TestCases
8 | {
9 | public class AsyncProperties
10 | {
11 | public static bool Success { get; }
12 |
13 | public static Task GetSuccessAsync()
14 | {
15 | return Task.FromResult(true);
16 | }
17 |
18 | public static string Write { get; set; }
19 |
20 | public static async Task SetWriteAsync(string value)
21 | {
22 | await Task.Yield();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AnonymousFunctions/Input/MethodWithDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 | using NUnit.Framework;
8 |
9 | namespace AsyncGenerator.Tests.AnonymousFunctions.Input
10 | {
11 | public class MethodWithDelegate
12 | {
13 | public void Test()
14 | {
15 | Assert.DoesNotThrow(() => Read(s => Console.WriteLine(s)));
16 | }
17 |
18 | public void Read(Action action)
19 | {
20 | SimpleFile.Read();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/ArrowGetter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class ArrowGetter
11 | {
12 | public bool WriteSuccess => Write();
13 |
14 | private bool Write()
15 | {
16 | return SimpleFile.Write("");
17 | }
18 |
19 | protected void CheckSuccess()
20 | {
21 | if (WriteSuccess)
22 | {
23 | return;
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/MethodReferences/Input/ForwardCall.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.CompilerServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Xml.Serialization;
8 | using AsyncGenerator.TestCases;
9 |
10 | namespace AsyncGenerator.Tests.MethodReferences.Input
11 | {
12 | public class ForwardCall
13 | {
14 | [Custom]
15 | public void Test()
16 | {
17 | SimpleFile.Read();
18 | }
19 |
20 | [Custom]
21 | public void ForwardTest()
22 | {
23 | Test();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/ITypeTransformer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Transformation;
7 | using Microsoft.CodeAnalysis.CSharp.Syntax;
8 |
9 | namespace AsyncGenerator.Core.Plugins
10 | {
11 | public interface ITypeTransformer : IPlugin
12 | {
13 | TypeDeclarationSyntax Transform(TypeDeclarationSyntax transformedNode, ITypeTransformationResult transformationResult,
14 | INamespaceTransformationMetadata namespaceMetadata, bool missingMembers);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/Setter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class Setter
11 | {
12 | public string WriteSuccess
13 | {
14 | set { Write(value); }
15 | }
16 |
17 | private bool Write(string value)
18 | {
19 | return SimpleFile.Write(value);
20 | }
21 |
22 | protected void SetSuccess()
23 | {
24 | WriteSuccess = "";
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestCases/ExternalReaderWithToken.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace AsyncGenerator.TestCases
9 | {
10 | public class ExternalReaderWithToken
11 | {
12 | public virtual bool Read()
13 | {
14 | SimpleFile.Read();
15 | return true;
16 | }
17 |
18 | public virtual async Task ReadAsync(CancellationToken cancellationToken)
19 | {
20 | await SimpleFile.ReadAsync(cancellationToken);
21 | return true;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestCases/IExternalInterface.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace AsyncGenerator.TestCases
9 | {
10 | public interface IExternalInterface
11 | {
12 | void Method();
13 |
14 | bool Method2();
15 |
16 | bool Method3();
17 |
18 | Task MethodAsync();
19 |
20 | Task Method2Async(CancellationToken cancellationToken);
21 |
22 | Task Method3Async(CancellationToken cancellationToken = default(CancellationToken));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/IgnoreAsyncCounterparts/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.IgnoreAsyncCounterparts.Input
9 | {
10 | public class TestCase
11 | {
12 | public void Test()
13 | {
14 | Read();
15 | SimpleFile.Read();
16 | }
17 |
18 | public void Read()
19 | {
20 | SimpleFile.Read();
21 | }
22 |
23 | public Task ReadAsync()
24 | {
25 | return SimpleFile.ReadAsync();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/ArrowSetter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class ArrowSetter
11 | {
12 | public string WriteSuccess
13 | {
14 | set => Write(value);
15 | }
16 |
17 | private bool Write(string value)
18 | {
19 | return SimpleFile.Write(value);
20 | }
21 |
22 | protected void SetSuccess()
23 | {
24 | WriteSuccess = "";
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Events/Input/AddRemoveEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.Events.Input
9 | {
10 | public class AddRemoveEvent
11 | {
12 | public delegate void Delegate();
13 |
14 | public event Delegate Event = () => {};
15 |
16 | public void Test()
17 | {
18 | Event += Read;
19 | Event -= Read;
20 | Event();
21 | }
22 |
23 | public void Read()
24 | {
25 | SimpleFile.Read();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PreserveReturnType/Input/LastStatement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.PreserveReturnType.Input
10 | {
11 | public class LastStatement
12 | {
13 | private void Read()
14 | {
15 | SimpleFile.Read();
16 | }
17 |
18 | public void Test()
19 | {
20 | Runner.RunWithIntParameter(i =>
21 | {
22 | SimpleFile.Read();
23 | });
24 |
25 | Read();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PrivateMethods/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq.Expressions;
4 | using AsyncGenerator.TestCases;
5 |
6 | namespace AsyncGenerator.Tests.PrivateMethods.Input
7 | {
8 | public class TestCase
9 | {
10 | public event Action Event = () => { };
11 |
12 | public void Read()
13 | {
14 | SimpleFile.Read();
15 | Event += ReadInternal;
16 | }
17 |
18 | private void ReadInternal()
19 | {
20 | SimpleFile.Read();
21 | }
22 |
23 | protected void TriggetEvent()
24 | {
25 | Event?.Invoke();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Internal/DiagnosticData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 |
8 | namespace AsyncGenerator.Internal
9 | {
10 | internal class DiagnosticData
11 | {
12 | public DiagnosticData(string description, DiagnosticSeverity diagnosticSeverity)
13 | {
14 | Description = description;
15 | DiagnosticSeverity = diagnosticSeverity;
16 | }
17 |
18 | public string Description { get; }
19 |
20 | public DiagnosticSeverity DiagnosticSeverity { get; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestCases/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 |
5 | namespace AsyncGenerator.TestCases
6 | {
7 | public static class StringExtensions
8 | {
9 | public static string ReadFile(this string path)
10 | {
11 | return File.ReadAllText(path);
12 | }
13 |
14 | public static async Task ReadFileAsync(this string path, CancellationToken cancellationToken = default(CancellationToken))
15 | {
16 | using (var stream = File.OpenText(path))
17 | {
18 | return await stream.ReadToEndAsync();
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Input/ExtensionMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
9 | {
10 | public class ExtensionMethods
11 | {
12 | public void External()
13 | {
14 | "test".ReadFile();
15 | }
16 |
17 | public void InternalGeneric()
18 | {
19 | var item = Query().Delete();
20 | }
21 |
22 | public IQueryable Query()
23 | {
24 | return null;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/Getter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class Getter
11 | {
12 | public bool WriteSuccess
13 | {
14 | get { return Write(); }
15 | }
16 |
17 | private bool Write()
18 | {
19 | return SimpleFile.Write("");
20 | }
21 |
22 | protected void CheckSuccess()
23 | {
24 | if (WriteSuccess)
25 | {
26 | return;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Diagnostics/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.Diagnostics.Input
9 | {
10 | public class TestCase
11 | {
12 | public void Read()
13 | {
14 | SimpleFile.Read();
15 | }
16 |
17 | public void Test(out bool success)
18 | {
19 | SimpleFile.Read();
20 | success = true;
21 | }
22 |
23 | public void Test2(out bool success)
24 | {
25 | Read();
26 | success = true;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/AutoProperty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Tests.TryCatch.Input
8 | {
9 | public class AutoProperty
10 | {
11 | public bool Success { get; set; }
12 |
13 | public int Test()
14 | {
15 | return Success ? 1 : 0;
16 | }
17 |
18 | public void Test2()
19 | {
20 | Success = true;
21 | }
22 |
23 | public AutoProperty Create()
24 | {
25 | return new AutoProperty
26 | {
27 | Success = true
28 | };
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/ArgumentGetter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class ArgumentGetter
11 | {
12 | public ArgumentGetter(bool value)
13 | {
14 |
15 | }
16 |
17 | public bool Success
18 | {
19 | get
20 | {
21 | SimpleFile.Read();
22 | return true;
23 | }
24 | }
25 |
26 | public void Test()
27 | {
28 | new ArgumentGetter(Success);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/SimpleClassInheritance/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.TestCases;
2 |
3 | namespace AsyncGenerator.Tests.SimpleClassInheritance.Input
4 | {
5 | public interface IClass
6 | {
7 | void ReadFile();
8 | }
9 |
10 | public class BaseClass : IClass
11 | {
12 | public virtual void ReadFile()
13 | {
14 | }
15 | }
16 |
17 | public class DerivedClass : BaseClass
18 | {
19 | public override void ReadFile()
20 | {
21 | SimpleFile.Read();
22 | }
23 | }
24 |
25 | public class TestCase
26 | {
27 | public void Read()
28 | {
29 | new DerivedClass().ReadFile();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/ILockAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 | using Microsoft.CodeAnalysis.CSharp.Syntax;
8 |
9 | namespace AsyncGenerator.Core.Analyzation
10 | {
11 | public interface ILockAnalyzationResult
12 | {
13 | ///
14 | /// Symbol of the lock statement expression
15 | ///
16 | ISymbol Symbol { get; }
17 |
18 | ///
19 | /// Lock statement node
20 | ///
21 | LockStatementSyntax Node { get; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IFileConfigurator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 |
4 | namespace AsyncGenerator.Core.Configuration
5 | {
6 | public interface IFileConfigurator
7 | {
8 | FileConfiguration.AsyncGenerator Parse(string content);
9 |
10 | void Configure(FileConfiguration.AsyncGenerator configuration, FileConfiguration.Solution solution, IFluentSolutionConfiguration solutionConfiguration, Assembly assembly);
11 |
12 | void Configure(FileConfiguration.AsyncGenerator configuration, FileConfiguration.Project project, IFluentProjectConfiguration projectConfiguration, Assembly assembly);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IFluentProjectPreprocessorDirectivesConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Configuration
5 | {
6 | public interface IFluentProjectPreprocessorDirectivesConfiguration
7 | {
8 | ///
9 | /// Set a function that will add preprocessor directives before and after a method.
10 | ///
11 | /// A function that returns the preprocessor directives for the given method.
12 | IFluentProjectPreprocessorDirectivesConfiguration AddForMethod(Func func);
13 | }
14 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Input/MultilineParameters.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.Formatting.Input
9 | {
10 | public interface IMultilineParameters
11 | {
12 | void Test(int param1,
13 | string param2,
14 | string param3);
15 | }
16 |
17 | public class MultilineParameters : IMultilineParameters
18 | {
19 | public void Test(int param1,
20 | string param2,
21 | string param3)
22 | {
23 | SimpleFile.Read();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/VirtualAutoProperty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Tests.TryCatch.Input
8 | {
9 | public class VirtualAutoProperty
10 | {
11 | public virtual bool Success { get; set; }
12 |
13 | public int Test()
14 | {
15 | return Success ? 1 : 0;
16 | }
17 |
18 | public void Test2()
19 | {
20 | Success = true;
21 | }
22 |
23 | public VirtualAutoProperty Create()
24 | {
25 | return new VirtualAutoProperty { Success = true };
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Transformation/Internal/FieldVariableTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.Core.Analyzation;
2 | using Microsoft.CodeAnalysis.CSharp.Syntax;
3 |
4 | namespace AsyncGenerator.Transformation.Internal
5 | {
6 | internal class FieldVariableTransformationResult : TransformationResult
7 | {
8 | public FieldVariableTransformationResult(IFieldVariableDeclaratorResult variableAnalyzationResult) : base(variableAnalyzationResult.Node)
9 | {
10 | AnalyzationResult = variableAnalyzationResult;
11 | }
12 |
13 | public IFieldVariableDeclaratorResult AnalyzationResult { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Extensions/Internal/EnumExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using AsyncGenerator.Core;
4 |
5 | namespace AsyncGenerator.Extensions.Internal
6 | {
7 | internal static class EnumExtensions
8 | {
9 | public static bool HasAnyFlag(this Enum e, params Enum[] enums)
10 | {
11 | return enums.Any(e.HasFlag);
12 | }
13 |
14 | public static bool HasOptionalCancellationToken(this MethodCancellationToken e)
15 | {
16 | return e.HasAnyFlag(
17 | MethodCancellationToken.Optional,
18 | MethodCancellationToken.ForwardNone,
19 | MethodCancellationToken.SealedForwardNone);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/ListGetter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class ListGetter
11 | {
12 | public void Test()
13 | {
14 | if (List.Count > 0 || List.Contains("") || new ListGetter().List.Count > 0)
15 | {
16 | return;
17 | }
18 | }
19 |
20 | public List List
21 | {
22 | get
23 | {
24 | SimpleFile.Read();
25 | return new List();
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Input/MethodBodyBraces.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.Formatting.Input
9 | {
10 | public class MethodBodyBraces
11 | {
12 | public void Test()
13 | { SimpleFile.Read(); }
14 |
15 | public void Test2() { SimpleFile.Read(); }
16 |
17 | public void Test3() {}
18 |
19 | T Test() where T : class, new()
20 | { return Test2(); }
21 |
22 | public T Test2() where T : class { SimpleFile.Read(); return default(T); }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/ParallelFor/Input/Variables.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.ParallelFor.Input
9 | {
10 | public class Variables
11 | {
12 | public void Read()
13 | {
14 | var start = 5;
15 | var end = 10;
16 | Parallel.For(start, end, i =>
17 | {
18 | SimpleFile.Read();
19 | });
20 | }
21 |
22 | public void Read2(int start, int end)
23 | {
24 | Parallel.For(start, end, i =>
25 | {
26 | SimpleFile.Read();
27 | });
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Plugins/Input/EmptyRegions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.Plugins.Input
9 | {
10 | public class EmptyRegions
11 | {
12 | #region Test
13 |
14 | #endregion Test
15 |
16 | #region MyRegion
17 |
18 | #endregion MyRegion
19 |
20 | #region Async
21 |
22 | public void Test()
23 | {
24 | SimpleFile.Read();
25 | }
26 |
27 | #endregion Async
28 | #region Empty1
29 |
30 | #endregion
31 | #region Empty2
32 |
33 | #endregion
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/SimpleReference/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using AsyncGenerator.TestCases;
3 |
4 | namespace AsyncGenerator.Tests.SimpleReference.Input
5 | {
6 | ///
7 | /// A simple example of using
8 | ///
9 | public class TestCase
10 | {
11 | public void CallCallReadFile()
12 | {
13 | CallReadFile();
14 | }
15 |
16 | public void CallReadFile()
17 | {
18 | ReadFile();
19 | }
20 |
21 | ///
22 | /// Use to read a file
23 | ///
24 | public void ReadFile()
25 | {
26 | SimpleFile.Read();
27 | }
28 |
29 | }
30 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IProjectAnalyzeConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Configuration
5 | {
6 | public interface IProjectAnalyzeConfiguration
7 | {
8 | bool SearchAsyncCounterpartsInInheritedTypes { get; }
9 |
10 | bool ScanMethodBody { get; }
11 |
12 | Predicate CanScanForMissingAsyncMembers { get; }
13 |
14 | bool UseCancellationTokens { get; }
15 |
16 | IProjectCancellationTokenConfiguration CancellationTokens { get; }
17 |
18 | bool ConcurrentRun { get; }
19 |
20 | IProjectExceptionHandlingConfiguration ExceptionHandling { get; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Plugins/IFunctionReferenceTransformer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Analyzation;
7 | using AsyncGenerator.Core.Transformation;
8 | using Microsoft.CodeAnalysis;
9 |
10 | namespace AsyncGenerator.Core.Plugins
11 | {
12 | public interface IFunctionReferenceTransformer : IPlugin
13 | {
14 | SyntaxNode TransformFunctionReference(SyntaxNode node, IFunctionAnalyzationResult funcResult,
15 | IFunctionReferenceAnalyzationResult funcReferenceResult, INamespaceTransformationMetadata namespaceMetadata);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/PropertyConversion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AsyncGenerator.Core
4 | {
5 | public enum PropertyConversion
6 | {
7 | ///
8 | /// The conversion will be decided by the analyzer.
9 | ///
10 | Unknown = 0,
11 | ///
12 | /// The property will not be modified
13 | ///
14 | Ignore = 1,
15 | ///
16 | /// The property will be copied into the new type, only type references may be modified. This option is only valid when the type conversion is set to
17 | /// or .
18 | ///
19 | Copy = 2
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue50/Output/IInterface.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 |
12 |
13 | namespace AsyncGenerator.Tests.Github.Issue50.Input
14 | {
15 | using System.Threading.Tasks;
16 | public partial interface IInterface
17 | {
18 |
19 | Task WriteAsync(string content);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/CustomProperty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Tests.TryCatch.Input
8 | {
9 | public class CustomProperty
10 | {
11 | public bool Success
12 | {
13 | get => false;
14 | set => throw new NotSupportedException();
15 | }
16 |
17 | public int Test()
18 | {
19 | return Success ? 1 : 0;
20 | }
21 |
22 | public void Test2()
23 | {
24 | Success = true;
25 | }
26 |
27 | public CustomProperty Create()
28 | {
29 | return new CustomProperty { Success = true };
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IMethodSymbolInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Analyzation
5 | {
6 | public interface IMethodSymbolInfo
7 | {
8 | IMethodSymbol Symbol { get; }
9 |
10 | ///
11 | /// Interface members within project that the method implements
12 | ///
13 | IReadOnlyList ImplementedInterfaces { get; }
14 |
15 | ///
16 | /// Methods within project that the method overrides. Includes all overriden methods including the abstract/virtual one.
17 | ///
18 | IReadOnlyList OverridenMethods { get; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NUnit/Input/AssertThatNoToken.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 | using NUnit.Framework;
8 |
9 | namespace AsyncGenerator.Tests.NUnit.Input
10 | {
11 | public class AssertThatNoToken
12 | {
13 | public void Read()
14 | {
15 | SimpleFile.Read();
16 | }
17 |
18 | public void Test()
19 | {
20 | Read();
21 | Assert.That(() => Read(), Throws.Nothing);
22 | Assert.That(() => Write(), Throws.Nothing);
23 | Write();
24 | }
25 |
26 | public void Write()
27 | {
28 | SimpleFile.Read();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IFieldVariableDeclaratorResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 | using Microsoft.CodeAnalysis.CSharp.Syntax;
8 |
9 | namespace AsyncGenerator.Core.Analyzation
10 | {
11 | public interface IFieldVariableDeclaratorResult
12 | {
13 | VariableDeclaratorSyntax Node { get; }
14 |
15 | FieldVariableConversion Conversion { get; }
16 |
17 | ///
18 | /// References of types that are used inside this type
19 | ///
20 | IReadOnlyList TypeReferences { get; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/CancellationTokens/Input/DefaultParameter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.CancellationTokens.Input
9 | {
10 | public class DefaultParameter
11 | {
12 | public void Read(string test = "Test")
13 | {
14 | Read3();
15 | SimpleFile.Read();
16 | }
17 |
18 | public void Read2()
19 | {
20 | Read();
21 | }
22 |
23 | public bool Write()
24 | {
25 | return SimpleFile.FastWrite();
26 | }
27 |
28 | public void Read3()
29 | {
30 | SimpleFile.Read();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IReferenceAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 | using Microsoft.CodeAnalysis.CSharp.Syntax;
3 | using Microsoft.CodeAnalysis.FindSymbols;
4 |
5 | namespace AsyncGenerator.Core.Analyzation
6 | {
7 | public interface IReferenceAnalyzationResult
8 | {
9 | SimpleNameSyntax ReferenceNameNode { get; }
10 |
11 | ReferenceLocation ReferenceLocation { get; }
12 |
13 | bool IsCref { get; }
14 |
15 | bool IsTypeOf { get; }
16 |
17 | bool IsNameOf { get; }
18 | }
19 |
20 | public interface IReferenceAnalyzationResult : IReferenceAnalyzationResult where TSymbol : ISymbol
21 | {
22 | TSymbol ReferenceSymbol { get; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/InitSetter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class InitSetter
11 | {
12 | public string InitWriteSuccess
13 | {
14 | init { Write(value); }
15 | }
16 |
17 | public string WriteSuccess
18 | {
19 | set { Write(value); }
20 | }
21 |
22 | private bool Write(string value)
23 | {
24 | return SimpleFile.Write(value);
25 | }
26 |
27 | protected void SetSuccess()
28 | {
29 | WriteSuccess = "";
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NUnit/Input/NestedAssertThat.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 | using NUnit.Framework;
8 |
9 | namespace AsyncGenerator.Tests.NUnit.Input
10 | {
11 | public class NestedAssertThat
12 | {
13 | public void Test()
14 | {
15 | Throws();
16 | }
17 |
18 | private void Throws()
19 | {
20 | Assert.Throws(
21 | () => new NestedClass().Build(), $"Test{typeof(T)}");
22 | }
23 |
24 | private class NestedClass
25 | {
26 | public void Build()
27 | {
28 |
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IFunctionReferenceAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace AsyncGenerator.Core.Analyzation
4 | {
5 | public interface IFunctionReferenceAnalyzationResult : IReferenceAnalyzationResult
6 | {
7 | IFunctionAnalyzationResult ReferenceFunction { get; }
8 |
9 | SyntaxNode ReferenceNode { get; }
10 |
11 | ReferenceConversion GetConversion();
12 |
13 | AsyncReturnType GetAsyncReturnType();
14 |
15 | string AsyncCounterpartName { get; }
16 |
17 | IMethodSymbol AsyncCounterpartSymbol { get; }
18 |
19 | IFunctionAnalyzationResult AsyncCounterpartFunction { get; }
20 |
21 | bool InsideMethodBody { get; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/ITypeTransformationMetadata.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Immutable;
2 | using AsyncGenerator.Core.Analyzation;
3 | using Microsoft.CodeAnalysis;
4 |
5 | namespace AsyncGenerator.Core.Transformation
6 | {
7 | ///
8 | /// Holds the current information about the type that is under transformation process
9 | ///
10 | public interface ITypeTransformationMetadata
11 | {
12 | ITypeAnalyzationResult AnalyzationResult { get; }
13 |
14 | IImmutableSet MemberNames { get; }
15 |
16 | SyntaxTrivia LeadingWhitespaceTrivia { get; }
17 |
18 | SyntaxTrivia EndOfLineTrivia { get; }
19 |
20 | SyntaxTrivia IndentTrivia { get; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestCases/AsyncGenerator.TestCases.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(LibTargetFrameworks)
5 | false
6 | 7.3
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IFluentProjectDiagnosticsConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 |
8 | namespace AsyncGenerator.Core.Configuration
9 | {
10 | public interface IFluentProjectDiagnosticsConfiguration
11 | {
12 | void Disable();
13 |
14 | IFluentProjectDiagnosticsConfiguration DiagnoseDocument(Predicate predicate);
15 |
16 | IFluentProjectDiagnosticsConfiguration DiagnoseType(Predicate predicate);
17 |
18 | IFluentProjectDiagnosticsConfiguration DiagnoseMethod(Predicate predicate);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/ExternalGetter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class ExternalGetter
11 | {
12 | public bool Test()
13 | {
14 | if (AsyncProperties.Success)
15 | {
16 | return false;
17 | }
18 | return !AsyncProperties.Success;
19 | }
20 |
21 | public string Test2()
22 | {
23 | if (SuccessProp)
24 | {
25 | return null;
26 | }
27 | return "";
28 | }
29 |
30 | public bool SuccessProp => AsyncProperties.Success;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NUnit/Input/SimpleFixture.cs:
--------------------------------------------------------------------------------
1 | #if TEST
2 | using AsyncGenerator.TestCases;
3 | using NUnit.Framework;
4 |
5 | namespace AsyncGenerator.Tests.NUnit.Input
6 | {
7 | [TestFixture]
8 | public class SimpleFixture
9 | {
10 | [Test]
11 | public void Test()
12 | {
13 | SimpleFile.Read();
14 | }
15 |
16 | [TestCaseSource(nameof(SetUp))]
17 | public void TestCaseSource()
18 | {
19 | SimpleFile.Read();
20 | }
21 |
22 | [TestCase("test")]
23 | public void TestCase(string test)
24 | {
25 | SimpleFile.Read();
26 | }
27 |
28 | [SetUp]
29 | public void SetUp()
30 | {
31 | }
32 |
33 | [TearDown]
34 | public void TearDown()
35 | {
36 | }
37 | }
38 | }
39 | #endif
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/ExceptionHandling/Input/CatchProperty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.ExceptionHandling.Input
9 | {
10 | public class CatchProperty
11 | {
12 | public bool IsValid => Validate();
13 |
14 | public void Read()
15 | {
16 | if (IsValid)
17 | {
18 | SimpleFile.Read();
19 | }
20 | }
21 |
22 | public void Read2()
23 | {
24 | if (DateTime.Today.Hour > 9)
25 | {
26 | SimpleFile.Read();
27 | }
28 | }
29 |
30 | private bool Validate()
31 | {
32 | return true;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Extensions/Internal/AssemblyExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Reflection;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace AsyncGenerator.Extensions.Internal
10 | {
11 | internal static class AssemblyExtensions
12 | {
13 | public static string GetPath(this Assembly assembly)
14 | {
15 | var path = assembly.Location;
16 | if (!Uri.TryCreate(path, UriKind.Absolute, out var uri))
17 | {
18 | throw new InvalidOperationException($"Invalid assembly location: '{assembly.Location}'");
19 | }
20 |
21 | return Uri.UnescapeDataString(uri.AbsolutePath);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Input/ActionFunc.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
10 | {
11 | public class ActionFunc
12 | {
13 | public void Test()
14 | {
15 | Execute(val =>
16 | {
17 | SimpleFile.Read();
18 | SimpleFile.Read();
19 | });
20 | }
21 |
22 | private void Execute(Action func)
23 | {
24 | SimpleFile.Read();
25 | }
26 |
27 | private Task ExecuteAsync(Func func)
28 | {
29 | return Task.CompletedTask;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.TestCases/AbstractDataReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.Common;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 |
9 | namespace AsyncGenerator.TestCases
10 | {
11 | public abstract class AbstractDataReader : DbDataReader
12 | {
13 | public override bool NextResult()
14 | {
15 | throw new NotSupportedException();
16 | }
17 |
18 | public override Task NextResultAsync(CancellationToken cancellationToken)
19 | {
20 | throw new NotSupportedException();
21 | }
22 |
23 | public new Task NextResultAsync()
24 | {
25 | throw new NotSupportedException();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NestedTypes/Input/MultipleNested.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NestedTypes.Input
9 | {
10 | public class MultipleNested
11 | {
12 | public void Read()
13 | {
14 | SimpleFile.Read();
15 | }
16 |
17 | public class Nested1
18 | {
19 | public bool Property { get; set; }
20 |
21 | public void DoSomething()
22 | {
23 |
24 | }
25 | }
26 |
27 | public class Nested2
28 | {
29 | public bool Property { get; set; }
30 |
31 | public void DoSomething()
32 | {
33 |
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NewTypes/Output/AlreadyAsync.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System.Threading.Tasks;
12 | using AsyncGenerator.TestCases;
13 |
14 | namespace AsyncGenerator.Tests.NewTypes.Input
15 | {
16 | public class AlreadyAsyncAsync
17 | {
18 | public Task ReadAsync()
19 | {
20 | return SimpleFile.ReadAsync();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Transformation/Internal/AnnotatedNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 |
8 | namespace AsyncGenerator.Transformation.Internal
9 | {
10 | internal abstract class AnnotatedNode: AnnotatedNode where T : SyntaxNode
11 | {
12 | protected AnnotatedNode(T originalNode)
13 | {
14 | OriginalNode = originalNode;
15 | }
16 |
17 | public T OriginalNode { get; }
18 |
19 |
20 | }
21 |
22 | internal abstract class AnnotatedNode
23 | {
24 | public string Annotation { get; } = Guid.NewGuid().ToString();
25 |
26 | public abstract int OriginalStartSpan { get; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Dynamic/Input/TypeArgument.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 | using NUnit.Framework;
8 |
9 | namespace AsyncGenerator.Tests.Dynamic.Input
10 | {
11 | public class TypeArgument
12 | {
13 | public void Test(Database database)
14 | {
15 | dynamic value = "test";
16 | database.Save("test", value);
17 | Assert.That(database.Save("test", value), Is.True);
18 |
19 | Assert.That(Database.IsInitialized(value.Test), Is.True);
20 | Assert.That(() => Database.IsInitialized(value.Test), Is.True);
21 |
22 | Assert.That(value.Length, Is.EqualTo(4));
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue50/Output/Abstract.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using AsyncGenerator.TestCases;
12 |
13 | namespace AsyncGenerator.Tests.Github.Issue50.Input
14 | {
15 | using System.Threading.Tasks;
16 | public abstract partial class Abstract : IInterface
17 | {
18 |
19 | public abstract Task WriteAsync(string content);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/MethodGeneration/Output/TestCase.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using AsyncGenerator.TestCases;
12 |
13 | namespace AsyncGenerator.Tests.MethodGeneration.Input
14 | {
15 | using System.Threading.Tasks;
16 | public partial class TestCase
17 | {
18 |
19 | public Task Read2Async()
20 | {
21 | return ReadAsync();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Internal/LockData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Analyzation;
7 | using Microsoft.CodeAnalysis;
8 | using Microsoft.CodeAnalysis.CSharp.Syntax;
9 |
10 | namespace AsyncGenerator.Internal
11 | {
12 | internal class LockData : ILockAnalyzationResult
13 | {
14 | public LockData(ISymbol symbol, LockStatementSyntax node)
15 | {
16 | Symbol = symbol ?? throw new ArgumentNullException(nameof(symbol));
17 | Node = node ?? throw new ArgumentNullException(nameof(node));
18 | }
19 |
20 | public ISymbol Symbol { get; }
21 |
22 | public LockStatementSyntax Node { get; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/IFunctionTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Analyzation;
7 | using Microsoft.CodeAnalysis;
8 |
9 | namespace AsyncGenerator.Core.Transformation
10 | {
11 | public interface IFunctionTransformationResult : ITransformationResult, IFunctionTransformationTrivia
12 | {
13 | ///
14 | /// The transformed function
15 | ///
16 | SyntaxNode Transformed { get; }
17 |
18 | IFunctionAnalyzationResult AnalyzationResult { get; }
19 |
20 | IReadOnlyList TransformedFunctionReferences { get; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Input/MixingIndent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using AsyncGenerator.TestCases;
5 |
6 | namespace AsyncGenerator.Tests.Formatting.Input
7 | {
8 | public class MixingIndent
9 | {
10 | [Obsolete]
11 | public void Test(string value)
12 | {
13 | if (value == null)
14 | throw new ArgumentNullException(nameof(value));
15 |
16 | SimpleFile
17 | .Read();
18 | value = value == "null" ? "test" : value;
19 | value = value != "test"
20 | ? "val" : value;
21 | value = value != "test"
22 | ? "val"
23 | : value;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Nameof/Output/SelfReferenceNewType.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using AsyncGenerator.TestCases;
12 |
13 | namespace AsyncGenerator.Tests.Nameof.Input
14 | {
15 | using System.Threading.Tasks;
16 | public class SelfReferenceAsync
17 | {
18 | public Task WriteAsync()
19 | {
20 | return SimpleFile.WriteAsync(nameof(WriteAsync));
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/OutsideMethodFunction/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.OutsideMethodFunction.Input
9 | {
10 | public class TestCase
11 | {
12 | private readonly Action _read = () => SimpleFile.Read();
13 | private readonly Func _write = content => SimpleFile.Write(content);
14 | private readonly Action _readDel = delegate { SimpleFile.Read(); };
15 |
16 | public void Read()
17 | {
18 | SimpleFile.Read();
19 | }
20 |
21 | public bool Write(string content)
22 | {
23 | return SimpleFile.Write(content);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/GetterWithAsyncPart.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class GetterWithAsyncPart
11 | {
12 | public bool WriteSuccess
13 | {
14 | get { return Write(); }
15 | }
16 |
17 | public Task GetWriteSuccessAsync()
18 | {
19 | return Task.FromResult(true);
20 | }
21 |
22 | private bool Write()
23 | {
24 | return SimpleFile.Write("");
25 | }
26 |
27 | protected void CheckSuccess()
28 | {
29 | if (WriteSuccess)
30 | {
31 | return;
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PrivateFields/Input/UsedByNestedFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using AsyncGenerator.TestCases;
5 |
6 | namespace AsyncGenerator.Tests.PrivateFields.Input
7 | {
8 | public class UsedByNestedFunction
9 | {
10 | private string _content = "";
11 | private string _content2 = "";
12 | private string _content3 = "";
13 |
14 | public void Write()
15 | {
16 | Runner.Run(s =>
17 | {
18 | SimpleFile.Write(_content);
19 | });
20 |
21 | var arr = new List
22 | {
23 | () =>
24 | {
25 | SimpleFile.Write(_content2);
26 | },
27 | delegate
28 | {
29 | File.Open(_content3, FileMode.Append);
30 | }
31 | };
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Configuration.Yaml/YamlFileConfigurator.cs:
--------------------------------------------------------------------------------
1 | using AsyncGenerator.Core.FileConfiguration;
2 | using YamlDotNet.Serialization;
3 | using YamlDotNet.Serialization.NamingConventions;
4 |
5 | namespace AsyncGenerator.Configuration.Yaml
6 | {
7 | public class YamlFileConfigurator : FileConfigurator
8 | {
9 | public override Core.FileConfiguration.AsyncGenerator Parse(string content)
10 | {
11 | return Deserialize(content);
12 | }
13 |
14 | private static T Deserialize(string content)
15 | {
16 | var deserializer = new DeserializerBuilder()
17 | .WithNamingConvention(CamelCaseNamingConvention.Instance)
18 | .Build();
19 | return deserializer.Deserialize(content);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/OmitAsync/Input/UsingAndTryPreserveAwait.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.OmitAsync.Input
10 | {
11 | public class UsingAndTryPreserveAwait
12 | {
13 | public bool AwaitShallNotBeOmittedInUsing()
14 | {
15 | using (new MemoryStream())
16 | {
17 | return SimpleFile.Write("");
18 | }
19 | }
20 |
21 | public bool AwaitShallNotBeOmittedInTry()
22 | {
23 | try
24 | {
25 | return SimpleFile.Write("");
26 | }
27 | catch (Exception e)
28 | {
29 | throw new AggregateException(e);
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Input/Await.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 | using NUnit.Framework;
8 |
9 | namespace AsyncGenerator.Tests.Formatting.Input
10 | {
11 | public class Await
12 | {
13 | public class Reader
14 | {
15 | public Reader Read()
16 | {
17 | SimpleFile.Read();
18 | return this;
19 | }
20 | }
21 |
22 |
23 | public void Test()
24 | {
25 | var reader = new Reader();
26 | reader.Read().Read();
27 |
28 | var str = SimpleFile
29 | .Write("")
30 | .ToString();
31 |
32 | Assert.That(
33 | SimpleFile
34 | .Write("").Equals(true), Is.True);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IFluentProjectParseConfiguration.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis.CSharp;
2 |
3 | namespace AsyncGenerator.Core.Configuration
4 | {
5 | public interface IFluentProjectParseConfiguration
6 | {
7 | ///
8 | /// Adds a preprocessor symbol name to the project
9 | ///
10 | IFluentProjectParseConfiguration AddPreprocessorSymbolName(string value);
11 |
12 | ///
13 | /// Removes a preprocessor symbol name from the project
14 | ///
15 | IFluentProjectParseConfiguration RemovePreprocessorSymbolName(string value);
16 |
17 | ///
18 | /// Specifies the language version
19 | ///
20 | IFluentProjectParseConfiguration LanguageVersion(LanguageVersion value);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Output/ExternalExtensionMethods.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using AsyncGenerator.TestCases;
12 |
13 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
14 | {
15 | using System.Threading.Tasks;
16 | public partial class ExternalExtensionMethods
17 | {
18 | public Task ExternalAsync(IFileReader reader)
19 | {
20 | return reader.ReadAsync("test");
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue50/Output/TestCase.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using AsyncGenerator.TestCases;
12 |
13 | namespace AsyncGenerator.Tests.Github.Issue50.Input
14 | {
15 | using System.Threading.Tasks;
16 | public partial class TestCase : Abstract
17 | {
18 |
19 | public override Task WriteAsync(string content)
20 | {
21 | return SimpleFile.WriteAsync(content);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/IfDirective/Input/VoidReturnType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.IfDirective.Input
9 | {
10 | public class VoidReturnType
11 | {
12 | public void Test()
13 | {
14 | #if TEST
15 | SimpleFile.Read();
16 | #else
17 | SimpleFile.Read();
18 | #endif
19 | }
20 |
21 | public void Test2()
22 | {
23 | #if ASYNC
24 | SimpleFile.Read();
25 | #else
26 | SimpleFile.Read();
27 | #endif
28 | }
29 |
30 | public void Test3()
31 | {
32 | #if TEST
33 | SimpleFile.Read();
34 | #elif ASYNC
35 | SimpleFile.Read();
36 | #else
37 | SimpleFile.Read();
38 | #endif
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Internal/FieldVariableDataReference.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 | using Microsoft.CodeAnalysis.CSharp.Syntax;
8 | using Microsoft.CodeAnalysis.FindSymbols;
9 |
10 | namespace AsyncGenerator.Internal
11 | {
12 | internal class FieldVariableDataReference : DataReference
13 | {
14 | public FieldVariableDataReference(AbstractData data, ReferenceLocation reference, SimpleNameSyntax referenceNameNode,
15 | ISymbol referenceSymbol, FieldVariableDeclaratorData referenceData)
16 | : base(data, reference, referenceNameNode, referenceSymbol, referenceData, false)
17 | {
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NewTypes/Input/DerivedClasses.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NewTypes.Input
9 | {
10 | public class BaseClass
11 | {
12 | private bool? _lastWrite;
13 | public bool Test;
14 |
15 | public virtual string Content => "";
16 |
17 | public bool Write()
18 | {
19 | if (_lastWrite.HasValue)
20 | {
21 | return _lastWrite.Value;
22 | }
23 | _lastWrite = SimpleFile.Write(Content);
24 | return _lastWrite.Value;
25 | }
26 | }
27 |
28 | public class DerivedClasses : BaseClass
29 | {
30 | public bool DerivedTest;
31 |
32 | public override string Content => "Test";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/DocumentationComments/Input/Comments.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.DocumentationComments.Input
9 | {
10 | ///
11 | /// My documentation comment
12 | ///
13 | public class Comments
14 | {
15 | public class Nested
16 | {
17 | public void Write(string content)
18 | {
19 | SimpleFile.Write(content);
20 | }
21 | }
22 |
23 | public void Read()
24 | {
25 | SimpleFile.Read();
26 | }
27 |
28 | // My comment
29 | public class Nested2
30 | {
31 | public void Write(string content)
32 | {
33 | SimpleFile.Write(content);
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Internal/DefaultPreconditionChecker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Analyzation;
7 | using AsyncGenerator.Core.Plugins;
8 | using AsyncGenerator.Extensions;
9 | using AsyncGenerator.Extensions.Internal;
10 | using AsyncGenerator.Plugins;
11 | using AsyncGenerator.Plugins.Internal;
12 | using Microsoft.CodeAnalysis;
13 | using Microsoft.CodeAnalysis.CSharp.Syntax;
14 |
15 | namespace AsyncGenerator.Internal
16 | {
17 | internal class DefaultPreconditionChecker : AbstractPlugin, IPreconditionChecker
18 | {
19 | public bool IsPrecondition(StatementSyntax statement, SemanticModel semanticModel)
20 | {
21 | return statement.IsPrecondition();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/AbstractAutoProperty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Tests.TryCatch.Input
8 | {
9 | public class AbstractAutoPropertyImpl : AbstractAutoProperty
10 | {
11 | public override bool Success { get; set; }
12 | }
13 |
14 | public abstract class AbstractAutoProperty
15 | {
16 | public abstract bool Success { get; set; }
17 |
18 | public int Test()
19 | {
20 | return Success ? 1 : 0;
21 | }
22 |
23 | public void Test2()
24 | {
25 | Success = true;
26 | }
27 |
28 | public AbstractAutoProperty Create()
29 | {
30 | return new AbstractAutoPropertyImpl
31 | {
32 | Success = true
33 | };
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IFieldAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 | using Microsoft.CodeAnalysis.CSharp.Syntax;
8 |
9 | namespace AsyncGenerator.Core.Analyzation
10 | {
11 | public interface IFieldAnalyzationResult : IMemberAnalyzationResult
12 | {
13 | BaseFieldDeclarationSyntax Node { get; }
14 |
15 | ///
16 | /// Returns variables of the field.
17 | ///
18 | IReadOnlyList Variables { get; }
19 |
20 | ///
21 | /// References of types that are used inside this type
22 | ///
23 | IReadOnlyList TypeReferences { get; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IPropertyAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.CodeAnalysis;
7 | using Microsoft.CodeAnalysis.CSharp.Syntax;
8 |
9 | namespace AsyncGenerator.Core.Analyzation
10 | {
11 | public interface IPropertyAnalyzationResult : IMemberAnalyzationResult
12 | {
13 | PropertyDeclarationSyntax Node { get; }
14 |
15 | ///
16 | /// Symbol of the property
17 | ///
18 | IPropertySymbol Symbol { get; }
19 |
20 | ///
21 | /// Returns getter and setter accessors of the property.
22 | ///
23 | IEnumerable GetAccessors();
24 |
25 | PropertyConversion Conversion { get; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Transformation/IMethodOrAccessorTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Analyzation;
7 | using Microsoft.CodeAnalysis;
8 | using Microsoft.CodeAnalysis.CSharp.Syntax;
9 |
10 | namespace AsyncGenerator.Core.Transformation
11 | {
12 | public interface IMethodOrAccessorTransformationResult : IMemberTransformationResult, IFunctionTransformationResult
13 | {
14 | ///
15 | /// The transformed method
16 | ///
17 | new MethodDeclarationSyntax Transformed { get; }
18 |
19 | new IMethodOrAccessorAnalyzationResult AnalyzationResult { get; }
20 |
21 | IReadOnlyList TransformedLocks { get; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Input/IndentSwitch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using AsyncGenerator.TestCases;
4 |
5 | namespace AsyncGenerator.Tests.Formatting.Input
6 | {
7 | public class IndentSwitch
8 | {
9 | public void Test(string value, IDisposable item)
10 | {
11 | if (value == null)
12 | throw new ArgumentNullException(nameof(value));
13 |
14 | SimpleFile.Read();
15 | switch (item)
16 | {
17 | case BinaryReader br:
18 | value = "test";
19 | break;
20 | case Stream _:
21 | value = "test2";
22 | break;
23 | default:
24 | throw new InvalidOperationException();
25 | }
26 |
27 | switch (value)
28 | {
29 | case "test":
30 | return;
31 | default:
32 | throw new InvalidOperationException();
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NewTypes/Input/DerivedAsyncClass.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NewTypes.Input
9 | {
10 | public class BaseNonAsyncClass
11 | {
12 | public void Test()
13 | {
14 |
15 | }
16 | }
17 |
18 | public class DerivedAsyncClass : BaseNonAsyncClass
19 | {
20 | public BaseNonAsyncClass BaseTypeField;
21 |
22 | public BaseNonAsyncClass BaseTypeProperty { get; set; }
23 |
24 | public void Read()
25 | {
26 | if (BaseTypeField == null)
27 | {
28 | BaseTypeField = new BaseNonAsyncClass();
29 | }
30 | if (BaseTypeProperty != null)
31 | {
32 | SimpleFile.Read();
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IBodyFunctionReferenceAnalyzation.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using AsyncGenerator.Core.Plugins;
3 | using Microsoft.CodeAnalysis;
4 | using Microsoft.CodeAnalysis.CSharp.Syntax;
5 | using Microsoft.CodeAnalysis.FindSymbols;
6 |
7 | namespace AsyncGenerator.Core.Analyzation
8 | {
9 | // TODO: define what we should do with this interface
10 | ///
11 | /// Used by in order to customize the analyzation process of a reference
12 | ///
13 | public interface IBodyFunctionReferenceAnalyzation : IBodyFunctionReferenceAnalyzationResult
14 | {
15 | IFunctionAnalyzationResult FunctionData { get; }
16 |
17 | IFunctionAnalyzationResult ReferenceFunctionData { get; }
18 |
19 | void Ignore(string reason);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AbstractClass/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AbstractClass.Input
9 | {
10 | public interface ITestInteraface
11 | {
12 | void Read();
13 |
14 | bool Write(string content);
15 | }
16 |
17 |
18 | public abstract class AbstractTest : ITestInteraface
19 | {
20 | public virtual void Read()
21 | {
22 | }
23 |
24 | public abstract bool Write(string content);
25 | }
26 |
27 | public class TestCase : AbstractTest
28 | {
29 | public override void Read()
30 | {
31 | }
32 |
33 | public override bool Write(string content)
34 | {
35 | return SimpleFile.Write(content);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/DocumentationComments/Input/MissingMembers.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Tests.DocumentationComments.Input
2 | {
3 | #if TEST
4 | public class MissingMembers : IExternalInterface
5 | {
6 | public class NestedClass : IExternalInterface
7 | {
8 | public void Method()
9 | {
10 | }
11 |
12 | public bool Method2()
13 | {
14 | return SimpleFile.Write("");
15 | }
16 |
17 | public bool Method3()
18 | {
19 | return false;
20 | }
21 | }
22 |
23 | public void Method()
24 | {
25 | SimpleFile.Read();
26 | }
27 |
28 | public bool Method2()
29 | {
30 | return SimpleFile.Write("");
31 | }
32 |
33 | public bool Method3()
34 | {
35 | return Method2();
36 | }
37 |
38 | public void Read()
39 | {
40 | Method();
41 | }
42 | }
43 | #endif
44 | }
45 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue51/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq.Expressions;
4 | using AsyncGenerator.TestCases;
5 |
6 | namespace AsyncGenerator.Tests.Github.Issue51.Input
7 | {
8 | public class TestCase : AbstractTest
9 | {
10 | public override void Read()
11 | {
12 | SimpleFile.Read();
13 | }
14 |
15 | public override bool Write(string content)
16 | {
17 | return SimpleFile.Write(content);
18 | }
19 | }
20 |
21 | public abstract class AbstractTest : ITestInterface
22 | {
23 | public virtual void Read()
24 | {
25 | SimpleFile.Read();
26 | }
27 |
28 | public abstract bool Write(string content);
29 | }
30 |
31 | public interface ITestInterface
32 | {
33 | void Read();
34 |
35 | bool Write(string content);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Configuration/Internal/ProjectPreprocessorDirectivesConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using AsyncGenerator.Core;
3 | using AsyncGenerator.Core.Configuration;
4 | using Microsoft.CodeAnalysis;
5 |
6 | namespace AsyncGenerator.Configuration.Internal
7 | {
8 | internal class ProjectPreprocessorDirectivesConfiguration : IFluentProjectPreprocessorDirectivesConfiguration, IProjectPreprocessorDirectivesConfiguration
9 | {
10 | public Func AddForMethod { get; private set; }
11 |
12 | IFluentProjectPreprocessorDirectivesConfiguration IFluentProjectPreprocessorDirectivesConfiguration.AddForMethod(Func func)
13 | {
14 | AddForMethod = func ?? throw new ArgumentNullException(nameof(func));
15 | return this;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Input/NestedClasses.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.Formatting.Input
9 | {
10 | public class NestedClasses
11 | {
12 | public void Test()
13 | {
14 | new Nested().Read();
15 | new Nested2().Read();
16 | Nested3.Read();
17 | }
18 |
19 | class Nested
20 | {
21 | public void Read()
22 | {
23 | SimpleFile.Read();
24 | }
25 | }
26 |
27 | sealed class Nested2
28 | {
29 | public void Read()
30 | {
31 | SimpleFile.Read();
32 | }
33 | }
34 |
35 | static class Nested3
36 | {
37 | public static void Read()
38 | {
39 | SimpleFile.Read();
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/ParallelForEach/Output/NoLinq.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System.Threading.Tasks;
12 | using AsyncGenerator.TestCases;
13 |
14 | namespace AsyncGenerator.Tests.ParallelForEach.Input
15 | {
16 | using System.Linq;
17 | public partial class NoLinq
18 | {
19 | public Task ReadAsync()
20 | {
21 | return Task.WhenAll(new []{ "" }.Select(i =>
22 | {
23 | return SimpleFile.ReadAsync();
24 | }));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Events/Output/AddRemoveEvent.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.Events.Input
19 | {
20 | public partial class AddRemoveEvent
21 | {
22 |
23 | public Task ReadAsync()
24 | {
25 | return SimpleFile.ReadAsync();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/ParallelFor/Output/NoLinq.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System.Threading.Tasks;
12 | using AsyncGenerator.TestCases;
13 |
14 | namespace AsyncGenerator.Tests.ParallelFor.Input
15 | {
16 | using System.Linq;
17 | public partial class NoLinq
18 | {
19 | public Task ReadAsync()
20 | {
21 | return Task.WhenAll(Enumerable.Range(1, 100 - 1).Select(i =>
22 | {
23 | return SimpleFile.ReadAsync();
24 | }));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PrivateMethods/Input/UsedByNestedFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using AsyncGenerator.TestCases;
5 |
6 | namespace AsyncGenerator.Tests.PrivateMethods.Input
7 | {
8 | public class UsedByNestedFunction
9 | {
10 | public void Write()
11 | {
12 | Runner.Run(s =>
13 | {
14 | Test();
15 | SimpleFile.Write("");
16 | });
17 |
18 | var arr = new List
19 | {
20 | () =>
21 | {
22 | Test2();
23 | SimpleFile.Write("");
24 | },
25 | delegate
26 | {
27 | File.Open(Test3(), FileMode.Append);
28 | }
29 | };
30 | }
31 |
32 | private void Test()
33 | {
34 | }
35 |
36 | private void Test2()
37 | {
38 | }
39 |
40 | private string Test3()
41 | {
42 | return null;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NestedTypes/Output/MultipleNested.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.NestedTypes.Input
19 | {
20 | public partial class MultipleNested
21 | {
22 | public Task ReadAsync()
23 | {
24 | return SimpleFile.ReadAsync();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/GetAccessor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public interface IGetAccessor
11 | {
12 | bool Write { get; }
13 | #if TEST
14 | Task GetWriteAsync();
15 | #endif
16 | }
17 |
18 | public class GetAccessor : IGetAccessor
19 | {
20 | private bool _value;
21 | private bool _isBusy;
22 |
23 | public bool Write
24 | {
25 | get
26 | {
27 | if (!IsBusy)
28 | {
29 | _value = SimpleFile.Write("");
30 | }
31 |
32 | return _value;
33 | }
34 | }
35 |
36 | public bool IsBusy
37 | {
38 | get => _isBusy;
39 | set => _isBusy = value;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Fields/Output/ArgumentNewType.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Threading;
13 | using AsyncGenerator.TestCases;
14 |
15 | namespace AsyncGenerator.Tests.Fields.Input
16 | {
17 | using System.Threading.Tasks;
18 | public class ArgumentAsync
19 | {
20 | private readonly string _test = "test";
21 |
22 | public async Task WriteAsync()
23 | {
24 | var result = await (SimpleFile.WriteAsync(_test));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue105/Input/TestCase3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.Common;
4 | using System.Linq.Expressions;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.Github.Issue105.Input
10 | {
11 | public abstract class MyDataReader : DbDataReader
12 | {
13 | public override bool IsDBNull(int ordinal)
14 | {
15 | throw new NotImplementedException();
16 | }
17 |
18 | public override Task IsDBNullAsync(int ordinal, CancellationToken cancellationToken)
19 | {
20 | return base.IsDBNullAsync(ordinal, cancellationToken);
21 | }
22 | }
23 |
24 | public class TestCase3
25 | {
26 | public bool Test(DbDataReader reader)
27 | {
28 | return reader.IsDBNull(0);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IProjectConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core.Configuration
2 | {
3 | public interface IProjectConfiguration
4 | {
5 | ///
6 | /// Name of the project
7 | ///
8 | string Name { get; }
9 |
10 | ///
11 | /// Analyzation configurations for the project
12 | ///
13 | IProjectAnalyzeConfiguration AnalyzeConfiguration { get; }
14 |
15 | ///
16 | /// Transformation configurations for the project
17 | ///
18 | IProjectTransformConfiguration TransformConfiguration { get; }
19 |
20 | ///
21 | /// Compilation configurations for the project
22 | ///
23 | IProjectCompileConfiguration CompileConfiguration { get; }
24 |
25 | bool ConcurrentRun { get; }
26 |
27 | string TargetFramework { get; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Configuration/IProjectDocumentationCommentConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Configuration
5 | {
6 | public interface IProjectDocumentationCommentConfiguration
7 | {
8 | Func AddOrReplacePartialTypeComments { get; }
9 |
10 | Predicate RemovePartialTypeComments { get; }
11 |
12 | Func AddOrReplaceNewTypeComments { get; }
13 |
14 | Predicate RemoveNewTypeComments { get; }
15 |
16 | Func AddOrReplaceMethodSummary { get; }
17 |
18 | Predicate CanRemoveMethodSummary { get; }
19 |
20 | Func AddOrReplaceMethodRemarks { get; }
21 |
22 | Predicate CanRemoveMethodRemarks { get; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/SetAccessor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public interface ISetAccessor
11 | {
12 | bool Write { set; }
13 | #if TEST
14 | Task SetWriteAsync(bool value);
15 | #endif
16 | }
17 |
18 | public class SetAccessor : ISetAccessor
19 | {
20 | private bool _value;
21 | private bool _isBusy;
22 |
23 | public bool Write
24 | {
25 | set
26 | {
27 | if (!IsBusy)
28 | {
29 | _value = SimpleFile.Write("");
30 | }
31 |
32 | _value = value;
33 | }
34 | }
35 |
36 | public bool IsBusy
37 | {
38 | get => _isBusy;
39 | set => _isBusy = value;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/InterfaceGetter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class InterfaceGetter : IInterfaceGetter
11 | {
12 | public bool IsSuccess { get { return true; } }
13 |
14 | public bool WriteSuccess
15 | {
16 | get { return Write(); }
17 | }
18 |
19 | private bool Write()
20 | {
21 | return SimpleFile.Write("");
22 | }
23 |
24 | protected void CheckSuccess()
25 | {
26 | if (WriteSuccess && IsSuccess)
27 | {
28 | return;
29 | }
30 | }
31 | }
32 |
33 | public interface IInterfaceGetter
34 | {
35 | bool WriteSuccess { get; }
36 |
37 | bool IsSuccess { get; }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Input/CustomLinqExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
9 | {
10 | public class CustomLinqExtensions
11 | {
12 |
13 | public IQueryable Query()
14 | {
15 | return null;
16 | }
17 |
18 | public void DoQuery()
19 | {
20 | var totalCount = Query().Count();
21 | var item = Query().FirstOrDefault(o => o.Length == totalCount);
22 | }
23 |
24 | public void DoAverage()
25 | {
26 | var item = Query().Average(o => o.Length);
27 | }
28 |
29 | public void DoAverage2()
30 | {
31 | var item = Query().Average(o => SimpleFile.Write(""));
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Output/GetterNoConversion.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.AsyncProperites.Input
19 | {
20 | public partial class Getter
21 | {
22 |
23 | private Task WriteAsync()
24 | {
25 | return SimpleFile.WriteAsync("");
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/CancellationTokens/Output/Params.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.CancellationTokens.Input
19 | {
20 | public partial class Params
21 | {
22 | public Task ReadAsync(params string[] param)
23 | {
24 | return SimpleFile.ReadAsync();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Configuration.Yaml/AsyncGenerator.Configuration.Yaml.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(LibTargetFrameworks)
5 | CSharpAsyncGenerator.Configuration.Yaml
6 | CSharpAsyncGenerator.Configuration.Yaml
7 | Configuration via yaml file
8 | true
9 | false
10 | 7.3
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/CSharpFeatures/Input/InModifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.CSharpFeatures.Input
9 | {
10 | public class InModifier
11 | {
12 | public void Test(in int value, in KeyValuePair pair = default)
13 | {
14 | SimpleFile.Read();
15 | }
16 |
17 | public bool Test2(in int value, in KeyValuePair pair = default)
18 | {
19 | SimpleFile.Read();
20 | return SimpleFile.Write(value.ToString());
21 | }
22 |
23 | public void Test3(int val)
24 | {
25 | Test3Method();
26 |
27 | bool Test3Method(in int value = 0)
28 | {
29 | SimpleFile.Read();
30 | return SimpleFile.Write(value.ToString());
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PrivateMethods/Output/TestCase.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq.Expressions;
14 | using AsyncGenerator.TestCases;
15 |
16 | namespace AsyncGenerator.Tests.PrivateMethods.Input
17 | {
18 | using System.Threading.Tasks;
19 | public partial class TestCase
20 | {
21 |
22 | public async Task ReadAsync()
23 | {
24 | await (SimpleFile.ReadAsync());
25 | Event += ReadInternal;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/SearchInheritedTypes/Output/Interface.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.SearchInheritedTypes.Input
19 | {
20 | public partial class Interface
21 | {
22 | public Task TestAsync(IDatabase database)
23 | {
24 | return database.SaveAsync();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NUnit/Input/AssertMultiple.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using AsyncGenerator.TestCases;
5 | using NUnit.Framework;
6 |
7 | namespace AsyncGenerator.Tests.NUnit.Input
8 | {
9 | public class AssertMultiple
10 | {
11 | public void MultipleWithDoesNotThrow()
12 | {
13 | Assert.Multiple(() =>
14 | {
15 | Assert.DoesNotThrow(() => SimpleFile.Read());
16 | Assert.DoesNotThrow(() => SimpleFile.Read(), "test");
17 | });
18 |
19 | Assert.Multiple(() =>
20 | {
21 | Assert.DoesNotThrow(() => SimpleFile.Read());
22 | Assert.DoesNotThrow(() => SimpleFile.Clear(), "test");
23 | });
24 |
25 | Assert.Multiple(() =>
26 | {
27 | Assert.DoesNotThrow(() => SimpleFile.Clear());
28 | Assert.DoesNotThrow(() => SimpleFile.Clear(), "test");
29 | });
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Internal/ChildFunctionData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Analyzation;
7 | using AsyncGenerator.Core.Analyzation;
8 | using Microsoft.CodeAnalysis;
9 |
10 | namespace AsyncGenerator.Internal
11 | {
12 | internal abstract class ChildFunctionData : FunctionData, IChildFunctionAnalyzationResult
13 | {
14 | protected ChildFunctionData(IMethodSymbol methodSymbol, FunctionData parentFunction)
15 | : base(methodSymbol)
16 | {
17 | ParentFunction = parentFunction;
18 | }
19 |
20 | public override FunctionData ParentFunction { get; }
21 |
22 | #region IChildFunctionAnalyzationResult
23 |
24 | IFunctionAnalyzationResult IChildFunctionAnalyzationResult.ParentFunction => ParentFunction;
25 |
26 | #endregion
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IDelegateArgumentAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Core.Analyzation
8 | {
9 | public interface IDelegateArgumentAnalyzationResult
10 | {
11 | ///
12 | /// Index of the delegate argument
13 | ///
14 | int Index { get; }
15 |
16 | ///
17 | /// Function that represent the argument. Not null when the argument is an internal function.
18 | ///
19 | IFunctionAnalyzationResult Function { get; }
20 |
21 | ///
22 | /// Body function reference that represent the argument. Not null when the argument is an external function.
23 | ///
24 | IBodyFunctionReferenceAnalyzationResult BodyFunctionReference { get; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Sleep/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using AsyncGenerator.TestCases;
7 | using NUnit.Framework;
8 |
9 | namespace AsyncGenerator.Tests.Sleep.Input
10 | {
11 | public class TestCase
12 | {
13 | ///
14 | ///
15 | ///
16 | ///
17 | public void Sleep()
18 | {
19 | Thread.Sleep(10);
20 | Thread.Sleep(TimeSpan.FromMilliseconds(10));
21 |
22 | var name = nameof(Thread.Sleep);
23 | Assert.That(name, Is.EqualTo(nameof(Thread.Sleep)));
24 |
25 | Runner.RunWithIntParameter(Thread.Sleep);
26 | Runner.RunWithIntParameter(Thread.Sleep);
27 | }
28 |
29 | public void Sleep2()
30 | {
31 | Thread.Sleep(10);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish Packages
2 |
3 | on:
4 | push:
5 | tags:
6 | - "v*"
7 | workflow_dispatch:
8 |
9 | permissions:
10 | id-token: write
11 | contents: read
12 |
13 | jobs:
14 | publish:
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - name: Checkout
19 | uses: actions/checkout@v4
20 |
21 | - name: Setup .NET
22 | uses: actions/setup-dotnet@v4
23 | with:
24 | dotnet-version: |
25 | 10.0.x
26 |
27 | - name: Install Cake
28 | run: dotnet tool restore
29 |
30 | - name: NuGet login (OIDC)
31 | uses: NuGet/login@v1
32 | id: login
33 | with:
34 | user: ${{ secrets.NUGET_USER }}
35 |
36 | - name: Run Cake Publish target
37 | run: dotnet cake --target=Publish --nugetApiKey=${{ steps.login.outputs.NUGET_API_KEY }}
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Output/Expression.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using AsyncGenerator.TestCases;
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Text;
16 | using System.Threading.Tasks;
17 |
18 | namespace AsyncGenerator.Tests.LocalFunctions.Input
19 | {
20 | public partial class Expression
21 | {
22 | public Task TestAsync()
23 | {
24 | Task ReadAsync() => SimpleFile.ReadAsync();
25 | return ReadAsync();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PartialCompilation/Input/Ctor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.PartialCompilation.Input
10 | {
11 | public class Ctor
12 | {
13 | private readonly Func _getList;
14 | private readonly Func _getListAsync;
15 |
16 | protected Ctor(Func getList, Func getListAsync)
17 | {
18 | _getList = getList;
19 | _getListAsync = getListAsync;
20 | }
21 |
22 | #if TEST
23 |
24 | public static Ctor Create()
25 | {
26 | return new Ctor(GetList, GetListAsync);
27 | }
28 |
29 | #endif
30 |
31 | protected static IList GetList()
32 | {
33 | SimpleFile.Read();
34 | return null;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/Analyzation/IAnalyzationResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Microsoft.CodeAnalysis;
3 |
4 | namespace AsyncGenerator.Core.Analyzation
5 | {
6 | public interface IAnalyzationResult
7 | {
8 | ///
9 | /// Get the member node
10 | ///
11 | ///
12 | SyntaxNode GetNode();
13 |
14 | ///
15 | /// References of objects that are referenced inside this object
16 | ///
17 | IReadOnlyList References { get; }
18 |
19 | ///
20 | /// References of this objects inside other objects
21 | ///
22 | IReadOnlyList SelfReferences { get; }
23 |
24 | ///
25 | /// Objects that references this object
26 | ///
27 | IEnumerable ReferencedBy { get; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue105/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq.Expressions;
4 | using System.Threading.Tasks;
5 | using AsyncGenerator.TestCases;
6 |
7 | namespace AsyncGenerator.Tests.Github.Issue105.Input
8 | {
9 | public class TestCase
10 | {
11 | public void Interface(IAsyncChild c)
12 | {
13 | c.SomeMethod();
14 | }
15 |
16 | public void Class(BothSyncAndAsync c)
17 | {
18 | c.SomeMethod();
19 | }
20 | }
21 |
22 | public interface IParent
23 | {
24 | void SomeMethod();
25 | }
26 |
27 | public interface IAsyncChild : IParent
28 | {
29 | Task SomeMethodAsync();
30 | }
31 |
32 | public class BothSyncAndAsync : IAsyncChild
33 | {
34 | public void SomeMethod()
35 | {
36 | }
37 |
38 | public Task SomeMethodAsync()
39 | {
40 | return Task.CompletedTask;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NestedTypes/Output/TestCase.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.NestedTypes.Input
19 | {
20 | public partial class TestCase
21 | {
22 | public partial class Child
23 | {
24 | public Task ReadAsync()
25 | {
26 | return SimpleFile.ReadAsync();
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NewTypes/Input/SubNestedClass.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NewTypes.Input
9 | {
10 | public class SubNestedClass
11 | {
12 | public void Read()
13 | {
14 | var nested = NestedFactory.Create();
15 | nested.DoSomething();
16 | SimpleFile.Read();
17 | }
18 |
19 | public class NestedFactory
20 | {
21 | public static Nested Create()
22 | {
23 | return new Nested();
24 | }
25 | }
26 |
27 | public class Nested
28 | {
29 | public void DoSomething()
30 | {
31 | var sub = new SubNested();
32 | sub.Do();
33 | }
34 |
35 | private class SubNested
36 | {
37 | public void Do()
38 | {
39 |
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Plugins/Output/EmptyRegions.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.Plugins.Input
19 | {
20 | public partial class EmptyRegions
21 | {
22 |
23 | #region Async
24 |
25 | public Task TestAsync()
26 | {
27 | return SimpleFile.ReadAsync();
28 | }
29 |
30 | #endregion Async
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Output/AnonymousFunction.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.TryCatch.Input
19 | {
20 | public partial class AnonymousFunction
21 | {
22 |
23 | public Task TestAsync()
24 | {
25 | return Runner.RunAsync(s =>
26 | {
27 | Success = true;
28 | });
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Output/IfStatement.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.TryCatch.Input
19 | {
20 | public partial class IfStatement
21 | {
22 |
23 | public Task TestAsync()
24 | {
25 | if (Success)
26 | return SimpleFile.ReadAsync();
27 | return Task.CompletedTask;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Input/InterfaceAutoProperty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Tests.TryCatch.Input
8 | {
9 | public interface IInterfaceAutoProperty
10 | {
11 | bool Success { get; set; }
12 | }
13 |
14 | public class InterfaceAutoProperty : IInterfaceAutoProperty
15 | {
16 | private static readonly IInterfaceAutoProperty Singleton = new InterfaceAutoProperty();
17 |
18 | public bool Success { get; set; }
19 |
20 | public int Test()
21 | {
22 | return Singleton.Success ? 1 : 0;
23 | }
24 |
25 | public void Test2()
26 | {
27 | Singleton.Success = true;
28 | }
29 |
30 | public IInterfaceAutoProperty Create()
31 | {
32 | return new InterfaceAutoProperty
33 | {
34 | Success = true
35 | };
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/FieldVariableConversion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AsyncGenerator.Core
8 | {
9 | public enum FieldVariableConversion
10 | {
11 | Unknown = 0,
12 | ///
13 | /// The field variable will not be modified or copied
14 | ///
15 | Ignore = 1,
16 | ///
17 | /// The field variable will be copied into the new type. This option is only valid when the type conversion is set to
18 | /// or .
19 | ///
20 | Copy = 2,
21 | ///
22 | /// The field variable will be copied only when the type that contains this field will be converted into a new type and is used by a converted method.
23 | ///
24 | Smart = 3
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AnonymousFunctions/Input/ArrayOfDelegates.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.AnonymousFunctions.Input
10 | {
11 | public class ArrayOfDelegates
12 | {
13 | public void Test()
14 | {
15 | var dict = new Dictionary()
16 | {
17 | {() => { Read(); }, true},
18 | {() => Read(), true},
19 | {Read, true}
20 | };
21 | var array = new List()
22 | {
23 | () => { Read(); },
24 | () => Read(),
25 | Read,
26 | };
27 | var array2 = new Action[]
28 | {
29 | () => { Read(); },
30 | () => Read(),
31 | Read,
32 | };
33 | }
34 |
35 | public void Read()
36 | {
37 | SimpleFile.Read();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Input/GenericTypeParameter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
10 | {
11 | public class GenericTypeParameter
12 | {
13 | public void Test(GenericTypeParameter test)
14 | {
15 | test.Execute(() =>
16 | {
17 | SimpleFile.Read();
18 | return true;
19 | });
20 | }
21 | }
22 |
23 | public class GenericTypeParameter
24 | {
25 | public TResult Execute(Func func)
26 | {
27 | return default(TResult);
28 | }
29 |
30 | public Task ExecuteAsync(Func> func, CancellationToken cancellationToken)
31 | {
32 | return Task.FromResult(default(TResult));
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Plugins/Input/TransactionScopeAsyncFlow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Transactions;
7 | using AsyncGenerator.TestCases;
8 |
9 | namespace AsyncGenerator.Tests.Plugins.Input
10 | {
11 | public class TransactionScopeAsyncFlow
12 | {
13 | public void Test()
14 | {
15 | using (new TransactionScope())
16 | {
17 | SimpleFile.Read();
18 | }
19 | using (new TransactionScope(TransactionScopeOption.Required))
20 | {
21 | SimpleFile.Read();
22 | }
23 | using (new TransactionScope(TransactionScopeOption.Suppress))
24 | {
25 | SimpleFile.Read();
26 | }
27 | using (new TransactionScope(TransactionScopeOption.Required, TransactionScopeAsyncFlowOption.Suppress))
28 | {
29 | SimpleFile.Read();
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Internal/DelegatePreconditionChecker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Core.Plugins;
7 | using AsyncGenerator.Plugins;
8 | using AsyncGenerator.Plugins.Internal;
9 | using Microsoft.CodeAnalysis;
10 | using Microsoft.CodeAnalysis.CSharp.Syntax;
11 |
12 | namespace AsyncGenerator.Internal
13 | {
14 | internal class DelegatePreconditionChecker : AbstractPlugin, IPreconditionChecker
15 | {
16 | private readonly Func _func;
17 |
18 | public DelegatePreconditionChecker(Func func)
19 | {
20 | _func = func;
21 | }
22 |
23 | public bool IsPrecondition(StatementSyntax statement, SemanticModel semanticModel)
24 | {
25 | return _func(statement, semanticModel);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncMethodFinder/Output/IgnoreSomeAsyncMethods.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.AsyncMethodFinder.Input
19 | {
20 | public partial class IgnoreSomeAsyncMethods
21 | {
22 | public async Task ReadAsync()
23 | {
24 | await (SimpleFile.ReadAsync());
25 | SimpleFile.Write("");
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Output/Simple.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using AsyncGenerator.TestCases;
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Text;
16 | using System.Threading.Tasks;
17 |
18 | namespace AsyncGenerator.Tests.LocalFunctions.Input
19 | {
20 | public partial class Simple
21 | {
22 | public Task TestAsync()
23 | {
24 | Task ReadAsync()
25 | {
26 | return SimpleFile.ReadAsync();
27 | }
28 | return ReadAsync();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PreserveReturnType/Output/FunctionArgument.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 | using NUnit.Framework;
18 |
19 | namespace AsyncGenerator.Tests.PreserveReturnType.Input
20 | {
21 | public partial class FunctionArgument
22 | {
23 | public void TestAsync()
24 | {
25 | Assert.DoesNotThrowAsync(SimpleFile.ReadAsync);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/AbstractGetter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class AbstractGetter : BaseAbstractGetter
11 | {
12 | public override bool IsSuccess { get { return true; } }
13 |
14 | public override bool WriteSuccess
15 | {
16 | get { return Write(); }
17 | }
18 |
19 | private bool Write()
20 | {
21 | return SimpleFile.Write("");
22 | }
23 |
24 | protected void CheckSuccess()
25 | {
26 | if (WriteSuccess && IsSuccess)
27 | {
28 | return;
29 | }
30 | }
31 | }
32 |
33 | public abstract class BaseAbstractGetter
34 | {
35 | public abstract bool WriteSuccess { get; }
36 |
37 | public abstract bool IsSuccess { get; }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/CancellationTokens/Input/AbstractClass.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.CancellationTokens.Input
9 | {
10 | public abstract class AbstractClass
11 | {
12 | public virtual void Read()
13 | {
14 | SimpleFile.Read();
15 | }
16 |
17 | public virtual bool Write(string value)
18 | {
19 | return SimpleFile.Write(value);
20 | }
21 |
22 | public abstract void Clear();
23 | }
24 |
25 | public class DerivedClass : AbstractClass
26 | {
27 | public override void Read()
28 | {
29 | base.Read();
30 | }
31 |
32 | public override bool Write(string value)
33 | {
34 | return base.Write(value);
35 | }
36 |
37 | public override void Clear()
38 | {
39 | SimpleFile.Read();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Output/Precondition.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.TryCatch.Input
19 | {
20 | public partial class Precondition
21 | {
22 |
23 | public Task TestAsync()
24 | {
25 | if (Success)
26 | {
27 | throw new NotSupportedException();
28 | }
29 | return Task.CompletedTask;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Input/AbstractSetter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.AsyncProperites.Input
9 | {
10 | public class AbstractSetter : BaseAbstractSetter
11 | {
12 | public override bool IsSuccess { get { return true; } }
13 |
14 | public override string WriteSuccess
15 | {
16 | set { Write(value); }
17 | }
18 |
19 | private bool Write(string value)
20 | {
21 | return SimpleFile.Write(value);
22 | }
23 |
24 | protected void SetSuccess()
25 | {
26 | if (IsSuccess)
27 | {
28 | WriteSuccess = "";
29 | }
30 | }
31 | }
32 |
33 | public abstract class BaseAbstractSetter
34 | {
35 | public abstract string WriteSuccess { set; }
36 |
37 | public abstract bool IsSuccess { get; }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/CastOmitAsync/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using AsyncGenerator.TestCases;
4 |
5 | namespace AsyncGenerator.Tests.CastOmitAsync.Input
6 | {
7 | public class TestCase
8 | {
9 | public long LongCastReturn()
10 | {
11 | return ReadFileInt();
12 | }
13 |
14 | public IEnumerable EnumerableCastReturn()
15 | {
16 | return ReadFiles();
17 | }
18 |
19 | public List NoCastReturn()
20 | {
21 | return ReadFiles();
22 | }
23 |
24 | public Task NoCastReturnTask()
25 | {
26 | return Task.Run(() =>
27 | {
28 | SimpleFile.Read();
29 | return true;
30 | });
31 | }
32 |
33 | public int ReadFileInt()
34 | {
35 | SimpleFile.Read();
36 | return 1;
37 | }
38 |
39 | public List ReadFiles()
40 | {
41 | SimpleFile.Read();
42 | return new List();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Formatting/Output/ConfigureAwait.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.Formatting.Input
19 | {
20 | public partial class ConfigureAwait
21 | {
22 | public async Task TestAsync()
23 | {
24 | var obj = new
25 | {
26 | test = await (SimpleFile.WriteAsync("")).ConfigureAwait(false)
27 | };
28 |
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/IfDirective/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | #if ASYNC
9 | namespace AsyncGenerator.Tests.IfDirective
10 | {
11 | #if TRACE
12 | namespace Input
13 | {
14 | public class Parent
15 | {
16 | public class TestCase
17 | {
18 | #if ASYNC
19 |
20 | public void Read()
21 | {
22 | SimpleFile.Read();
23 | }
24 |
25 | public void SyncMethod()
26 | {
27 |
28 | }
29 | #elif TRACE
30 | #else
31 |
32 | public void Sync2Method()
33 | {
34 |
35 | }
36 |
37 | #endif
38 |
39 | }
40 |
41 | #if TRACE
42 | public class TestCase2
43 | {
44 | }
45 | #else
46 |
47 | #endif
48 | }
49 | }
50 |
51 | #endif
52 |
53 | public class TestCase3
54 | {
55 | }
56 |
57 | }
58 | #endif
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AnonymousFunctions/Output/Variable.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.AnonymousFunctions.Input
19 | {
20 | public partial class Variable
21 | {
22 | public async Task TestAsync()
23 | {
24 | await (SimpleFile.ReadAsync());
25 | Action action = () =>
26 | {
27 | SimpleFile.Read();
28 | };
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/CancellationTokens/Input/ClassWithLocalAsyncMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 |
6 | namespace AsyncGenerator.Tests.CancellationTokens.Input
7 | {
8 | public class ClassWithLocalAsyncMethods
9 | {
10 | public void Work()
11 | {
12 | LocalMethodWithCancellation();
13 | LocalMethodWithoutCancellation();
14 | LocalMethodWithCancellation();
15 | }
16 |
17 | public void LocalMethodWithCancellation()
18 | {
19 | Thread.Sleep(100);
20 | }
21 | public void LocalMethodWithoutCancellation()
22 | {
23 | Thread.Sleep(100);
24 | }
25 |
26 | public async Task LocalMethodWithCancellationAsync(CancellationToken cancellationToken)
27 | {
28 | await Task.Delay(100, cancellationToken);
29 | }
30 | public async Task LocalMethodWithoutCancellationAsync()
31 | {
32 | await Task.Delay(100);
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NestedNamespaces/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NestedNamespaces.Input
9 | {
10 | public class TestCase
11 | {
12 | public class Child
13 | {
14 | public void Read()
15 | {
16 | SimpleFile.Read();
17 | }
18 | }
19 |
20 | public void VoidMethod()
21 | {
22 |
23 | }
24 | }
25 |
26 | namespace Inner
27 | {
28 | public class TestCase
29 | {
30 | public class Child
31 | {
32 | public void Read()
33 | {
34 | SimpleFile.Read();
35 | }
36 | }
37 |
38 | public void VoidMethod()
39 | {
40 |
41 | }
42 | }
43 | }
44 |
45 | namespace Empty
46 | {
47 | public class TestCase
48 | {
49 | public void VoidMethod()
50 | {
51 |
52 | }
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Preconditions/Input/TestCase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using AsyncGenerator.TestCases;
3 |
4 | namespace AsyncGenerator.Tests.Preconditions.Input
5 | {
6 | public static class Requires
7 | {
8 | public static void IsNotNull(object value, string name)
9 | {
10 | if (value == null)
11 | throw new ArgumentNullException(name);
12 | }
13 | }
14 |
15 | public class TestCase
16 | {
17 | public void ReadFile(string path)
18 | {
19 | if (path == null)
20 | {
21 | throw new ArgumentNullException(nameof(path));
22 | }
23 | SimpleFile.Read();
24 | }
25 |
26 | public int Divide(int a, int b)
27 | {
28 | if (b == 0) throw new InvalidOperationException();
29 | SimpleFile.Read();
30 | return a/b;
31 | }
32 |
33 | public int DivideShort(short a, short b)
34 | {
35 | Requires.IsNotNull(b, nameof(b));
36 | SimpleFile.Read();
37 | return a/b;
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Output/Cast.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 |
17 | namespace AsyncGenerator.Tests.TryCatch.Input
18 | {
19 | public partial class Cast
20 | {
21 |
22 | public Task TestAsync()
23 | {
24 | try
25 | {
26 | return Task.FromResult((int)_maxLong);
27 | }
28 | catch (Exception ex)
29 | {
30 | return Task.FromException(ex);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Transformation/Internal/FunctionReferenceTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Analyzation;
7 | using AsyncGenerator.Configuration;
8 | using AsyncGenerator.Core.Analyzation;
9 | using AsyncGenerator.Core.Transformation;
10 | using Microsoft.CodeAnalysis.CSharp.Syntax;
11 |
12 | namespace AsyncGenerator.Transformation.Internal
13 | {
14 | internal class FunctionReferenceTransformationResult : TransformationResult, IFunctionReferenceTransformationResult
15 | {
16 | public FunctionReferenceTransformationResult(IFunctionReferenceAnalyzationResult analyzationResult) : base(analyzationResult.ReferenceNameNode)
17 | {
18 | AnalyzationResult = analyzationResult;
19 | }
20 |
21 | public IFunctionReferenceAnalyzationResult AnalyzationResult { get; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AnonymousFunctions/Output/ReturnTypeMismatch.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.AnonymousFunctions.Input
19 | {
20 | public partial class ReturnTypeMismatch
21 | {
22 | public Task TestAsync()
23 | {
24 | return Runner.RunAsync(s =>
25 | {
26 | SimpleFile.Clear();
27 | SimpleFile.Write("");
28 | });
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/IfDirective/Output/TryCatchForwardCall.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 |
17 | namespace AsyncGenerator.Tests.IfDirective.Input
18 | {
19 | public partial class TryCatch
20 | {
21 | public Task TestAsync()
22 | {
23 | try
24 | {
25 | return Task.FromResult(Test());
26 | }
27 | catch (Exception ex)
28 | {
29 | return Task.FromException(ex);
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/TypeConversion.cs:
--------------------------------------------------------------------------------
1 | namespace AsyncGenerator.Core
2 | {
3 | public enum TypeConversion
4 | {
5 | ///
6 | /// Conversion will be decided by the analyzer. The final conversion can be if the type contains at least one
7 | /// method with the conversion otherwise
8 | ///
9 | Unknown = 0,
10 | ///
11 | /// The type will not be modified
12 | ///
13 | Ignore = 1,
14 | ///
15 | /// A partial type will be created that could contain one or more async methods
16 | ///
17 | Partial = 2,
18 | ///
19 | /// A new type will be created with an Async postfix that could contain one or more async methods
20 | ///
21 | NewType = 3,
22 | ///
23 | /// The type will be copied into the new one
24 | ///
25 | Copy = 4
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PrivateMethods/Output/ExplicitInterface.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq.Expressions;
14 | using AsyncGenerator.TestCases;
15 |
16 | namespace AsyncGenerator.Tests.PrivateMethods.Input
17 | {
18 | using System.Threading.Tasks;
19 | public partial interface IInterface
20 | {
21 | Task ReadAsync();
22 | }
23 |
24 | public partial class ExplicitInterface : IInterface
25 | {
26 | Task IInterface.ReadAsync()
27 | {
28 | return SimpleFile.ReadAsync();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Github/Issue105/Output/TestCase.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq.Expressions;
14 | using System.Threading.Tasks;
15 | using AsyncGenerator.TestCases;
16 |
17 | namespace AsyncGenerator.Tests.Github.Issue105.Input
18 | {
19 | public partial class TestCase
20 | {
21 | public Task InterfaceAsync(IAsyncChild c)
22 | {
23 | return c.SomeMethodAsync();
24 | }
25 |
26 | public Task ClassAsync(BothSyncAndAsync c)
27 | {
28 | return c.SomeMethodAsync();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Nameof/Output/MethodPartial.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System.ComponentModel;
12 | using AsyncGenerator.TestCases;
13 |
14 | namespace AsyncGenerator.Tests.Nameof.Input
15 | {
16 | using System.Threading.Tasks;
17 | public partial class Method
18 | {
19 | [DefaultValue(nameof(WriteAsync))]
20 | public Task WriteAsync()
21 | {
22 | return SimpleFile.WriteAsync(nameof(DoSomething));
23 | }
24 |
25 | [DefaultValue(nameof(DoSomething2))]
26 | public Task ReadAsync()
27 | {
28 | return SimpleFile.ReadAsync();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/TryCatch/Output/ElementAccess.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 |
17 | namespace AsyncGenerator.Tests.TryCatch.Input
18 | {
19 | public partial class ElementAccess
20 | {
21 |
22 | public Task TestAsync()
23 | {
24 | try
25 | {
26 | return Task.FromResult(_list[10]);
27 | }
28 | catch (Exception ex)
29 | {
30 | return Task.FromException(ex);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Transformation/Internal/RootTypeTransformationResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.Analyzation;
7 | using AsyncGenerator.Core.Analyzation;
8 |
9 | namespace AsyncGenerator.Transformation.Internal
10 | {
11 | internal class RootTypeTransformationResult : TypeTransformationResult
12 | {
13 | public RootTypeTransformationResult(ITypeAnalyzationResult analyzationResult) : base(analyzationResult)
14 | {
15 | }
16 |
17 | public List DescendantTransformedTypes { get; } = new List();
18 |
19 | public IEnumerable GetSelfAndDescendantTransformedTypes()
20 | {
21 | yield return this;
22 | foreach (var transformType in DescendantTransformedTypes)
23 | {
24 | yield return transformType;
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NewTypes/Input/NestedCopy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using AsyncGenerator.TestCases;
7 |
8 | namespace AsyncGenerator.Tests.NewTypes.Input
9 | {
10 | public abstract class AbstractNestedCopy
11 | {
12 | protected abstract void Setup();
13 | }
14 |
15 | public class NestedCopy : AbstractNestedCopy
16 | {
17 | protected override void Setup()
18 | {
19 | Read();
20 | }
21 |
22 | public void Test()
23 | {
24 | Read();
25 | }
26 |
27 | private void Read()
28 | {
29 | InternalInternalInternalRead();
30 | }
31 |
32 | private void InternalInternalInternalRead()
33 | {
34 | InternalInternalRead();
35 | }
36 |
37 | private void InternalInternalRead()
38 | {
39 | InternalRead();
40 | }
41 |
42 | private void InternalRead()
43 | {
44 | SimpleFile.Read();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NullableReferences/Output/NullableRestore.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | #nullable restore
12 | using System.IO;
13 |
14 | namespace NullableRestore
15 | {
16 | using System.Threading.Tasks;
17 | using System.Threading;
18 | public partial class TestCase
19 | {
20 | public async Task ReadFileAsync(CancellationToken cancellationToken = default(CancellationToken))
21 | {
22 | var stream = File.OpenRead("");
23 | await (stream.ReadAsync(new byte[] { }, 0, 100, cancellationToken));
24 | stream.Dispose();
25 | return null;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Source/AsyncGenerator/Internal/TypeDataReference.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using AsyncGenerator.Analyzation;
3 | using AsyncGenerator.Core.Analyzation;
4 | using AsyncGenerator.Extensions.Internal;
5 | using Microsoft.CodeAnalysis;
6 | using Microsoft.CodeAnalysis.CSharp.Syntax;
7 | using Microsoft.CodeAnalysis.FindSymbols;
8 |
9 | namespace AsyncGenerator.Internal
10 | {
11 | internal class TypeDataReference : DataReference, ITypeReferenceAnalyzationResult
12 | {
13 | public TypeDataReference(AbstractData data, ReferenceLocation reference, SimpleNameSyntax referenceNameNode, INamedTypeSymbol referenceSymbol, TypeData referenceData)
14 | : base(data, reference, referenceNameNode, referenceSymbol, referenceData)
15 | {
16 | }
17 |
18 | #region ITypeReferenceAnalyzationResult
19 |
20 | ITypeAnalyzationResult ITypeReferenceAnalyzationResult.TypeAnalyzationResult => ReferenceData;
21 |
22 | #endregion
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/LocalFunctions/Output/SimpleAsync.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using AsyncGenerator.TestCases;
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Text;
16 | using System.Threading.Tasks;
17 |
18 | namespace AsyncGenerator.Tests.LocalFunctions.Input
19 | {
20 | public partial class SimpleAsync
21 | {
22 | public Task TestAsync()
23 | {
24 | async Task ReadAsync()
25 | {
26 | await (SimpleFile.ReadAsync());
27 | await (SimpleFile.ReadAsync());
28 | }
29 | return ReadAsync();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NUnit/Output/AssertThatTryCatch.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 | using NUnit.Framework;
18 |
19 | namespace AsyncGenerator.Tests.NUnit.Input
20 | {
21 | public partial class AssertThatTryCatch
22 | {
23 | public void TestAsync()
24 | {
25 | Assert.That(() =>
26 | {
27 | SimpleFile.Clear();
28 | return SimpleFile.WriteAsync("");
29 | }, Throws.Nothing);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/NUnit/Output/DoesNotThrowTryCatch.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 | using NUnit.Framework;
18 |
19 | namespace AsyncGenerator.Tests.NUnit.Input
20 | {
21 | public partial class DoesNotThrowTryCatch
22 | {
23 | public void TestAsync()
24 | {
25 | Assert.DoesNotThrowAsync(() =>
26 | {
27 | SimpleFile.Clear();
28 | return SimpleFile.ReadAsync();
29 | });
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Nameof/Output/ArgumentFunctionNewType.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading;
16 | using System.Threading.Tasks;
17 | using AsyncGenerator.TestCases;
18 |
19 | namespace AsyncGenerator.Tests.Nameof.Input
20 | {
21 | public class ArgumentFunctionAsync
22 | {
23 | public Task TestAsync()
24 | {
25 | return Task.FromResult(new Thread(() =>
26 | {
27 | SimpleFile.Write(nameof(TestAsync));
28 | }));
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/PartialCompilation/Output/Ctor.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Text;
16 | using System.Threading.Tasks;
17 | using AsyncGenerator.TestCases;
18 |
19 | namespace AsyncGenerator.Tests.PartialCompilation.Input
20 | {
21 | public partial class Ctor
22 | {
23 |
24 | #if TEST
25 |
26 | #endif
27 |
28 | protected static async Task GetListAsync()
29 | {
30 | await (SimpleFile.ReadAsync());
31 | return null;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/Nameof/Output/Variable.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Concurrent;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Text;
16 | using System.Threading;
17 | using System.Threading.Tasks;
18 | using AsyncGenerator.TestCases;
19 | using NUnit.Framework;
20 |
21 | namespace AsyncGenerator.Tests.Nameof.Input
22 | {
23 | public partial class Variable
24 | {
25 | public Task TestAsync()
26 | {
27 | var region = nameof(TestAsync);
28 | return SimpleFile.WriteAsync(region);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Core/AsyncGenerator.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(LibTargetFrameworks)
5 | CSharpAsyncGenerator.Core
6 | CSharpAsyncGenerator.Core
7 | Contains various plugins and public api for creating custom plugins
8 | true
9 | false
10 | 7.3
11 | NU1510
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AnonymousFunctions/Output/ArrayOfDelegates.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading;
16 | using System.Threading.Tasks;
17 | using AsyncGenerator.TestCases;
18 |
19 | namespace AsyncGenerator.Tests.AnonymousFunctions.Input
20 | {
21 | public class ArrayOfDelegatesAsync
22 | {
23 |
24 | public Task ReadAsync(CancellationToken cancellationToken = default(CancellationToken))
25 | {
26 | return SimpleFile.ReadAsync(cancellationToken);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Source/AsyncGenerator.Tests/AsyncProperites/Output/GetAccessor.txt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by AsyncGenerator.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Linq;
14 | using System.Text;
15 | using System.Threading.Tasks;
16 | using AsyncGenerator.TestCases;
17 |
18 | namespace AsyncGenerator.Tests.AsyncProperites.Input
19 | {
20 |
21 | public partial class GetAccessor : IGetAccessor
22 | {
23 |
24 | public async Task GetWriteAsync()
25 | {
26 | if (!IsBusy)
27 | {
28 | _value = await (SimpleFile.WriteAsync(""));
29 | }
30 |
31 | return _value;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------