2 * Copyright 2008 James Hawkins
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/test.h"
30 /* ok-like statement which takes two unicode strings or one unicode and one ANSI string as arguments */
31 static CHAR string1
[MAX_PATH
];
33 #define ok_aw(aString, wString) \
34 WideCharToMultiByte(CP_ACP, 0, wString, -1, string1, MAX_PATH, NULL, NULL); \
35 if (lstrcmpA(string1, aString) != 0) \
36 ok(0, "Expected \"%s\", got \"%s\"\n", aString, string1);
38 static HRESULT (WINAPI
*pCreateAssemblyNameObject
)(LPASSEMBLYNAME
*ppAssemblyNameObj
,
39 LPCWSTR szAssemblyName
, DWORD dwFlags
,
41 static HRESULT (WINAPI
*pLoadLibraryShim
)(LPCWSTR szDllName
, LPCWSTR szVersion
,
42 LPVOID pvReserved
, HMODULE
*phModDll
);
44 static BOOL
init_functionpointers(void)
50 static const WCHAR szFusion
[] = {'f','u','s','i','o','n','.','d','l','l',0};
52 hmscoree
= LoadLibraryA("mscoree.dll");
56 pLoadLibraryShim
= (void *)GetProcAddress(hmscoree
, "LoadLibraryShim");
57 if (!pLoadLibraryShim
)
59 FreeLibrary(hmscoree
);
63 hr
= pLoadLibraryShim(szFusion
, NULL
, NULL
, &hfusion
);
67 pCreateAssemblyNameObject
= (void *)GetProcAddress(hfusion
, "CreateAssemblyNameObject");
68 if (!pCreateAssemblyNameObject
)
74 typedef struct _tagASMPROP_RES
81 static const ASMPROP_RES defaults
[ASM_NAME_MAX_PARAMS
] =
98 {S_FALSE
, "", MAX_PATH
},
99 {S_FALSE
, "", MAX_PATH
},
101 {S_OK
, "", MAX_PATH
},
113 static const ASMPROP_RES emptyname
[ASM_NAME_MAX_PARAMS
] =
130 {S_FALSE
, "", MAX_PATH
},
131 {S_FALSE
, "", MAX_PATH
},
133 {S_OK
, "", MAX_PATH
},
145 static const ASMPROP_RES winename
[ASM_NAME_MAX_PARAMS
] =
162 {S_FALSE
, "", MAX_PATH
},
163 {S_FALSE
, "", MAX_PATH
},
165 {S_OK
, "", MAX_PATH
},
177 static const ASMPROP_RES vername
[ASM_NAME_MAX_PARAMS
] =
194 {S_FALSE
, "", MAX_PATH
},
195 {S_FALSE
, "", MAX_PATH
},
197 {S_OK
, "", MAX_PATH
},
209 static const ASMPROP_RES badvername
[ASM_NAME_MAX_PARAMS
] =
226 {S_FALSE
, "", MAX_PATH
},
227 {S_FALSE
, "", MAX_PATH
},
229 {S_OK
, "", MAX_PATH
},
241 static const ASMPROP_RES neutralname
[ASM_NAME_MAX_PARAMS
] =
258 {S_FALSE
, "", MAX_PATH
},
259 {S_FALSE
, "", MAX_PATH
},
261 {S_OK
, "", MAX_PATH
},
273 static const ASMPROP_RES enname
[ASM_NAME_MAX_PARAMS
] =
290 {S_FALSE
, "", MAX_PATH
},
291 {S_FALSE
, "", MAX_PATH
},
293 {S_OK
, "", MAX_PATH
},
305 static const ASMPROP_RES pubkeyname
[ASM_NAME_MAX_PARAMS
] =
308 {S_OK
, "\x12\x34\x56\x78\x90\xab\xcd\xef", 8},
322 {S_OK
, "", MAX_PATH
},
323 {S_OK
, "", MAX_PATH
},
325 {S_OK
, "", MAX_PATH
},
337 static inline void to_widechar(LPWSTR dest
, LPCSTR src
)
339 MultiByteToWideChar(CP_ACP
, 0, src
, -1, dest
, MAX_PATH
);
342 static inline void to_multibyte(LPSTR dest
, LPWSTR src
)
344 WideCharToMultiByte(CP_ACP
, 0, src
, -1, dest
, MAX_PATH
, NULL
, NULL
);
347 static void test_assembly_name_props_line(IAssemblyName
*name
,
348 const ASMPROP_RES
*vals
, int line
)
352 WCHAR expect
[MAX_PATH
];
356 for (i
= 0; i
< ASM_NAME_MAX_PARAMS
; i
++)
358 to_widechar(expect
, vals
[i
].val
);
361 ZeroMemory(str
, MAX_PATH
);
362 hr
= IAssemblyName_GetProperty(name
, i
, str
, &size
);
363 to_multibyte(val
, str
);
365 ok(hr
== vals
[i
].hr
||
366 broken(i
>= ASM_NAME_CONFIG_MASK
&& hr
== E_INVALIDARG
) || /* .NET 1.1 */
367 broken(i
>= ASM_NAME_FILE_MAJOR_VERSION
&& hr
== E_INVALIDARG
), /* .NET 1.0 */
368 "%d: prop %d: Expected %08x, got %08x\n", line
, i
, vals
[i
].hr
, hr
);
369 if (hr
!= E_INVALIDARG
)
371 if (i
== ASM_NAME_PUBLIC_KEY_TOKEN
)
372 ok(!memcmp(vals
[i
].val
, str
, size
), "Expected a correct ASM_NAME_PUBLIC_KEY_TOKEN\n");
374 ok(!lstrcmpA(vals
[i
].val
, val
), "%d: prop %d: Expected \"%s\", got \"%s\"\n", line
, i
, vals
[i
].val
, val
);
375 ok(size
== vals
[i
].size
, "%d: prop %d: Expected %d, got %d\n", line
, i
, vals
[i
].size
, size
);
380 #define test_assembly_name_props(name, vals) \
381 test_assembly_name_props_line(name, vals, __LINE__);
383 static void test_CreateAssemblyNameObject(void)
387 WCHAR namestr
[MAX_PATH
];
391 static const WCHAR empty
[] = {0};
393 /* NULL ppAssemblyNameObj */
394 to_widechar(namestr
, "wine.dll");
395 hr
= pCreateAssemblyNameObject(NULL
, namestr
, 0, NULL
);
396 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
398 /* NULL szAssemblyName, CANOF_PARSE_DISPLAY_NAME */
399 name
= (IAssemblyName
*)0xdeadbeef;
400 hr
= pCreateAssemblyNameObject(&name
, NULL
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
401 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
402 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
404 /* empty szAssemblyName, CANOF_PARSE_DISPLAY_NAME */
405 name
= (IAssemblyName
*)0xdeadbeef;
406 hr
= pCreateAssemblyNameObject(&name
, empty
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
407 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
408 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
410 /* check the contents of the AssemblyName for default values */
412 /* NULL szAssemblyName */
414 hr
= pCreateAssemblyNameObject(&name
, NULL
, CANOF_SET_DEFAULT_VALUES
, NULL
);
415 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
416 ok(name
!= NULL
, "Expected non-NULL name\n");
419 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
420 ok(hr
== FUSION_E_INVALID_NAME
||
421 broken(hr
== E_INVALIDARG
), /* .NET 1.x */
422 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
426 hr
= IAssemblyName_GetName(name
, &size
, str
);
427 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
428 ok(lstrlenW(str
) == 0, "Expected empty name\n");
429 ok(size
== 0, "Expected 0, got %d\n", size
);
433 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
434 ok(hr
== FUSION_E_INVALID_NAME
||
435 broken(hr
== S_OK
), /* .NET 1.x */
436 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
437 ok(hi
== 0, "Expected 0, got %08x\n", hi
);
438 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
441 win_skip(".NET 1.x doesn't handle ASM_NAME_PROCESSOR_ID_ARRAY"
442 " and ASM_NAME_OSINFO_ARRAY correctly\n");
444 test_assembly_name_props(name
, defaults
);
446 IAssemblyName_Release(name
);
448 /* empty szAssemblyName */
450 hr
= pCreateAssemblyNameObject(&name
, empty
, CANOF_SET_DEFAULT_VALUES
, NULL
);
451 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
452 ok(name
!= NULL
, "Expected non-NULL name\n");
455 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
456 ok(hr
== FUSION_E_INVALID_NAME
||
457 broken(hr
== S_OK
), /* .NET 1.x */
458 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
462 hr
= IAssemblyName_GetName(name
, &size
, str
);
463 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
464 ok(lstrlenW(str
) == 0, "Expected empty name\n");
465 ok(size
== 1, "Expected 1, got %d\n", size
);
469 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
470 ok(hr
== FUSION_E_INVALID_NAME
||
471 broken(hr
== S_OK
), /* .NET 1.x */
472 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
473 ok(hi
== 0, "Expected 0, got %08x\n", hi
);
474 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
477 win_skip(".NET 1.x doesn't handle ASM_NAME_PROCESSOR_ID_ARRAY"
478 " and ASM_NAME_OSINFO_ARRAY correctly\n");
480 test_assembly_name_props(name
, emptyname
);
482 IAssemblyName_Release(name
);
485 to_widechar(namestr
, "wine");
487 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_SET_DEFAULT_VALUES
, NULL
);
488 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
489 ok(name
!= NULL
, "Expected non-NULL name\n");
492 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
493 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
495 ok(size
== 5, "Expected 5, got %d\n", size
);
499 hr
= IAssemblyName_GetName(name
, &size
, str
);
500 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
502 ok(size
== 5, "Expected 5, got %d\n", size
);
506 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
507 ok(hr
== FUSION_E_INVALID_NAME
||
508 broken(hr
== S_OK
), /* .NET 1.x */
509 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
510 ok(hi
== 0, "Expected 0, got %08x\n", hi
);
511 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
514 win_skip(".NET 1.x doesn't handle ASM_NAME_PROCESSOR_ID_ARRAY"
515 " and ASM_NAME_OSINFO_ARRAY correctly\n");
517 test_assembly_name_props(name
, winename
);
519 IAssemblyName_Release(name
);
521 /* check the contents of the AssemblyName with parsing */
524 to_widechar(namestr
, "wine");
526 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
527 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
528 ok(name
!= NULL
, "Expected non-NULL name\n");
531 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
532 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
534 ok(size
== 5, "Expected 5, got %d\n", size
);
538 hr
= IAssemblyName_GetName(name
, &size
, str
);
539 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
541 ok(size
== 5, "Expected 5, got %d\n", size
);
545 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
546 ok(hr
== FUSION_E_INVALID_NAME
||
547 broken(hr
== S_OK
), /* .NET 1.x */
548 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
549 ok(hi
== 0, "Expected 0, got %08x\n", hi
);
550 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
552 test_assembly_name_props(name
, winename
);
554 IAssemblyName_Release(name
);
556 /* 'wine, Version=1.2.3.4' */
557 to_widechar(namestr
, "wine, Version=1.2.3.4");
559 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
560 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
561 ok(name
!= NULL
, "Expected non-NULL name\n");
564 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
565 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
566 ok_aw("wine, Version=1.2.3.4", str
);
567 ok(size
== 22, "Expected 22, got %d\n", size
);
571 hr
= IAssemblyName_GetName(name
, &size
, str
);
572 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
574 ok(size
== 5, "Expected 5, got %d\n", size
);
578 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
579 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
580 ok(hi
== 0x00010002, "Expected 0x00010002, got %08x\n", hi
);
581 ok(lo
== 0x00030004, "Expected 0x00030004, got %08x\n", lo
);
583 test_assembly_name_props(name
, vername
);
585 IAssemblyName_Release(name
);
587 /* Version isn't of the form 1.x.x.x */
588 to_widechar(namestr
, "wine, Version=1.5");
590 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
591 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
592 ok(name
!= NULL
, "Expected non-NULL name\n");
595 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
596 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
597 ok_aw("wine, Version=1.5", str
);
598 ok(size
== 18, "Expected 18, got %d\n", size
);
602 hr
= IAssemblyName_GetName(name
, &size
, str
);
603 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
605 ok(size
== 5, "Expected 5, got %d\n", size
);
609 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
610 ok(hr
== FUSION_E_INVALID_NAME
||
611 broken(hr
== S_OK
), /* .NET 1.x */
612 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
614 broken(hi
== 0x10005), /* .NET 1.x */
615 "Expected 0, got %08x\n", hi
);
616 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
618 test_assembly_name_props(name
, badvername
);
620 IAssemblyName_Release(name
);
622 /* 'wine, Culture=neutral' */
623 to_widechar(namestr
, "wine, Culture=neutral");
625 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
626 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
627 ok(name
!= NULL
, "Expected non-NULL name\n");
630 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
631 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
632 ok_aw("wine, Culture=neutral", str
);
633 ok(size
== 22, "Expected 22, got %d\n", size
);
637 hr
= IAssemblyName_GetName(name
, &size
, str
);
638 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
640 ok(size
== 5, "Expected 5, got %d\n", size
);
644 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
645 ok(hr
== FUSION_E_INVALID_NAME
||
646 broken(hr
== S_OK
), /* .NET 1.x */
647 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
648 ok(hi
== 0, "Expected 0, got %08x\n", hi
);
649 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
651 test_assembly_name_props(name
, neutralname
);
653 IAssemblyName_Release(name
);
655 /* 'wine, Culture=en' */
656 to_widechar(namestr
, "wine, Culture=en");
658 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
659 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
660 ok(name
!= NULL
, "Expected non-NULL name\n");
663 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
664 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
665 ok_aw("wine, Culture=en", str
);
666 ok(size
== 17, "Expected 17, got %d\n", size
);
670 hr
= IAssemblyName_GetName(name
, &size
, str
);
671 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
673 ok(size
== 5, "Expected 5, got %d\n", size
);
677 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
678 ok(hr
== FUSION_E_INVALID_NAME
||
679 broken(hr
== S_OK
), /* .NET 1.x */
680 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
681 ok(hi
== 0, "Expected 0, got %08x\n", hi
);
682 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
684 test_assembly_name_props(name
, enname
);
686 IAssemblyName_Release(name
);
688 /* 'wine, PublicKeyToken=1234567890abcdef' */
689 to_widechar(namestr
, "wine, PublicKeyToken=1234567890abcdef");
691 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
692 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
693 ok(name
!= NULL
, "Expected non-NULL name\n");
696 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
697 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
698 ok_aw("wine, PublicKeyToken=1234567890abcdef", str
);
699 ok(size
== 38, "Expected 38, got %d\n", size
);
703 hr
= IAssemblyName_GetName(name
, &size
, str
);
704 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
706 ok(size
== 5, "Expected 5, got %d\n", size
);
710 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
711 ok(hr
== FUSION_E_INVALID_NAME
||
712 broken(hr
== S_OK
), /* .NET 1.x */
713 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
714 ok(hi
== 0, "Expected 0, got %08x\n", hi
);
715 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
717 test_assembly_name_props(name
, pubkeyname
);
719 IAssemblyName_Release(name
);
721 /* Processor architecture tests */
722 to_widechar(namestr
, "wine, processorArchitecture=x86");
724 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
725 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
727 ok(name
!= NULL
, "Expected non-NULL name\n");
730 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
731 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
733 WideCharToMultiByte(CP_ACP
, 0, str
, -1, string1
, MAX_PATH
, NULL
, NULL
);
735 if (lstrcmpA(string1
, "wine") == 0)
736 win_skip("processorArchitecture not supported on .NET 1.x\n");
739 ok_aw("wine, processorArchitecture=x86", str
);
740 ok(size
== 32, "Expected 32, got %d\n", size
);
742 IAssemblyName_Release(name
);
745 to_widechar(namestr
, "wine, processorArchitecture=AMD64");
747 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
748 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
751 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
752 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
753 ok_aw("wine, processorArchitecture=AMD64", str
);
754 ok(size
== 34, "Expected 34, got %d\n", size
);
756 IAssemblyName_Release(name
);
759 to_widechar(namestr
, "wine, processorArchitecture=IA64");
761 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
762 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
765 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
766 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
767 ok_aw("wine, processorArchitecture=IA64", str
);
768 ok(size
== 33, "Expected 33, got %d\n", size
);
770 IAssemblyName_Release(name
);
773 to_widechar(namestr
, "wine, processorArchitecture=MSIL");
775 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
776 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
779 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
780 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
781 ok_aw("wine, processorArchitecture=MSIL", str
);
782 ok(size
== 33, "Expected 33, got %d\n", size
);
784 IAssemblyName_Release(name
);
787 /* Pulling out various different values */
788 to_widechar(namestr
, "wine, Version=1.2.3.4, Culture=en, PublicKeyToken=1234567890abcdef");
790 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
791 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
792 ok(name
!= NULL
, "Expected non-NULL name\n");
795 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_VERSION
| ASM_DISPLAYF_CULTURE
);
796 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
797 ok_aw("wine, Version=1.2.3.4, Culture=en", str
);
798 ok(size
== 34, "Expected 34, got %d\n", size
);
801 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_CULTURE
| ASM_DISPLAYF_PUBLIC_KEY_TOKEN
);
802 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
803 ok_aw("wine, Culture=en, PublicKeyToken=1234567890abcdef", str
);
804 ok(size
== 50, "Expected 50, got %d\n", size
);
807 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
808 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
809 ok_aw("wine, Version=1.2.3.4, Culture=en, PublicKeyToken=1234567890abcdef", str
);
810 ok(size
== 67, "Expected 67, got %d\n", size
);
812 IAssemblyName_Release(name
);
814 /* invalid property */
815 to_widechar(namestr
, "wine, BadProp=42");
817 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
818 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
819 ok(name
!= NULL
, "Expected non-NULL name\n");
823 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
824 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
826 ok(size
== 5, "Expected 5, got %d\n", size
);
830 hr
= IAssemblyName_GetName(name
, &size
, str
);
831 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
833 ok(size
== 5, "Expected 5, got %d\n", size
);
837 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
838 ok(hr
== FUSION_E_INVALID_NAME
||
839 broken(hr
== S_OK
), /* .NET 1.x */
840 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
841 ok(hi
== 0, "Expected 0, got %08x\n", hi
);
842 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
844 test_assembly_name_props(name
, winename
);
846 IAssemblyName_Release(name
);
848 /* PublicKeyToken is not 16 chars long */
849 to_widechar(namestr
, "wine, PublicKeyToken=567890abcdef");
850 name
= (IAssemblyName
*)0xdeadbeef;
851 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
852 if (hr
== S_OK
&& name
!= (IAssemblyName
*)0xdeadbeef)
854 win_skip(".NET 1.x doesn't check PublicKeyToken correctly\n");
855 IAssemblyName_Release(name
);
858 ok(hr
== FUSION_E_INVALID_NAME
,
859 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
860 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
862 /* PublicKeyToken contains invalid chars */
863 to_widechar(namestr
, "wine, PublicKeyToken=1234567890ghijkl");
864 name
= (IAssemblyName
*)0xdeadbeef;
865 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
866 ok(hr
== FUSION_E_INVALID_NAME
,
867 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
868 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
870 /* no comma separator */
871 to_widechar(namestr
, "wine PublicKeyToken=1234567890abcdef");
872 name
= (IAssemblyName
*)0xdeadbeef;
873 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
874 ok(hr
== FUSION_E_INVALID_NAME
,
875 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
876 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
877 if(SUCCEEDED(hr
)) IAssemblyName_Release(name
);
880 to_widechar(namestr
, "wine, PublicKeyToken");
881 name
= (IAssemblyName
*)0xdeadbeef;
882 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
883 ok(hr
== FUSION_E_INVALID_NAME
,
884 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
885 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
888 to_widechar(namestr
, "wine, PublicKeyToken=");
889 name
= (IAssemblyName
*)0xdeadbeef;
890 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
891 ok(hr
== FUSION_E_INVALID_NAME
,
892 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
893 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
896 to_widechar(namestr
, "wine,version=1.0.0.0");
897 name
= (IAssemblyName
*)0xdeadbeef;
898 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
899 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
900 ok(name
!= NULL
, "Expected non-NULL name\n");
901 hi
= lo
= 0xdeadbeef;
902 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
903 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
904 ok(hi
== 65536, "Expected 536, got %u\n", hi
);
905 ok(lo
== 0, "Expected 0, got %u\n", lo
);
906 IAssemblyName_Release(name
);
909 to_widechar(namestr
, "wine, version=\"1.0.0.0\",culture=\"en\"");
910 name
= (IAssemblyName
*)0xdeadbeef;
911 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
912 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
913 ok(name
!= NULL
, "Expected non-NULL name\n");
914 hi
= lo
= 0xdeadbeef;
915 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
916 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
917 ok(hi
== 65536, "Expected 65536, got %u\n", hi
);
918 ok(lo
== 0, "Expected 0, got %u\n", lo
);
919 IAssemblyName_Release(name
);
922 static void test_IAssemblyName_IsEqual(void)
924 static const WCHAR wine1
[] =
926 static const WCHAR wine2
[] =
927 {'w','i','n','e',',','v','e','r','s','i','o','n','=','1','.','0','.','0','.','0',0};
928 static const WCHAR wine3
[] =
929 {'w','i','n','e',',','v','e','r','s','i','o','n','=','1','.','0','.','0','.','0',',',
930 'c','u','l','t','u','r','e','=','n','e','u','t','r','a','l',0};
931 static const WCHAR wine4
[] =
932 {'w','i','n','e',',','v','e','r','s','i','o','n','=','1','.','0','.','0','.','0',',',
933 'c','u','l','t','u','r','e','=','e','n',0};
934 static const WCHAR wine5
[] =
935 {'w','i','n','e',',','v','e','r','s','i','o','n','=','1','.','0','.','0','.','0',',',
936 'p','u','b','l','i','c','K','e','y','T','o','k','e','n','=','1','2','3','4','5','6',
937 '7','8','9','0','a','b','c','d','e','f',0};
939 IAssemblyName
*name1
, *name2
;
941 hr
= pCreateAssemblyNameObject( &name1
, wine1
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
942 ok( hr
== S_OK
, "got %08x\n", hr
);
944 hr
= pCreateAssemblyNameObject( &name2
, wine1
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
945 ok( hr
== S_OK
, "got %08x\n", hr
);
947 if (0) { /* crashes on some old version */
948 hr
= IAssemblyName_IsEqual( name1
, NULL
, 0 );
949 ok( hr
== S_FALSE
, "got %08x\n", hr
);
951 hr
= IAssemblyName_IsEqual( name1
, NULL
, ASM_CMPF_IL_ALL
);
952 ok( hr
== S_FALSE
, "got %08x\n", hr
);
955 hr
= IAssemblyName_IsEqual( name1
, name1
, ASM_CMPF_IL_ALL
);
956 ok( hr
== S_OK
, "got %08x\n", hr
);
958 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
959 ok( hr
== S_OK
, "got %08x\n", hr
);
961 IAssemblyName_Release( name2
);
962 hr
= pCreateAssemblyNameObject( &name2
, wine2
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
963 ok( hr
== S_OK
, "got %08x\n", hr
);
965 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
966 ok( hr
== S_OK
, "got %08x\n", hr
);
968 IAssemblyName_Release( name2
);
969 hr
= pCreateAssemblyNameObject( &name2
, wine3
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
970 ok( hr
== S_OK
, "got %08x\n", hr
);
972 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
973 ok( hr
== S_OK
, "got %08x\n", hr
);
975 IAssemblyName_Release( name1
);
976 hr
= pCreateAssemblyNameObject( &name1
, wine4
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
977 ok( hr
== S_OK
, "got %08x\n", hr
);
979 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
980 ok( hr
== S_FALSE
, "got %08x\n", hr
);
982 IAssemblyName_Release( name1
);
983 hr
= pCreateAssemblyNameObject( &name1
, wine1
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
984 ok( hr
== S_OK
, "got %08x\n", hr
);
986 IAssemblyName_Release( name2
);
987 hr
= pCreateAssemblyNameObject( &name2
, wine5
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
988 ok( hr
== S_OK
, "got %08x\n", hr
);
990 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
991 ok( hr
== S_OK
, "got %08x\n", hr
);
993 IAssemblyName_Release( name1
);
994 IAssemblyName_Release( name2
);
999 if (!init_functionpointers())
1001 win_skip("fusion.dll not available\n");
1005 test_CreateAssemblyNameObject();
1006 test_IAssemblyName_IsEqual();