-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix Validation SG for Blazor Wasm SDK projects #63687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ public static WellKnownTypes GetOrCreate(Compilation compilation) => | |
|
||
private readonly INamedTypeSymbol?[] _lazyWellKnownTypes; | ||
private readonly Compilation _compilation; | ||
private readonly INamedTypeSymbol _missingTypeSymbol; | ||
|
||
static WellKnownTypes() | ||
{ | ||
|
@@ -51,6 +52,7 @@ private WellKnownTypes(Compilation compilation) | |
{ | ||
_lazyWellKnownTypes = new INamedTypeSymbol?[WellKnownTypeData.WellKnownTypeNames.Length]; | ||
_compilation = compilation; | ||
_missingTypeSymbol = compilation.GetTypeByMetadataName(typeof(MissingType).FullName!)!; | ||
|
||
} | ||
|
||
public INamedTypeSymbol Get(SpecialType type) | ||
|
@@ -74,11 +76,7 @@ public INamedTypeSymbol Get(WellKnownTypeData.WellKnownType type) | |
|
||
private INamedTypeSymbol GetAndCache(int index) | ||
{ | ||
var result = GetTypeByMetadataNameInTargetAssembly(WellKnownTypeData.WellKnownTypeNames[index]); | ||
if (result == null) | ||
{ | ||
throw new InvalidOperationException($"Failed to resolve well-known type '{WellKnownTypeData.WellKnownTypeNames[index]}'."); | ||
} | ||
var result = GetTypeByMetadataNameInTargetAssembly(WellKnownTypeData.WellKnownTypeNames[index]) ?? _missingTypeSymbol; | ||
Interlocked.CompareExchange(ref _lazyWellKnownTypes[index], result, null); | ||
|
||
// GetTypeByMetadataName should always return the same instance for a name. | ||
|
@@ -159,4 +157,6 @@ public static bool Implements(ITypeSymbol? type, ITypeSymbol interfaceType) | |
} | ||
return false; | ||
} | ||
|
||
internal class MissingType { } | ||
} |
Uh oh!
There was an error while loading. Please reload this page.