Browse Source

LazyInitializer.EnsureInitialized does not allow null as return value. Use LazyInit instead.

pull/3265/head
Siegfried Pammer 1 year ago
parent
commit
76cc084dcd
  1. 13
      ICSharpCode.ILSpyX/LoadedAssembly.cs

13
ICSharpCode.ILSpyX/LoadedAssembly.cs

@ -209,14 +209,19 @@ namespace ICSharpCode.ILSpyX @@ -209,14 +209,19 @@ namespace ICSharpCode.ILSpyX
/// </remarks>
public ICompilation? GetTypeSystemOrNull()
{
return LazyInitializer.EnsureInitialized(ref this.typeSystem, () => {
var value = Volatile.Read(ref this.typeSystem);
if (value == null)
{
var module = GetMetadataFileOrNull();
if (module == null || module.IsMetadataOnly)
return null!;
return new SimpleCompilation(
return null;
value = new SimpleCompilation(
module.WithOptions(TypeSystemOptions.Default | TypeSystemOptions.Uncached | TypeSystemOptions.KeepModifiers),
MinimalCorlib.Instance);
});
value = LazyInit.GetOrSet(ref this.typeSystem, value);
}
return value;
}
readonly object typeSystemWithOptionsLockObj = new object();

Loading…
Cancel
Save