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
);
750 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
751 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
752 ok_aw("wine, processorArchitecture=AMD64", str
);
753 ok(size
== 34, "Expected 34, got %d\n", size
);
755 IAssemblyName_Release(name
);
758 to_widechar(namestr
, "wine, processorArchitecture=IA64");
760 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
763 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
764 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
765 ok_aw("wine, processorArchitecture=IA64", str
);
766 ok(size
== 33, "Expected 33, got %d\n", size
);
768 IAssemblyName_Release(name
);
771 to_widechar(namestr
, "wine, processorArchitecture=MSIL");
773 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
776 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_PROCESSORARCHITECTURE
);
777 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
778 ok_aw("wine, processorArchitecture=MSIL", str
);
779 ok(size
== 33, "Expected 33, got %d\n", size
);
781 IAssemblyName_Release(name
);
784 /* Pulling out various different values */
785 to_widechar(namestr
, "wine, Version=1.2.3.4, Culture=en, PublicKeyToken=1234567890abcdef");
787 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
788 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
789 ok(name
!= NULL
, "Expected non-NULL name\n");
792 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_VERSION
| ASM_DISPLAYF_CULTURE
);
793 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
794 ok_aw("wine, Version=1.2.3.4, Culture=en", str
);
795 ok(size
== 34, "Expected 34, got %d\n", size
);
798 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_CULTURE
| ASM_DISPLAYF_PUBLIC_KEY_TOKEN
);
799 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
800 ok_aw("wine, Culture=en, PublicKeyToken=1234567890abcdef", str
);
801 ok(size
== 50, "Expected 50, got %d\n", size
);
804 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
805 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
806 ok_aw("wine, Version=1.2.3.4, Culture=en, PublicKeyToken=1234567890abcdef", str
);
807 ok(size
== 67, "Expected 67, got %d\n", size
);
809 IAssemblyName_Release(name
);
811 /* invalid property */
812 to_widechar(namestr
, "wine, BadProp=42");
814 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
815 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
816 ok(name
!= NULL
, "Expected non-NULL name\n");
820 hr
= IAssemblyName_GetDisplayName(name
, str
, &size
, ASM_DISPLAYF_FULL
);
821 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
823 ok(size
== 5, "Expected 5, got %d\n", size
);
827 hr
= IAssemblyName_GetName(name
, &size
, str
);
828 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
830 ok(size
== 5, "Expected 5, got %d\n", size
);
834 hr
= IAssemblyName_GetVersion(name
, &hi
, &lo
);
835 ok(hr
== FUSION_E_INVALID_NAME
||
836 broken(hr
== S_OK
), /* .NET 1.x */
837 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
838 ok(hi
== 0, "Expected 0, got %08x\n", hi
);
839 ok(lo
== 0, "Expected 0, got %08x\n", lo
);
841 test_assembly_name_props(name
, winename
);
843 IAssemblyName_Release(name
);
845 /* PublicKeyToken is not 16 chars long */
846 to_widechar(namestr
, "wine, PublicKeyToken=567890abcdef");
847 name
= (IAssemblyName
*)0xdeadbeef;
848 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
849 if (hr
== S_OK
&& name
!= (IAssemblyName
*)0xdeadbeef)
851 win_skip(".NET 1.x doesn't check PublicKeyToken correctly\n");
852 IAssemblyName_Release(name
);
855 ok(hr
== FUSION_E_INVALID_NAME
,
856 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
857 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
859 /* PublicKeyToken contains invalid chars */
860 to_widechar(namestr
, "wine, PublicKeyToken=1234567890ghijkl");
861 name
= (IAssemblyName
*)0xdeadbeef;
862 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
863 ok(hr
== FUSION_E_INVALID_NAME
,
864 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
865 ok(name
== (IAssemblyName
*)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", name
);
867 /* no comma separator */
868 to_widechar(namestr
, "wine PublicKeyToken=1234567890abcdef");
869 name
= (IAssemblyName
*)0xdeadbeef;
870 hr
= pCreateAssemblyNameObject(&name
, namestr
, CANOF_PARSE_DISPLAY_NAME
, NULL
);
873 ok(hr
== FUSION_E_INVALID_NAME
,
874 "Expected FUSION_E_INVALID_NAME, got %08x\n", hr
);
875 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
);
898 if (!init_functionpointers())
900 win_skip("fusion.dll not available\n");
904 test_CreateAssemblyNameObject();