11using System ;
22using System . Collections . Concurrent ;
3+ using System . Collections . Generic ;
34using System . Collections . Immutable ;
45using System . Linq ;
56using Microsoft . CodeAnalysis ;
@@ -66,17 +67,17 @@ public static LibraryTypes FromCompilation(Compilation compilation, CodeGenerato
6667 Task_1 = Type ( "System.Threading.Tasks.Task`1" ) ,
6768 Type = Type ( "System.Type" ) ,
6869 Uri = Type ( "System.Uri" ) ,
69- Int128 = Type ( "System.Int128" ) ,
70- UInt128 = Type ( "System.UInt128" ) ,
71- Half = Type ( "System.Half" ) ,
72- DateOnly = Type ( "System.DateOnly" ) ,
70+ Int128 = TypeOrDefault ( "System.Int128" ) ,
71+ UInt128 = TypeOrDefault ( "System.UInt128" ) ,
72+ Half = TypeOrDefault ( "System.Half" ) ,
73+ DateOnly = TypeOrDefault ( "System.DateOnly" ) ,
7374 DateTimeOffset = Type ( "System.DateTimeOffset" ) ,
7475 BitVector32 = Type ( "System.Collections.Specialized.BitVector32" ) ,
7576 Guid = Type ( "System.Guid" ) ,
7677 CompareInfo = Type ( "System.Globalization.CompareInfo" ) ,
7778 CultureInfo = Type ( "System.Globalization.CultureInfo" ) ,
7879 Version = Type ( "System.Version" ) ,
79- TimeOnly = Type ( "System.TimeOnly" ) ,
80+ TimeOnly = TypeOrDefault ( "System.TimeOnly" ) ,
8081 ICodecProvider = Type ( "Orleans.Serialization.Serializers.ICodecProvider" ) ,
8182 ValueSerializer = Type ( "Orleans.Serialization.Serializers.IValueSerializer`1" ) ,
8283 ValueTask = Type ( "System.Threading.Tasks.ValueTask" ) ,
@@ -86,7 +87,7 @@ public static LibraryTypes FromCompilation(Compilation compilation, CodeGenerato
8687 Writer = Type ( "Orleans.Serialization.Buffers.Writer`1" ) ,
8788 FSharpSourceConstructFlagsOrDefault = TypeOrDefault ( "Microsoft.FSharp.Core.SourceConstructFlags" ) ,
8889 FSharpCompilationMappingAttributeOrDefault = TypeOrDefault ( "Microsoft.FSharp.Core.CompilationMappingAttribute" ) ,
89- StaticCodecs = new WellKnownCodecDescription [ ]
90+ StaticCodecs = new List < WellKnownCodecDescription >
9091 {
9192 new ( compilation . GetSpecialType ( SpecialType . System_Object ) , Type ( "Orleans.Serialization.Codecs.ObjectCodec" ) ) ,
9293 new ( compilation . GetSpecialType ( SpecialType . System_Boolean ) , Type ( "Orleans.Serialization.Codecs.BoolCodec" ) ) ,
@@ -107,19 +108,19 @@ public static LibraryTypes FromCompilation(Compilation compilation, CodeGenerato
107108 new ( compilation . GetSpecialType ( SpecialType . System_DateTime ) , Type ( "Orleans.Serialization.Codecs.DateTimeCodec" ) ) ,
108109 new ( Type ( "System.TimeSpan" ) , Type ( "Orleans.Serialization.Codecs.TimeSpanCodec" ) ) ,
109110 new ( Type ( "System.DateTimeOffset" ) , Type ( "Orleans.Serialization.Codecs.DateTimeOffsetCodec" ) ) ,
110- new ( Type ( "System.DateOnly" ) , Type ( "Orleans.Serialization.Codecs.DateOnlyCodec" ) ) ,
111- new ( Type ( "System.TimeOnly" ) , Type ( "Orleans.Serialization.Codecs.TimeOnlyCodec" ) ) ,
111+ new ( TypeOrDefault ( "System.DateOnly" ) , TypeOrDefault ( "Orleans.Serialization.Codecs.DateOnlyCodec" ) ) ,
112+ new ( TypeOrDefault ( "System.TimeOnly" ) , TypeOrDefault ( "Orleans.Serialization.Codecs.TimeOnlyCodec" ) ) ,
112113 new ( Type ( "System.Guid" ) , Type ( "Orleans.Serialization.Codecs.GuidCodec" ) ) ,
113114 new ( Type ( "System.Type" ) , Type ( "Orleans.Serialization.Codecs.TypeSerializerCodec" ) ) ,
114115 new ( Type ( "System.ReadOnlyMemory`1" ) . Construct ( compilation . GetSpecialType ( SpecialType . System_Byte ) ) , Type ( "Orleans.Serialization.Codecs.ReadOnlyMemoryOfByteCodec" ) ) ,
115116 new ( Type ( "System.Memory`1" ) . Construct ( compilation . GetSpecialType ( SpecialType . System_Byte ) ) , Type ( "Orleans.Serialization.Codecs.MemoryOfByteCodec" ) ) ,
116117 new ( Type ( "System.Net.IPAddress" ) , Type ( "Orleans.Serialization.Codecs.IPAddressCodec" ) ) ,
117118 new ( Type ( "System.Net.IPEndPoint" ) , Type ( "Orleans.Serialization.Codecs.IPEndPointCodec" ) ) ,
118- new ( Type ( "System.UInt128" ) , Type ( "Orleans.Serialization.Codecs.UInt128Codec" ) ) ,
119- new ( Type ( "System.Int128" ) , Type ( "Orleans.Serialization.Codecs.Int128Codec" ) ) ,
120- new ( Type ( "System.Half" ) , Type ( "Orleans.Serialization.Codecs.HalfCodec" ) ) ,
119+ new ( TypeOrDefault ( "System.UInt128" ) , TypeOrDefault ( "Orleans.Serialization.Codecs.UInt128Codec" ) ) ,
120+ new ( TypeOrDefault ( "System.Int128" ) , TypeOrDefault ( "Orleans.Serialization.Codecs.Int128Codec" ) ) ,
121+ new ( TypeOrDefault ( "System.Half" ) , TypeOrDefault ( "Orleans.Serialization.Codecs.HalfCodec" ) ) ,
121122 new ( Type ( "System.Uri" ) , Type ( "Orleans.Serialization.Codecs.UriCodec" ) ) ,
122- } ,
123+ } . Where ( desc => desc . UnderlyingType is { } && desc . CodecType is { } ) . ToArray ( ) ,
123124 WellKnownCodecs = new WellKnownCodecDescription [ ]
124125 {
125126 new ( Type ( "System.Exception" ) , Type ( "Orleans.Serialization.ExceptionCodec" ) ) ,
@@ -266,7 +267,7 @@ INamedTypeSymbol TypeOrDefault(string metadataName)
266267 private INamedTypeSymbol UInt128 ;
267268 private INamedTypeSymbol Half ;
268269 private INamedTypeSymbol [ ] _regularShallowCopyableTypes ;
269- private INamedTypeSymbol [ ] RegularShallowCopyableType => _regularShallowCopyableTypes ??= new [ ]
270+ private INamedTypeSymbol [ ] RegularShallowCopyableType => _regularShallowCopyableTypes ??= new List < INamedTypeSymbol >
270271 {
271272 TimeSpan ,
272273 DateOnly ,
@@ -285,7 +286,7 @@ INamedTypeSymbol TypeOrDefault(string metadataName)
285286 UInt128 ,
286287 Int128 ,
287288 Half
288- } ;
289+ } . Where ( t => t is { } ) . ToArray ( ) ;
289290
290291 public INamedTypeSymbol [ ] ImmutableAttributes { get ; private set ; }
291292 public INamedTypeSymbol Exception { get ; private set ; }
0 commit comments