Uh oh!
There was an error while loading. Please reload this page.
Address feedback from config binding gen PR to improve enum parsing - #89952
Conversation
ghost
commented
Aug 3, 2023
Tagging subscribers to this area: @dotnet/area-extensions-configuration |
There was a problem hiding this comment.
I'd re-write this as
| if(stringParsableSpec.StringParsableTypeKind!=StringParsableTypeKind.AssignFromSectionValue&&stringParsableSpec.StringParsableTypeKind!=StringParsableTypeKind.Enum) | |
| if(specialTypeKindisStringParsableTypeKind.Enum) | |
| { | |
| _sourceGenSpec.EmitEnumParseMethod=true; | |
| } | |
| elseif(specialTypeKindis not StringParsableTypeKind.AssignFromSectionValue) | |
| { | |
| _sourceGenSpec.PrimitivesForHelperGen.Add(stringParsableSpec); | |
| } |
There was a problem hiding this comment.
Shouldn't need this given the suggestion below.
@pedrobsaila, let's go with checking for the right method in the parser - #89823 (comment). We could also address #89879 in this PR. |
layomia
commented
Aug 25, 2023
@pedrobsaila apologies for my delayed response. Could you pls resolve merge conflicts here? |
| ISet_Unbound = ISet?.ConstructUnboundGenericType(); | ||
| // needed to be able to know if a member exist inside the compilation unit | ||
| Enum = compilation.GetBestTypeByMetadataName(typeof(Enum)); |
There was a problem hiding this comment.
Use the overload taking a SpecialType (i.e. SpecialType.System_Enum). All the special types are guaranteed to be in the input compilation.
| public INamedTypeSymbol? ISet_Unbound { get; } | ||
| public INamedTypeSymbol? ISet { get; } | ||
| public INamedTypeSymbol? List { get; } | ||
| public INamedTypeSymbol? Enum { get; } |
There was a problem hiding this comment.
| publicINamedTypeSymbol?Enum{get;} | |
| publicINamedTypeSymbolEnum{get;} |
Per https://github.com/dotnet/runtime/pull/89952/files#r1307693295 the fetched value would not be null.
| } | ||
| } | ||
| _sourceGenSpec.EmitThrowIfNullMethod = !_typeSymbols.ArgumentNullException.GetMembers("ThrowIfNull").IsEmpty; |
There was a problem hiding this comment.
| _sourceGenSpec.EmitThrowIfNullMethod=!_typeSymbols.ArgumentNullException.GetMembers("ThrowIfNull").IsEmpty; | |
| _sourceGenSpec.EmitThrowIfNullMethod=_typeSymbols.ArgumentNullException?.GetMembers("ThrowIfNull").IsEmptyisfalse; |
The symbol could be null; avoid a null-ref exception.
| @@ -0,0 +1,243 @@ | |||
| // <auto-generated/> | |||
There was a problem hiding this comment.
Thanks for adding the net462 variants. Could we refactor to the following structure?
> baselines
> netcoreapp
> foo.generated.txt
> net462
> foo.generated.txt
I'd actually suggest making a preliminary PR doing this. We'd need to remove the condition on [this line] so that the net462 tests would be included in automated runs. Doing this will reveal a bit of additional, tangential work needed to complete the effort.
layomia
commented
Aug 28, 2023
Oof looks like merging #91180 reset your rebase effort. If you take another stab, I'll be sure to check if this PR is merge-ready & queue it up first if so. |
| ExtensionClassType extType = ExtensionClassType.None) | ||
| Action<ImmutableArray<Diagnostic>>? assessDiagnostics = null) | ||
| { | ||
| string path = extType is ExtensionClassType.None |
There was a problem hiding this comment.
Please use a a preprocessor directive to determine the path
stringpath= #if NETCOREAPP
...
#else ...;| { | ||
| string source = GetCollectionsSource(); | ||
| await VerifyAgainstBaselineUsingFile("Collections.net462.generated.txt", source, assessDiagnostics: (d) => |
There was a problem hiding this comment.
Per f5a2abc#r1321885499, please revert the changes to these invocations.
| </ItemGroup> | ||
| <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'"> | ||
| <Content Include="Baselines\*.generated.txt; |
There was a problem hiding this comment.
Please revert back to partitioning the baselines based on the binder ext. type. This is helpful when working issues specific to a particular binder.
| } | ||
| _sourceGenSpec.EmitThrowIfNullMethod = !_typeSymbols.ArgumentNullException.GetMembers("ThrowIfNull").IsEmpty; | ||
| _sourceGenSpec.EmitThrowIfNullMethod = _typeSymbols.ArgumentNullException is not null && _typeSymbols.ArgumentNullException.GetMembers("ThrowIfNull").IsEmpty is false; |
There was a problem hiding this comment.
_sourceGenSpec.EmitThrowIfNullMethod = _typeSymbols.ArgumentNullException?.GetMembers("ThrowIfNull").IsEmpty is false;
Also -- to be doubly sure, check that the method has the expected parameters.
@layomia can you check it please before the PR become stale again |
eiriktsarpalis
commented
Oct 4, 2023
@pedrobsaila apologies for the delayed response, would it be possible to rebase your changes? Thanks! |
@pedrobsaila do you have a chance to resolve the merging conflicts? |
I'm on it. The code in main branch changed deeply, resolving conflict is not easy and will take some time |
pedrobsaila
commented
Oct 7, 2023
@eiriktsarpalis@tarekgh ready for a new round of reviews |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'"> | ||
| <Content Include="Baselines\*.generated.txt;Baselines\ConfigurationBinder\*.generated.txt;Baselines\OptionsBuilder\*.generated.txt;Baselines\ServiceCollection\*.generated.txt"> | ||
| <ItemGroup> | ||
| <Content Include="Baselines\net462\*.generated.txt; |
There was a problem hiding this comment.
Include just Baselines does not seem to work, the max I could do is this lightweight version :
<Content Include="Baselines\*\*\*.generated.txt;
Baselines\*\*.generated.txt;">
There was a problem hiding this comment.
tarekgh
commented
Oct 10, 2023
@pedrobsaila thanks for getting this ready. I added a few questions if you can help with. otherwise LGTM. |
| Baselines\netcoreapp\ConfigurationBinder\*.generated.txt; | ||
| Baselines\netcoreapp\OptionsBuilder\*.generated.txt; | ||
| Baselines\netcoreapp\ServiceCollection\*.generated.txt;"> | ||
| <Content Include="Baselines\*\*\*.generated.txt; |
There was a problem hiding this comment.
seems right to me. There are 2 patterns of files :
Baselines\netcoreapp\OptionsBuilder\*.generated.txt=> would matchBaselines\*\*\*.generated.txtBaselines\netcoreapp\Primitives.generated.txt=> would matchBaselines\*.generated.txt
There was a problem hiding this comment.
If we can copy the whole Baseline as I pointed out in #89952 (comment) that will be better I guess.
Fixes#89936
Fixes#89879
@layomia I addressed the follow-up fixes.