@@ -31,19 +31,16 @@ public static class AssemblyLoader
3131 /// Returns false if some of the content could not be loaded successfully,
3232 /// possibly because the referenced assembly has been compiled with an older compiler version.
3333 /// If onDeserializationException is specified, invokes the given action on any exception thrown during deserialization.
34- /// Throws an ArgumentNullException if the given uri is null .
34+ /// Throws an ArgumentException if the URI is not an absolute file URI .
3535 /// Throws a FileNotFoundException if no file with the given name exists.
3636 /// Throws the corresponding exceptions if the information cannot be extracted.
3737 /// </summary>
3838 public static bool LoadReferencedAssembly ( Uri asm , out References . Headers headers , bool ignoreDllResources = false , Action < Exception > ? onDeserializationException = null )
3939 {
40- if ( asm == null )
40+ var id = CompilationUnitManager . GetFileId ( asm ) ;
41+ if ( ! File . Exists ( asm . LocalPath ) )
4142 {
42- throw new ArgumentNullException ( nameof ( asm ) ) ;
43- }
44- if ( ! CompilationUnitManager . TryGetFileId ( asm , out var id ) || ! File . Exists ( asm . LocalPath ) )
45- {
46- throw new FileNotFoundException ( $ "The uri '{ asm } ' given to the assembly loader is invalid or the file does not exist.") ;
43+ throw new FileNotFoundException ( $ "The file '{ asm . LocalPath } ' given to the assembly loader does not exist.") ;
4744 }
4845
4946 using var stream = File . OpenRead ( asm . LocalPath ) ;
@@ -65,18 +62,13 @@ public static bool LoadReferencedAssembly(Uri asm, out References.Headers header
6562 /// possibly because the referenced assembly has been compiled with an older compiler version.
6663 /// Catches any exception throw upon loading the compilation, and invokes onException with it if such an action has been specified.
6764 /// Sets the out parameter to null if an exception occurred during loading.
68- /// Throws an ArgumentNullException if the given uri is null.
6965 /// Throws a FileNotFoundException if no file with the given name exists.
7066 /// </summary>
7167 public static bool LoadReferencedAssembly (
7268 string asmPath ,
7369 [ NotNullWhen ( true ) ] out QsCompilation ? compilation ,
7470 Action < Exception > ? onException = null )
7571 {
76- if ( asmPath == null )
77- {
78- throw new ArgumentNullException ( nameof ( asmPath ) ) ;
79- }
8072 if ( ! File . Exists ( asmPath ) )
8173 {
8274 throw new FileNotFoundException ( $ "The file '{ asmPath } ' does not exist.") ;
@@ -102,17 +94,12 @@ public static bool LoadReferencedAssembly(
10294 /// Given a stream containing the binary representation of compiled Q# code, returns the corresponding Q# compilation.
10395 /// Returns true if the compilation could be deserialized without throwing an exception, and false otherwise.
10496 /// If onDeserializationException is specified, invokes the given action on any exception thrown during deserialization.
105- /// Throws an ArgumentNullException if the given stream is null, but ignores exceptions thrown during deserialization.
10697 /// </summary>
10798 public static bool LoadSyntaxTree (
10899 Stream stream ,
109100 [ NotNullWhen ( true ) ] out QsCompilation ? compilation ,
110101 Action < Exception > ? onDeserializationException = null )
111102 {
112- if ( stream == null )
113- {
114- throw new ArgumentNullException ( nameof ( stream ) ) ;
115- }
116103 using var reader = new BsonDataReader ( stream ) ;
117104 ( compilation , reader . ReadRootValueAsArray ) = ( null , false ) ;
118105 try
@@ -141,18 +128,13 @@ private static ImmutableDictionary<string, ManifestResource> Resources(this Meta
141128 /// Given a reader for the byte stream of a dotnet dll, loads any Q# compilation included as a resource.
142129 /// Returns true as well as the loaded compilation if the given dll includes a suitable resource, and returns false otherwise.
143130 /// If onDeserializationException is specified, invokes the given action on any exception thrown during deserialization.
144- /// Throws an ArgumentNullException if any of the given readers is null.
145131 /// May throw an exception if the given binary file has been compiled with a different compiler version.
146132 /// </summary>
147133 private static bool FromResource (
148134 PEReader assemblyFile ,
149135 [ NotNullWhen ( true ) ] out QsCompilation ? compilation ,
150136 Action < Exception > ? onDeserializationException = null )
151137 {
152- if ( assemblyFile == null )
153- {
154- throw new ArgumentNullException ( nameof ( assemblyFile ) ) ;
155- }
156138 var metadataReader = assemblyFile . GetMetadataReader ( ) ;
157139 compilation = null ;
158140
@@ -239,15 +221,10 @@ private static (string, string)? GetAttribute(MetadataReader metadataReader, Cus
239221 /// Given a reader for the byte stream of a dotnet dll, read its custom attributes and
240222 /// returns a tuple containing the name of the attribute and the constructor argument
241223 /// for all attributes defined in a Microsoft.Quantum* namespace.
242- /// Throws an ArgumentNullException if the given stream is null.
243224 /// Throws the corresponding exceptions if the information cannot be extracted.
244225 /// </summary>
245226 private static IEnumerable < ( string , string ) > LoadHeaderAttributes ( PEReader assemblyFile )
246227 {
247- if ( assemblyFile == null )
248- {
249- throw new ArgumentNullException ( nameof ( assemblyFile ) ) ;
250- }
251228 var metadataReader = assemblyFile . GetMetadataReader ( ) ;
252229 return metadataReader . GetAssemblyDefinition ( ) . GetCustomAttributes ( )
253230 . Select ( metadataReader . GetCustomAttribute )
0 commit comments