Skip to content

Commit

Permalink
[Source Gen] Refactor to walk dependent assemblies (#1896)
Browse files Browse the repository at this point in the history
  • Loading branch information
satvu authored Sep 18, 2023
1 parent f406711 commit fec76f4
Show file tree
Hide file tree
Showing 15 changed files with 376 additions and 87 deletions.
7 changes: 7 additions & 0 deletions DotNetWorker.sln
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.Tests", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetIntegration", "samples\AspNetIntegration\AspNetIntegration.csproj", "{D2F67410-9933-42E8-B04A-E17634D83A30}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependentAssemblyWithFunctions", "test\DependentAssemblyWithFunctions\DependentAssemblyWithFunctions.csproj", "{AB6E1E7A-0D2C-4086-9487-566887C1E753}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -326,6 +328,10 @@ Global
{D2F67410-9933-42E8-B04A-E17634D83A30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2F67410-9933-42E8-B04A-E17634D83A30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2F67410-9933-42E8-B04A-E17634D83A30}.Release|Any CPU.Build.0 = Release|Any CPU
{AB6E1E7A-0D2C-4086-9487-566887C1E753}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB6E1E7A-0D2C-4086-9487-566887C1E753}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB6E1E7A-0D2C-4086-9487-566887C1E753}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB6E1E7A-0D2C-4086-9487-566887C1E753}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -383,6 +389,7 @@ Global
{286F9EE3-00AE-4EFA-BFD8-A2E58BC809D2} = {FD7243E4-BF18-43F8-8744-BA1D17ACF378}
{17BDCE12-6964-4B87-B2AC-68CE270A3E9A} = {FD7243E4-BF18-43F8-8744-BA1D17ACF378}
{D2F67410-9933-42E8-B04A-E17634D83A30} = {9D6603BD-7EA2-4D11-A69C-0D9E01317FD6}
{AB6E1E7A-0D2C-4086-9487-566887C1E753} = {B5821230-6E0A-4535-88A9-ED31B6F07596}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {497D2ED4-A13E-4BCA-8D29-F30CA7D0EA4A}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ internal ICollection<ExecutableFunction> GetFunctions(List<MethodDeclarationSynt
_context.CancellationToken.ThrowIfCancellationRequested();
var model = Compilation.GetSemanticModel(method.SyntaxTree);

if (!FunctionsUtil.IsValidFunctionMethod(_context, Compilation, model, method,
out _))
if (!FunctionsUtil.IsValidFunctionMethod(_context, Compilation, model, method))
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ private bool TryGetIsBatchedProp(AttributeData attribute, out ISymbol? isBatched
/// attribute must be an iterable collection.
/// </summary>
/// <param name="parameterSymbol">The parameter associated with a binding attribute that supports cardinality represented as an <see cref="IParameterSymbol"/>.</param>
/// <param name="parameterTypeSyntax">The <see cref="TypeSyntax"/> representation of the paramter's type if it exists.</param>
/// <param name="attribute">The binding attribute that supports cardinality.</param>
/// <param name="dataType">The <see cref="DataType"/> that best represents the parameter.</param>
/// <returns>Returns true if the parameter is compatible with the cardinality defined by the attribute, else returns false.</returns>
public bool IsCardinalityValid(IParameterSymbol parameterSymbol, TypeSyntax? parameterTypeSyntax, AttributeData attribute, out DataType dataType)
public bool IsCardinalityValid(IParameterSymbol parameterSymbol, AttributeData attribute, out DataType dataType)
{
dataType = DataType.Undefined;
var cardinalityIsNamedArg = false;
Expand Down Expand Up @@ -139,12 +138,7 @@ public bool IsCardinalityValid(IParameterSymbol parameterSymbol, TypeSyntax? par
}
else if (isGenericEnumerable)
{
if (parameterTypeSyntax is null)
{
return false;
}

dataType = ResolveIEnumerableOfT(parameterSymbol, parameterTypeSyntax, out bool hasError);
dataType = ResolveIEnumerableOfT(parameterSymbol, out bool hasError);

if (hasError)
{
Expand All @@ -164,10 +158,9 @@ public bool IsCardinalityValid(IParameterSymbol parameterSymbol, TypeSyntax? par
/// Find the underlying data type of an IEnumerableOfT (String, Binary, Undefined)
/// ex. IEnumerable<byte[]> would return DataType.Binary
/// </summary>
private DataType ResolveIEnumerableOfT(IParameterSymbol parameterSymbol, TypeSyntax parameterSyntax, out bool hasError)
private DataType ResolveIEnumerableOfT(IParameterSymbol parameterSymbol, out bool hasError)
{
var result = DataType.Undefined;
var currentSyntax = parameterSyntax;
hasError = false;

var currSymbol = parameterSymbol.Type;
Expand Down
Loading

0 comments on commit fec76f4

Please sign in to comment.