@@ -7,12 +7,15 @@ public class TypedMemberStateFactoryProvider
7
7
{
8
8
private static readonly object _lock7 = new ( ) ;
9
9
private static readonly object _lock8 = new ( ) ;
10
+ private static readonly object _lock9 = new ( ) ;
10
11
11
12
private static readonly Version _version7 = new ( 7 , 0 , 0 , 0 ) ;
12
13
private static readonly Version _version8 = new ( 8 , 0 , 0 , 0 ) ;
14
+ private static readonly Version _version9 = new ( 9 , 0 , 0 , 0 ) ;
13
15
14
16
private static TypedMemberStateFactory ? _dotnet7 ;
15
17
private static TypedMemberStateFactory ? _dotnet8 ;
18
+ private static TypedMemberStateFactory ? _dotnet9 ;
16
19
17
20
private static readonly ConcurrentDictionary < Version , TypedMemberStateFactory > _factoriesByVersion = new ( ) ;
18
21
@@ -31,40 +34,13 @@ public class TypedMemberStateFactoryProvider
31
34
version = dotnetVersion ;
32
35
33
36
if ( version == _version7 )
34
- {
35
- var factory = _dotnet7 ;
36
-
37
- if ( factory is not null )
38
- return factory ;
39
-
40
- lock ( _lock7 )
41
- {
42
- if ( _dotnet7 is not null )
43
- return _dotnet7 ;
44
-
45
- logger . LogDebug ( "Create TypedMemberStateFactory for .NET 7" ) ;
46
-
47
- return _dotnet7 = TypedMemberStateFactory . Create ( compilation ) ;
48
- }
49
- }
37
+ return GetFactory ( compilation , logger , _version7 , _lock7 , ref _dotnet7 ) ;
50
38
51
39
if ( version == _version8 )
52
- {
53
- var factory = _dotnet8 ;
54
-
55
- if ( factory is not null )
56
- return factory ;
57
-
58
- lock ( _lock8 )
59
- {
60
- if ( _dotnet8 is not null )
61
- return _dotnet8 ;
40
+ return GetFactory ( compilation , logger , _version8 , _lock8 , ref _dotnet8 ) ;
62
41
63
- logger . LogDebug ( "Create TypedMemberStateFactory for .NET 8" ) ;
64
-
65
- return _dotnet8 = TypedMemberStateFactory . Create ( compilation ) ;
66
- }
67
- }
42
+ if ( version == _version9 )
43
+ return GetFactory ( compilation , logger , _version9 , _lock9 , ref _dotnet9 ) ;
68
44
69
45
if ( version is null )
70
46
{
@@ -80,4 +56,27 @@ public class TypedMemberStateFactoryProvider
80
56
return TypedMemberStateFactory . Create ( compilation ) ;
81
57
} ) ;
82
58
}
59
+
60
+ private static TypedMemberStateFactory GetFactory (
61
+ Compilation compilation ,
62
+ ILogger logger ,
63
+ Version dotnetVersion ,
64
+ object lockObj ,
65
+ ref TypedMemberStateFactory ? cachedFactory )
66
+ {
67
+ var factory = cachedFactory ;
68
+
69
+ if ( factory is not null )
70
+ return factory ;
71
+
72
+ lock ( lockObj )
73
+ {
74
+ if ( cachedFactory is not null )
75
+ return cachedFactory ;
76
+
77
+ logger . LogDebug ( $ "Create TypedMemberStateFactory for .NET { dotnetVersion } ") ;
78
+
79
+ return cachedFactory = TypedMemberStateFactory . Create ( compilation ) ;
80
+ }
81
+ }
83
82
}
0 commit comments