-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit interceptor info correctly when invocation expr is on separate l…
…ine (#91107) * Emit interceptor info correctly when invocation expr is on separate line * Add more tests and add helper to udpate baselines
- Loading branch information
Showing
9 changed files
with
144 additions
and
44 deletions.
There are no files selected for viewing
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
86 changes: 86 additions & 0 deletions
86
...ns.Configuration.Binder/tests/SourceGenerationTests/ConfigurationBinderTests.Generator.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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Extensions.Configuration; | ||
using Xunit; | ||
|
||
namespace Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests | ||
{ | ||
public partial class ConfigurationBinderTests : ConfigurationBinderTestsBase | ||
{ | ||
[Fact] | ||
public void GeneratorHandlesInvocationsOnNewline() | ||
{ | ||
IConfiguration configuration = TestHelpers.GetConfigurationFromJsonString(@"{""Longitude"":1,""Latitude"":2}"); | ||
|
||
GeolocationRecord record = configuration.Get< | ||
GeolocationRecord | ||
>(); | ||
Verify(); | ||
|
||
record = (GeolocationRecord)configuration | ||
.Get(typeof(GeolocationRecord), _ => { }); | ||
Verify(); | ||
|
||
TestHelpers | ||
.GetConfigurationFromJsonString(@"{""Longitude"":3,""Latitude"":4}") | ||
.Bind(record); | ||
Verify(3, 4); | ||
|
||
int lat = configuration | ||
.GetValue<int>("Latitude"); | ||
Assert.Equal(2, lat); | ||
|
||
record = configuration.Get | ||
<GeolocationRecord>(); | ||
Verify(); | ||
|
||
record = (GeolocationRecord)configuration | ||
.Get( | ||
typeof(GeolocationRecord), _ => | ||
{ }); | ||
Verify(); | ||
|
||
TestHelpers | ||
.GetConfigurationFromJsonString(@"{""Longitude"":3, | ||
""Latitude"":4} | ||
") | ||
.Bind( | ||
record | ||
); | ||
Verify(3, 4); | ||
|
||
long latLong = configuration | ||
.GetValue< | ||
#if DEBUG | ||
int | ||
#else | ||
long | ||
#endif | ||
> | ||
("Latitude") | ||
; | ||
Assert.Equal(2, lat); | ||
|
||
record = (GeolocationRecord)configuration. | ||
Get(typeof(GeolocationRecord), _ => { }); | ||
Verify(); | ||
|
||
record = (GeolocationRecord) | ||
configuration. | ||
Get(typeof(GeolocationRecord), _ => { }); | ||
Verify(); | ||
|
||
record = (GeolocationRecord) | ||
configuration | ||
.Get(typeof(GeolocationRecord), _ => { }); | ||
Verify(); | ||
|
||
void Verify(int longitude = 1, int latitude = 2) | ||
{ | ||
Assert.Equal(longitude, record.Longitude); | ||
Assert.Equal(latitude, record.Latitude); | ||
} | ||
} | ||
} | ||
} |
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
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