-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverted Microsoft.CodeAnalysis back to 4.1.0 because JetBrains Rider…
… does not support 4.2.0 yet. Made the `MetadataReferencesProvider` backwards compatible due to dotnet/roslyn#58059
- Loading branch information
Showing
8 changed files
with
65 additions
and
42 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
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
23 changes: 23 additions & 0 deletions
23
...ensions.SourceGenerator/Extensions/IncrementalGeneratorInitializationContextExtensions.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,23 @@ | ||
using System.Collections.Immutable; | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Thinktecture; | ||
|
||
public static class IncrementalGeneratorInitializationContextExtensions | ||
{ | ||
public static IncrementalValuesProvider<MetadataReference> GetMetadataReferencesProvider(this IncrementalGeneratorInitializationContext context) | ||
{ | ||
var metadataProviderProperty = context.GetType().GetProperty(nameof(context.MetadataReferencesProvider)) | ||
?? throw new Exception($"The property '{nameof(context.MetadataReferencesProvider)}' not found"); | ||
|
||
var metadataProvider = metadataProviderProperty.GetValue(context); | ||
|
||
if (metadataProvider is IncrementalValuesProvider<MetadataReference> metadataValuesProvider) | ||
return metadataValuesProvider; | ||
|
||
if (metadataProvider is IncrementalValueProvider<MetadataReference> metadataValueProvider) | ||
return metadataValueProvider.SelectMany(static (reference, _) => ImmutableArray.Create(reference)); | ||
|
||
throw new Exception($"The '{nameof(context.MetadataReferencesProvider)}' is neither an 'IncrementalValuesProvider<{nameof(MetadataReference)}>' nor an 'IncrementalValueProvider<{nameof(MetadataReference)}>.'"); | ||
} | ||
} |
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