@@ -50,8 +50,8 @@ public void Dispose()
50
50
var writer = Activator . CreateInstance ( twriter ) ;
51
51
52
52
var result = ExecuteWithTimeLimit (
53
- new TimeSpan ( 0 , 0 , 15 )
54
- , new Func < object ? > ( ( ) => method ? . Invoke ( writer , new object [ ] { } ) )
53
+ new TimeSpan ( 0 , 0 , 15 )
54
+ , new Func < object ? > ( ( ) => method ? . Invoke ( writer , new object [ ] { } ) )
55
55
) ;
56
56
if ( ! result . IsCompleted )
57
57
{
@@ -71,15 +71,16 @@ public void Dispose()
71
71
return ( ( bool pass , string message ) ) output ;
72
72
}
73
73
catch ( Exception ex )
74
- {
74
+ {
75
75
if ( ex is IOException )
76
- {
76
+ {
77
77
throw new IOException ( ex . Message ) ;
78
- } else
79
- {
78
+ }
79
+ else
80
+ {
80
81
throw new Exception ( ex . Message ) ;
81
- }
82
- }
82
+ }
83
+ }
83
84
}
84
85
public static ( bool IsCompleted , object ? Output ) ExecuteWithTimeLimit ( TimeSpan timeSpan , Func < object ? > codeBlock )
85
86
{
@@ -108,7 +109,7 @@ public static (bool IsCompleted, object? Output) ExecuteWithTimeLimit(TimeSpan t
108
109
Assembly ? assembly = null ;
109
110
try
110
111
{
111
- assembly = this . Assemblies . FirstOrDefault ( asm => asm . FullName == "EllabitChallenge, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" ) ;
112
+ assembly = this . Assemblies . FirstOrDefault ( asm => asm . FullName == "EllabitChallenge, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" ) ;
112
113
113
114
}
114
115
catch { }
@@ -129,7 +130,7 @@ public static (bool IsCompleted, object? Output) ExecuteWithTimeLimit(TimeSpan t
129
130
treeItems . Add ( codeTestTree ) ;
130
131
}
131
132
string assemblyName = Path . GetFileName ( "EllabitChallenge" ) ;
132
-
133
+
133
134
Assembly [ ] referenceAssemblyRoots = new [ ]
134
135
{
135
136
typeof ( AssemblyTargetedPatchBandAttribute ) . Assembly , // System.Private.CoreLib
@@ -143,7 +144,7 @@ public static (bool IsCompleted, object? Output) ExecuteWithTimeLimit(TimeSpan t
143
144
typeof ( WebAssemblyHostBuilder ) . Assembly , // Microsoft.AspNetCore.Components.WebAssembly
144
145
typeof ( System . Drawing . Color ) . Assembly ,
145
146
} ;
146
-
147
+
147
148
List < string > referenceAssemblyNames = referenceAssemblyRoots
148
149
. SelectMany ( a => a . GetReferencedAssemblies ( ) . Concat ( new [ ] { a . GetName ( ) } ) )
149
150
. Select ( an => an . Name ?? "" )
@@ -184,7 +185,7 @@ public static (bool IsCompleted, object? Output) ExecuteWithTimeLimit(TimeSpan t
184
185
line = diagnostic . Location . GetLineSpan ( ) . StartLinePosition . Line ;
185
186
}
186
187
error += $ "{ diagnostic ? . Id } { diagnostic ? . GetMessage ( ) } \n line: { line } ";
187
-
188
+
188
189
}
189
190
throw new IOException ( error ) ;
190
191
}
@@ -200,7 +201,7 @@ public static (bool IsCompleted, object? Output) ExecuteWithTimeLimit(TimeSpan t
200
201
201
202
private async Task < IEnumerable < Stream > > GetReferenceAssembliesStreamsAsync ( IEnumerable < string > referenceAssemblyNames )
202
203
{
203
- if ( client == null )
204
+ if ( client == null )
204
205
{
205
206
return new Stream [ ] { } ;
206
207
}
@@ -210,26 +211,31 @@ await Task.WhenAll(
210
211
referenceAssemblyNames . Select ( async assemblyName =>
211
212
{
212
213
HttpResponseMessage ? result = null ;
214
+ bool hasError = false ;
213
215
try
214
216
{
215
217
result = await client . GetAsync ( $ "/_framework/{ assemblyName } .dll") ;
216
218
217
219
result . EnsureSuccessStatusCode ( ) ;
218
- } catch
220
+ }
221
+ catch
219
222
{
220
223
try
221
224
{
222
225
result = await client . GetAsync ( $ "/Ellabit/_framework/{ assemblyName } .dll") ;
223
226
224
- result . EnsureSuccessStatusCode ( ) ;
227
+ result . EnsureSuccessStatusCode ( ) ;
225
228
}
226
229
catch ( Exception ex )
227
230
{
228
- throw new Exception ( $ "GetReferenceAssembliesStreamsAsync: { result ? . RequestMessage ? . RequestUri ? . Host } :{ result ? . RequestMessage ? . RequestUri ? . Port } { result ? . RequestMessage ? . RequestUri ? . AbsolutePath } =" + ex . Message ) ;
231
+ hasError = true ;
232
+ //throw new Exception($"GetReferenceAssembliesStreamsAsync: {result?.RequestMessage?.RequestUri?.Host}:{result?.RequestMessage?.RequestUri?.Port}{result?.RequestMessage?.RequestUri?.AbsolutePath} =" + ex.Message);
229
233
}
230
234
}
231
-
232
- streams . Add ( await result . Content . ReadAsStreamAsync ( ) ) ;
235
+ if ( ! hasError )
236
+ {
237
+ streams . Add ( await result . Content . ReadAsStreamAsync ( ) ) ;
238
+ }
233
239
} ) ) ;
234
240
235
241
return streams ;
0 commit comments