Skip to content

Commit 88f0b6a

Browse files
committed
Merge errors not distuinguishable
1 parent ae6a8bf commit 88f0b6a

File tree

9 files changed

+33
-36
lines changed

9 files changed

+33
-36
lines changed

src/hostfxr/delegate_loader.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,8 @@ pub enum GetManagedFunctionError {
408408
Hosting(#[from] HostingError),
409409

410410
/// A type with the specified name could not be found or loaded.
411-
#[error("Failed to load type containing method of delegate type.")]
412-
TypeNotFound,
413-
414-
/// A method with the required signature and name could not be found.
415-
#[error("Specified method does not exists or has an incompatible signature.")]
416-
MissingMethod,
411+
#[error("Failed to load the type or method or it has an incompatible signature.")]
412+
TypeOrMethodNotFound,
417413

418414
/// The specified assembly could not be found.
419415
#[error("The specified assembly could not be found.")]
@@ -438,10 +434,9 @@ impl GetManagedFunctionError {
438434
_ => {}
439435
}
440436
match HResult::try_from(code) {
441-
Ok(HResult::COR_E_TYPELOAD) => return Err(Self::TypeNotFound),
442-
Ok(HResult::COR_E_MISSINGMETHOD | HResult::COR_E_ARGUMENT) => {
443-
return Err(Self::MissingMethod)
444-
}
437+
Ok(
438+
HResult::COR_E_TYPELOAD | HResult::COR_E_MISSINGMETHOD | HResult::COR_E_ARGUMENT,
439+
) => return Err(Self::TypeOrMethodNotFound),
445440
Ok(HResult::FILE_NOT_FOUND) => return Err(Self::AssemblyNotFound),
446441
Ok(HResult::COR_E_INVALIDOPERATION) => return Err(Self::MethodNotUnmanagedCallersOnly),
447442
_ => {}

tests/ClassLibrary/ClassLibrary-net10.0.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<AssemblyName>ClassLibrary</AssemblyName>
45
<TargetFrameworks>net10.0</TargetFrameworks>
56
</PropertyGroup>
67

tests/ClassLibrary/ClassLibrary-net8.0.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<AssemblyName>ClassLibrary</AssemblyName>
45
<TargetFrameworks>net8.0</TargetFrameworks>
56
</PropertyGroup>
67

tests/ClassLibrary/ClassLibrary-net9.0.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<AssemblyName>ClassLibrary</AssemblyName>
45
<TargetFrameworks>net9.0</TargetFrameworks>
56
</PropertyGroup>
67

tests/Test/Test-net10.0.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net10.0</TargetFrameworks>
6-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<AssemblyName>Test</AssemblyName>
6+
<TargetFrameworks>net10.0</TargetFrameworks>
7+
</PropertyGroup>
78

89
</Project>

tests/Test/Test-net8.0.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net8.0</TargetFrameworks>
6-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<AssemblyName>Test</AssemblyName>
6+
<TargetFrameworks>net8.0</TargetFrameworks>
7+
</PropertyGroup>
78

89
</Project>

tests/Test/Test-net9.0.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net9.0</TargetFrameworks>
6-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<AssemblyName>Test</AssemblyName>
6+
<TargetFrameworks>net9.0</TargetFrameworks>
7+
</PropertyGroup>
78

89
</Project>

tests/common.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ pub fn test_project_file_path() -> PathBuf {
2727
pub fn test_runtime_config_path() -> PdCString {
2828
PdCString::from_os_str(
2929
PathBuf::from_str(&format!(
30-
"tests/Test/bin/Debug/{}/Test-{}.runtimeconfig.json",
31-
test_netcore_version(),
30+
"tests/Test/bin/Debug/{}/Test.runtimeconfig.json",
3231
test_netcore_version()
3332
))
3433
.unwrap()
@@ -42,8 +41,7 @@ pub fn test_runtime_config_path() -> PdCString {
4241
pub fn test_dll_path() -> PdCString {
4342
PdCString::from_os_str(
4443
PathBuf::from_str(&format!(
45-
"tests/Test/bin/Debug/{}/Test-{}.dll",
46-
test_netcore_version(),
44+
"tests/Test/bin/Debug/{}/Test.dll",
4745
test_netcore_version()
4846
))
4947
.unwrap()
@@ -56,7 +54,7 @@ pub fn test_dll_path() -> PdCString {
5654

5755
pub fn library_project_file_path() -> PathBuf {
5856
PathBuf::from_str(&format!(
59-
"tests/ClassLibrary/ClassLibrary-{}.csproj",
57+
"tests/ClassLibrary/ClassLibrary-{}.csproj",
6058
test_netcore_version()
6159
))
6260
.unwrap()
@@ -68,8 +66,7 @@ pub fn library_project_file_path() -> PathBuf {
6866
pub fn library_symbols_path() -> PdCString {
6967
PdCString::from_os_str(
7068
PathBuf::from_str(&format!(
71-
"tests/ClassLibrary/bin/Debug/{}/ClassLibrary-{}.pdb",
72-
test_netcore_version(),
69+
"tests/ClassLibrary/bin/Debug/{}/ClassLibrary.pdb",
7370
test_netcore_version()
7471
))
7572
.unwrap()
@@ -83,8 +80,7 @@ pub fn library_symbols_path() -> PdCString {
8380
pub fn library_dll_path() -> PdCString {
8481
PdCString::from_os_str(
8582
PathBuf::from_str(&format!(
86-
"tests/ClassLibrary/bin/Debug/{}/ClassLibrary-{}.dll",
87-
test_netcore_version(),
83+
"tests/ClassLibrary/bin/Debug/{}/ClassLibrary.dll",
8884
test_netcore_version()
8985
))
9086
.unwrap()

tests/errors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ rusty_fork_test! {
2727
assert!(invalid_method_name.is_err());
2828
assert_eq!(
2929
invalid_method_name.unwrap_err(),
30-
GetManagedFunctionError::MissingMethod
30+
GetManagedFunctionError::TypeOrMethodNotFound
3131
);
3232

3333
let invalid_method_signature = fn_loader
3434
.get_function_with_default_signature(pdcstr!("Test.Program, Test"), pdcstr!("Main"));
3535
assert!(invalid_method_signature.is_err());
3636
assert_eq!(
3737
invalid_method_signature.unwrap_err(),
38-
GetManagedFunctionError::MissingMethod
38+
GetManagedFunctionError::TypeOrMethodNotFound
3939
);
4040

4141
let invalid_type_name = fn_loader.get_function_with_default_signature(
@@ -45,7 +45,7 @@ rusty_fork_test! {
4545
assert!(invalid_type_name.is_err());
4646
assert_eq!(
4747
invalid_type_name.unwrap_err(),
48-
GetManagedFunctionError::MissingMethod
48+
GetManagedFunctionError::TypeOrMethodNotFound
4949
);
5050

5151
let invalid_namespace_name = fn_loader.get_function_with_default_signature(
@@ -55,7 +55,7 @@ rusty_fork_test! {
5555
assert!(invalid_namespace_name.is_err());
5656
assert_eq!(
5757
invalid_namespace_name.unwrap_err(),
58-
GetManagedFunctionError::MissingMethod
58+
GetManagedFunctionError::TypeOrMethodNotFound
5959
);
6060

6161
let invalid_assembly_name = fn_loader.get_function_with_default_signature(
@@ -86,7 +86,7 @@ rusty_fork_test! {
8686
assert!(invalid_delegate_type_name.is_err());
8787
assert_eq!(
8888
invalid_delegate_type_name.unwrap_err(),
89-
GetManagedFunctionError::TypeNotFound
89+
GetManagedFunctionError::TypeOrMethodNotFound
9090
);
9191

9292
context.close().unwrap();

0 commit comments

Comments
 (0)