-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct formatting of config binder generator (#83614)
* Correct formatting of config binder generator * Use span tokenization in multi-line emission logic
- Loading branch information
Showing
12 changed files
with
820 additions
and
466 deletions.
There are no files selected for viewing
438 changes: 274 additions & 164 deletions
438
...rosoft.Extensions.Configuration.Binder/gen/ConfigurationBindingSourceGenerator.Emitter.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 50 additions & 3 deletions
53
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/SourceGenerationSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,59 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration | ||
{ | ||
|
||
internal sealed record SourceGenerationSpec( | ||
HashSet<TypeSpec> TypesForBindMethodGen, | ||
HashSet<TypeSpec> TypesForGetMethodGen, | ||
HashSet<TypeSpec> TypesForConfigureMethodGen); | ||
Dictionary<MethodSpecifier, HashSet<TypeSpec>> Methods, | ||
HashSet<string> Namespaces) | ||
{ | ||
private MethodSpecifier? _methodsToGen; | ||
public MethodSpecifier MethodsToGen | ||
{ | ||
get | ||
{ | ||
if (!_methodsToGen.HasValue) | ||
{ | ||
_methodsToGen = MethodSpecifier.None; | ||
|
||
foreach (KeyValuePair<MethodSpecifier, HashSet<TypeSpec>> method in Methods) | ||
{ | ||
if (method.Value.Count > 0) | ||
{ | ||
MethodSpecifier specifier = method.Key; | ||
|
||
if (specifier is MethodSpecifier.Configure or MethodSpecifier.Get) | ||
{ | ||
_methodsToGen |= MethodSpecifier.HasValueOrChildren; | ||
} | ||
else if (specifier is MethodSpecifier.BindCore) | ||
{ | ||
_methodsToGen |= MethodSpecifier.HasChildren; | ||
} | ||
|
||
_methodsToGen |= specifier; | ||
} | ||
} | ||
} | ||
|
||
return _methodsToGen.Value; | ||
} | ||
} | ||
} | ||
|
||
[Flags] | ||
internal enum MethodSpecifier | ||
{ | ||
None = 0x0, | ||
Bind = 0x1, | ||
Get = 0x2, | ||
Configure = 0x4, | ||
BindCore = 0x8, | ||
HasValueOrChildren = 0x10, | ||
HasChildren = 0x20, | ||
} | ||
} |
Oops, something went wrong.