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
29 #include "wine/test.h"
31 /* ok-like statement which takes two unicode strings or one unicode and one ANSI string as arguments */
32 static CHAR string1
[MAX_PATH
];
34 #define ok_aw(aString, wString) \
35 WideCharToMultiByte(CP_ACP, 0, wString, -1, string1, MAX_PATH, NULL, NULL); \
36 if (lstrcmpA(string1, aString) != 0) \
37 ok(0, "Expected \"%s\", got \"%s\"\n", aString, string1);
39 static HRESULT (WINAPI
*pCreateAssemblyNameObject
)(IAssemblyName
**ppAssemblyNameObj
,
40 LPCWSTR szAssemblyName
, DWORD dwFlags
,
42 static HRESULT (WINAPI
*pLoadLibraryShim
)(LPCWSTR szDllName
, LPCWSTR szVersion
,
43 LPVOID pvReserved
, HMODULE
*phModDll
);
45 static BOOL
init_functionpointers(void)
51 hmscoree
= LoadLibraryA("mscoree.dll");
55 pLoadLibraryShim
= (void *)GetProcAddress(hmscoree
, "LoadLibraryShim");
56 if (!pLoadLibraryShim
)
58 FreeLibrary(hmscoree
);
62 hr
= pLoadLibraryShim(L
"fusion.dll", NULL
, NULL
, &hfusion
);
66 pCreateAssemblyNameObject
= (void *)GetProcAddress(hfusion
, "CreateAssemblyNameObject");
67 if (!pCreateAssemblyNameObject
)
73 typedef struct _tagASMPROP_RES
80 static const ASMPROP_RES defaults
[ASM_NAME_MAX_PARAMS
] =
97 {S_FALSE
, "", MAX_PATH
},
98 {S_FALSE
, "", MAX_PATH
},
100 {S_OK
, "", MAX_PATH
},
112 static const ASMPROP_RES emptyname
[ASM_NAME_MAX_PARAMS
] =
129 {S_FALSE
, "", MAX_PATH
},
130 {S_FALSE
, "", MAX_PATH
},
132 {S_OK
, "", MAX_PATH
},
144 static const ASMPROP_RES winename
[ASM_NAME_MAX_PARAMS
] =
161 {S_FALSE
, "", MAX_PATH
},
162 {S_FALSE
, "", MAX_PATH
},
164 {S_OK
, "", MAX_PATH
},
176 static const ASMPROP_RES vername
[ASM_NAME_MAX_PARAMS
] =
193 {S_FALSE
, "", MAX_PATH
},
194 {S_FALSE
, "", MAX_PATH
},
196 {S_OK
, "", MAX_PATH
},
208 static const ASMPROP_RES badvername
[ASM_NAME_MAX_PARAMS
] =
225 {S_FALSE
, "", MAX_PATH
},
226 {S_FALSE
, "", MAX_PATH
},
228 {S_OK
, "", MAX_PATH
},
240 static const ASMPROP_RES neutralname
[ASM_NAME_MAX_PARAMS
] =
257 {S_FALSE
, "", MAX_PATH
},
258 {S_FALSE
, "", MAX_PATH
},
260 {S_OK
, "", MAX_PATH
},
272 static const ASMPROP_RES enname
[ASM_NAME_MAX_PARAMS
] =
289 {S_FALSE
, "", MAX_PATH
},
290 {S_FALSE
, "", MAX_PATH
},
292 {S_OK
, "", MAX_PATH
},
304 static const ASMPROP_RES pubkeyname
[ASM_NAME_MAX_PARAMS
] =
307 {S_OK
, "\x01\x23\x45\x67\x89\x0a\xbc\xde", 8},
321 {S_OK
, "", MAX_PATH
},
322 {S_OK
, "", MAX_PATH
},
324 {S_OK
, "", MAX_PATH
},
336 static inline void to_widechar(LPWSTR dest
, LPCSTR src
)
338 MultiByteToWideChar(CP_ACP
, 0, src
, -1, dest
, MAX_PATH
);
341 static void test_assembly_name_props_line(IAssemblyName
*name
,
342 const ASMPROP_RES
*vals
, int line
)
346 WCHAR expect
[MAX_PATH
];
349 for (i
= 0; i
< ASM_NAME_MAX_PARAMS
; i
++)
351 to_widechar(expect
, vals
[i
].val
);
354 memset( str
, 0xcc, sizeof(str
) );
355 hr
= IAssemblyName_GetProperty(name
, i
, str
, &size
);
357 ok(hr
== vals
[i
].hr
||
358 broken(i
>= ASM_NAME_CONFIG_MASK
&& hr
== E_INVALIDARG
) || /* .NET 1.1 */
359 broken(i
>= ASM_NAME_FILE_MAJOR_VERSION
&& hr
== E_INVALIDARG
), /* .NET 1.0 */
360 "%d: prop %ld: Expected %08lx, got %08lx\n", line
, i
, vals
[i
].hr
, hr
);
361 if (hr
!= E_INVALIDARG
)
363 ok(size
== vals
[i
].size
, "%d: prop %ld: Expected %ld, got %ld\n", line
, i
, vals
[i
].size
, size
);
366 ok(str
[0] == 0xcccc, "%d: prop %ld: str[0] = %x\n", line
, i
, str
[0]);
368 else if (size
!= MAX_PATH
)
370 if (i
!= ASM_NAME_NAME
&& i
!= ASM_NAME_CULTURE
)
371 ok( !memcmp( vals
[i
].val
, str
, size
), "%d: prop %ld: wrong value\n", line
, i
);
373 ok( !lstrcmpW( expect
, str
), "%d: prop %ld: Expected %s, got %s\n",
374 line
, i
, wine_dbgstr_w(expect
), wine_dbgstr_w(str
) );
377 if (size
!= 0 && size
!= MAX_PATH
)
380 hr
= IAssemblyName_GetProperty(name
, i
, str
, &size
);
381 ok(hr
== STRSAFE_E_INSUFFICIENT_BUFFER
,
382 "%d: prop %ld: Expected STRSAFE_E_INSUFFICIENT_BUFFER, got %08lx\n", line
, i
, hr
);
383 ok(size
== vals
[i
].size
, "%d: prop %ld: Expected %ld, got %ld\n", line
, i
, vals
[i
].size
, size
);
389 #define test_assembly_name_props(name, vals) \
390 test_assembly_name_props_line(name, vals, __LINE__);
392 static void test_CreateAssemblyNameObject(void)
396 WCHAR namestr
[MAX_PATH
];
401 /* NULL ppAssemblyNameObj */
402 to_widechar(namestr
, "wine.dll");
403 hr
= pCreateAssemblyNameObject(NULL
, namestr
, 0, NULL
);
404 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08lx\n", hr
);
406 /* NULL szAssemblyName, CANOF_PARSE_DISPLAY_NAME */
407 name
= (IAssemblyName
*)0xdeadbeef;
408 hr
= pCreateAssemblyNameObject(&name
, NULL
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
409 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08lx\n", hr
);
410 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
412 /* empty szAssemblyName, CANOF_PARSE_DISPLAY_NAME */
413 name
= (IAssemblyName
*)0xdeadbeef;
414 hr
= pCreateAssemblyNameObject(&name
, L
"", CANOF_PARSE_DISPLAY_NAME
, NULL
);
415 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08lx\n", hr
);
416 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
418 /* check the contents of the AssemblyName for default values */
420 /* NULL szAssemblyName */
422 hr
= pCreateAssemblyNameObject(&name
, NULL
, CANOF_SET_DEFAULT_VALUES
, NULL
);
423 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
424 ok(name
!= NULL
, "Expected non-NULL name\n");
427 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
428 ok(hr
== FUSION_E_INVALID_NAME
||
429 broken(hr
== E_INVALIDARG
), /* .NET 1.x */
430 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
434 hr
= IAssemblyName_GetName(name
, &size
, str
);
435 ok(hr
== S_OK
, "got %08lx\n", hr
);
436 ok(str
[0] == 'a', "got %c\n", str
[0]);
437 ok(!size
, "got %lu\n", size
);
441 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
442 ok(hr
== FUSION_E_INVALID_NAME
||
443 broken(hr
== S_OK
), /* .NET 1.x */
444 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
445 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
446 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
449 win_skip(".NET 1.x doesn't handle ASM_NAME_PROCESSOR_ID_ARRAY"
450 " and ASM_NAME_OSINFO_ARRAY correctly\n");
452 test_assembly_name_props(name
, defaults
);
454 IAssemblyName_Release(name
);
456 /* empty szAssemblyName */
458 hr
= pCreateAssemblyNameObject(&name
, L
"", CANOF_SET_DEFAULT_VALUES
, NULL
);
459 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
460 ok(name
!= NULL
, "Expected non-NULL name\n");
463 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
464 ok(hr
== FUSION_E_INVALID_NAME
||
465 broken(hr
== S_OK
), /* .NET 1.x */
466 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
469 hr
= IAssemblyName_GetName(name
, &size
, NULL
);
470 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "got %08lx\n", hr
);
471 ok(size
== 1, "got %lu\n", size
);
476 hr
= IAssemblyName_GetName(name
, NULL
, str
);
477 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "got %08lx\n", hr
);
478 ok(!str
[0], "got %c\n", str
[0]);
483 hr
= IAssemblyName_GetName(name
, &size
, str
);
484 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "got %08lx\n", hr
);
485 ok(!str
[0], "got %c\n", str
[0]);
486 ok(size
== 1, "got %lu\n", size
);
490 hr
= IAssemblyName_GetName(name
, &size
, str
);
491 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
492 ok(!str
[0], "Expected empty name\n");
493 ok(size
== 1, "Expected 1, got %ld\n", size
);
497 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
498 ok(hr
== FUSION_E_INVALID_NAME
||
499 broken(hr
== S_OK
), /* .NET 1.x */
500 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
501 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
502 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
505 win_skip(".NET 1.x doesn't handle ASM_NAME_PROCESSOR_ID_ARRAY"
506 " and ASM_NAME_OSINFO_ARRAY correctly\n");
508 test_assembly_name_props(name
, emptyname
);
510 IAssemblyName_Release(name
);
513 to_widechar(namestr
, "wine");
515 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_SET_DEFAULT_VALUES
, NULL
);
516 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
517 ok(name
!= NULL
, "Expected non-NULL name\n");
520 hr
= IAssemblyName_GetDisplayName(name
, NULL
, &size
, 0);
521 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "got %08lx\n", hr
);
522 ok(size
== 5, "got %lu\n", size
);
525 hr
= IAssemblyName_GetDisplayName(name
, NULL
, &size
, 0);
526 ok(hr
== E_NOT_SUFFICIENT_BUFFER
|| broken(hr
== E_INVALIDARG
), "got %08lx\n", hr
);
527 ok(size
== 5 || broken(size
== 3), "got %lu\n", size
);
531 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, 0);
532 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "got %08lx\n", hr
);
533 ok(str
[0] == 'a', "got %c\n", str
[0]);
534 ok(size
== 5, "got %lu\n", size
);
538 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
539 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "got %08lx\n", hr
);
540 ok(str
[0] == 'a', "got %c\n", str
[0]);
541 ok(size
== 5, "Wrong size %lu\n", size
);
544 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
545 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
547 ok(size
== 5, "Expected 5, got %ld\n", size
);
551 hr
= IAssemblyName_GetName(name
, &size
, str
);
552 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "got %08lx\n", hr
);
553 ok(!str
[0], "got %c\n", str
[0]);
554 ok(size
== 5, "got %lu\n", size
);
558 hr
= IAssemblyName_GetName(name
, &size
, str
);
559 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
561 ok(size
== 5, "Expected 5, got %ld\n", size
);
565 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
566 ok(hr
== FUSION_E_INVALID_NAME
||
567 broken(hr
== S_OK
), /* .NET 1.x */
568 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
569 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
570 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
573 win_skip(".NET 1.x doesn't handle ASM_NAME_PROCESSOR_ID_ARRAY"
574 " and ASM_NAME_OSINFO_ARRAY correctly\n");
576 test_assembly_name_props(name
, winename
);
578 IAssemblyName_Release(name
);
580 /* check the contents of the AssemblyName with parsing */
583 to_widechar(namestr
, "wine");
585 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
586 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
587 ok(name
!= NULL
, "Expected non-NULL name\n");
590 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
591 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
593 ok(size
== 5, "Expected 5, got %ld\n", size
);
597 hr
= IAssemblyName_GetName(name
, &size
, str
);
598 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
600 ok(size
== 5, "Expected 5, got %ld\n", size
);
604 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
605 ok(hr
== FUSION_E_INVALID_NAME
||
606 broken(hr
== S_OK
), /* .NET 1.x */
607 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
608 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
609 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
611 test_assembly_name_props(name
, winename
);
613 IAssemblyName_Release(name
);
615 /* 'wine, Version=1.2.3.4' */
616 to_widechar(namestr
, "wine, Version=1.2.3.4");
618 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
619 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
620 ok(name
!= NULL
, "Expected non-NULL name\n");
623 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
624 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
625 ok_aw("wine, Version=1.2.3.4", str
);
626 ok(size
== 22, "Expected 22, got %ld\n", size
);
630 hr
= IAssemblyName_GetName(name
, &size
, str
);
631 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
633 ok(size
== 5, "Expected 5, got %ld\n", size
);
637 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
638 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
639 ok(hi
== 0x00010002, "Expected 0x00010002, got %08lx\n", hi
);
640 ok(lo
== 0x00030004, "Expected 0x00030004, got %08lx\n", lo
);
642 test_assembly_name_props(name
, vername
);
644 IAssemblyName_Release(name
);
646 /* Version isn't of the form 1.x.x.x */
647 to_widechar(namestr
, "wine, Version=1.5");
649 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
650 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
651 ok(name
!= NULL
, "Expected non-NULL name\n");
654 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
655 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
656 ok_aw("wine, Version=1.5", str
);
657 ok(size
== 18, "Expected 18, got %ld\n", size
);
661 hr
= IAssemblyName_GetName(name
, &size
, str
);
662 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
664 ok(size
== 5, "Expected 5, got %ld\n", size
);
668 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
669 ok(hr
== FUSION_E_INVALID_NAME
||
670 broken(hr
== S_OK
), /* .NET 1.x */
671 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
673 broken(hi
== 0x10005), /* .NET 1.x */
674 "Expected 0, got %08lx\n", hi
);
675 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
677 test_assembly_name_props(name
, badvername
);
679 IAssemblyName_Release(name
);
681 /* 'wine, Culture=neutral' */
682 to_widechar(namestr
, "wine, Culture=neutral");
684 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
685 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
686 ok(name
!= NULL
, "Expected non-NULL name\n");
689 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
690 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
691 ok_aw("wine, Culture=neutral", str
);
692 ok(size
== 22, "Expected 22, got %ld\n", size
);
696 hr
= IAssemblyName_GetName(name
, &size
, str
);
697 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
699 ok(size
== 5, "Expected 5, got %ld\n", size
);
703 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
704 ok(hr
== FUSION_E_INVALID_NAME
||
705 broken(hr
== S_OK
), /* .NET 1.x */
706 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
707 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
708 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
710 test_assembly_name_props(name
, neutralname
);
712 IAssemblyName_Release(name
);
714 /* 'wine, Culture=en' */
715 to_widechar(namestr
, "wine, Culture=en");
717 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
718 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
719 ok(name
!= NULL
, "Expected non-NULL name\n");
722 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
723 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
724 ok_aw("wine, Culture=en", str
);
725 ok(size
== 17, "Expected 17, got %ld\n", size
);
729 hr
= IAssemblyName_GetName(name
, &size
, str
);
730 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
732 ok(size
== 5, "Expected 5, got %ld\n", size
);
736 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
737 ok(hr
== FUSION_E_INVALID_NAME
||
738 broken(hr
== S_OK
), /* .NET 1.x */
739 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
740 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
741 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
743 test_assembly_name_props(name
, enname
);
745 IAssemblyName_Release(name
);
747 /* 'wine, PublicKeyToken=01234567890abcde' */
748 to_widechar(namestr
, "wine, PublicKeyToken=01234567890abcde");
750 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
751 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
752 ok(name
!= NULL
, "Expected non-NULL name\n");
755 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
756 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
757 ok_aw("wine, PublicKeyToken=01234567890abcde", str
);
758 ok(size
== 38, "Expected 38, got %ld\n", size
);
762 hr
= IAssemblyName_GetName(name
, &size
, str
);
763 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
765 ok(size
== 5, "Expected 5, got %ld\n", size
);
769 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
770 ok(hr
== FUSION_E_INVALID_NAME
||
771 broken(hr
== S_OK
), /* .NET 1.x */
772 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
773 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
774 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
776 test_assembly_name_props(name
, pubkeyname
);
778 IAssemblyName_Release(name
);
780 /* Processor architecture tests */
781 to_widechar(namestr
, "wine, processorArchitecture=x86");
783 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
784 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
786 ok(name
!= NULL
, "Expected non-NULL name\n");
789 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
790 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
792 WideCharToMultiByte(CP_ACP
, 0, str
, -1, string1
, MAX_PATH
, NULL
, NULL
);
794 if (lstrcmpA(string1
, "wine") == 0)
795 win_skip("processorArchitecture not supported on .NET 1.x\n");
798 ok_aw("wine, processorArchitecture=x86", str
);
799 ok(size
== 32, "Expected 32, got %ld\n", size
);
802 hr
= IAssemblyName_GetProperty(name
, ASM_NAME_ARCHITECTURE
, &arch
, &size
);
803 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
804 ok(arch
== peI386
, "Expected peI386, got %d\n", arch
);
805 ok(size
== sizeof(arch
), "Wrong size %ld\n", size
);
807 IAssemblyName_Release(name
);
810 to_widechar(namestr
, "wine, processorArchitecture=AMD64");
812 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
813 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
816 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
817 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
818 ok_aw("wine, processorArchitecture=AMD64", str
);
819 ok(size
== 34, "Expected 34, got %ld\n", size
);
822 hr
= IAssemblyName_GetProperty(name
, ASM_NAME_ARCHITECTURE
, &arch
, &size
);
823 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
824 ok(arch
== peAMD64
, "Expected peAMD64, got %d\n", arch
);
825 ok(size
== sizeof(arch
), "Wrong size %ld\n", size
);
827 IAssemblyName_Release(name
);
830 to_widechar(namestr
, "wine, processorArchitecture=IA64");
832 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
833 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
836 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
837 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
838 ok_aw("wine, processorArchitecture=IA64", str
);
839 ok(size
== 33, "Expected 33, got %ld\n", size
);
842 hr
= IAssemblyName_GetProperty(name
, ASM_NAME_ARCHITECTURE
, &arch
, &size
);
843 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
844 ok(arch
== peIA64
, "Expected peIA64, got %d\n", arch
);
845 ok(size
== sizeof(arch
), "Wrong size %ld\n", size
);
847 IAssemblyName_Release(name
);
850 to_widechar(namestr
, "wine, processorArchitecture=MSIL");
852 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
853 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
856 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
857 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
858 ok_aw("wine, processorArchitecture=MSIL", str
);
859 ok(size
== 33, "Expected 33, got %ld\n", size
);
862 hr
= IAssemblyName_GetProperty(name
, ASM_NAME_ARCHITECTURE
, &arch
, &size
);
863 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
864 ok(arch
== peMSIL
, "Expected peMSIL, got %d\n", arch
);
865 ok(size
== sizeof(arch
), "Wrong size %ld\n", size
);
867 IAssemblyName_Release(name
);
870 /* Pulling out various different values */
871 to_widechar(namestr
, "wine, Version=1.2.3.4, Culture=en, PublicKeyToken=1234567890abcdef");
873 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
874 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
875 ok(name
!= NULL
, "Expected non-NULL name\n");
878 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_VERSION
| ASM_DISPLAYF_CULTURE
);
879 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
880 ok_aw("wine, Version=1.2.3.4, Culture=en", str
);
881 ok(size
== 34, "Expected 34, got %ld\n", size
);
884 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_CULTURE
| ASM_DISPLAYF_PUBLIC_KEY_TOKEN
);
885 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
886 ok_aw("wine, Culture=en, PublicKeyToken=1234567890abcdef", str
);
887 ok(size
== 50, "Expected 50, got %ld\n", size
);
890 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
891 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
892 ok_aw("wine, Version=1.2.3.4, Culture=en, PublicKeyToken=1234567890abcdef", str
);
893 ok(size
== 67, "Expected 67, got %ld\n", size
);
895 IAssemblyName_Release(name
);
897 /* invalid property */
898 to_widechar(namestr
, "wine, BadProp=42");
900 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
901 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
902 ok(name
!= NULL
, "Expected non-NULL name\n");
906 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
907 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
909 ok(size
== 5, "Expected 5, got %ld\n", size
);
913 hr
= IAssemblyName_GetName(name
, &size
, str
);
914 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
916 ok(size
== 5, "Expected 5, got %ld\n", size
);
920 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
921 ok(hr
== FUSION_E_INVALID_NAME
||
922 broken(hr
== S_OK
), /* .NET 1.x */
923 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
924 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
925 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
927 test_assembly_name_props(name
, winename
);
929 IAssemblyName_Release(name
);
931 /* PublicKeyToken is not 16 chars long */
932 to_widechar(namestr
, "wine, PublicKeyToken=567890abcdef");
933 name
= (IAssemblyName
*)0xdeadbeef;
934 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
935 if (hr
== S_OK
&& name
!= (IAssemblyName
*)0xdeadbeef)
937 win_skip(".NET 1.x doesn't check PublicKeyToken correctly\n");
938 IAssemblyName_Release(name
);
941 ok(hr
== FUSION_E_INVALID_NAME
,
942 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
943 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
945 /* PublicKeyToken contains invalid chars */
946 to_widechar(namestr
, "wine, PublicKeyToken=1234567890ghijkl");
947 name
= (IAssemblyName
*)0xdeadbeef;
948 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
949 ok(hr
== FUSION_E_INVALID_NAME
,
950 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
951 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
953 /* no comma separator */
954 to_widechar(namestr
, "wine PublicKeyToken=1234567890abcdef");
955 name
= (IAssemblyName
*)0xdeadbeef;
956 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
957 ok(hr
== FUSION_E_INVALID_NAME
,
958 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
959 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
960 if(SUCCEEDED(hr
)) IAssemblyName_Release(name
);
963 to_widechar(namestr
, "wine, PublicKeyToken");
964 name
= (IAssemblyName
*)0xdeadbeef;
965 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
966 ok(hr
== FUSION_E_INVALID_NAME
,
967 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
968 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
971 to_widechar(namestr
, "wine, PublicKeyToken=");
972 name
= (IAssemblyName
*)0xdeadbeef;
973 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
974 ok(hr
== FUSION_E_INVALID_NAME
,
975 "Expected FUSION_E_INVALID_NAME, got %08lx\n", hr
);
976 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
979 to_widechar(namestr
, "wine,version=1.0.0.0");
980 name
= (IAssemblyName
*)0xdeadbeef;
981 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
982 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
983 ok(name
!= NULL
, "Expected non-NULL name\n");
984 hi
= lo
= 0xdeadbeef;
985 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
986 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
987 ok(hi
== 65536, "Expected 536, got %lu\n", hi
);
988 ok(lo
== 0, "Expected 0, got %lu\n", lo
);
989 IAssemblyName_Release(name
);
992 to_widechar(namestr
, "wine, version=\"1.0.0.0\",culture=\"en\"");
993 name
= (IAssemblyName
*)0xdeadbeef;
994 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
995 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
996 ok(name
!= NULL
, "Expected non-NULL name\n");
997 hi
= lo
= 0xdeadbeef;
998 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
999 ok(hr
== S_OK
, "Expected S_OK, got %08lx\n", hr
);
1000 ok(hi
== 65536, "Expected 65536, got %lu\n", hi
);
1001 ok(lo
== 0, "Expected 0, got %lu\n", lo
);
1002 IAssemblyName_Release(name
);
1005 static void test_IAssemblyName_IsEqual(void)
1008 IAssemblyName
*name1
, *name2
;
1010 hr
= pCreateAssemblyNameObject( &name1
, L
"wine", CANOF_PARSE_DISPLAY_NAME
, NULL
);
1011 ok( hr
== S_OK
, "got %08lx\n", hr
);
1013 hr
= pCreateAssemblyNameObject( &name2
, L
"wine", CANOF_PARSE_DISPLAY_NAME
, NULL
);
1014 ok( hr
== S_OK
, "got %08lx\n", hr
);
1016 if (0) { /* crashes on some old version */
1017 hr
= IAssemblyName_IsEqual( name1
, NULL
, 0 );
1018 ok( hr
== S_FALSE
, "got %08lx\n", hr
);
1020 hr
= IAssemblyName_IsEqual( name1
, NULL
, ASM_CMPF_IL_ALL
);
1021 ok( hr
== S_FALSE
, "got %08lx\n", hr
);
1024 hr
= IAssemblyName_IsEqual( name1
, name1
, ASM_CMPF_IL_ALL
);
1025 ok( hr
== S_OK
, "got %08lx\n", hr
);
1027 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
1028 ok( hr
== S_OK
, "got %08lx\n", hr
);
1030 IAssemblyName_Release( name2
);
1031 hr
= pCreateAssemblyNameObject( &name2
, L
"wine,version=1.0.0.0", CANOF_PARSE_DISPLAY_NAME
, NULL
);
1032 ok( hr
== S_OK
, "got %08lx\n", hr
);
1034 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
1035 ok( hr
== S_OK
, "got %08lx\n", hr
);
1037 IAssemblyName_Release( name2
);
1038 hr
= pCreateAssemblyNameObject( &name2
, L
"wine,version=1.0.0.0,culture=neutral",
1039 CANOF_PARSE_DISPLAY_NAME
, NULL
);
1040 ok( hr
== S_OK
, "got %08lx\n", hr
);
1042 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
1043 ok( hr
== S_OK
, "got %08lx\n", hr
);
1045 IAssemblyName_Release( name1
);
1046 hr
= pCreateAssemblyNameObject( &name1
, L
"wine,version=1.0.0.0,culture=en",
1047 CANOF_PARSE_DISPLAY_NAME
, NULL
);
1048 ok( hr
== S_OK
, "got %08lx\n", hr
);
1050 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
1051 ok( hr
== S_FALSE
, "got %08lx\n", hr
);
1053 IAssemblyName_Release( name1
);
1054 hr
= pCreateAssemblyNameObject( &name1
, L
"wine", CANOF_PARSE_DISPLAY_NAME
, NULL
);
1055 ok( hr
== S_OK
, "got %08lx\n", hr
);
1057 IAssemblyName_Release( name2
);
1058 hr
= pCreateAssemblyNameObject( &name2
, L
"wine,version=1.0.0.0,publicKeyToken=1234567890abcdef",
1059 CANOF_PARSE_DISPLAY_NAME
, NULL
);
1060 ok( hr
== S_OK
, "got %08lx\n", hr
);
1062 hr
= IAssemblyName_IsEqual( name1
, name2
, ASM_CMPF_IL_ALL
);
1063 ok( hr
== S_OK
, "got %08lx\n", hr
);
1065 IAssemblyName_Release( name1
);
1066 IAssemblyName_Release( name2
);
1071 if (!init_functionpointers())
1073 win_skip("fusion.dll not available\n");
1077 test_CreateAssemblyNameObject();
1078 test_IAssemblyName_IsEqual();