From 6123a772ed769988d9895a9e581c00d336f5e7b4 Mon Sep 17 00:00:00 2001 From: "Xamarin Public Jenkins (auto-signing)" Date: Tue, 28 Nov 2017 19:36:51 +0000 Subject: [PATCH] Imported Upstream version 5.8.0.88 Former-commit-id: 4b7216ffda08448e562271ce733688e761120fc5 --- configure.REMOVED.git-id | 2 +- configure.ac.REMOVED.git-id | 2 +- .../profiles/net_4_x/Mono.Cecil.Mdb.cs | 2 +- .../net_4_x/Mono.Cecil.cs.REMOVED.git-id | 2 +- external/cecil/Mono.Cecil.Cil/CodeReader.cs | 217 ++++++++++-------- external/cecil/Mono.Cecil.Cil/Symbols.cs | 51 ++-- external/cecil/Mono.Cecil.PE/Image.cs | 1 + external/cecil/Mono.Cecil.PE/ImageReader.cs | 8 +- external/cecil/Mono.Cecil.PE/ImageWriter.cs | 22 +- external/cecil/Mono.Cecil.Tests.props | 27 ++- external/cecil/Mono.Cecil.nuspec | 2 +- external/cecil/Mono.Cecil.props | 11 +- external/cecil/Mono.Cecil.sln | 20 +- external/cecil/Mono.Cecil/AssemblyReader.cs | 92 ++++---- external/cecil/Mono.Cecil/AssemblyWriter.cs | 18 +- .../cecil/Mono.Cecil/BaseAssemblyResolver.cs | 60 ++++- external/cecil/Mono.Cecil/CustomAttribute.cs | 3 +- .../Mono.Cecil/DefaultAssemblyResolver.cs | 4 - external/cecil/Mono.Cecil/MethodDefinition.cs | 6 +- external/cecil/Mono.Cecil/ModuleDefinition.cs | 30 +-- .../cecil/Mono.Cecil/SecurityDeclaration.cs | 14 +- external/cecil/Mono.Cecil/TypeDefinition.cs | 3 + external/cecil/Mono.Cecil/TypeSystem.cs | 8 +- external/cecil/Mono/Type.cs | 3 +- external/cecil/NetStandard.props | 2 +- external/cecil/ProjectInfo.cs | 2 +- external/cecil/Test/Mono.Cecil.Tests.csproj | 27 ++- .../Test/Mono.Cecil.Tests/AssemblyTests.cs | 6 + .../CallerMemberNameAttribute.cs | 10 + .../Mono.Cecil.Tests/CompilationService.cs | 110 ++++++++- .../Mono.Cecil.Tests/CustomAttributesTests.cs | 18 +- .../Test/Mono.Cecil.Tests/ImageReadTests.cs | 3 +- .../Test/Mono.Cecil.Tests/ImportCecilTests.cs | 20 +- .../Mono.Cecil.Tests/ImportReflectionTests.cs | 35 +-- .../Test/Mono.Cecil.Tests/MethodTests.cs | 2 + .../Test/Mono.Cecil.Tests/ModuleTests.cs | 20 +- .../Test/Mono.Cecil.Tests/PortablePdbTests.cs | 14 +- .../Test/Mono.Cecil.Tests/ResolveTests.cs | 36 ++- .../SecurityDeclarationTests.cs | 4 +- .../Test/Mono.Cecil.Tests/TypeParserTests.cs | 15 +- .../WindowsRuntimeAssemblyResolver.cs | 5 +- .../WindowsRuntimeProjectionsTests.cs | 5 +- .../cecil/rocks/Mono.Cecil.Rocks/ILParser.cs | 14 +- .../rocks/Mono.Cecil.Rocks/MethodBodyRocks.cs | 6 +- .../symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs | 6 + .../MonoSymbolTable.cs | 2 +- .../pdb/Mono.Cecil.Pdb/NativePdbReader.cs | 29 ++- .../pdb/Mono.Cecil.Pdb/NativePdbWriter.cs | 13 +- .../pdb/Test/Mono.Cecil.Tests/PdbTests.cs | 20 +- .../pdb/Test/Resources/assemblies/AVbTest.pdb | Bin 0 -> 24064 bytes external/linker/corebuild/.cliversion | 2 +- external/linker/corebuild/.toolversions | 1 - external/linker/corebuild/bootstrap.ps1 | 2 +- external/linker/corebuild/bootstrap.sh | 2 +- external/linker/corebuild/global.json | 5 + .../ILLink.CustomSteps.csproj | 1 - .../ILLink.Tasks/ILLink.Tasks.csproj | 1 - .../integration/test/IntegrationTestBase.cs | 55 ++--- .../integration/test/MusicStoreTest.cs | 75 +++++- .../corebuild/integration/test/TestContext.cs | 8 +- .../corebuild/integration/test/test.csproj | 8 +- .../linker/Mono.Linker.Steps/BlacklistStep.cs | 6 +- .../linker/Mono.Linker.Steps/MarkStep.cs | 26 ++- .../Mono.Linker.Steps/ResolveFromXmlStep.cs | 21 +- .../linker/Mono.Linker.Steps/SweepStep.cs | 57 ++++- .../linker/linker/Mono.Linker/Annotations.cs | 20 ++ .../linker/Mono.Linker/AssemblyAction.cs | 6 +- external/linker/linker/Mono.Linker/Driver.cs | 49 ++-- .../linker/linker/Mono.Linker/LinkContext.cs | 15 +- .../Assertions/KeptResourceAttribute.cs | 15 ++ .../KeptResourceInAssemblyAttribute.cs | 18 ++ .../RemovedResourceInAssemblyAttribute.cs | 18 ++ .../Metadata/SandboxDependencyAttribute.cs | 4 +- .../SetupCompileAssemblyNameAttribute.cs | 12 + .../Metadata/SetupCompileResourceAttribute.cs | 12 + ...ono.Linker.Tests.Cases.Expectations.csproj | 5 + .../Basic/UsedInterfaceIsKept.cs | 24 ++ ...TypePreservedByLinkXmlWithCommentIsKept.cs | 15 ++ ...ypePreservedByLinkXmlWithCommentIsKept.xml | 6 + .../Mono.Linker.Tests.Cases.csproj | 15 ++ ...tProcessedIfNameDoesNotMatchAnAssembly.xml | 5 + ...otProcessedWhenBlacklistStepIsDisabled.xml | 5 + ...IsNotProcessedWhenCoreLinkActionIsSkip.xml | 5 + .../EmbeddedLinkXmlFileIsProcessed.xml | 5 + .../NonLinkerEmbeddedResourceHasNoImpact.xml | 2 + ...otProcessedIfNameDoesNotMatchAnAssembly.cs | 19 ++ ...NotProcessedWhenBlacklistStepIsDisabled.cs | 21 ++ ...eIsNotProcessedWhenCoreLinkActionIsSkip.cs | 23 ++ .../EmbeddedLinkXmlFileIsProcessed.cs | 22 ++ .../NonLinkerEmbeddedResourceHasNoImpact.cs | 18 ++ ...fyResourceInAssemblyAttributesBehavior.txt | 1 + ...ifyResourceInAssemblyAttributesBehavior.cs | 18 ++ .../linker/Tests/Mono.Linker.Tests.csproj | 1 + .../linker/Tests/TestCases/TestDatabase.cs | 6 + .../linker/Tests/TestCases/TestSuites.cs | 6 + .../Tests/TestCasesRunner/AssemblyChecker.cs | 10 + .../Tests/TestCasesRunner/CompilerOptions.cs | 1 + .../Tests/TestCasesRunner/ResultChecker.cs | 22 ++ .../SourceAndDestinationPair.cs | 9 + .../Tests/TestCasesRunner/TestCaseCompiler.cs | 13 +- .../TestCasesRunner/TestCaseMetadaProvider.cs | 36 ++- .../Tests/TestCasesRunner/TestCaseSandbox.cs | 11 +- .../Tests/TestCasesRunner/TestRunner.cs | 17 +- .../Json/Json.Designer.cs | 38 ++- .../Json/Json.resx | 3 + ...ckFileWithWithSpecifiedPackageFolders.json | 8 +- .../MultipleProjectFileDependencyGroups.json | 8 +- ...jectFileDependencyGroups_CaseMismatch.json | 150 ++++++++++++ .../Microsoft.NuGet.Build.Tasks.Tests.csproj | 3 +- .../PackageFolderTests.cs | 2 +- .../ReferenceResolutionTests.cs | 27 +++ .../Microsoft.NuGet.ImportAfter.targets | 6 - .../Microsoft.NuGet.Build.Tasks.csproj | 2 - .../Microsoft.NuGet.targets | 18 ++ .../ResolveNuGetPackageAssets.cs | 2 +- .../Microsoft.NuGet.Build.Tasks/project.json | 13 +- mcs/build/common/Consts.cs | 2 +- .../Test/Evaluator/CompletionTest.cs | 4 +- .../Test/Evaluator/EvaluatorTest.cs | 5 +- .../Test/Evaluator/ExpressionsTest.cs | 3 +- .../Mono.CSharp/Test/Evaluator/TypesTest.cs | 5 +- mcs/class/Mono.Data.Sqlite/Test/Bug27864.cs | 24 +- .../Test/SqliteCommandUnitTests.cs | 19 +- .../Test/SqliteConnectionTest.cs | 114 +++++---- .../Test/SqliteDataAdapterUnitTests.cs | 23 +- .../Test/SqliteExceptionUnitTests.cs | 19 +- .../Test/SqliteFunctionTests.cs | 15 +- .../Test/SqliteParameterUnitTests.cs | 20 +- .../Mono.Data.Sqlite/Test/SqliteTests.cs | 12 +- .../Test/Mono.Unix.Native/SocketTest.cs | 15 ++ .../AesManagedTest.cs | 4 +- .../ZipTest.cs | 64 +++--- .../Test/System.IO.Compression/ZipTest.cs | 157 +++++++------ .../System.Net.Http/HttpClientHandler.cs | 16 +- .../CmsSignerTest.cs | 4 +- .../PkitsTest.cs | 4 +- .../Pkits_4_01_SignatureVerification.cs | 4 +- .../SignedCmsTest.cs | 3 +- .../SignerInfoCollectionTest.cs | 4 +- .../SignerInfoTest.cs | 3 +- .../SubjectIdentifierTest.cs | 4 +- .../X509Certificate2UICas.cs | 3 +- .../X509Certificate2UITest.cs | 4 +- .../DSAKeyValueTest.cs | 2 + .../DataObjectTest.cs | 2 + .../DataReferenceTest.cs | 3 +- .../EncryptedXmlTest.cs | 3 +- .../KeyInfoNameTest.cs | 2 + .../KeyInfoNodeTest.cs | 2 + .../KeyInfoRetrievalMethodTest.cs | 2 + .../KeyInfoTest.cs | 2 + .../KeyInfoX509DataTest.cs | 2 + .../RSAKeyValueTest.cs | 2 + .../ReferenceTest.cs | 2 + .../SignatureTest.cs | 2 + .../SignedInfoTest.cs | 2 + .../SignedXmlTest.cs | 4 +- .../TransformChainTest.cs | 2 + .../TransformTest.cs | 2 + .../XmlDecryptionTransformTest.cs | 4 +- .../XmlDsigBase64TransformTest.cs | 2 + .../XmlDsigC14NTransformTest.cs | 2 + .../XmlDsigC14NWithCommentsTransformTest.cs | 2 + .../XmlDsigEnvelopedSignatureTransformTest.cs | 2 + .../XmlDsigExcC14NTransformTest.cs | 2 + ...XmlDsigExcC14NWithCommentsTransformTest.cs | 4 +- .../XmlDsigXPathTransformTest.cs | 3 +- .../XmlDsigXsltTransformTest.cs | 3 + .../XmlLicenseTransformTest.cs | 4 +- .../ProtectedDataCas.cs | 4 +- .../ProtectedDataTest.cs | 2 + .../ProtectedMemoryCas.cs | 4 +- .../ProtectedMemoryTest.cs | 4 +- .../WebInvokeAttributeTest.cs | 9 +- .../Mono.Net.Security/AsyncProtocolRequest.cs | 2 +- .../System/System.Diagnostics/Process.cs | 11 +- .../System.IO.Compression/DeflateStream.cs | 42 ++-- mcs/class/System/System_test.dll.sources | 1 + .../AsyncOperationManagerTest.cs | 2 +- .../System.Net/HttpListenerRequestTest.cs | 6 + .../CryptoConfigTest.cs | 54 +++++ .../corlib/LinkerDescriptor/mscorlib.xml | 5 + .../corlib/LinkerDescriptor/mscorlib_test.xml | 9 + mcs/class/corlib/Makefile | 5 +- .../CryptoConfig.cs | 2 +- mcs/class/corlib/Test/System.IO/FileTest.cs | 160 ++++++------- .../corlib/Test/System.IO/StreamReaderTest.cs | 25 +- .../corlib/Test/System.IO/StreamWriterTest.cs | 45 ++-- .../ModuleBuilderTest.cs | 53 +++++ .../AssemblyAlgorithmIdAttributeTest.cs | 12 +- .../AssemblyCompanyAttributeTest.cs | 112 +++++++++ .../AssemblyConfigurationAttributeTest.cs | 12 +- .../AssemblyCopyrightAttributeTest.cs | 11 +- .../AssemblyCultureAttributeTest.cs | 12 +- .../AssemblyDefaultAliasAttributeTest.cs | 112 +++++++++ .../AssemblyDelaySignAttributeTest.cs | 11 +- .../AssemblyDescriptionAttributeTest.cs | 10 +- .../AssemblyFileVersionAttributeTest.cs | 11 +- .../AssemblyFlagsAttributeTest.cs | 118 ++++++++++ ...semblyInformationalVersionAttributeTest.cs | 11 +- .../AssemblyKeyFileAttributeTest.cs | 112 +++++++++ .../AssemblyKeyNameAttributeTest.cs | 112 +++++++++ .../AssemblyMetadataAttributeTest.cs | 116 ++++++++++ .../AssemblyProductAttributeTest.cs | 112 +++++++++ .../AssemblySignatureKeyAttributeTest.cs | 116 ++++++++++ .../AssemblyTitleAttributeTest.cs | 112 +++++++++ .../AssemblyTrademarkAttributeTest.cs | 112 +++++++++ .../AssemblyVersionAttributeTest.cs | 112 +++++++++ .../Test/System.Reflection/FieldInfoTest.cs | 57 +++++ .../MethodImplAttributeTest.cs | 127 ++++++++++ .../TypeForwardedFromAttributeTest.cs | 50 ++++ .../TypeForwardedToAttributeTest.cs | 51 ++++ .../DllImportAttributeTest.cs | 128 +++++++++++ .../MarshalAsAttributeTest.cs | 132 +++++++++++ .../StructLayoutAttributeTest.cs | 62 +++++ .../SignatureDescriptionTest.cs | 2 +- .../System/AttributeUsageAttributeTest.cs | 131 +++++++++++ .../corlib/Test/System/ConsoleKeyInfoTest.cs | 65 ++++++ mcs/class/corlib/Test/System/TimeZoneTest.cs | 2 +- mcs/class/corlib/corlib_test.dll.sources | 19 ++ .../Mono.Security.dll.REMOVED.git-id | 2 +- .../System.Configuration.dll.REMOVED.git-id | 2 +- .../System.Numerics.dll.REMOVED.git-id | 2 +- .../System.Security.dll.REMOVED.git-id | 2 +- .../1050800000/System.Xml.dll.REMOVED.git-id | 2 +- .../1050800000/System.dll.REMOVED.git-id | 2 +- .../1050800000/mcs.exe.REMOVED.git-id | 2 +- .../1050800000/mscorlib.dll.REMOVED.git-id | 2 +- .../Mono.Security.dll.REMOVED.git-id | 2 +- .../System.Configuration.dll.REMOVED.git-id | 2 +- .../System.Numerics.dll.REMOVED.git-id | 2 +- .../System.Security.dll.REMOVED.git-id | 2 +- .../1050800000/System.Xml.dll.REMOVED.git-id | 2 +- .../1050800000/System.dll.REMOVED.git-id | 2 +- .../1050800000/mscorlib.dll.REMOVED.git-id | 2 +- .../Mono.Security.dll.REMOVED.git-id | 2 +- .../System.Configuration.dll.REMOVED.git-id | 2 +- .../System.Numerics.dll.REMOVED.git-id | 2 +- .../System.Security.dll.REMOVED.git-id | 2 +- .../1050800000/System.Xml.dll.REMOVED.git-id | 2 +- .../1050800000/System.dll.REMOVED.git-id | 2 +- .../1050800000/mcs.exe.REMOVED.git-id | 2 +- .../1050800000/mscorlib.dll.REMOVED.git-id | 2 +- mcs/packages/Makefile | 15 +- mcs/tools/linker/Makefile | 3 +- mcs/tools/xbuild/Makefile | 5 + mono/metadata/class.c.REMOVED.git-id | 2 +- mono/metadata/icall.c.REMOVED.git-id | 2 +- mono/metadata/loader.c | 111 +++++---- mono/metadata/locales.c | 13 +- mono/metadata/object-offsets.h | 2 + mono/metadata/sre.c.REMOVED.git-id | 2 +- mono/mini/aot-compiler.c.REMOVED.git-id | 2 +- mono/mini/gshared.cs | 46 ++++ mono/mini/iltests.il | 29 +++ mono/mini/interp/interp.c.REMOVED.git-id | 2 +- mono/mini/interp/transform.c.REMOVED.git-id | 2 +- mono/mini/method-to-ir.c.REMOVED.git-id | 2 +- mono/mini/mini-arm.c.REMOVED.git-id | 2 +- mono/mini/mini-arm.h | 7 +- mono/mini/mini-llvm.c.REMOVED.git-id | 2 +- mono/mini/objects.cs | 1 + mono/mini/simd-intrinsics.c | 1 - mono/mini/version.h | 2 +- mono/profiler/log-args.c | 67 +++++- mono/tests/Makefile.am | 1 + mono/tests/Makefile.in.REMOVED.git-id | 2 +- mono/tests/iface-contravariant1.cs | 60 +++++ po/mcs/de.gmo | Bin 5406 -> 5406 bytes po/mcs/de.po.REMOVED.git-id | 2 +- po/mcs/es.gmo | Bin 16329 -> 16329 bytes po/mcs/es.po.REMOVED.git-id | 2 +- po/mcs/ja.gmo | Bin 20863 -> 20863 bytes po/mcs/ja.po.REMOVED.git-id | 2 +- po/mcs/mcs.pot | 4 +- po/mcs/pt_BR.gmo | Bin 73055 -> 73055 bytes po/mcs/pt_BR.po.REMOVED.git-id | 2 +- 277 files changed, 4817 insertions(+), 941 deletions(-) create mode 100644 external/cecil/Test/Mono.Cecil.Tests/CallerMemberNameAttribute.cs create mode 100644 external/cecil/symbols/pdb/Test/Resources/assemblies/AVbTest.pdb delete mode 100644 external/linker/corebuild/.toolversions create mode 100644 external/linker/corebuild/global.json create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptResourceAttribute.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptResourceInAssemblyAttribute.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedResourceInAssemblyAttribute.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileResourceAttribute.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Basic/UsedInterfaceIsKept.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/LinkXml/UnusedTypePreservedByLinkXmlWithCommentIsKept.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/LinkXml/UnusedTypePreservedByLinkXmlWithCommentIsKept.xml create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly.xml create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled.xml create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip.xml create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsProcessed.xml create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/NonLinkerEmbeddedResourceHasNoImpact.xml create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsProcessed.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/NonLinkerEmbeddedResourceHasNoImpact.cs create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/TestFramework/Dependencies/VerifyResourceInAssemblyAttributesBehavior.txt create mode 100644 external/linker/linker/Tests/Mono.Linker.Tests.Cases/TestFramework/VerifyResourceInAssemblyAttributesBehavior.cs create mode 100644 external/linker/linker/Tests/TestCasesRunner/SourceAndDestinationPair.cs create mode 100644 external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups_CaseMismatch.json create mode 100644 mcs/class/System/Test/System.Security.Cryptography/CryptoConfigTest.cs create mode 100644 mcs/class/corlib/LinkerDescriptor/mscorlib_test.xml create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyCompanyAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyDefaultAliasAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyFlagsAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyKeyFileAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyKeyNameAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyMetadataAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyProductAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblySignatureKeyAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyTitleAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyTrademarkAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Reflection/AssemblyVersionAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Runtime.CompilerServices/MethodImplAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Runtime.CompilerServices/TypeForwardedFromAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Runtime.CompilerServices/TypeForwardedToAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Runtime.InteropServices/DllImportAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Runtime.InteropServices/MarshalAsAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System.Runtime.InteropServices/StructLayoutAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System/AttributeUsageAttributeTest.cs create mode 100644 mcs/class/corlib/Test/System/ConsoleKeyInfoTest.cs create mode 100644 mono/tests/iface-contravariant1.cs diff --git a/configure.REMOVED.git-id b/configure.REMOVED.git-id index 670880e579..d752e9d091 100644 --- a/configure.REMOVED.git-id +++ b/configure.REMOVED.git-id @@ -1 +1 @@ -3fb2fb8eee096ec9f26b7a4dae0ff3e1d0fb7eb1 \ No newline at end of file +37c1b000c4419715dad5a8f78a060364b72479dd \ No newline at end of file diff --git a/configure.ac.REMOVED.git-id b/configure.ac.REMOVED.git-id index 7d7f6d7d07..7b77cd99a1 100644 --- a/configure.ac.REMOVED.git-id +++ b/configure.ac.REMOVED.git-id @@ -1 +1 @@ -3aa404de51236fe4a603243f724c4b33a6d206c1 \ No newline at end of file +0fcbd9917a47e8f359dbdcbd676abae3b61dc4e6 \ No newline at end of file diff --git a/external/api-snapshot/profiles/net_4_x/Mono.Cecil.Mdb.cs b/external/api-snapshot/profiles/net_4_x/Mono.Cecil.Mdb.cs index cfc40391e5..6abd957dba 100644 --- a/external/api-snapshot/profiles/net_4_x/Mono.Cecil.Mdb.cs +++ b/external/api-snapshot/profiles/net_4_x/Mono.Cecil.Mdb.cs @@ -7,7 +7,7 @@ [assembly:System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute.DebuggingModes)(2))] [assembly:System.Reflection.AssemblyCopyrightAttribute("Copyright © 2008 - 2015 Jb Evain")] [assembly:System.Reflection.AssemblyFileVersionAttribute("0.10.0.0")] -[assembly:System.Reflection.AssemblyInformationalVersionAttribute("0.10.0.0-beta6")] +[assembly:System.Reflection.AssemblyInformationalVersionAttribute("0.10.0.0-beta7")] [assembly:System.Reflection.AssemblyProductAttribute("Mono.Cecil")] [assembly:System.Reflection.AssemblyTitleAttribute("Mono.Cecil.Mdb")] [assembly:System.Runtime.CompilerServices.CompilationRelaxationsAttribute(8)] diff --git a/external/api-snapshot/profiles/net_4_x/Mono.Cecil.cs.REMOVED.git-id b/external/api-snapshot/profiles/net_4_x/Mono.Cecil.cs.REMOVED.git-id index a4ff598dd7..7b2da70822 100644 --- a/external/api-snapshot/profiles/net_4_x/Mono.Cecil.cs.REMOVED.git-id +++ b/external/api-snapshot/profiles/net_4_x/Mono.Cecil.cs.REMOVED.git-id @@ -1 +1 @@ -9f405648ac44af0776db1fccb6ed79229217457a \ No newline at end of file +dfcf34172908a18aaf781b2b50e901e96b820136 \ No newline at end of file diff --git a/external/cecil/Mono.Cecil.Cil/CodeReader.cs b/external/cecil/Mono.Cecil.Cil/CodeReader.cs index 17376d421a..f7f11d5d9e 100644 --- a/external/cecil/Mono.Cecil.Cil/CodeReader.cs +++ b/external/cecil/Mono.Cecil.Cil/CodeReader.cs @@ -45,7 +45,7 @@ namespace Mono.Cecil.Cil { return position; } - void MoveBackTo (int position) + public void MoveBackTo (int position) { this.reader.context = null; this.Position = position; @@ -62,6 +62,30 @@ namespace Mono.Cecil.Cil { return this.body; } + public int ReadCodeSize (MethodDefinition method) + { + var position = MoveTo (method); + + var code_size = ReadCodeSize (); + + MoveBackTo (position); + return code_size; + } + + int ReadCodeSize () + { + var flags = ReadByte (); + switch (flags & 0x3) { + case 0x2: // tiny + return flags >> 2; + case 0x3: // fat + Advance (-1 + 2 + 2); // go back, 2 bytes flags, 2 bytes stack size + return (int) ReadUInt32 (); + default: + throw new InvalidOperationException (); + } + } + void ReadMethodBody () { var flags = ReadByte (); @@ -88,99 +112,6 @@ namespace Mono.Cecil.Cil { ReadDebugInfo (); } - void ReadDebugInfo () - { - if (method.debug_info.sequence_points != null) - ReadSequencePoints (); - - if (method.debug_info.scope != null) - ReadScope (method.debug_info.scope); - - if (method.custom_infos != null) - ReadCustomDebugInformations (method); - } - - void ReadCustomDebugInformations (MethodDefinition method) - { - var custom_infos = method.custom_infos; - - for (int i = 0; i < custom_infos.Count; i++) { - var state_machine_scope = custom_infos [i] as StateMachineScopeDebugInformation; - if (state_machine_scope != null) - ReadStateMachineScope (state_machine_scope); - - var async_method = custom_infos [i] as AsyncMethodBodyDebugInformation; - if (async_method != null) - ReadAsyncMethodBody (async_method); - } - } - - void ReadAsyncMethodBody (AsyncMethodBodyDebugInformation async_method) - { - if (async_method.catch_handler.Offset > -1) - async_method.catch_handler = new InstructionOffset (GetInstruction (async_method.catch_handler.Offset)); - - if (!async_method.yields.IsNullOrEmpty ()) - for (int i = 0; i < async_method.yields.Count; i++) - async_method.yields [i] = new InstructionOffset (GetInstruction (async_method.yields [i].Offset)); - - if (!async_method.resumes.IsNullOrEmpty ()) - for (int i = 0; i < async_method.resumes.Count; i++) - async_method.resumes [i] = new InstructionOffset (GetInstruction (async_method.resumes [i].Offset)); - } - - void ReadStateMachineScope (StateMachineScopeDebugInformation state_machine_scope) - { - state_machine_scope.start = new InstructionOffset (GetInstruction (state_machine_scope.start.Offset)); - - var end_instruction = GetInstruction (state_machine_scope.end.Offset); - state_machine_scope.end = end_instruction == null - ? new InstructionOffset () - : new InstructionOffset (end_instruction); - } - - void ReadSequencePoints () - { - var symbol = method.debug_info; - - for (int i = 0; i < symbol.sequence_points.Count; i++) { - var sequence_point = symbol.sequence_points [i]; - var instruction = GetInstruction (sequence_point.Offset); - if (instruction != null) - sequence_point.offset = new InstructionOffset (instruction); - } - } - - void ReadScopes (Collection scopes) - { - for (int i = 0; i < scopes.Count; i++) - ReadScope (scopes [i]); - } - - void ReadScope (ScopeDebugInformation scope) - { - var start_instruction = GetInstruction (scope.Start.Offset); - if (start_instruction != null) - scope.Start = new InstructionOffset (start_instruction); - - var end_instruction = GetInstruction (scope.End.Offset); - scope.End = end_instruction != null - ? new InstructionOffset (end_instruction) - : new InstructionOffset (); - - if (!scope.variables.IsNullOrEmpty ()) { - for (int i = 0; i < scope.variables.Count; i++) { - var variable_info = scope.variables [i]; - var variable = GetVariable (variable_info.Index); - if (variable != null) - variable_info.index = new VariableIndex (variable); - } - } - - if (!scope.scopes.IsNullOrEmpty ()) - ReadScopes (scope.scopes); - } - void ReadFatMethod () { var flags = ReadUInt16 (); @@ -442,6 +373,104 @@ namespace Mono.Cecil.Cil { return new MetadataToken (ReadUInt32 ()); } + void ReadDebugInfo () + { + if (method.debug_info.sequence_points != null) + ReadSequencePoints (); + + if (method.debug_info.scope != null) + ReadScope (method.debug_info.scope); + + if (method.custom_infos != null) + ReadCustomDebugInformations (method); + } + + void ReadCustomDebugInformations (MethodDefinition method) + { + var custom_infos = method.custom_infos; + + for (int i = 0; i < custom_infos.Count; i++) { + var state_machine_scope = custom_infos [i] as StateMachineScopeDebugInformation; + if (state_machine_scope != null) + ReadStateMachineScope (state_machine_scope); + + var async_method = custom_infos [i] as AsyncMethodBodyDebugInformation; + if (async_method != null) + ReadAsyncMethodBody (async_method); + } + } + + void ReadAsyncMethodBody (AsyncMethodBodyDebugInformation async_method) + { + if (async_method.catch_handler.Offset > -1) + async_method.catch_handler = new InstructionOffset (GetInstruction (async_method.catch_handler.Offset)); + + if (!async_method.yields.IsNullOrEmpty ()) + for (int i = 0; i < async_method.yields.Count; i++) + async_method.yields [i] = new InstructionOffset (GetInstruction (async_method.yields [i].Offset)); + + if (!async_method.resumes.IsNullOrEmpty ()) + for (int i = 0; i < async_method.resumes.Count; i++) + async_method.resumes [i] = new InstructionOffset (GetInstruction (async_method.resumes [i].Offset)); + } + + void ReadStateMachineScope (StateMachineScopeDebugInformation state_machine_scope) + { + if (state_machine_scope.scopes.IsNullOrEmpty ()) + return; + + foreach (var scope in state_machine_scope.scopes) { + scope.start = new InstructionOffset (GetInstruction (scope.start.Offset)); + + var end_instruction = GetInstruction (scope.end.Offset); + scope.end = end_instruction == null + ? new InstructionOffset () + : new InstructionOffset (end_instruction); + } + } + + void ReadSequencePoints () + { + var symbol = method.debug_info; + + for (int i = 0; i < symbol.sequence_points.Count; i++) { + var sequence_point = symbol.sequence_points [i]; + var instruction = GetInstruction (sequence_point.Offset); + if (instruction != null) + sequence_point.offset = new InstructionOffset (instruction); + } + } + + void ReadScopes (Collection scopes) + { + for (int i = 0; i < scopes.Count; i++) + ReadScope (scopes [i]); + } + + void ReadScope (ScopeDebugInformation scope) + { + var start_instruction = GetInstruction (scope.Start.Offset); + if (start_instruction != null) + scope.Start = new InstructionOffset (start_instruction); + + var end_instruction = GetInstruction (scope.End.Offset); + scope.End = end_instruction != null + ? new InstructionOffset (end_instruction) + : new InstructionOffset (); + + if (!scope.variables.IsNullOrEmpty ()) { + for (int i = 0; i < scope.variables.Count; i++) { + var variable_info = scope.variables [i]; + var variable = GetVariable (variable_info.Index); + if (variable != null) + variable_info.index = new VariableIndex (variable); + } + } + + if (!scope.scopes.IsNullOrEmpty ()) + ReadScopes (scope.scopes); + } + #if !READ_ONLY public ByteBuffer PatchRawMethodBody (MethodDefinition method, CodeWriter writer, out int code_size, out MetadataToken local_var_token) diff --git a/external/cecil/Mono.Cecil.Cil/Symbols.cs b/external/cecil/Mono.Cecil.Cil/Symbols.cs index 6ef5ad2a60..4c4a8b0306 100644 --- a/external/cecil/Mono.Cecil.Cil/Symbols.cs +++ b/external/cecil/Mono.Cecil.Cil/Symbols.cs @@ -479,7 +479,7 @@ namespace Mono.Cecil.Cil { internal InstructionOffset catch_handler; internal Collection yields; internal Collection resumes; - internal MethodDefinition move_next; + internal Collection resume_methods; public InstructionOffset CatchHandler { get { return catch_handler; } @@ -494,9 +494,8 @@ namespace Mono.Cecil.Cil { get { return resumes ?? (resumes = new Collection ()); } } - public MethodDefinition MoveNextMethod { - get { return move_next; } - set { move_next = value; } + public Collection ResumeMethods { + get { return resume_methods ?? (resume_methods = new Collection ()); } } public override CustomDebugInformationKind Kind { @@ -524,7 +523,7 @@ namespace Mono.Cecil.Cil { } } - public sealed class StateMachineScopeDebugInformation : CustomDebugInformation { + public sealed class StateMachineScope { internal InstructionOffset start; internal InstructionOffset end; @@ -539,24 +538,36 @@ namespace Mono.Cecil.Cil { set { end = value; } } + internal StateMachineScope (int start, int end) + { + this.start = new InstructionOffset (start); + this.end = new InstructionOffset (end); + } + + public StateMachineScope (Instruction start, Instruction end) + { + this.start = new InstructionOffset (start); + this.end = end != null ? new InstructionOffset (end) : new InstructionOffset (); + } + } + + public sealed class StateMachineScopeDebugInformation : CustomDebugInformation { + + internal Collection scopes; + + public Collection Scopes { + get { return scopes ?? (scopes = new Collection ()); } + } + public override CustomDebugInformationKind Kind { get { return CustomDebugInformationKind.StateMachineScope; } } public static Guid KindIdentifier = new Guid ("{6DA9A61E-F8C7-4874-BE62-68BC5630DF71}"); - internal StateMachineScopeDebugInformation (int start, int end) + public StateMachineScopeDebugInformation () : base (KindIdentifier) { - this.start = new InstructionOffset (start); - this.end = new InstructionOffset (end); - } - - public StateMachineScopeDebugInformation (Instruction start, Instruction end) - : base (KindIdentifier) - { - this.start = new InstructionOffset (start); - this.end = end != null ? new InstructionOffset (end) : new InstructionOffset (); } } @@ -671,8 +682,10 @@ namespace Mono.Cecil.Cil { var offset_mapping = new Dictionary (sequence_points.Count); - for (int i = 0; i < sequence_points.Count; i++) - offset_mapping.Add (sequence_points [i].Offset, sequence_points [i]); + for (int i = 0; i < sequence_points.Count; i++) { + if (!offset_mapping.ContainsKey (sequence_points [i].Offset)) + offset_mapping.Add (sequence_points [i].Offset, sequence_points [i]); + } var instructions = method.Body.Instructions; @@ -782,7 +795,7 @@ namespace Mono.Cecil.Cil { try { return SymbolProvider.GetReaderProvider (SymbolKind.NativePdb).GetSymbolReader (module, fileName); - } catch (TypeLoadException) { + } catch (Exception) { // We might not include support for native pdbs. } } @@ -791,7 +804,7 @@ namespace Mono.Cecil.Cil { if (File.Exists (mdb_file_name)) { try { return SymbolProvider.GetReaderProvider (SymbolKind.Mdb).GetSymbolReader (module, fileName); - } catch (TypeLoadException) { + } catch (Exception) { // We might not include support for mdbs. } } diff --git a/external/cecil/Mono.Cecil.PE/Image.cs b/external/cecil/Mono.Cecil.PE/Image.cs index 8160f94b94..d9d182ad7e 100644 --- a/external/cecil/Mono.Cecil.PE/Image.cs +++ b/external/cecil/Mono.Cecil.PE/Image.cs @@ -39,6 +39,7 @@ namespace Mono.Cecil.PE { public uint Timestamp; public ModuleAttributes Attributes; + public DataDirectory Win32Resources; public DataDirectory Debug; public DataDirectory Resources; public DataDirectory StrongName; diff --git a/external/cecil/Mono.Cecil.PE/ImageReader.cs b/external/cecil/Mono.Cecil.PE/ImageReader.cs index f36d2e5ab3..63213f3941 100644 --- a/external/cecil/Mono.Cecil.PE/ImageReader.cs +++ b/external/cecil/Mono.Cecil.PE/ImageReader.cs @@ -160,12 +160,18 @@ namespace Mono.Cecil.PE { // ExportTable 8 // ImportTable 8 + + Advance (pe64 ? 56 : 40); + // ResourceTable 8 + + image.Win32Resources = ReadDataDirectory (); + // ExceptionTable 8 // CertificateTable 8 // BaseRelocationTable 8 - Advance (pe64 ? 88 : 72); + Advance (24); // Debug 8 image.Debug = ReadDataDirectory (); diff --git a/external/cecil/Mono.Cecil.PE/ImageWriter.cs b/external/cecil/Mono.Cecil.PE/ImageWriter.cs index 3fc689d2dc..f69e134677 100644 --- a/external/cecil/Mono.Cecil.PE/ImageWriter.cs +++ b/external/cecil/Mono.Cecil.PE/ImageWriter.cs @@ -87,21 +87,15 @@ namespace Mono.Cecil.PE { void GetWin32Resources () { - var rsrc = GetImageResourceSection (); - if (rsrc == null) + if (!module.HasImage) return; - win32_resources = module.Image.GetReaderAt (rsrc.VirtualAddress, rsrc.SizeOfRawData, (s, reader) => new ByteBuffer (reader.ReadBytes ((int) s))); - } + DataDirectory win32_resources_directory = module.Image.Win32Resources; + var size = win32_resources_directory.Size; - Section GetImageResourceSection () - { - if (!module.HasImage) - return null; - - const string rsrc_section = ".rsrc"; - - return module.Image.GetSection (rsrc_section); + if (size > 0) { + win32_resources = module.Image.GetReaderAt (win32_resources_directory.VirtualAddress, size, (s, reader) => new ByteBuffer (reader.ReadBytes ((int) s))); + } } public static ImageWriter CreateWriter (ModuleDefinition module, MetadataBuilder metadata, Disposable stream) @@ -846,10 +840,10 @@ namespace Mono.Cecil.PE { void PatchResourceDataEntry (ByteBuffer resources) { - var old_rsrc = GetImageResourceSection (); var rva = resources.ReadUInt32 (); resources.position -= 4; - resources.WriteUInt32 (rva - old_rsrc.VirtualAddress + rsrc.VirtualAddress); + + resources.WriteUInt32 (rva - module.Image.Win32Resources.VirtualAddress + rsrc.VirtualAddress); } } } diff --git a/external/cecil/Mono.Cecil.Tests.props b/external/cecil/Mono.Cecil.Tests.props index e1290901b2..e4a4031565 100644 --- a/external/cecil/Mono.Cecil.Tests.props +++ b/external/cecil/Mono.Cecil.Tests.props @@ -2,9 +2,24 @@ $(MSBuildProjectDirectory) + true - + + true + + + + 3.7.1 + + + 15.3.0 + + + 3.8.0 + + + False $(MSBuildThisFileDirectory)\Test\libs\nunit-2.6.2\nunit.core.dll @@ -18,4 +33,14 @@ $(MSBuildThisFileDirectory)\Test\libs\nunit-2.6.2\nunit.framework.dll + + + + + true + + diff --git a/external/cecil/Mono.Cecil.nuspec b/external/cecil/Mono.Cecil.nuspec index 95ef8b4de7..4fc12bc83d 100644 --- a/external/cecil/Mono.Cecil.nuspec +++ b/external/cecil/Mono.Cecil.nuspec @@ -2,7 +2,7 @@ Mono.Cecil - 0.10.0.0-beta6 + 0.10.0.0-beta7 Mono.Cecil Jb Evain Jb Evain diff --git a/external/cecil/Mono.Cecil.props b/external/cecil/Mono.Cecil.props index da63a2ffe3..366603e2a9 100644 --- a/external/cecil/Mono.Cecil.props +++ b/external/cecil/Mono.Cecil.props @@ -36,18 +36,19 @@ v3.5 - $(DefineConstants); + $(DefineConstants);NET_3_5; v4.0 $(DefineConstants);NET_4_0; - - netstandard1.3 + + netcoreapp2.0 + netstandard1.3 - + - + diff --git a/external/cecil/Mono.Cecil.sln b/external/cecil/Mono.Cecil.sln index f7ce9efa63..a8c436f342 100644 --- a/external/cecil/Mono.Cecil.sln +++ b/external/cecil/Mono.Cecil.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26927.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{74E5ECE0-06B4-401C-AEBA-E8DD53E17943}" EndProject @@ -22,6 +22,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Rocks.Tests", "r EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Rocks", "rocks\Mono.Cecil.Rocks.csproj", "{FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0893F44-CB9F-49C5-B38C-70082EFC5072}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution net_3_5_Debug_ReadOnly|Any CPU = net_3_5_Debug_ReadOnly|Any CPU @@ -81,9 +86,11 @@ Global {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Debug_ReadOnly|Any CPU.Build.0 = netstandard_Debug_ReadOnly|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU + {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Debug|Any CPU.Build.0 = netstandard_Debug|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Release_ReadOnly|Any CPU.Build.0 = netstandard_Release_ReadOnly|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU + {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Release|Any CPU.Build.0 = netstandard_Release|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU @@ -125,10 +132,8 @@ Global {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Debug_ReadOnly|Any CPU.Build.0 = netstandard_Debug_ReadOnly|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Release_ReadOnly|Any CPU.Build.0 = netstandard_Release_ReadOnly|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU @@ -171,10 +176,8 @@ Global {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Debug_ReadOnly|Any CPU.Build.0 = netstandard_Debug_ReadOnly|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Release_ReadOnly|Any CPU.Build.0 = netstandard_Release_ReadOnly|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU @@ -193,10 +196,8 @@ Global {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Debug_ReadOnly|Any CPU.Build.0 = netstandard_Debug_ReadOnly|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Release_ReadOnly|Any CPU.Build.0 = netstandard_Release_ReadOnly|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU @@ -234,4 +235,7 @@ Global {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D75C0801-AFCB-4B1F-90AD-2B7852A74E6A} + EndGlobalSection EndGlobal diff --git a/external/cecil/Mono.Cecil/AssemblyReader.cs b/external/cecil/Mono.Cecil/AssemblyReader.cs index 02d7787844..0be4404289 100644 --- a/external/cecil/Mono.Cecil/AssemblyReader.cs +++ b/external/cecil/Mono.Cecil/AssemblyReader.cs @@ -156,7 +156,6 @@ namespace Mono.Cecil { this.module.Read (this.module, (module, reader) => { ReadModuleManifest (reader); ReadModule (module, resolve_attributes: true); - return module; }); } @@ -422,10 +421,7 @@ namespace Mono.Cecil { protected override void ReadModule () { - this.module.Read (this.module, (module, reader) => { - ReadModuleManifest (reader); - return module; - }); + this.module.Read (this.module, (_, reader) => ReadModuleManifest (reader)); } public override void ReadSymbols (ModuleDefinition module) @@ -943,8 +939,8 @@ namespace Mono.Cecil { type.BaseType = GetTypeDefOrRef (ReadMetadataToken (CodedIndex.TypeDefOrRef)); - type.fields_range = ReadFieldsRange (rid); - type.methods_range = ReadMethodsRange (rid); + type.fields_range = ReadListRange (rid, Table.TypeDef, Table.Field); + type.methods_range = ReadListRange (rid, Table.TypeDef, Table.Method); if (IsNested (attributes)) type.DeclaringType = GetNestedTypeDeclaringType (type); @@ -965,21 +961,13 @@ namespace Mono.Cecil { return GetTypeDefinition (declaring_rid); } - Range ReadFieldsRange (uint type_index) - { - return ReadListRange (type_index, Table.TypeDef, Table.Field); - } - - Range ReadMethodsRange (uint type_index) - { - return ReadListRange (type_index, Table.TypeDef, Table.Method); - } - Range ReadListRange (uint current_index, Table current, Table target) { var list = new Range (); - list.Start = ReadTableIndex (target); + var start = ReadTableIndex (target); + if (start == 0) + return list; uint next_index; var current_table = image.TableHeap [current]; @@ -993,7 +981,8 @@ namespace Mono.Cecil { this.position = position; } - list.Length = next_index - list.Start; + list.Start = start; + list.Length = next_index - start; return list; } @@ -1496,16 +1485,11 @@ namespace Mono.Cecil { for (uint i = 1; i <= length; i++) { var type_rid = ReadTableIndex (Table.TypeDef); - Range events_range = ReadEventsRange (i); + Range events_range = ReadListRange (i, Table.EventMap, Table.Event); metadata.AddEventsRange (type_rid, events_range); } } - Range ReadEventsRange (uint rid) - { - return ReadListRange (rid, Table.EventMap, Table.Event); - } - public bool HasProperties (TypeDefinition type) { InitializeProperties (); @@ -1585,16 +1569,11 @@ namespace Mono.Cecil { for (uint i = 1; i <= length; i++) { var type_rid = ReadTableIndex (Table.TypeDef); - var properties_range = ReadPropertiesRange (i); + var properties_range = ReadListRange (i, Table.PropertyMap, Table.Property); metadata.AddPropertiesRange (type_rid, properties_range); } } - Range ReadPropertiesRange (uint rid) - { - return ReadListRange (rid, Table.PropertyMap, Table.Property); - } - MethodSemanticsAttributes ReadMethodSemantics (MethodDefinition method) { InitializeMethodSemantics (); @@ -1697,23 +1676,19 @@ namespace Mono.Cecil { } } - public PropertyDefinition ReadMethods (PropertyDefinition property) + public void ReadMethods (PropertyDefinition property) { ReadAllSemantics (property.DeclaringType); - return property; } - public EventDefinition ReadMethods (EventDefinition @event) + public void ReadMethods (EventDefinition @event) { ReadAllSemantics (@event.DeclaringType); - return @event; } - public MethodSemanticsAttributes ReadAllSemantics (MethodDefinition method) + public void ReadAllSemantics (MethodDefinition method) { ReadAllSemantics (method.DeclaringType); - - return method.SemanticsAttributes; } void ReadAllSemantics (TypeDefinition type) @@ -1729,11 +1704,6 @@ namespace Mono.Cecil { } } - Range ReadParametersRange (uint method_rid) - { - return ReadListRange (method_rid, Table.Method, Table.Param); - } - public Collection ReadMethods (TypeDefinition type) { var methods_range = type.methods_range; @@ -1794,7 +1764,7 @@ namespace Mono.Cecil { methods.Add (method); // attach method var signature = ReadBlobIndex (); - var param_range = ReadParametersRange (method_rid); + var param_range = ReadListRange (method_rid, Table.Method, Table.Param); this.context = method; @@ -2121,6 +2091,11 @@ namespace Mono.Cecil { return code.ReadMethodBody (method); } + public int ReadCodeSize (MethodDefinition method) + { + return code.ReadCodeSize (method); + } + public CallSite ReadCallSite (MetadataToken token) { if (!MoveTo (Table.StandAloneSig, token.RID)) @@ -2387,8 +2362,8 @@ namespace Mono.Cecil { var type_system = module.TypeSystem; - var context = new MethodReference (string.Empty, type_system.Void); - context.DeclaringType = new TypeReference (string.Empty, string.Empty, module, type_system.CoreLibrary); + var context = new MethodDefinition (string.Empty, MethodAttributes.Static, type_system.Void); + context.DeclaringType = new TypeDefinition (string.Empty, string.Empty, TypeAttributes.Public); var member_references = new MemberReference [length]; @@ -3183,25 +3158,36 @@ namespace Mono.Cecil { for (int i = 0; i < rows.Length; i++) { if (rows [i].Col1 == StateMachineScopeDebugInformation.KindIdentifier) { var signature = ReadSignature (rows [i].Col2); - infos.Add (new StateMachineScopeDebugInformation (signature.ReadInt32 (), signature.ReadInt32 ())); + var scopes = new Collection (); + + while (signature.CanReadMore ()) { + var start = signature.ReadInt32 (); + var end = start + signature.ReadInt32 (); + scopes.Add (new StateMachineScope (start, end)); + } + + var state_machine = new StateMachineScopeDebugInformation (); + state_machine.scopes = scopes; + + infos.Add (state_machine); } else if (rows [i].Col1 == AsyncMethodBodyDebugInformation.KindIdentifier) { var signature = ReadSignature (rows [i].Col2); var catch_offset = signature.ReadInt32 () - 1; var yields = new Collection (); var resumes = new Collection (); - uint move_next_rid = 0; + var resume_methods = new Collection (); while (signature.CanReadMore ()) { yields.Add (new InstructionOffset (signature.ReadInt32 ())); resumes.Add (new InstructionOffset (signature.ReadInt32 ())); - move_next_rid = signature.ReadCompressedUInt32 (); + resume_methods.Add (GetMethodDefinition (signature.ReadCompressedUInt32 ())); } var async_body = new AsyncMethodBodyDebugInformation (catch_offset); async_body.yields = yields; async_body.resumes = resumes; - async_body.move_next = GetMethodDefinition (move_next_rid); + async_body.resume_methods = resume_methods; infos.Add (async_body); } else if (rows [i].Col1 == EmbeddedSourceDebugInformation.KindIdentifier) { @@ -3370,7 +3356,7 @@ namespace Mono.Cecil { switch (etype) { case ElementType.ValueType: { var value_type = GetTypeDefOrRef (ReadTypeTokenSignature ()); - value_type.IsValueType = true; + value_type.KnownValueType (); return value_type; } case ElementType.Class: @@ -3410,8 +3396,8 @@ namespace Mono.Cecil { ReadGenericInstanceSignature (element_type, generic_instance); if (is_value_type) { - generic_instance.IsValueType = true; - element_type.GetElementType ().IsValueType = true; + generic_instance.KnownValueType (); + element_type.GetElementType ().KnownValueType (); } return generic_instance; diff --git a/external/cecil/Mono.Cecil/AssemblyWriter.cs b/external/cecil/Mono.Cecil/AssemblyWriter.cs index 5496cac87b..52c601c742 100644 --- a/external/cecil/Mono.Cecil/AssemblyWriter.cs +++ b/external/cecil/Mono.Cecil/AssemblyWriter.cs @@ -2392,13 +2392,19 @@ namespace Mono.Cecil { var method_info = ((MethodDefinition) provider).DebugInformation; var signature = CreateSignatureWriter (); - signature.WriteUInt32 ((uint) state_machine_scope.Start.Offset); - var end_offset = state_machine_scope.End.IsEndOfMethod - ? method_info.code_size - : state_machine_scope.End.Offset; + var scopes = state_machine_scope.Scopes; - signature.WriteUInt32 ((uint) (end_offset - state_machine_scope.Start.Offset)); + for (int i = 0; i < scopes.Count; i++) { + var scope = scopes [i]; + signature.WriteUInt32 ((uint) scope.Start.Offset); + + var end_offset = scope.End.IsEndOfMethod + ? method_info.code_size + : scope.End.Offset; + + signature.WriteUInt32 ((uint) (end_offset - scope.Start.Offset)); + } AddCustomDebugInformation (provider, state_machine_scope, signature); } @@ -2411,7 +2417,7 @@ namespace Mono.Cecil { for (int i = 0; i < async_method.yields.Count; i++) { signature.WriteUInt32 ((uint) async_method.yields [i].Offset); signature.WriteUInt32 ((uint) async_method.resumes [i].Offset); - signature.WriteCompressedUInt32 (async_method.move_next.MetadataToken.RID); + signature.WriteCompressedUInt32 (async_method.resume_methods [i].MetadataToken.RID); } AddCustomDebugInformation (provider, async_method, signature); diff --git a/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs b/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs index ade0102e5c..cf6a3a3451 100644 --- a/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs +++ b/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Reflection; using System.Text; using Mono.Collections.Generic; @@ -65,14 +66,19 @@ namespace Mono.Cecil { #endif } -#if !NET_CORE public abstract class BaseAssemblyResolver : IAssemblyResolver { static readonly bool on_mono = Type.GetType ("Mono.Runtime") != null; readonly Collection directories; +#if NET_CORE + // Maps file names of available trusted platform assemblies to their full paths. + // Internal for testing. + internal static readonly Lazy> TrustedPlatformAssemblies = new Lazy> (CreateTrustedPlatformAssemblyMap); +#else Collection gac_paths; +#endif public void AddSearchDirectory (string directory) { @@ -127,6 +133,11 @@ namespace Mono.Cecil { }; } +#if NET_CORE + assembly = SearchTrustedPlatformAssemblies (name, parameters); + if (assembly != null) + return assembly; +#else var framework_dir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName); var framework_dirs = on_mono ? new [] { framework_dir, Path.Combine (framework_dir, "Facades") } @@ -151,7 +162,7 @@ namespace Mono.Cecil { assembly = SearchDirectory (name, framework_dirs, parameters); if (assembly != null) return assembly; - +#endif if (ResolveFailure != null) { assembly = ResolveFailure (this, name); if (assembly != null) @@ -161,7 +172,45 @@ namespace Mono.Cecil { throw new AssemblyResolutionException (name); } - AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable directories, ReaderParameters parameters) +#if NET_CORE + AssemblyDefinition SearchTrustedPlatformAssemblies (AssemblyNameReference name, ReaderParameters parameters) + { + if (name.IsWindowsRuntime) + return null; + + if (TrustedPlatformAssemblies.Value.TryGetValue (name.Name, out string path)) + return GetAssembly (path, parameters); + + return null; + } + + static Dictionary CreateTrustedPlatformAssemblyMap () + { + var result = new Dictionary (StringComparer.OrdinalIgnoreCase); + + string paths; + + try { + // AppContext is only available on platforms that implement .NET Standard 1.6 + var appContextType = Type.GetType ("System.AppContext, System.AppContext, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false); + var getData = appContextType?.GetTypeInfo ().GetDeclaredMethod ("GetData"); + paths = (string) getData?.Invoke (null, new [] { "TRUSTED_PLATFORM_ASSEMBLIES" }); + } catch { + paths = null; + } + + if (paths == null) + return result; + + foreach (var path in paths.Split (Path.PathSeparator)) + if (string.Equals (Path.GetExtension (path), ".dll", StringComparison.OrdinalIgnoreCase)) + result [Path.GetFileNameWithoutExtension (path)] = path; + + return result; + } +#endif + + protected virtual AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable directories, ReaderParameters parameters) { var extensions = name.IsWindowsRuntime ? new [] { ".winmd", ".dll" } : new [] { ".exe", ".dll" }; foreach (var directory in directories) { @@ -185,11 +234,11 @@ namespace Mono.Cecil { return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0; } +#if !NET_CORE AssemblyDefinition GetCorlib (AssemblyNameReference reference, ReaderParameters parameters) { var version = reference.Version; var corlib = typeof (object).Assembly.GetName (); - if (corlib.Version == version || IsZero (version)) return GetAssembly (typeof (object).Module.FullyQualifiedName, parameters); @@ -325,7 +374,7 @@ namespace Mono.Cecil { return null; } - +#endif static string GetAssemblyFile (AssemblyNameReference reference, string prefix, string gac) { var gac_folder = new StringBuilder () @@ -352,5 +401,4 @@ namespace Mono.Cecil { { } } -#endif } diff --git a/external/cecil/Mono.Cecil/CustomAttribute.cs b/external/cecil/Mono.Cecil/CustomAttribute.cs index 5e33667679..135f8b7247 100644 --- a/external/cecil/Mono.Cecil/CustomAttribute.cs +++ b/external/cecil/Mono.Cecil/CustomAttribute.cs @@ -62,8 +62,10 @@ namespace Mono.Cecil { bool HasFields { get; } bool HasProperties { get; } + bool HasConstructorArguments { get; } Collection Fields { get; } Collection Properties { get; } + Collection ConstructorArguments { get; } } public sealed class CustomAttribute : ICustomAttribute { @@ -196,7 +198,6 @@ namespace Mono.Cecil { resolved = false; } - return this; }); } } diff --git a/external/cecil/Mono.Cecil/DefaultAssemblyResolver.cs b/external/cecil/Mono.Cecil/DefaultAssemblyResolver.cs index 197aaa0e6f..755071ea4c 100644 --- a/external/cecil/Mono.Cecil/DefaultAssemblyResolver.cs +++ b/external/cecil/Mono.Cecil/DefaultAssemblyResolver.cs @@ -8,8 +8,6 @@ // Licensed under the MIT/X11 license. // -#if !NET_CORE - using System; using System.Collections.Generic; @@ -61,5 +59,3 @@ namespace Mono.Cecil { } } } - -#endif diff --git a/external/cecil/Mono.Cecil/MethodDefinition.cs b/external/cecil/Mono.Cecil/MethodDefinition.cs index 71de613ce3..5dda999ce0 100644 --- a/external/cecil/Mono.Cecil/MethodDefinition.cs +++ b/external/cecil/Mono.Cecil/MethodDefinition.cs @@ -143,9 +143,9 @@ namespace Mono.Cecil { public MethodBody Body { get { - MethodBody localBody = this.body; - if (localBody != null) - return localBody; + var local = this.body; + if (local != null) + return local; if (!HasBody) return null; diff --git a/external/cecil/Mono.Cecil/ModuleDefinition.cs b/external/cecil/Mono.Cecil/ModuleDefinition.cs index 137691cb20..d82db4e490 100644 --- a/external/cecil/Mono.Cecil/ModuleDefinition.cs +++ b/external/cecil/Mono.Cecil/ModuleDefinition.cs @@ -418,13 +418,11 @@ namespace Mono.Cecil { public IAssemblyResolver AssemblyResolver { get { -#if !NET_CORE if (assembly_resolver.value == null) { lock (module_lock) { assembly_resolver = Disposable.Owned (new DefaultAssemblyResolver () as IAssemblyResolver); } } -#endif return assembly_resolver.value; } @@ -754,28 +752,16 @@ namespace Mono.Cecil { internal FieldDefinition Resolve (FieldReference field) { -#if NET_CORE - if (MetadataResolver == null) - throw new NotSupportedException (); -#endif return MetadataResolver.Resolve (field); } internal MethodDefinition Resolve (MethodReference method) { -#if NET_CORE - if (MetadataResolver == null) - throw new NotSupportedException (); -#endif return MetadataResolver.Resolve (method); } internal TypeDefinition Resolve (TypeReference type) { -#if NET_CORE - if (MetadataResolver == null) - throw new NotSupportedException (); -#endif return MetadataResolver.Resolve (type); } @@ -970,6 +956,19 @@ namespace Mono.Cecil { get { return module_lock; } } + internal void Read (TItem item, Action read) + { + lock (module_lock) { + var position = reader.position; + var context = reader.context; + + read (item, reader); + + reader.position = position; + reader.context = context; + } + } + internal TRet Read (TItem item, Func read) { lock (module_lock) { @@ -1321,6 +1320,9 @@ namespace Mono.Cecil { public static TargetRuntime ParseRuntime (this string self) { + if (string.IsNullOrEmpty (self)) + return TargetRuntime.Net_4_0; + switch (self [1]) { case '1': return self [3] == '0' diff --git a/external/cecil/Mono.Cecil/SecurityDeclaration.cs b/external/cecil/Mono.Cecil/SecurityDeclaration.cs index 309f7d2188..2762d08b39 100644 --- a/external/cecil/Mono.Cecil/SecurityDeclaration.cs +++ b/external/cecil/Mono.Cecil/SecurityDeclaration.cs @@ -70,6 +70,14 @@ namespace Mono.Cecil { { this.attribute_type = attributeType; } + + bool ICustomAttribute.HasConstructorArguments { + get { return false; } + } + + Collection ICustomAttribute.ConstructorArguments { + get { throw new NotSupportedException (); } + } } public sealed class SecurityDeclaration { @@ -143,11 +151,7 @@ namespace Mono.Cecil { if (resolved || !HasImage) return; - module.Read (this, (declaration, reader) => { - reader.ReadSecurityDeclarationSignature (declaration); - return this; - }); - + module.Read (this, (declaration, reader) => reader.ReadSecurityDeclarationSignature (declaration)); resolved = true; } } diff --git a/external/cecil/Mono.Cecil/TypeDefinition.cs b/external/cecil/Mono.Cecil/TypeDefinition.cs index 3e4928ce57..6b6558c413 100644 --- a/external/cecil/Mono.Cecil/TypeDefinition.cs +++ b/external/cecil/Mono.Cecil/TypeDefinition.cs @@ -416,6 +416,9 @@ namespace Mono.Cecil { return base_type.IsTypeOf ("System", "Enum") || (base_type.IsTypeOf ("System", "ValueType") && !this.IsTypeOf ("System", "Enum")); } + set { + throw new NotSupportedException (); + } } public override bool IsPrimitive { diff --git a/external/cecil/Mono.Cecil/TypeSystem.cs b/external/cecil/Mono.Cecil/TypeSystem.cs index 3b5202c1aa..e16ec6f3b6 100644 --- a/external/cecil/Mono.Cecil/TypeSystem.cs +++ b/external/cecil/Mono.Cecil/TypeSystem.cs @@ -184,7 +184,7 @@ namespace Mono.Cecil { return typeRef; var type = LookupType ("System", name); type.etype = element_type; - type.IsValueType = true; + type.KnownValueType (); return typeRef = type; } } @@ -313,6 +313,12 @@ namespace Mono.Cecil { return true; } + public static void KnownValueType (this TypeReference type) + { + if (!type.IsDefinition) + type.IsValueType = true; + } + static bool IsCoreLibrary (AssemblyNameReference reference) { var name = reference.Name; diff --git a/external/cecil/Mono/Type.cs b/external/cecil/Mono/Type.cs index 4ff204830c..fd53f81b4a 100644 --- a/external/cecil/Mono/Type.cs +++ b/external/cecil/Mono/Type.cs @@ -100,7 +100,8 @@ namespace Mono { public static Type [] GetGenericArguments (this Type type) { #if NET_CORE - return type.GetTypeInfo ().GenericTypeArguments; + var info = type.GetTypeInfo (); + return info.IsGenericTypeDefinition ? info.GenericTypeParameters : info.GenericTypeArguments; #else return type.GetGenericArguments (); #endif diff --git a/external/cecil/NetStandard.props b/external/cecil/NetStandard.props index d5f4196efe..bc0bacc6ef 100644 --- a/external/cecil/NetStandard.props +++ b/external/cecil/NetStandard.props @@ -1,7 +1,7 @@ - $(DefineConstants);NET_4_0;NET_CORE; + $(DefineConstants);NET_CORE; false false true diff --git a/external/cecil/ProjectInfo.cs b/external/cecil/ProjectInfo.cs index 4d9e9221a5..0b94141540 100644 --- a/external/cecil/ProjectInfo.cs +++ b/external/cecil/ProjectInfo.cs @@ -17,4 +17,4 @@ using System.Runtime.InteropServices; [assembly: AssemblyVersion ("0.10.0.0")] [assembly: AssemblyFileVersion ("0.10.0.0")] -[assembly: AssemblyInformationalVersion ("0.10.0.0-beta6")] +[assembly: AssemblyInformationalVersion ("0.10.0.0-beta7")] diff --git a/external/cecil/Test/Mono.Cecil.Tests.csproj b/external/cecil/Test/Mono.Cecil.Tests.csproj index 9277d6a3a0..a8c4d0eac6 100644 --- a/external/cecil/Test/Mono.Cecil.Tests.csproj +++ b/external/cecil/Test/Mono.Cecil.Tests.csproj @@ -1,10 +1,34 @@  + {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055} Mono.Cecil.Tests Mono.Cecil.Tests + + + 4.3.0 + + + 4.3.0 + + + 4.3.0 + + + 4.3.0 + + + 4.3.0 + + + 2.3.2 + + + 2.3.2 + + {D68133BD-1E63-496E-9EDE-4FBDBF77B486} @@ -26,6 +50,5 @@ - - + \ No newline at end of file diff --git a/external/cecil/Test/Mono.Cecil.Tests/AssemblyTests.cs b/external/cecil/Test/Mono.Cecil.Tests/AssemblyTests.cs index 0d484de538..af45a3c4c4 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/AssemblyTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/AssemblyTests.cs @@ -59,6 +59,9 @@ namespace Mono.Cecil.Tests { [Test] public void Retargetable () { + if (Platform.OnCoreClr) + return; + TestModule ("RetargetableExample.dll", module => { var type = module.Types [1]; var property = type.Properties [0]; @@ -76,6 +79,9 @@ namespace Mono.Cecil.Tests { [Test] public void SystemRuntime () { + if (Platform.OnCoreClr) + return; + TestModule ("System.Runtime.dll", module => { Assert.AreEqual ("System.Runtime", module.Assembly.Name.Name); Assert.AreEqual (1, module.AssemblyReferences.Count); diff --git a/external/cecil/Test/Mono.Cecil.Tests/CallerMemberNameAttribute.cs b/external/cecil/Test/Mono.Cecil.Tests/CallerMemberNameAttribute.cs new file mode 100644 index 0000000000..63bd9b8acb --- /dev/null +++ b/external/cecil/Test/Mono.Cecil.Tests/CallerMemberNameAttribute.cs @@ -0,0 +1,10 @@ +#if NET_3_5 || NET_4_0 +namespace System.Runtime.CompilerServices { + [AttributeUsage (AttributeTargets.Parameter, Inherited = false)] + public sealed class CallerMemberNameAttribute : Attribute { + public CallerMemberNameAttribute () + { + } + } +} +#endif \ No newline at end of file diff --git a/external/cecil/Test/Mono.Cecil.Tests/CompilationService.cs b/external/cecil/Test/Mono.Cecil.Tests/CompilationService.cs index 877ed24d3e..5501d571d0 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/CompilationService.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/CompilationService.cs @@ -4,9 +4,16 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; - +using System.Reflection; using NUnit.Framework; +#if NET_CORE +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Emit; +using CS = Microsoft.CodeAnalysis.CSharp; +using VB = Microsoft.CodeAnalysis.VisualBasic; +#endif + namespace Mono.Cecil.Tests { struct CompilationResult { @@ -22,7 +29,23 @@ namespace Mono.Cecil.Tests { public static class Platform { - public static bool OnMono { get { return typeof (object).Assembly.GetType ("Mono.Runtime") != null; } } + public static bool OnMono { + get { return TryGetType ("Mono.Runtime") != null; } + } + + public static bool OnCoreClr { + get { return TryGetType ("System.Runtime.Loader.AssemblyLoadContext, System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") != null; } + } + + static Type TryGetType (string assemblyQualifiedName) + { + try { + // Note that throwOnError=false only suppresses some exceptions, not all. + return Type.GetType(assemblyQualifiedName, throwOnError: false); + } catch { + return null; + } + } } abstract class CompilationService { @@ -68,8 +91,11 @@ namespace Mono.Cecil.Tests { return IlasmCompilationService.Instance.Compile (name); if (extension == ".cs" || extension == ".vb") +#if NET_CORE + return RoslynCompilationService.Instance.Compile (name); +#else return CodeDomCompilationService.Instance.Compile (name); - +#endif throw new NotSupportedException (extension); } @@ -84,9 +110,11 @@ namespace Mono.Cecil.Tests { public static void Verify (string name) { +#if !NET_CORE var output = Platform.OnMono ? ShellService.PEDump (name) : ShellService.PEVerify (name); if (output.ExitCode != 0) Assert.Fail (output.ToString ()); +#endif } } @@ -112,6 +140,76 @@ namespace Mono.Cecil.Tests { } } +#if NET_CORE + + class RoslynCompilationService : CompilationService { + + public static readonly RoslynCompilationService Instance = new RoslynCompilationService (); + + protected override string CompileFile (string name) + { + var compilation = GetCompilation (name); + var outputName = GetCompiledFilePath (name); + + var result = compilation.Emit (outputName); + Assert.IsTrue (result.Success, GetErrorMessage (result)); + + return outputName; + } + + static Compilation GetCompilation (string name) + { + var assemblyName = Path.GetFileNameWithoutExtension (name); + var source = File.ReadAllText (name); + + var tpa = BaseAssemblyResolver.TrustedPlatformAssemblies.Value; + + var references = new [] + { + MetadataReference.CreateFromFile (tpa ["netstandard"]), + MetadataReference.CreateFromFile (tpa ["mscorlib"]), + MetadataReference.CreateFromFile (tpa ["System.Private.CoreLib"]), + MetadataReference.CreateFromFile (tpa ["System.Runtime"]), + MetadataReference.CreateFromFile (tpa ["System.Console"]), + MetadataReference.CreateFromFile (tpa ["System.Security.AccessControl"]), + }; + + var extension = Path.GetExtension (name); + switch (extension) { + case ".cs": + return CS.CSharpCompilation.Create ( + assemblyName, + new [] { CS.SyntaxFactory.ParseSyntaxTree (source) }, + references, + new CS.CSharpCompilationOptions (OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release)); + + case ".vb": + return VB.VisualBasicCompilation.Create ( + assemblyName, + new [] { VB.SyntaxFactory.ParseSyntaxTree (source) }, + references, + new VB.VisualBasicCompilationOptions (OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release)); + + default: + throw new NotSupportedException (); + } + } + + static string GetErrorMessage (EmitResult result) + { + if (result.Success) + return string.Empty; + + var builder = new StringBuilder (); + foreach (var diagnostic in result.Diagnostics) + builder.AppendLine (diagnostic.ToString ()); + + return builder.ToString (); + } + } + +#else + class CodeDomCompilationService : CompilationService { public static readonly CodeDomCompilationService Instance = new CodeDomCompilationService (); @@ -166,6 +264,8 @@ namespace Mono.Cecil.Tests { } } +#endif + class ShellService { public class ProcessOutput { @@ -243,9 +343,13 @@ namespace Mono.Cecil.Tests { static string NetFrameworkTool (string tool) { +#if NET_CORE + return Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Windows), "Microsoft.NET", "Framework", "v4.0.30319", tool + ".exe"); +#else return Path.Combine ( Path.GetDirectoryName (typeof (object).Assembly.Location), tool + ".exe"); +#endif } static string WinSdkTool (string tool) diff --git a/external/cecil/Test/Mono.Cecil.Tests/CustomAttributesTests.cs b/external/cecil/Test/Mono.Cecil.Tests/CustomAttributesTests.cs index a89fcfdfca..8ec02705a3 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/CustomAttributesTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/CustomAttributesTests.cs @@ -21,15 +21,15 @@ namespace Mono.Cecil.Tests { TestCSharp ("CustomAttributes.cs", module => { var hamster = module.GetType ("Hamster"); - Assert.IsTrue (hamster.HasCustomAttributes); - Assert.AreEqual (1, hamster.CustomAttributes.Count); + Assert.IsTrue (hamster.HasCustomAttributes); + Assert.AreEqual (1, hamster.CustomAttributes.Count); - var attribute = hamster.CustomAttributes [0]; - Assert.AreEqual ("System.Void FooAttribute::.ctor(System.String)", - attribute.Constructor.FullName); + var attribute = hamster.CustomAttributes [0]; + Assert.AreEqual ("System.Void FooAttribute::.ctor(System.String)", + attribute.Constructor.FullName); - Assert.IsTrue (attribute.HasConstructorArguments); - Assert.AreEqual (1, attribute.ConstructorArguments.Count); + Assert.IsTrue (attribute.HasConstructorArguments); + Assert.AreEqual (1, attribute.ConstructorArguments.Count); AssertArgument ("bar", attribute.ConstructorArguments [0]); }); @@ -559,10 +559,10 @@ namespace Mono.Cecil.Tests { } switch (Type.GetTypeCode (value.GetType ())) { - case TypeCode.String: + case System.TypeCode.String: signature.AppendFormat ("\"{0}\"", value); break; - case TypeCode.Char: + case System.TypeCode.Char: signature.AppendFormat ("'{0}'", (char) value); break; default: diff --git a/external/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs b/external/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs index 16f89d295d..16b8a7b3f1 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs @@ -170,6 +170,7 @@ namespace Mono.Cecil.Tests { }, verify: false); } +#if !NET_CORE [Test] public void WindowsRuntimeComponentAssembly () { @@ -181,7 +182,7 @@ namespace Mono.Cecil.Tests { Assert.IsTrue (module.Assembly.Name.IsWindowsRuntime); }, verify: false, assemblyResolver: resolver); } - +#endif [Test] public void DeterministicAssembly () { diff --git a/external/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs b/external/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs index a28b0935ef..bc12f5e0db 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs @@ -1,7 +1,6 @@ #if !READ_ONLY using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using SR = System.Reflection; @@ -255,6 +254,9 @@ namespace Mono.Cecil.Tests { [Test] public void ContextGenericTest () { + if (Platform.OnCoreClr) + return; + var module = ModuleDefinition.ReadModule (typeof (ContextGeneric1Method2<>).Module.FullyQualifiedName); // by mixing open generics with 2 & 1 parameters, we make sure the right context is used (because otherwise, an exception will be thrown) var type = typeof (ContextGeneric1Method2<>).MakeGenericType (typeof (ContextGeneric2Method1<,>)); @@ -287,11 +289,10 @@ namespace Mono.Cecil.Tests { delegate void Emitter (ModuleDefinition module, MethodBody body); - [MethodImpl (MethodImplOptions.NoInlining)] - static TDelegate Compile (Emitter emitter) + static TDelegate Compile (Emitter emitter, [CallerMemberName] string testMethodName = null) where TDelegate : class { - var name = GetTestCaseName (); + var name = "ImportCecil_" + testMethodName; var module = CreateTestModule (name, emitter); var assembly = LoadTestModule (module); @@ -362,15 +363,6 @@ namespace Mono.Cecil.Tests { { return ModuleDefinition.CreateModule (name, ModuleKind.Dll); } - - [MethodImpl (MethodImplOptions.NoInlining)] - static string GetTestCaseName () - { - var stack_trace = new StackTrace (); - var stack_frame = stack_trace.GetFrame (2); - - return "ImportCecil_" + stack_frame.GetMethod ().Name; - } } } -#endif \ No newline at end of file +#endif diff --git a/external/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs b/external/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs index 04768615f9..c99ca4fc44 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs @@ -1,7 +1,6 @@ #if !READ_ONLY using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using SR = System.Reflection; using System.Runtime.CompilerServices; @@ -156,6 +155,9 @@ namespace Mono.Cecil.Tests { [Test] public void ImportGenericField () { + if (Platform.OnCoreClr) + return; + var get_field = Compile, string>> ((module, body) => { var il = body.GetILProcessor (); il.Emit (OpCodes.Ldarg_0); @@ -173,6 +175,9 @@ namespace Mono.Cecil.Tests { [Test] public void ImportGenericMethod () { + if (Platform.OnCoreClr) + return; + var generic_identity = Compile, int, int>> ((module, body) => { var il = body.GetILProcessor (); il.Emit (OpCodes.Ldarg_0); @@ -187,6 +192,9 @@ namespace Mono.Cecil.Tests { [Test] public void ImportGenericMethodSpec () { + if (Platform.OnCoreClr) + return; + var gen_spec_id = Compile, int, int>> ((module, body) => { var il = body.GetILProcessor (); il.Emit (OpCodes.Ldarg_0); @@ -202,6 +210,9 @@ namespace Mono.Cecil.Tests { [Test] public void ImportComplexGenericMethodSpec () { + if (Platform.OnCoreClr) + return; + var gen_spec_id = Compile, int, int>> ((module, body) => { var il = body.GetILProcessor (); il.Emit (OpCodes.Ldarg_0); @@ -279,6 +290,9 @@ namespace Mono.Cecil.Tests { [Test] public void ImportGenericFieldFromContext () { + if (Platform.OnCoreClr) + return; + var list_foo = typeof (Foo<>).GetField ("list").FieldType; var generic_list_foo_open = typeof (Generic<>).MakeGenericType (list_foo); var generic_list_foo_open_field = generic_list_foo_open.GetField ("Field"); @@ -295,6 +309,9 @@ namespace Mono.Cecil.Tests { [Test] public void ImportGenericMethodFromContext () { + if (Platform.OnCoreClr) + return; + var list_foo = typeof (Foo<>).GetField ("list").FieldType; var generic_list_foo_open = typeof (Generic<>).MakeGenericType (list_foo); var generic_list_foo_open_method = generic_list_foo_open.GetMethod ("Method"); @@ -334,11 +351,10 @@ namespace Mono.Cecil.Tests { delegate void Emitter (ModuleDefinition module, MethodBody body); - [MethodImpl (MethodImplOptions.NoInlining)] - static TDelegate Compile (Emitter emitter) + static TDelegate Compile (Emitter emitter, [CallerMemberName] string testMethodName = null) where TDelegate : class { - var name = GetTestCaseName (); + var name = "ImportReflection_" + testMethodName; var module = CreateTestModule (name, emitter); var assembly = LoadTestModule (module); @@ -409,15 +425,6 @@ namespace Mono.Cecil.Tests { { return ModuleDefinition.CreateModule (name, ModuleKind.Dll); } - - [MethodImpl (MethodImplOptions.NoInlining)] - static string GetTestCaseName () - { - var stack_trace = new StackTrace (); - var stack_frame = stack_trace.GetFrame (2); - - return "ImportReflection_" + stack_frame.GetMethod ().Name; - } } } -#endif \ No newline at end of file +#endif diff --git a/external/cecil/Test/Mono.Cecil.Tests/MethodTests.cs b/external/cecil/Test/Mono.Cecil.Tests/MethodTests.cs index bbf1742d8d..b878613c06 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/MethodTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/MethodTests.cs @@ -204,6 +204,8 @@ namespace Mono.Cecil.Tests { var beta = type.GetMethod ("Beta"); var charlie = type.GetMethod ("Charlie"); + // Note that the test depends on the C# compiler emitting the constructor call instruction as + // the first instruction of the method body. This requires optimizations to be enabled. var new_list_beta = (MethodReference) beta.Body.Instructions [0].Operand; var new_list_charlie = (MethodReference) charlie.Body.Instructions [0].Operand; diff --git a/external/cecil/Test/Mono.Cecil.Tests/ModuleTests.cs b/external/cecil/Test/Mono.Cecil.Tests/ModuleTests.cs index 476b8ffbeb..2b8eda19cd 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/ModuleTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/ModuleTests.cs @@ -49,7 +49,10 @@ namespace Mono.Cecil.Tests { [Test] public void MultiModules () { - TestModule ("mma.exe", module => { + if (Platform.OnCoreClr) + return; + + TestModule("mma.exe", module => { var assembly = module.Assembly; Assert.AreEqual (3, assembly.Modules.Count); @@ -157,6 +160,9 @@ namespace Mono.Cecil.Tests { [Test] public void ExportedTypeFromNetModule () { + if (Platform.OnCoreClr) + return; + TestModule ("mma.exe", module => { Assert.IsTrue (module.HasExportedTypes); Assert.AreEqual (2, module.ExportedTypes.Count); @@ -183,14 +189,14 @@ namespace Mono.Cecil.Tests { var exported_type = module.ExportedTypes [0]; Assert.AreEqual ("System.Diagnostics.DebuggableAttribute", exported_type.FullName); - Assert.AreEqual ("mscorlib", exported_type.Scope.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", exported_type.Scope.Name); Assert.IsTrue (exported_type.IsForwarder); var nested_exported_type = module.ExportedTypes [1]; Assert.AreEqual ("System.Diagnostics.DebuggableAttribute/DebuggingModes", nested_exported_type.FullName); Assert.AreEqual (exported_type, nested_exported_type.DeclaringType); - Assert.AreEqual ("mscorlib", nested_exported_type.Scope.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", nested_exported_type.Scope.Name); }); } @@ -199,7 +205,7 @@ namespace Mono.Cecil.Tests { { TestCSharp ("CustomAttributes.cs", module => { Assert.IsTrue (module.HasTypeReference ("System.Attribute")); - Assert.IsTrue (module.HasTypeReference ("mscorlib", "System.Attribute")); + Assert.IsTrue (module.HasTypeReference (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", "System.Attribute")); Assert.IsFalse (module.HasTypeReference ("System.Core", "System.Attribute")); Assert.IsFalse (module.HasTypeReference ("System.Linq.Enumerable")); @@ -234,10 +240,9 @@ namespace Mono.Cecil.Tests { } [Test] - [ExpectedException (typeof (BadImageFormatException))] public void OpenIrrelevantFile () { - GetResourceModule ("text_file.txt"); + Assert.Throws (() => GetResourceModule ("text_file.txt")); } [Test] @@ -273,7 +278,8 @@ namespace Mono.Cecil.Tests { { using (var module = ModuleDefinition.ReadModule (file)) { - Assert.IsNotNullOrEmpty (module.FileName); + Assert.IsNotNull (module.FileName); + Assert.IsNotEmpty (module.FileName); Assert.AreEqual (path, module.FileName); } } diff --git a/external/cecil/Test/Mono.Cecil.Tests/PortablePdbTests.cs b/external/cecil/Test/Mono.Cecil.Tests/PortablePdbTests.cs index 2e73eec61c..25ee2d1994 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/PortablePdbTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/PortablePdbTests.cs @@ -320,8 +320,15 @@ namespace Mono.Cecil.Tests { var state_machine_scope = move_next.CustomDebugInformations.OfType ().FirstOrDefault (); Assert.IsNotNull (state_machine_scope); - Assert.AreEqual (0, state_machine_scope.Start.Offset); - Assert.IsTrue (state_machine_scope.End.IsEndOfMethod); + Assert.AreEqual (3, state_machine_scope.Scopes.Count); + Assert.AreEqual (0, state_machine_scope.Scopes [0].Start.Offset); + Assert.IsTrue (state_machine_scope.Scopes [0].End.IsEndOfMethod); + + Assert.AreEqual (0, state_machine_scope.Scopes [1].Start.Offset); + Assert.AreEqual (0, state_machine_scope.Scopes [1].End.Offset); + + Assert.AreEqual (184, state_machine_scope.Scopes [2].Start.Offset); + Assert.AreEqual (343, state_machine_scope.Scopes [2].End.Offset); var async_body = move_next.CustomDebugInformations.OfType ().FirstOrDefault (); Assert.IsNotNull (async_body); @@ -335,7 +342,8 @@ namespace Mono.Cecil.Tests { Assert.AreEqual (91, async_body.Resumes [0].Offset); Assert.AreEqual (252, async_body.Resumes [1].Offset); - Assert.AreEqual (move_next, async_body.MoveNextMethod); + Assert.AreEqual (move_next, async_body.ResumeMethods [0]); + Assert.AreEqual (move_next, async_body.ResumeMethods [1]); }); } diff --git a/external/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs b/external/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs index aab7d0cf5b..f65b889b60 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs @@ -26,7 +26,8 @@ namespace Mono.Cecil.Tests { Assert.IsNotNull (definition); Assert.AreEqual ("System.String System.String::Empty", definition.FullName); - Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", + definition.Module.Assembly.Name.Name); } delegate string GetSubstring (string str, int start, int length); @@ -42,7 +43,8 @@ namespace Mono.Cecil.Tests { Assert.IsNotNull (definition); Assert.AreEqual ("System.String System.String::Substring(System.Int32,System.Int32)", definition.FullName); - Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", + definition.Module.Assembly.Name.Name); } [Test] @@ -56,7 +58,8 @@ namespace Mono.Cecil.Tests { Assert.AreEqual ("get_Length", definition.Name); Assert.AreEqual ("System.String", definition.DeclaringType.FullName); - Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", + definition.Module.Assembly.Name.Name); } [Test] @@ -72,7 +75,8 @@ namespace Mono.Cecil.Tests { Assert.IsNotNull (definition); Assert.AreEqual ("System.Void System.Collections.Generic.List`1::Add(T)", definition.FullName); - Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", + definition.Module.Assembly.Name.Name); } [Test] @@ -92,7 +96,8 @@ namespace Mono.Cecil.Tests { Assert.IsNotNull (definition); Assert.AreEqual ("System.Boolean System.Collections.Generic.Dictionary`2::TryGetValue(TKey,TValue&)", definition.FullName); - Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", + definition.Module.Assembly.Name.Name); } class CustomResolver : DefaultAssemblyResolver { @@ -140,7 +145,7 @@ namespace Mono.Cecil.Tests { var definition = reference.Resolve (); Assert.IsNotNull (definition); Assert.AreEqual ("System.Diagnostics.DebuggableAttribute", definition.FullName); - Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", definition.Module.Assembly.Name.Name); } [Test] @@ -162,7 +167,7 @@ namespace Mono.Cecil.Tests { var definition = reference.Resolve (); Assert.IsNotNull (definition); Assert.AreEqual ("System.Diagnostics.DebuggableAttribute/DebuggingModes", definition.FullName); - Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", definition.Module.Assembly.Name.Name); } [Test] @@ -175,6 +180,19 @@ namespace Mono.Cecil.Tests { Assert.IsNull (get_a_b.Resolve ()); } + [Test] + public void GenericRectangularArrayGetMethodInMemberReferences () + { + using (var module = GetResourceModule ("FSharp.Core.dll")) { + foreach (var member in module.GetMemberReferences ()) { + if (!member.DeclaringType.IsArray) + continue; + + Assert.IsNull (member.Resolve ()); + } + } + } + [Test] public void ResolveFunctionPointer () { @@ -223,7 +241,9 @@ namespace Mono.Cecil.Tests { Assert.IsTrue (reference.IsRetargetable); var assembly = resolver.Resolve (reference); Assert.IsNotNull (assembly); - Assert.AreEqual (typeof (object).Assembly.GetName ().Version, assembly.Name.Version); + + if (!Platform.OnCoreClr) + Assert.AreEqual (typeof (object).Assembly.GetName ().Version, assembly.Name.Version); } } diff --git a/external/cecil/Test/Mono.Cecil.Tests/SecurityDeclarationTests.cs b/external/cecil/Test/Mono.Cecil.Tests/SecurityDeclarationTests.cs index 3b59e6f78e..c3106f424c 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/SecurityDeclarationTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/SecurityDeclarationTests.cs @@ -249,10 +249,10 @@ namespace Mono.Cecil.Tests { } switch (Type.GetTypeCode (value.GetType ())) { - case TypeCode.String: + case System.TypeCode.String: signature.AppendFormat ("\"{0}\"", value); break; - case TypeCode.Char: + case System.TypeCode.Char: signature.AppendFormat ("'{0}'", (char) value); break; default: diff --git a/external/cecil/Test/Mono.Cecil.Tests/TypeParserTests.cs b/external/cecil/Test/Mono.Cecil.Tests/TypeParserTests.cs index 603b7f4d50..a838c07e97 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/TypeParserTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/TypeParserTests.cs @@ -233,6 +233,9 @@ namespace Mono.Cecil.Tests { [Test] public void GenericInstanceExternArguments () { + if (Platform.OnCoreClr) + return; + var module = GetCurrentModule (); var fullname = string.Format ("System.Collections.Generic.Dictionary`2[[System.Int32, {0}],[System.String, {0}]]", @@ -280,7 +283,7 @@ namespace Mono.Cecil.Tests { var instance = type as GenericInstanceType; Assert.IsNotNull (instance); Assert.AreEqual (2, instance.GenericArguments.Count); - Assert.AreEqual ("mscorlib", type.Scope.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Runtime" : "mscorlib", type.Scope.Name); Assert.AreEqual (module, type.Module); Assert.AreEqual ("System.Collections.Generic", type.Namespace); Assert.AreEqual ("Dictionary`2", type.Name); @@ -296,7 +299,7 @@ namespace Mono.Cecil.Tests { Assert.AreEqual ("TypeParserTests", argument.Name); argument = instance.GenericArguments [1]; - Assert.AreEqual ("mscorlib", argument.Scope.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", argument.Scope.Name); Assert.AreEqual (module, argument.Module); Assert.AreEqual ("System", argument.Namespace); Assert.AreEqual ("String", argument.Name); @@ -319,7 +322,7 @@ namespace Mono.Cecil.Tests { var instance = type as GenericInstanceType; Assert.IsNotNull (instance); Assert.AreEqual (2, instance.GenericArguments.Count); - Assert.AreEqual ("mscorlib", type.Scope.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", type.Scope.Name); Assert.AreEqual (module, type.Module); Assert.AreEqual ("System.Collections.Generic", type.Namespace); Assert.AreEqual ("Dictionary`2", type.Name); @@ -354,7 +357,7 @@ namespace Mono.Cecil.Tests { var instance = type as GenericInstanceType; Assert.IsNotNull (instance); Assert.AreEqual (2, instance.GenericArguments.Count); - Assert.AreEqual ("mscorlib", type.Scope.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Runtime" : "mscorlib", type.Scope.Name); Assert.AreEqual (module, type.Module); Assert.AreEqual ("System.Collections.Generic", type.Namespace); Assert.AreEqual ("Dictionary`2", type.Name); @@ -364,7 +367,7 @@ namespace Mono.Cecil.Tests { Assert.AreEqual (2, type.GenericParameters.Count); var argument = instance.GenericArguments [0]; - Assert.AreEqual ("mscorlib", argument.Scope.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", argument.Scope.Name); Assert.AreEqual (module, argument.Module); Assert.AreEqual ("System", argument.Namespace); Assert.AreEqual ("String", argument.Name); @@ -385,7 +388,7 @@ namespace Mono.Cecil.Tests { Assert.IsInstanceOf (typeof (TypeDefinition), argument); argument = instance.GenericArguments [1]; - Assert.AreEqual ("mscorlib", argument.Scope.Name); + Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", argument.Scope.Name); Assert.AreEqual (module, argument.Module); Assert.AreEqual ("System", argument.Namespace); Assert.AreEqual ("Int32", argument.Name); diff --git a/external/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeAssemblyResolver.cs b/external/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeAssemblyResolver.cs index 1e3a90bb73..fb39e33428 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeAssemblyResolver.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeAssemblyResolver.cs @@ -1,4 +1,6 @@ -using System; +#if !NET_CORE + +using System; using System.Collections.Generic; using System.IO; using Microsoft.Win32; @@ -91,3 +93,4 @@ namespace Mono.Cecil.Tests { } } } +#endif \ No newline at end of file diff --git a/external/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs b/external/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs index 166f4d9bef..d5ed3b0b33 100644 --- a/external/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs +++ b/external/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs @@ -1,4 +1,6 @@ -using NUnit.Framework; +#if !NET_CORE + +using NUnit.Framework; using System; using System.Collections.Generic; using System.IO; @@ -141,3 +143,4 @@ namespace Mono.Cecil.Tests { protected override string [] CustomListTypeNames { get { return new [] { "CustomList" }; } } } } +#endif diff --git a/external/cecil/rocks/Mono.Cecil.Rocks/ILParser.cs b/external/cecil/rocks/Mono.Cecil.Rocks/ILParser.cs index 8d119eb0d6..e05068ff3c 100644 --- a/external/cecil/rocks/Mono.Cecil.Rocks/ILParser.cs +++ b/external/cecil/rocks/Mono.Cecil.Rocks/ILParser.cs @@ -44,6 +44,7 @@ namespace Mono.Cecil.Rocks { class ParseContext { public CodeReader Code { get; set; } + public int Position { get; set; } public MetadataReader Metadata { get; set; } public Collection Variables { get; set; } public IILVisitor Visitor { get; set; } @@ -58,6 +59,14 @@ namespace Mono.Cecil.Rocks { if (!method.HasBody || !method.HasImage) throw new ArgumentException (); + method.Module.Read (method, (m, _) => { + ParseMethod (m, visitor); + return true; + }); + } + + static void ParseMethod (MethodDefinition method, IILVisitor visitor) + { var context = CreateContext (method, visitor); var code = context.Code; @@ -75,15 +84,18 @@ namespace Mono.Cecil.Rocks { default: throw new NotSupportedException (); } + + code.MoveBackTo (context.Position); } static ParseContext CreateContext (MethodDefinition method, IILVisitor visitor) { var code = method.Module.Read (method, (_, reader) => reader.code); - code.MoveTo (method); + var position = code.MoveTo (method); return new ParseContext { Code = code, + Position = position, Metadata = code.reader, Visitor = visitor, }; diff --git a/external/cecil/rocks/Mono.Cecil.Rocks/MethodBodyRocks.cs b/external/cecil/rocks/Mono.Cecil.Rocks/MethodBodyRocks.cs index dfdaeced69..c627d2f3e9 100644 --- a/external/cecil/rocks/Mono.Cecil.Rocks/MethodBodyRocks.cs +++ b/external/cecil/rocks/Mono.Cecil.Rocks/MethodBodyRocks.cs @@ -189,10 +189,10 @@ namespace Mono.Cecil.Rocks { var instruction = self.Instructions [i]; if (instruction.OpCode.Code != Code.Ldc_I8) continue; - var l = (long)instruction.Operand; - if (l >= uint.MaxValue) + var l = (long) instruction.Operand; + if (l >= int.MaxValue || l <= int.MinValue) continue; - ExpandMacro (instruction, OpCodes.Ldc_I4, (uint)l); + ExpandMacro (instruction, OpCodes.Ldc_I4, (int) l); self.Instructions.Insert (++i, Instruction.Create (OpCodes.Conv_I8)); } } diff --git a/external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs b/external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs index 66a7225901..59e933a370 100644 --- a/external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs +++ b/external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs @@ -78,6 +78,7 @@ namespace Mono.Cecil.Mdb { return null; var info = new MethodDebugInformation (method); + info.code_size = ReadCodeSize (method); var scopes = ReadScopes (entry, info); ReadLineNumbers (entry, info); @@ -86,6 +87,11 @@ namespace Mono.Cecil.Mdb { return info; } + static int ReadCodeSize (MethodDefinition method) + { + return method.Module.Read (method, (m, reader) => reader.ReadCodeSize (m)); + } + static void ReadLocalVariables (MethodEntry entry, ScopeDebugInformation [] scopes) { var locals = entry.GetLocals (); diff --git a/external/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs b/external/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs index 0eec10fd7e..e151c756dc 100644 --- a/external/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs +++ b/external/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs @@ -234,7 +234,7 @@ namespace Mono.CompilerServices.SymbolWriter public override string ToString () { - return String.Format ("[Line {0}:{1,2}-{3,4}:{5}]", File, Row, Column, EndRow, EndColumn, Offset); + return String.Format ("[Line {0}:{1},{2}-{3},{4}:{5}]", File, Row, Column, EndRow, EndColumn, Offset); } } diff --git a/external/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbReader.cs b/external/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbReader.cs index b07191dba6..964f4ad5ba 100644 --- a/external/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbReader.cs +++ b/external/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbReader.cs @@ -137,9 +137,15 @@ namespace Mono.Cecil.Pdb { } } - if (function.iteratorScopes != null) - foreach (var iterator_scope in function.iteratorScopes) - symbol.CustomDebugInformations.Add (new StateMachineScopeDebugInformation ((int) iterator_scope.Offset, (int) (iterator_scope.Offset + iterator_scope.Length + 1))); + if (function.iteratorScopes != null) { + var state_machine = new StateMachineScopeDebugInformation (); + + foreach (var iterator_scope in function.iteratorScopes) { + state_machine.Scopes.Add (new StateMachineScope ((int) iterator_scope.Offset, (int) (iterator_scope.Offset + iterator_scope.Length + 1))); + } + + symbol.CustomDebugInformations.Add (state_machine); + } if (function.synchronizationInformation != null) { var async_debug_info = new AsyncMethodBodyDebugInformation ((int) function.synchronizationInformation.GeneratedCatchHandlerOffset); @@ -147,11 +153,11 @@ namespace Mono.Cecil.Pdb { foreach (var synchronization_point in function.synchronizationInformation.synchronizationPoints) { async_debug_info.Yields.Add (new InstructionOffset ((int) synchronization_point.SynchronizeOffset)); async_debug_info.Resumes.Add (new InstructionOffset ((int) synchronization_point.ContinuationOffset)); + async_debug_info.ResumeMethods.Add (method); } symbol.CustomDebugInformations.Add (async_debug_info); - async_debug_info.MoveNextMethod = method; symbol.StateMachineKickOffMethod = (MethodDefinition) method.Module.LookupToken ((int) function.synchronizationInformation.kickoffMethodToken); } @@ -280,7 +286,11 @@ namespace Mono.Cecil.Pdb { break; } case 'A': - var index = used_namespace.IndexOf(' '); + var index = used_namespace.IndexOf (' '); + if (index < 0) { + target = new ImportTarget (ImportTargetKind.ImportNamespace) { @namespace = used_namespace }; + break; + } var alias_value = used_namespace.Substring (1, index - 1); var alias_target_value = used_namespace.Substring (index + 2); switch (used_namespace [index + 1]) { @@ -294,6 +304,15 @@ namespace Mono.Cecil.Pdb { break; } break; + case '*': + target = new ImportTarget (ImportTargetKind.ImportNamespace) { @namespace = value }; + break; + case '@': + if (!value.StartsWith ("P:")) + continue; + + target = new ImportTarget (ImportTargetKind.ImportNamespace) { @namespace = value.Substring (2) }; + break; } if (target != null) diff --git a/external/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs b/external/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs index e3d6d178ba..be871ac481 100644 --- a/external/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs +++ b/external/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs @@ -111,10 +111,10 @@ namespace Mono.Cecil.Pdb { } if (info.HasCustomDebugInformations) { - var scopes = info.CustomDebugInformations.OfType ().ToArray (); + var state_machine = info.CustomDebugInformations.FirstOrDefault (cdi => cdi.Kind == CustomDebugInformationKind.StateMachineScope) as StateMachineScopeDebugInformation; - if (scopes.Length > 0) - metadata.WriteIteratorScopes (scopes, info); + if (state_machine != null) + metadata.WriteIteratorScopes (state_machine, info); } metadata.WriteCustomMetadata (); @@ -139,7 +139,7 @@ namespace Mono.Cecil.Pdb { async_metadata.WriteUInt32 ((uint) async_debug_info.Resumes.Count); for (int i = 0; i < async_debug_info.Resumes.Count; ++i) { async_metadata.WriteUInt32 ((uint) async_debug_info.Yields [i].Offset); - async_metadata.WriteUInt32 (async_debug_info.MoveNextMethod != null ? async_debug_info.MoveNextMethod.MetadataToken.ToUInt32 () : 0); + async_metadata.WriteUInt32 (async_debug_info.resume_methods [i].MetadataToken.ToUInt32 ()); async_metadata.WriteUInt32 ((uint) async_debug_info.Resumes [i].Offset); } @@ -312,10 +312,11 @@ namespace Mono.Cecil.Pdb { Write (CustomMetadataType.ForwardInfo, () => writer.WriteUInt32 (import_parent.ToUInt32 ())); } - public void WriteIteratorScopes (StateMachineScopeDebugInformation [] scopes, MethodDebugInformation debug_info) + public void WriteIteratorScopes (StateMachineScopeDebugInformation state_machine, MethodDebugInformation debug_info) { Write (CustomMetadataType.IteratorScopes, () => { - writer.WriteInt32 (scopes.Length); + var scopes = state_machine.Scopes; + writer.WriteInt32 (scopes.Count); foreach (var scope in scopes) { var start = scope.Start.Offset; var end = scope.End.IsEndOfMethod ? debug_info.code_size : scope.End.Offset; diff --git a/external/cecil/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs b/external/cecil/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs index 054f1f89fb..b6fdcdf566 100644 --- a/external/cecil/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs +++ b/external/cecil/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs @@ -143,7 +143,7 @@ namespace Mono.Cecil.Tests { Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm); Assert.AreEqual (DocumentLanguage.FSharp, document.Language); Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider)); + }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); } [Test] @@ -157,7 +157,15 @@ namespace Mono.Cecil.Tests { public void EmptyRootNamespace () { TestModule ("EmptyRootNamespace.dll", module => { - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider)); + }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); + } + + [Test] + public void VisualBasicNamespace () + { + TestModule ("AVbTest.exe", module => { + }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); + } [Test] @@ -346,8 +354,9 @@ namespace Mono.Cecil.Tests { var state_machine_scope = move_next.DebugInformation.CustomDebugInformations [0] as StateMachineScopeDebugInformation; Assert.IsNotNull (state_machine_scope); - Assert.AreEqual (142, state_machine_scope.Start.Offset); - Assert.AreEqual (319, state_machine_scope.End.Offset); + Assert.AreEqual (1, state_machine_scope.Scopes.Count); + Assert.AreEqual (142, state_machine_scope.Scopes [0].Start.Offset); + Assert.AreEqual (319, state_machine_scope.Scopes [0].End.Offset); var async_body = move_next.DebugInformation.CustomDebugInformations [1] as AsyncMethodBodyDebugInformation; Assert.IsNotNull (async_body); @@ -361,7 +370,8 @@ namespace Mono.Cecil.Tests { Assert.AreEqual (98, async_body.Resumes [0].Offset); Assert.AreEqual (227, async_body.Resumes [1].Offset); - Assert.AreEqual (move_next, async_body.MoveNextMethod); + Assert.AreEqual (move_next, async_body.ResumeMethods [0]); + Assert.AreEqual (move_next, async_body.ResumeMethods [1]); }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); } diff --git a/external/cecil/symbols/pdb/Test/Resources/assemblies/AVbTest.pdb b/external/cecil/symbols/pdb/Test/Resources/assemblies/AVbTest.pdb new file mode 100644 index 0000000000000000000000000000000000000000..c46ce47b3cd02f91e6ad004a7155ee0af9b6c638 GIT binary patch literal 24064 zcmeHP3viUx6}}5$LmXg>bl<_q>V#gOVXtkA&&iJaMQ?=?iPVHb+##WuG^!x6;=ih(V-9V5| zOR@*f-q$(jo_p@S=RW@bPfMgT7L7+YC49lE;JkUhmi5iP#r{B`WZbmI^$IXb|5sIv zd-$W&StiK;4g(A9Kb(h=Y=I>l!}&olVu!%^KUaJ77%0U!AOb4X;ll+84<8<_)A^s_ zYk_S2KQ-U~!?(jTT6UYi+H+v;^OtaIxAfsFKPtZa(v`ngkH5X{jYm%xQkL1RpJb^w z*DcJ6#feM1pMJ4yZ-d%h zx$4xHpJ_V(jt@V0x$Ktn)c!ShkNWlayLSGdY||@c`{pY3#n_em4whFOzU-dTmg_%{ zuI#+Frem@-)6Sx8`yT1t^7yLl*L?o-c;ljhlUlZq3=5vvtvp`+AAY-a(qAjj4g4 z|HN)>Ui(}Y*lAC566T`I=MOIneDm=)AG7Oc@F%#mEz#50w(O#ft>JjW30p#uUjMd@ zN_Cp@(6)^UmP^=U%X6{!`_{&ySA;tgZR^8{M5K3f+}{|EM>h9{V-%Z9YQL|~vc-k1 z%f)u&+Aavkqg!L0;h|O+bNJl#jkg`|vmt|-z*9@ZREAJkpAz)tvVPULg6-u}p0JY#?P{weoKtv>{Hb_<$@60|jOxBD6Jq_x+T# zl;s1m%uUNYp}k_m?)z6D%{)OjEqg?0@4e)gMU-0)^Z{AsrbTkZ0{hRe=9bX_7ki8u z@W|HzJQDC8L`oOY5g=Z!MwgMV6`7=!@(HT4Y_4@4$W}9uu3x*fMIJHxFN(yshPoR< z@kl4jNssdN{qaP&2kB|wL<^jlM$;Hdgfe9|Mnao= zqwz$flQPrkS4VoUWZPUi`7iG2_M3d$7Ne`b_3~Ia)CEuGZwUs%LLF5UJ{a4Ee|JFgyNS6 zqg~p~alYP%g8AUnJeE$+zv@7swszsd>V=%IM&}}z&TdiE;aK!uVD&Dwj}z@iJ z=w0m6yS2a1(YXuyz6m6~&}8Z?b{?0mvljDR^?k$WrQyS&py-`42*L=0X4`q9Rd zL4OO7^g@%Vuh5Tv-``||Keg-73&}X)Tb(yhY*S#^O8h3psqrUG;eg4iwG-l*~1=+2jC#{s{l79#^ z+!Go9=+VBCHE~#RT_AjJ{r?vTInKXCSfb8{foH1{HC3-6lwsz!$IM?O-7@}dWqgGY z^FV#AWt;~YbJJv)IpmSY{An`qfG3IOvYzAw1_(>k3dr!M$uQ$OyB?##LmBX0T8}YW z#@Uc@rX!;pC{R4nX%x}{YE;s{mLMNdQU{ib$1fN615z1PKS)iP9K>5&MxC* zE2F~7n5t!*3R_RtGGtBnK|X=+T&xCm0e=j<9rz&dIp8}$j0aT;rD}kyfqlSTz&nA* z6EK{eb>&ejSWY@jVk~&yMX0OY98R>$5e|8>58Qz`d4$eA9|DV0>k9hW@f$8NL-7}B z>!HjqQ?Ezs05#J3w$YC3CWM@`&3bN>LXmUQ`lX(X0QUc0H1Zi=UN!3+9Ff`Z)pA?_Gd|F5>tKMtl0U zCc<#HdVF;ud>=?2q06jC)>O!F#+OUXF^?}bzxdwiRYx4~Vv4>Q*A)J8_VYVI2krt! zob|?x_w4I6ju=VW|HPg&ZvaTR&dS(nWnAybs7sS! z#zA%&w^$jsS{XlcWGqdSVfrMyjE}600W0HU9hRXjK`kS5?VJtW|IWsv&ntj6z}3KR zAjkWiz`ej%fq59*0vw~V@1`vY+%E}WJ@m$qaOR#|sVAjmk$OMGyRFpyfM2Yr{nu&sT!l5o@k>G=W~Ps8gl*r1jeQ7z0%V`i7qi>kytqy4 zLzc7tE;!1&2Koq|#XM`$?;D=C;Rgv?s4V}*MRLn0{m2xbal1mZ# z5gMP~gp|T*a1YKkXTn$~TTDNn7&~X*2V)zqb-}hw?}O_c**u%2&N!ys9&H2G>0U3O zla_HdLafPbv(=Ah)ydAiCG{Xw01v{Zy!V+6Yy`Few*&L=|6u|8f7$0gX;qr#QVo6R z-GD)?=M3lh@^C_~jz}hFfnA7`PiWoq#(lSldEm@-x2Pe^_q01BIlFMLP2l_!m;8}#UQl6==d!BcI&a}&;+lVA?kZ=#g2;f3{_P+?>Nl0^^PejP{bcEnd zRwBF@VHxJh6onZCI7e+jyb1=XaQ1vgpX_%Gmw}(nY)42R)q$`Cw%e-U%iw)bd*bvi~O*Q@RvLX4<9>?Bfr42{w`p&ke*7wxf%XNZ#A_Di} zGCtWA^!z8w-mS@5+Q!s#j%ZGuv1h^L14a~!T#{&GOV_H$wryOg0Fh+}DYxY&04evml zX*{6O;Q^b*ow-hAtjbdTjnnLTAH|Z2nA3|Dnyl)#_1Z!-s76h%Ilj>9=e+)ylcfhAp<< zIl^c2FSY5bZTUks^q_u_y=fuzCg0N6(6<_$cwQ=0+1_qQwa3s{UMz&d z%Xbh8RrZ$@q+UZ~d9fi9JM;a5LS+tGLTmCYt={vc`ecm0d`mq|6(0827;EbQ7Fn?a z^G89xISmiXA)Rm35G>%sJmQ$hgu~DNVxQ~{xxkGD9j2+qOxj_b9&~LV4()dPi&5e) z;5WrLccGD^%mu&mU|x7knej`!&!1s^C-346kNZh>%5R!-%Ll(HzUg&`&pb_*dQ85h zhp&`+_{`VT<9>>ps>hUDKKM=X&m8Zgb(=DuvZQzojpbdEvd47PX?Rl)4@6H>W_jvT zJbbP&I^%(Z@R%~o6H2v>^^es$x^GF-^&2Z|DfE-|W54E0Uq4KqsiPWt2`%gJWUMtN z&+6k^Z<$}t`6k=PnxsioM1_MpYNSWdje)HEsOqs&1b(^l!oM&xR3RCs)Q<7y17cH!9Xl}Np zDS7huMjSRoCa5-aEP;MDr`&$%Z$CFf%)KyF*9L2X)l0At00ysXqCQKL?n&TL)nz^j zSs&UIUbB(kxf zvml{zaQU*Ch`ZkISR7nZTiaZN%@JVmc1%{2?YvBacF=an{8UTog3B5LbvR2C2A6-5 z9?PW5><99V)!v%lD2>LtJqEt85IUs)`yP0S8-PBG2y`CvbA6F1pO5A$Kf?E+M`lY| z-u+#vl5bnJE!_rXgAEjGqnS9HGU8yczyI|XtWkx}-?psm-4s<-y`dhwZ&?+Obyi)D zuiwJ4jos1CEhb}Aq&pn1>Ky$0V9h!>7t*3WodBJ@H!0gdF?_yE^mgqwhP zQAod>Pe;r+i%tW|hKB19Z@{?Nz66vF%L({L(Rc^#1FnM&aEwsn(I$ojylt)o8OZ%3*CMV}Yy;P%X+VAxG9AeM7vHa?U-AKG0xN;1 Z1KE{l0A~S5I&gi@L*4>;3ye$){0CA>dcptz literal 0 HcmV?d00001 diff --git a/external/linker/corebuild/.cliversion b/external/linker/corebuild/.cliversion index fcce3b80cc..227cea2156 100644 --- a/external/linker/corebuild/.cliversion +++ b/external/linker/corebuild/.cliversion @@ -1 +1 @@ -2.0.0-preview2-005905 +2.0.0 diff --git a/external/linker/corebuild/.toolversions b/external/linker/corebuild/.toolversions deleted file mode 100644 index 8b13789179..0000000000 --- a/external/linker/corebuild/.toolversions +++ /dev/null @@ -1 +0,0 @@ - diff --git a/external/linker/corebuild/bootstrap.ps1 b/external/linker/corebuild/bootstrap.ps1 index 173d01d55e..68b3e10eeb 100644 --- a/external/linker/corebuild/bootstrap.ps1 +++ b/external/linker/corebuild/bootstrap.ps1 @@ -6,7 +6,7 @@ param [Parameter(Mandatory=$false)][string]$SharedFrameworkSymlinkPath = (Join-Path $ToolsLocalPath "dotnetcli\shared\Microsoft.NETCore.App\version"), [Parameter(Mandatory=$false)][string]$SharedFrameworkVersion = "", [Parameter(Mandatory=$false)][string]$Architecture = "", - [Parameter(Mandatory=$false)][string]$DotNetInstallBranch = "rel/1.0.0", + [Parameter(Mandatory=$false)][string]$DotNetInstallBranch = "release/2.0.0", [switch]$Force = $false ) diff --git a/external/linker/corebuild/bootstrap.sh b/external/linker/corebuild/bootstrap.sh index 992e486128..66f15e5cd3 100755 --- a/external/linker/corebuild/bootstrap.sh +++ b/external/linker/corebuild/bootstrap.sh @@ -80,7 +80,7 @@ sharedFxVersion="" force= forcedCliLocalPath="" architecture="" -dotNetInstallBranch="rel/1.0.0" +dotNetInstallBranch="release/2.0.0" while [ $# -ne 0 ] do diff --git a/external/linker/corebuild/global.json b/external/linker/corebuild/global.json new file mode 100644 index 0000000000..9c9949cd74 --- /dev/null +++ b/external/linker/corebuild/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.0.0" + } +} diff --git a/external/linker/corebuild/integration/ILLink.CustomSteps/ILLink.CustomSteps.csproj b/external/linker/corebuild/integration/ILLink.CustomSteps/ILLink.CustomSteps.csproj index 64d0992686..c90895967f 100644 --- a/external/linker/corebuild/integration/ILLink.CustomSteps/ILLink.CustomSteps.csproj +++ b/external/linker/corebuild/integration/ILLink.CustomSteps/ILLink.CustomSteps.csproj @@ -3,7 +3,6 @@ netcoreapp2.0;net46 netcoreapp2.0 - 2.0.0-beta-001509-00 $(DefineConstants);FEATURE_ILLINK false false diff --git a/external/linker/corebuild/integration/ILLink.Tasks/ILLink.Tasks.csproj b/external/linker/corebuild/integration/ILLink.Tasks/ILLink.Tasks.csproj index 45d1bca53d..27e3401408 100644 --- a/external/linker/corebuild/integration/ILLink.Tasks/ILLink.Tasks.csproj +++ b/external/linker/corebuild/integration/ILLink.Tasks/ILLink.Tasks.csproj @@ -3,7 +3,6 @@ 0.1.4-preview netcoreapp2.0;net46 netcoreapp2.0 - 2.0.0-beta-001509-00 false ../bin/ $(BaseOutputPath)nupkgs diff --git a/external/linker/corebuild/integration/test/IntegrationTestBase.cs b/external/linker/corebuild/integration/test/IntegrationTestBase.cs index ad1f0e33f1..0a82eededa 100644 --- a/external/linker/corebuild/integration/test/IntegrationTestBase.cs +++ b/external/linker/corebuild/integration/test/IntegrationTestBase.cs @@ -29,10 +29,11 @@ namespace ILLink.Tests protected int Dotnet(string args, string workingDir, string additionalPath = null) { - return RunCommand(context.DotnetToolPath, args, workingDir, additionalPath, out string commandOutput); + return RunCommand(Path.GetFullPath(context.DotnetToolPath), args, + workingDir, additionalPath, out string commandOutput); } - protected int RunCommand(string command, string args, int timeout = 60000) + protected int RunCommand(string command, string args, int timeout = Int32.MaxValue) { return RunCommand(command, args, null, null, out string commandOutput, timeout); } @@ -42,7 +43,7 @@ namespace ILLink.Tests return RunCommand(command, args, workingDir, null, out string commandOutput); } - protected int RunCommand(string command, string args, string workingDir, string additionalPath, out string commandOutput, int timeout = 60000) + protected int RunCommand(string command, string args, string workingDir, string additionalPath, out string commandOutput, int timeout = Int32.MaxValue) { output.WriteLine($"{command} {args}"); if (workingDir != null) @@ -64,6 +65,14 @@ namespace ILLink.Tests var process = new Process(); process.StartInfo = psi; + // dotnet sets some environment variables that + // may cause problems in the child process. + psi.Environment.Remove("MSBuildExtensionsPath"); + psi.Environment.Remove("MSBuildLoadMicrosoftTargetsReadOnly"); + psi.Environment.Remove("MSBuildSDKsPath"); + psi.Environment.Remove("VbcToolExe"); + psi.Environment.Remove("CscToolExe"); + StringBuilder processOutput = new StringBuilder(); DataReceivedEventHandler handler = (sender, e) => { processOutput.Append(e.Data); @@ -80,6 +89,7 @@ namespace ILLink.Tests process.BeginOutputReadLine(); process.BeginErrorReadLine(); if (!process.WaitForExit(timeout)) { + output.WriteLine($"killing process after {timeout} ms"); process.Kill(); } // WaitForExit with timeout doesn't guarantee @@ -101,26 +111,25 @@ namespace ILLink.Tests /// linker task package. /// Optionally takes a list of root descriptor files. /// - public void BuildAndLink(string csproj, List rootFiles = null) + public void BuildAndLink(string csproj, List rootFiles = null, Dictionary extraPublishArgs = null) { string rid = context.RuntimeIdentifier; string config = context.Configuration; string demoRoot = Path.GetDirectoryName(csproj); - int ret = Dotnet($"restore -r {rid}", demoRoot); - if (ret != 0) { - output.WriteLine("restore failed"); - Assert.True(false); - return; - } - string publishArgs = $"publish -r {rid} -c {config} /v:n /p:ShowLinkerSizeComparison=true"; string rootFilesStr; if (rootFiles != null && rootFiles.Any()) { rootFilesStr = String.Join(";", rootFiles); publishArgs += $" /p:LinkerRootDescriptors={rootFilesStr}"; } - ret = Dotnet(publishArgs, demoRoot); + if (extraPublishArgs != null) { + foreach (var item in extraPublishArgs) { + publishArgs += $" /p:{item.Key}={item.Value}"; + } + } + int ret = Dotnet(publishArgs, demoRoot); + if (ret != 0) { output.WriteLine("publish failed, returning " + ret); Assert.True(false); @@ -128,11 +137,13 @@ namespace ILLink.Tests } } - public int RunApp(string csproj, out string processOutput, int timeout = 60000) + public int RunApp(string csproj, out string processOutput, int timeout = Int32.MaxValue) { string demoRoot = Path.GetDirectoryName(csproj); - string executablePath = Path.Combine( - demoRoot, "bin", context.Configuration, "netcoreapp2.0", + // detect the target framework for which the app was published + string tfmDir = Path.Combine(demoRoot, "bin", context.Configuration); + string tfm = Directory.GetDirectories(tfmDir).Select(p => Path.GetFileName(p)).Single(); + string executablePath = Path.Combine(tfmDir, tfm, context.RuntimeIdentifier, "publish", Path.GetFileNameWithoutExtension(csproj) ); @@ -141,17 +152,9 @@ namespace ILLink.Tests } Assert.True(File.Exists(executablePath)); - // work around bug in prerelease .NET Core, - // where the published host isn't executable - int ret; - if (!context.RuntimeIdentifier.Contains("win")) { - ret = RunCommand("chmod", "+x " + executablePath, 1000); - Assert.True(ret == 0); - } - - ret = RunCommand(executablePath, null, - Directory.GetParent(executablePath).FullName, - null, out processOutput, timeout); + int ret = RunCommand(executablePath, null, + Directory.GetParent(executablePath).FullName, + null, out processOutput, timeout); return ret; } diff --git a/external/linker/corebuild/integration/test/MusicStoreTest.cs b/external/linker/corebuild/integration/test/MusicStoreTest.cs index 54c46f3479..027b743dd8 100644 --- a/external/linker/corebuild/integration/test/MusicStoreTest.cs +++ b/external/linker/corebuild/integration/test/MusicStoreTest.cs @@ -14,6 +14,8 @@ namespace ILLink.Tests private static List rootFiles = new List { "MusicStoreReflection.xml" }; + private string netcoreappVersion; + [Fact] public void RunMusicStore() { @@ -32,10 +34,70 @@ namespace ILLink.Tests AddLinkerReference(csproj); - BuildAndLink(csproj, rootFiles); + Dictionary extraPublishArgs = new Dictionary(); + extraPublishArgs.Add("JITBENCH_FRAMEWORK_VERSION", netcoreappVersion); + BuildAndLink(csproj, rootFiles, extraPublishArgs); + } - int ret = RunApp(csproj, out string commandOutput); - Assert.True(ret == 0); + string ObtainSDK(string repoDir) + { + int ret; + string dotnetDirName = ".dotnet"; + string dotnetInstall = Path.Combine(repoDir, "dotnet-install"); + if (context.RuntimeIdentifier.Contains("win")) { + dotnetInstall += ".ps1"; + } else { + dotnetInstall += ".sh"; + } + if (!File.Exists(dotnetInstall)) { + output.WriteLine($"missing dotnet-install script at {dotnetInstall}"); + Assert.True(false); + } + + if (context.RuntimeIdentifier.Contains("win")) { + ret = RunCommand(dotnetInstall, $"-SharedRuntime -InstallDir {dotnetDirName} -Channel master -Architecture x64", repoDir); + if (ret != 0) { + output.WriteLine("failed to retrieve shared runtime"); + Assert.True(false); + } + ret = RunCommand(dotnetInstall, $"-InstallDir {dotnetDirName} -Channel master -Architecture x64", repoDir); + if (ret != 0) { + output.WriteLine("failed to retrieve sdk"); + Assert.True(false); + } + } else { + ret = RunCommand(dotnetInstall, $"-sharedruntime -runtimeid {context.RuntimeIdentifier} -installdir {dotnetDirName} -channel master -architecture x64", repoDir); + if (ret != 0) { + output.WriteLine("failed to retrieve shared runtime"); + Assert.True(false); + } + ret = RunCommand(dotnetInstall, $"-installdir {dotnetDirName} -channel master -architecture x64", repoDir); + if (ret != 0) { + output.WriteLine("failed to retrieve sdk"); + Assert.True(false); + } + } + + string dotnetDir = Path.Combine(repoDir, dotnetDirName); + string dotnetToolName = Directory.GetFiles(dotnetDir) + .Select(p => Path.GetFileName(p)) + .Where(p => p.Contains("dotnet")) + .Single(); + string dotnetToolPath = Path.Combine(dotnetDir, dotnetToolName); + if (!File.Exists(dotnetToolPath)) { + output.WriteLine("repo-local dotnet tool does not exist."); + Assert.True(false); + } + + string ncaDir = Path.Combine(dotnetDir, "shared", "Microsoft.NETCore.App"); + netcoreappVersion = Directory.GetDirectories(ncaDir) + .Select(p => Path.GetFileName(p)).Max(); + if (String.IsNullOrEmpty(netcoreappVersion)) { + output.WriteLine($"no netcoreapp version found in {ncaDir}"); + Assert.True(false); + } + + return dotnetToolPath; } // returns path to .csproj project file @@ -44,7 +106,6 @@ namespace ILLink.Tests string gitRepo = "http://github.com/aspnet/JitBench"; string repoName = "JitBench"; string gitBranch = "dev"; - string demoRoot = Path.Combine("JitBench", Path.Combine("src", "MusicStore")); int ret; if (Directory.Exists(repoName)) { @@ -57,6 +118,7 @@ namespace ILLink.Tests Assert.True(false); } + string demoRoot = Path.Combine("JitBench", Path.Combine("src", "MusicStore")); if (!Directory.Exists(demoRoot)) { output.WriteLine($"{demoRoot} does not exist"); Assert.True(false); @@ -68,6 +130,11 @@ namespace ILLink.Tests Assert.True(false); } + // MusicStore targets .NET Core 2.1, so it must be built + // using an SDK that can target 2.1. We obtain that SDK + // here. + context.DotnetToolPath = ObtainSDK(repoName); + string csproj = Path.Combine(demoRoot, "MusicStore.csproj"); return csproj; } diff --git a/external/linker/corebuild/integration/test/TestContext.cs b/external/linker/corebuild/integration/test/TestContext.cs index 3e0fcf5c52..4d785b4982 100644 --- a/external/linker/corebuild/integration/test/TestContext.cs +++ b/external/linker/corebuild/integration/test/TestContext.cs @@ -29,7 +29,7 @@ namespace ILLink.Tests /// The path to the dotnet tool to use to run the /// integration tests. /// - public string DotnetToolPath { get; private set; } + public string DotnetToolPath { get; set; } /// /// The RID to use when restoring, building, and linking the @@ -87,6 +87,12 @@ namespace ILLink.Tests context.DotnetToolPath = dotnetToolPath; // This sets the RID to the RID of the currently-executing system. context.RuntimeIdentifier = RuntimeEnvironment.GetRuntimeIdentifier(); + // workaround: the osx.10.13-x64 RID doesn't exist yet. + // see https://github.com/dotnet/core-setup/issues/3301 + if (context.RuntimeIdentifier == "osx.10.13-x64") + { + context.RuntimeIdentifier = "osx.10.12-x64"; + } // We want to build and link integration projects in the // release configuration. context.Configuration = "Release"; diff --git a/external/linker/corebuild/integration/test/test.csproj b/external/linker/corebuild/integration/test/test.csproj index a0fb5ac2fc..98649432a0 100644 --- a/external/linker/corebuild/integration/test/test.csproj +++ b/external/linker/corebuild/integration/test/test.csproj @@ -24,10 +24,10 @@ - - - - + + + + diff --git a/external/linker/linker/Mono.Linker.Steps/BlacklistStep.cs b/external/linker/linker/Mono.Linker.Steps/BlacklistStep.cs index 197d32b40c..01ac53ceaf 100644 --- a/external/linker/linker/Mono.Linker.Steps/BlacklistStep.cs +++ b/external/linker/linker/Mono.Linker.Steps/BlacklistStep.cs @@ -96,9 +96,9 @@ namespace Mono.Linker.Steps { return false; } - static ResolveFromXmlStep GetExternalResolveStep (EmbeddedResource resource, AssemblyDefinition assembly) + protected virtual IStep GetExternalResolveStep (EmbeddedResource resource, AssemblyDefinition assembly) { - return new ResolveFromXmlStep (GetExternalDescriptor (resource), "resource " + resource.Name + " in " + assembly.FullName); + return new ResolveFromXmlStep (GetExternalDescriptor (resource), resource.Name, assembly, "resource " + resource.Name + " in " + assembly.FullName); } static ResolveFromXmlStep GetResolveStep (string descriptor) @@ -106,7 +106,7 @@ namespace Mono.Linker.Steps { return new ResolveFromXmlStep (GetDescriptor (descriptor), "descriptor " + descriptor + " from " + Assembly.GetExecutingAssembly ().FullName); } - static XPathDocument GetExternalDescriptor (EmbeddedResource resource) + protected static XPathDocument GetExternalDescriptor (EmbeddedResource resource) { using (var sr = new StreamReader (resource.GetResourceStream ())) { return new XPathDocument (new StringReader (sr.ReadToEnd ())); diff --git a/external/linker/linker/Mono.Linker.Steps/MarkStep.cs b/external/linker/linker/Mono.Linker.Steps/MarkStep.cs index 29bd85812c..fe38bca42f 100644 --- a/external/linker/linker/Mono.Linker.Steps/MarkStep.cs +++ b/external/linker/linker/Mono.Linker.Steps/MarkStep.cs @@ -647,8 +647,7 @@ namespace Mono.Linker.Steps { if (type.HasInterfaces) { foreach (var iface in type.Interfaces) { - MarkCustomAttributes (iface); - MarkType (iface.InterfaceType); + MarkInterfaceImplementation (type, iface); } } @@ -1444,7 +1443,14 @@ namespace Mono.Linker.Steps { return true; case MethodAction.Parse: AssemblyDefinition assembly = ResolveAssembly (method.DeclaringType.Scope); - return Annotations.GetAction (assembly) == AssemblyAction.Link; + switch (Annotations.GetAction (assembly)) { + case AssemblyAction.Link: + case AssemblyAction.Copy: + case AssemblyAction.CopyUsed: + return true; + default: + return false; + } default: return false; } @@ -1550,12 +1556,22 @@ namespace Mono.Linker.Steps { protected virtual void HandleUnresolvedType (TypeReference reference) { - throw new ResolutionException (reference); + if (!_context.IgnoreUnresolved) { + throw new ResolutionException (reference); + } } protected virtual void HandleUnresolvedMethod (MethodReference reference) { - throw new ResolutionException (reference); + if (!_context.IgnoreUnresolved) { + throw new ResolutionException (reference); + } + } + + protected virtual void MarkInterfaceImplementation (TypeDefinition type, InterfaceImplementation iface) + { + MarkCustomAttributes (iface); + MarkType (iface.InterfaceType); } } } diff --git a/external/linker/linker/Mono.Linker.Steps/ResolveFromXmlStep.cs b/external/linker/linker/Mono.Linker.Steps/ResolveFromXmlStep.cs index 1f4cc89c6e..c4173a59d7 100644 --- a/external/linker/linker/Mono.Linker.Steps/ResolveFromXmlStep.cs +++ b/external/linker/linker/Mono.Linker.Steps/ResolveFromXmlStep.cs @@ -59,6 +59,8 @@ namespace Mono.Linker.Steps { XPathDocument _document; string _xmlDocumentLocation; + string _resourceName; + AssemblyDefinition _resourceAssembly; public ResolveFromXmlStep (XPathDocument document, string xmlDocumentLocation = "") { @@ -66,18 +68,33 @@ namespace Mono.Linker.Steps { _xmlDocumentLocation = xmlDocumentLocation; } + public ResolveFromXmlStep (XPathDocument document, string resourceName, AssemblyDefinition resourceAssembly, string xmlDocumentLocation = "") + : this (document, xmlDocumentLocation) + { + if (string.IsNullOrEmpty (resourceName)) + throw new ArgumentNullException (nameof (resourceName)); + + if (resourceAssembly == null) + throw new ArgumentNullException (nameof (resourceAssembly)); + + _resourceName = resourceName; + _resourceAssembly = resourceAssembly; + } + protected override void Process () { XPathNavigator nav = _document.CreateNavigator (); - nav.MoveToFirstChild (); // This step can be created with XML files that aren't necessarily // linker descriptor files. So bail if we don't have a element. - if (nav.LocalName != "linker") + if (!nav.MoveToChild("linker", _ns)) return; try { ProcessAssemblies (Context, nav.SelectChildren ("assembly", _ns)); + + if (!string.IsNullOrEmpty (_resourceName)) + Context.Annotations.AddResourceToRemove (_resourceAssembly, _resourceName); } catch (Exception ex) { throw new XmlResolutionException (string.Format ("Failed to process XML description: {0}", _xmlDocumentLocation), ex); } diff --git a/external/linker/linker/Mono.Linker.Steps/SweepStep.cs b/external/linker/linker/Mono.Linker.Steps/SweepStep.cs index 26b15544a8..b33b216080 100644 --- a/external/linker/linker/Mono.Linker.Steps/SweepStep.cs +++ b/external/linker/linker/Mono.Linker.Steps/SweepStep.cs @@ -75,11 +75,23 @@ namespace Mono.Linker.Steps { void SweepAssembly (AssemblyDefinition assembly) { - if (Annotations.GetAction (assembly) != AssemblyAction.Link) + switch (Annotations.GetAction (assembly)) { + case AssemblyAction.Link: + if (!IsMarkedAssembly (assembly)) { + RemoveAssembly (assembly); + return; + } + break; + + case AssemblyAction.CopyUsed: + if (!IsMarkedAssembly (assembly)) { + RemoveAssembly (assembly); + } else { + Annotations.SetAction (assembly, AssemblyAction.Copy); + } return; - if (!IsMarkedAssembly (assembly)) { - RemoveAssembly (assembly); + default: return; } @@ -101,6 +113,8 @@ namespace Mono.Linker.Steps { assembly.MainModule.Types.Clear (); foreach (TypeDefinition type in types) assembly.MainModule.Types.Add (type); + + SweepResources (assembly); } bool IsMarkedAssembly (AssemblyDefinition assembly) @@ -115,6 +129,23 @@ namespace Mono.Linker.Steps { SweepReferences (assembly); } + void SweepResources (AssemblyDefinition assembly) + { + var resourcesToRemove = Annotations.GetResourcesToRemove (assembly); + if (resourcesToRemove != null) { + var resources = assembly.MainModule.Resources; + + for (int i = 0; i < resources.Count; i++) { + var resource = resources [i] as EmbeddedResource; + if (resource == null) + continue; + + if (resourcesToRemove.Contains (resource.Name)) + resources.RemoveAt (i--); + } + } + } + void SweepReferences (AssemblyDefinition target) { foreach (var assembly in assemblies) @@ -147,8 +178,8 @@ namespace Mono.Linker.Steps { case AssemblyAction.Copy: // Copy means even if "unlinked" we still want that assembly to be saved back // to disk (OutputStep) without the (removed) reference - Annotations.SetAction (assembly, AssemblyAction.Save); if (!Context.KeepTypeForwarderOnlyAssemblies) { + Annotations.SetAction (assembly, AssemblyAction.Save); ResolveAllTypeReferences (assembly); } break; @@ -224,6 +255,9 @@ namespace Mono.Linker.Steps { if (type.HasNestedTypes) SweepNestedTypes (type); + + if (type.HasInterfaces) + SweepInterfaces (type); } protected void SweepNestedTypes (TypeDefinition type) @@ -239,6 +273,17 @@ namespace Mono.Linker.Steps { } } + protected void SweepInterfaces (TypeDefinition type) + { + for (int i = type.Interfaces.Count - 1; i >= 0; i--) { + var iface = type.Interfaces [i]; + if (Annotations.IsMarked (iface.InterfaceType.Resolve ())) + continue; + InterfaceRemoved (type, iface); + type.Interfaces.RemoveAt (i); + } + } + void SweepMethods (Collection methods) { SweepCollection (methods); @@ -321,5 +366,9 @@ namespace Mono.Linker.Steps { protected virtual void ReferenceRemoved (AssemblyDefinition assembly, AssemblyNameReference reference) { } + + protected virtual void InterfaceRemoved (TypeDefinition type, InterfaceImplementation iface) + { + } } } diff --git a/external/linker/linker/Mono.Linker/Annotations.cs b/external/linker/linker/Mono.Linker/Annotations.cs index 949128f0bb..cb2e14476e 100644 --- a/external/linker/linker/Mono.Linker/Annotations.cs +++ b/external/linker/linker/Mono.Linker/Annotations.cs @@ -50,6 +50,7 @@ namespace Mono.Linker { readonly Dictionary symbol_readers = new Dictionary (); readonly Dictionary> custom_annotations = new Dictionary> (); + readonly Dictionary> resources_to_remove = new Dictionary> (); Stack dependency_stack; System.Xml.XmlWriter writer; @@ -180,6 +181,25 @@ namespace Mono.Linker { throw new NotSupportedException (); } + public HashSet GetResourcesToRemove (AssemblyDefinition assembly) + { + HashSet resources; + if (resources_to_remove.TryGetValue (assembly, out resources)) + return resources; + + return null; + } + + public void AddResourceToRemove (AssemblyDefinition assembly, string name) + { + HashSet resources; + if (!resources_to_remove.TryGetValue (assembly, out resources)) { + resources = resources_to_remove [assembly] = new HashSet (); + } + + resources.Add (name); + } + public void SetPublic (IMetadataTokenProvider provider) { public_api.Add (provider); diff --git a/external/linker/linker/Mono.Linker/AssemblyAction.cs b/external/linker/linker/Mono.Linker/AssemblyAction.cs index 14282b376b..cfd2874ab7 100644 --- a/external/linker/linker/Mono.Linker/AssemblyAction.cs +++ b/external/linker/linker/Mono.Linker/AssemblyAction.cs @@ -32,8 +32,12 @@ namespace Mono.Linker { // Ignore the assembly Skip, // Copy the existing files, assembly and symbols, into the output destination. E.g. .dll and .mdb - // The linker still analyze the assemblies (to know what they require) but does not modify them + // The linker still analyzes the assemblies (to know what they require) but does not modify them. Copy, + // Copy the existing files, assembly and symbols, into the output destination if and only if + // anything from the assembly is used. + // The linker still analyzes the assemblies (to know what they require) but does not modify them. + CopyUsed, // Link the assembly Link, // Remove the assembly from the output diff --git a/external/linker/linker/Mono.Linker/Driver.cs b/external/linker/linker/Mono.Linker/Driver.cs index 16616b437e..9eb9ab16e4 100644 --- a/external/linker/linker/Mono.Linker/Driver.cs +++ b/external/linker/linker/Mono.Linker/Driver.cs @@ -95,6 +95,11 @@ namespace Mono.Linker { if (token.Length < 3) Usage ("Option is too short"); + if (token == "--skip-unresolved") { + context.IgnoreUnresolved = bool.Parse (GetParam ()); + continue; + } + switch (token [2]) { case 'v': Version (); @@ -120,6 +125,9 @@ namespace Mono.Linker { case 'c': context.CoreAction = ParseAssemblyAction (GetParam ()); break; + case 'u': + context.UserAction = ParseAssemblyAction (GetParam ()); + break; case 'p': AssemblyAction action = ParseAssemblyAction (GetParam ()); context.Actions [GetParam ()] = action; @@ -275,6 +283,7 @@ namespace Mono.Linker { { LinkContext context = new LinkContext (pipeline); context.CoreAction = AssemblyAction.Skip; + context.UserAction = AssemblyAction.Link; context.OutputDirectory = "output"; return context; } @@ -290,25 +299,27 @@ namespace Mono.Linker { Console.WriteLine ("monolinker [options] -x|-a|-i file"); #endif - Console.WriteLine (" --about About the {0}", _linker); - Console.WriteLine (" --version Print the version number of the {0}", _linker); - Console.WriteLine (" -out Specify the output directory, default to `output'"); - Console.WriteLine (" -c Action on the core assemblies, skip, copy or link, default to skip"); - Console.WriteLine (" -p Action per assembly"); - Console.WriteLine (" -s Add a new step to the pipeline."); - Console.WriteLine (" -t Keep assemblies in which only type forwarders are referenced."); - Console.WriteLine (" -d Add a directory where the linker will look for assemblies"); - Console.WriteLine (" -b Generate debug symbols for each linked module (true or false)"); - Console.WriteLine (" -g Generate a new unique guid for each linked module (true or false)"); - Console.WriteLine (" -v Keep memebers needed by debugger attributes (true or false)"); - Console.WriteLine (" -l List of i18n assemblies to copy to the output directory"); - Console.WriteLine (" separated with a comma: none,all,cjk,mideast,other,rare,west"); - Console.WriteLine (" default is all"); - Console.WriteLine (" -x Link from an XML descriptor"); - Console.WriteLine (" -a Link from a list of assemblies"); - Console.WriteLine (" -r Link from a list of assemblies using roots visible outside of the assembly"); - Console.WriteLine (" -i Link from an mono-api-info descriptor"); - Console.WriteLine (" -z Include default preservations (true or false), default to true"); + Console.WriteLine (" --about About the {0}", _linker); + Console.WriteLine (" --version Print the version number of the {0}", _linker); + Console.WriteLine (" --skip-unresolved Ignore unresolved types and methods (true or false)"); + Console.WriteLine (" -out Specify the output directory, default to `output'"); + Console.WriteLine (" -c Action on the core assemblies, skip, copy, copyused or link, default to skip"); + Console.WriteLine (" -u Action on the user assemblies, skip, copy, copyused or link, default to link"); + Console.WriteLine (" -p Action per assembly"); + Console.WriteLine (" -s Add a new step to the pipeline."); + Console.WriteLine (" -t Keep assemblies in which only type forwarders are referenced."); + Console.WriteLine (" -d Add a directory where the linker will look for assemblies"); + Console.WriteLine (" -b Generate debug symbols for each linked module (true or false)"); + Console.WriteLine (" -g Generate a new unique guid for each linked module (true or false)"); + Console.WriteLine (" -v Keep memebers needed by debugger attributes (true or false)"); + Console.WriteLine (" -l List of i18n assemblies to copy to the output directory"); + Console.WriteLine (" separated with a comma: none,all,cjk,mideast,other,rare,west"); + Console.WriteLine (" default is all"); + Console.WriteLine (" -x Link from an XML descriptor"); + Console.WriteLine (" -a Link from a list of assemblies"); + Console.WriteLine (" -r Link from a list of assemblies using roots visible outside of the assembly"); + Console.WriteLine (" -i Link from an mono-api-info descriptor"); + Console.WriteLine (" -z Include default preservations (true or false), default to true"); Console.WriteLine (""); Environment.Exit (1); diff --git a/external/linker/linker/Mono.Linker/LinkContext.cs b/external/linker/linker/Mono.Linker/LinkContext.cs index 155e202c18..44793eb41a 100644 --- a/external/linker/linker/Mono.Linker/LinkContext.cs +++ b/external/linker/linker/Mono.Linker/LinkContext.cs @@ -38,12 +38,14 @@ namespace Mono.Linker { Pipeline _pipeline; AssemblyAction _coreAction; + AssemblyAction _userAction; Dictionary _actions; string _outputDirectory; readonly Dictionary _parameters; bool _linkSymbols; bool _keepTypeForwarderOnlyAssemblies; bool _keepMembersForDebuggerAttributes; + bool _ignoreUnresolved; AssemblyResolver _resolver; @@ -71,6 +73,11 @@ namespace Mono.Linker { set { _coreAction = value; } } + public AssemblyAction UserAction { + get { return _userAction; } + set { _userAction = value; } + } + public bool LinkSymbols { get { return _linkSymbols; } set { _linkSymbols = value; } @@ -88,6 +95,12 @@ namespace Mono.Linker { set { _keepMembersForDebuggerAttributes = value; } } + public bool IgnoreUnresolved + { + get { return _ignoreUnresolved; } + set { _ignoreUnresolved = value; } + } + public System.Collections.IDictionary Actions { get { return _actions; } } @@ -247,7 +260,7 @@ namespace Mono.Linker { } else if (IsCore (name)) { action = _coreAction; } else { - action = AssemblyAction.Link; + action = _userAction; } _annotations.SetAction (assembly, action); diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptResourceAttribute.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptResourceAttribute.cs new file mode 100644 index 0000000000..0106dfd1a4 --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptResourceAttribute.cs @@ -0,0 +1,15 @@ +using System; + +namespace Mono.Linker.Tests.Cases.Expectations.Assertions { + /// + /// Verifies that a resource exists in the test case assembly + /// + [AttributeUsage (AttributeTargets.Class, AllowMultiple = true, Inherited = false)] + public class KeptResourceAttribute : KeptAttribute { + public KeptResourceAttribute (string name) + { + if (string.IsNullOrEmpty (name)) + throw new ArgumentException ("Value cannot be null or empty.", nameof (name)); + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptResourceInAssemblyAttribute.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptResourceInAssemblyAttribute.cs new file mode 100644 index 0000000000..c17fed964d --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptResourceInAssemblyAttribute.cs @@ -0,0 +1,18 @@ +using System; + +namespace Mono.Linker.Tests.Cases.Expectations.Assertions { + /// + /// Verifies that an embedded resource exists in an assembly + /// + [AttributeUsage (AttributeTargets.Class, AllowMultiple = true, Inherited = false)] + public class KeptResourceInAssemblyAttribute : BaseInAssemblyAttribute { + public KeptResourceInAssemblyAttribute (string assemblyFileName, string resourceName) + { + if (string.IsNullOrEmpty (assemblyFileName)) + throw new ArgumentNullException (nameof (assemblyFileName)); + + if (string.IsNullOrEmpty (resourceName)) + throw new ArgumentNullException (nameof (resourceName)); + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedResourceInAssemblyAttribute.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedResourceInAssemblyAttribute.cs new file mode 100644 index 0000000000..e05b7ed808 --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedResourceInAssemblyAttribute.cs @@ -0,0 +1,18 @@ +using System; + +namespace Mono.Linker.Tests.Cases.Expectations.Assertions { + /// + /// Verifies that an embedded resource was removed from an assembly + /// + [AttributeUsage (AttributeTargets.Class, AllowMultiple = true, Inherited = false)] + public class RemovedResourceInAssemblyAttribute : BaseInAssemblyAttribute { + public RemovedResourceInAssemblyAttribute (string assemblyFileName, string resourceName) + { + if (string.IsNullOrEmpty (assemblyFileName)) + throw new ArgumentNullException (nameof (assemblyFileName)); + + if (string.IsNullOrEmpty (resourceName)) + throw new ArgumentNullException (nameof (resourceName)); + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SandboxDependencyAttribute.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SandboxDependencyAttribute.cs index c204a92db4..df8033b468 100644 --- a/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SandboxDependencyAttribute.cs +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SandboxDependencyAttribute.cs @@ -1,10 +1,10 @@ using System; namespace Mono.Linker.Tests.Cases.Expectations.Metadata { - [AttributeUsage (AttributeTargets.Class)] + [AttributeUsage (AttributeTargets.Class, AllowMultiple = true)] public class SandboxDependencyAttribute : BaseMetadataAttribute { - public SandboxDependencyAttribute (string relativePathToFile) + public SandboxDependencyAttribute (string relativePathToFile, string destinationFileName = null) { if (string.IsNullOrEmpty (relativePathToFile)) throw new ArgumentException ("Value cannot be null or empty.", nameof (relativePathToFile)); diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs new file mode 100644 index 0000000000..ceb0842eb7 --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAssemblyNameAttribute.cs @@ -0,0 +1,12 @@ +using System; + +namespace Mono.Linker.Tests.Cases.Expectations.Metadata { + [AttributeUsage (AttributeTargets.Class, AllowMultiple = false)] + public class SetupCompileAssemblyNameAttribute : BaseMetadataAttribute { + public SetupCompileAssemblyNameAttribute (string outputName) + { + if (string.IsNullOrEmpty (outputName)) + throw new ArgumentNullException (nameof (outputName)); + } + } +} \ No newline at end of file diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileResourceAttribute.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileResourceAttribute.cs new file mode 100644 index 0000000000..b86a162c58 --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileResourceAttribute.cs @@ -0,0 +1,12 @@ +using System; + +namespace Mono.Linker.Tests.Cases.Expectations.Metadata { + [AttributeUsage (AttributeTargets.Class, AllowMultiple = true)] + public class SetupCompileResourceAttribute : BaseMetadataAttribute { + public SetupCompileResourceAttribute (string relativePathToFile, string destinationFileName = null) + { + if (string.IsNullOrEmpty (relativePathToFile)) + throw new ArgumentException ("Value cannot be null or empty.", nameof (relativePathToFile)); + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj index 5c063734c8..5b0c65be08 100644 --- a/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj @@ -45,13 +45,17 @@ + + + + @@ -66,6 +70,7 @@ + + + + + + \ No newline at end of file diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj index b293bb5fbd..e3e4ee0468 100644 --- a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj @@ -59,10 +59,17 @@ + + + + + + + @@ -140,6 +147,7 @@ + @@ -151,12 +159,19 @@ + + + + + + + diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly.xml b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly.xml new file mode 100644 index 0000000000..8494ad0139 --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled.xml b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled.xml new file mode 100644 index 0000000000..11c0c1f42a --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip.xml b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip.xml new file mode 100644 index 0000000000..ea60ba315b --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsProcessed.xml b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsProcessed.xml new file mode 100644 index 0000000000..518addf3df --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/EmbeddedLinkXmlFileIsProcessed.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/NonLinkerEmbeddedResourceHasNoImpact.xml b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/NonLinkerEmbeddedResourceHasNoImpact.xml new file mode 100644 index 0000000000..1fb65aa9fa --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/Dependencies/NonLinkerEmbeddedResourceHasNoImpact.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly.cs new file mode 100644 index 0000000000..69d1d1dc42 --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly.cs @@ -0,0 +1,19 @@ +using System; +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; + +namespace Mono.Linker.Tests.Cases.Resources { + [SetupLinkerCoreAction ("link")] + [IncludeBlacklistStep (true)] + [SetupCompileResource ("Dependencies/EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly.xml", "NotMatchingAnAssemblyName.xml")] + [SkipPeVerify] + [KeptResource ("NotMatchingAnAssemblyName.xml")] + public class EmbeddedLinkXmlFileIsNotProcessedIfNameDoesNotMatchAnAssembly { + public static void Main () + { + } + + public class Unused { + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled.cs new file mode 100644 index 0000000000..604520899a --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled.cs @@ -0,0 +1,21 @@ +using System; +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; + +namespace Mono.Linker.Tests.Cases.Resources { + [SetupLinkerCoreAction ("link")] + [IncludeBlacklistStep (false)] + + // We need to rename the resource so that it matches the name of an assembly being processed. This is a requriement of the black list step + [SetupCompileResource ("Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled.xml", "test.xml")] + [SkipPeVerify] + [KeptResource ("test.xml")] + public class EmbeddedLinkXmlFileIsNotProcessedWhenBlacklistStepIsDisabled { + public static void Main () + { + } + + public class Unused { + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip.cs new file mode 100644 index 0000000000..469ccf59fb --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip.cs @@ -0,0 +1,23 @@ +using System; +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; + +namespace Mono.Linker.Tests.Cases.Resources { + // I'm not sure why it was decided all link xml resources should be skipped when core link is set to skip, but that's the behavior + // that exists today and I don't have a reason to change it right now + [SetupLinkerCoreAction ("skip")] + [IncludeBlacklistStep (true)] + + // We need to rename the resource so that it matches the name of an assembly being processed. This is a requriement of the black list step + [SetupCompileResource ("Dependencies/EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip.xml", "test.xml")] + [SkipPeVerify] + [KeptResource ("test.xml")] + public class EmbeddedLinkXmlFileIsNotProcessedWhenCoreLinkActionIsSkip { + public static void Main () + { + } + + public class Unused { + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsProcessed.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsProcessed.cs new file mode 100644 index 0000000000..c7a043aaf8 --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/EmbeddedLinkXmlFileIsProcessed.cs @@ -0,0 +1,22 @@ +using System; +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; + +namespace Mono.Linker.Tests.Cases.Resources { + [SetupLinkerCoreAction ("link")] + [IncludeBlacklistStep (true)] + + // We need to rename the resource so that it matches the name of an assembly being processed. This is a requriement of the black list step + [SetupCompileResource ("Dependencies/EmbeddedLinkXmlFileIsProcessed.xml", "test.xml")] + [SkipPeVerify] + public class EmbeddedLinkXmlFileIsProcessed { + public static void Main () + { + } + + [Kept] + [KeptMember (".ctor()")] + public class Unused { + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/NonLinkerEmbeddedResourceHasNoImpact.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/NonLinkerEmbeddedResourceHasNoImpact.cs new file mode 100644 index 0000000000..b2112b92f5 --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/Resources/NonLinkerEmbeddedResourceHasNoImpact.cs @@ -0,0 +1,18 @@ +using System; +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; + +namespace Mono.Linker.Tests.Cases.Resources { + [SetupLinkerCoreAction ("link")] + [IncludeBlacklistStep (true)] + + // We need to rename the resource so that it matches the name of an assembly being processed. This is a requriement of the black list step + [SetupCompileResource ("Dependencies/NonLinkerEmbeddedResourceHasNoImpact.xml", "test.xml")] + [SkipPeVerify] + [KeptResource ("test.xml")] + public class NonLinkerEmbeddedResourceHasNoImpact { + public static void Main () + { + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/TestFramework/Dependencies/VerifyResourceInAssemblyAttributesBehavior.txt b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/TestFramework/Dependencies/VerifyResourceInAssemblyAttributesBehavior.txt new file mode 100644 index 0000000000..540b7baa7f --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/TestFramework/Dependencies/VerifyResourceInAssemblyAttributesBehavior.txt @@ -0,0 +1 @@ +Resource that is kept \ No newline at end of file diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.Cases/TestFramework/VerifyResourceInAssemblyAttributesBehavior.cs b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/TestFramework/VerifyResourceInAssemblyAttributesBehavior.cs new file mode 100644 index 0000000000..c54be7565a --- /dev/null +++ b/external/linker/linker/Tests/Mono.Linker.Tests.Cases/TestFramework/VerifyResourceInAssemblyAttributesBehavior.cs @@ -0,0 +1,18 @@ +using System; +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; + +namespace Mono.Linker.Tests.Cases.TestFramework { + [SetupCompileResource ("Dependencies/VerifyResourceInAssemblyAttributesBehavior.txt")] + [KeptResource ("VerifyResourceInAssemblyAttributesBehavior.txt")] + // These are technically redundant, but the goal of this test is to verify the attributes are working which we can do + // by using them on the test case assembly even though you would normally use these attributes for other checking other + // supporting assemblies + [KeptResourceInAssembly ("test.exe", "VerifyResourceInAssemblyAttributesBehavior.txt")] + [RemovedResourceInAssembly ("test.exe", "NeverExistedResource.txt")] + public class VerifyResourceInAssemblyAttributesBehavior { + public static void Main () + { + } + } +} diff --git a/external/linker/linker/Tests/Mono.Linker.Tests.csproj b/external/linker/linker/Tests/Mono.Linker.Tests.csproj index 7c69b2d6f0..afcf94268a 100644 --- a/external/linker/linker/Tests/Mono.Linker.Tests.csproj +++ b/external/linker/linker/Tests/Mono.Linker.Tests.csproj @@ -74,6 +74,7 @@ + diff --git a/external/linker/linker/Tests/TestCases/TestDatabase.cs b/external/linker/linker/Tests/TestCases/TestDatabase.cs index e7dd072c91..38165b6288 100644 --- a/external/linker/linker/Tests/TestCases/TestDatabase.cs +++ b/external/linker/linker/Tests/TestCases/TestDatabase.cs @@ -54,6 +54,11 @@ namespace Mono.Linker.Tests.TestCases return NUnitCasesByPrefix("References."); } + public static IEnumerable ResourcesTests () + { + return NUnitCasesByPrefix ("Resources."); + } + public static IEnumerable TypeForwardingTests () { return NUnitCasesByPrefix ("TypeForwarding."); @@ -77,6 +82,7 @@ namespace Mono.Linker.Tests.TestCases .Concat(StaticsTests()) .Concat(InteropTests()) .Concat(ReferencesTests ()) + .Concat(ResourcesTests ()) .Concat(TypeForwardingTests ()) .Concat(TestFrameworkTests ()) .Select(c => ((TestCase)c.Arguments[0]).ReconstructedFullTypeName)); diff --git a/external/linker/linker/Tests/TestCases/TestSuites.cs b/external/linker/linker/Tests/TestCases/TestSuites.cs index e5be82d622..afb3b499fb 100644 --- a/external/linker/linker/Tests/TestCases/TestSuites.cs +++ b/external/linker/linker/Tests/TestCases/TestSuites.cs @@ -60,6 +60,12 @@ namespace Mono.Linker.Tests.TestCases Run(testCase); } + [TestCaseSource (typeof (TestDatabase), nameof (TestDatabase.ResourcesTests))] + public void ResourcesTests (TestCase testCase) + { + Run (testCase); + } + [TestCaseSource (typeof (TestDatabase), nameof (TestDatabase.TypeForwardingTests))] public void TypeForwardingTests (TestCase testCase) { diff --git a/external/linker/linker/Tests/TestCasesRunner/AssemblyChecker.cs b/external/linker/linker/Tests/TestCasesRunner/AssemblyChecker.cs index 7a5132b95a..a785d55b32 100644 --- a/external/linker/linker/Tests/TestCasesRunner/AssemblyChecker.cs +++ b/external/linker/linker/Tests/TestCasesRunner/AssemblyChecker.cs @@ -28,6 +28,8 @@ namespace Mono.Linker.Tests.TestCasesRunner { VerifyCustomAttributes (linkedAssembly, originalAssembly); + VerifyResources (originalAssembly, linkedAssembly); + linkedMembers = new HashSet (linkedAssembly.MainModule.AllMembers ().Select (s => { return s.FullName; }), StringComparer.Ordinal); @@ -298,6 +300,14 @@ namespace Mono.Linker.Tests.TestCasesRunner { linkedMembers.Remove (srcField.FullName); } + void VerifyResources (AssemblyDefinition original, AssemblyDefinition linked) + { + var expectedResources = original.MainModule.AllDefinedTypes () + .SelectMany (t => GetCustomAttributeCtorValues (t, nameof (KeptResourceAttribute))); + + Assert.That (linked.MainModule.Resources.Select (r => r.Name), Is.EquivalentTo (expectedResources)); + } + static void VerifyCustomAttributes (ICustomAttributeProvider src, ICustomAttributeProvider linked) { var expectedAttrs = new List (GetCustomAttributeCtorValues (src, nameof (KeptAttributeAttribute))); diff --git a/external/linker/linker/Tests/TestCasesRunner/CompilerOptions.cs b/external/linker/linker/Tests/TestCasesRunner/CompilerOptions.cs index 5929c8b8bb..a0273deb32 100644 --- a/external/linker/linker/Tests/TestCasesRunner/CompilerOptions.cs +++ b/external/linker/linker/Tests/TestCasesRunner/CompilerOptions.cs @@ -7,5 +7,6 @@ namespace Mono.Linker.Tests.TestCasesRunner { public NPath[] SourceFiles; public string[] Defines; public NPath[] References; + public NPath[] Resources; } } diff --git a/external/linker/linker/Tests/TestCasesRunner/ResultChecker.cs b/external/linker/linker/Tests/TestCasesRunner/ResultChecker.cs index 1deef58705..c2cba8aa26 100644 --- a/external/linker/linker/Tests/TestCasesRunner/ResultChecker.cs +++ b/external/linker/linker/Tests/TestCasesRunner/ResultChecker.cs @@ -132,6 +132,12 @@ namespace Mono.Linker.Tests.TestCasesRunner { if (linkedAssembly.MainModule.ExportedTypes.Any (l => l.Name == expectedTypeName)) Assert.Fail ($"Forwarder `{expectedTypeName}' should have been removed"); + break; + case nameof (KeptResourceInAssemblyAttribute): + VerifyKeptResourceInAssembly (checkAttrInAssembly); + break; + case nameof (RemovedResourceInAssemblyAttribute): + VerifyRemovedResourceInAssembly (checkAttrInAssembly); break; default: UnhandledOtherAssemblyAssertion (expectedTypeName, checkAttrInAssembly, linkedType); @@ -220,6 +226,22 @@ namespace Mono.Linker.Tests.TestCasesRunner { } } + void VerifyKeptResourceInAssembly (CustomAttribute inAssemblyAttribute) + { + var assembly = ResolveLinkedAssembly (inAssemblyAttribute.ConstructorArguments [0].Value.ToString ()); + var resourceName = inAssemblyAttribute.ConstructorArguments [1].Value.ToString (); + + Assert.That (assembly.MainModule.Resources.Select (r => r.Name), Has.Member (resourceName)); + } + + void VerifyRemovedResourceInAssembly (CustomAttribute inAssemblyAttribute) + { + var assembly = ResolveLinkedAssembly (inAssemblyAttribute.ConstructorArguments [0].Value.ToString ()); + var resourceName = inAssemblyAttribute.ConstructorArguments [1].Value.ToString (); + + Assert.That (assembly.MainModule.Resources.Select (r => r.Name), Has.No.Member (resourceName)); + } + protected TypeDefinition GetOriginalTypeFromInAssemblyAttribute (CustomAttribute inAssemblyAttribute) { var attributeValueAsTypeReference = inAssemblyAttribute.ConstructorArguments [1].Value as TypeReference; diff --git a/external/linker/linker/Tests/TestCasesRunner/SourceAndDestinationPair.cs b/external/linker/linker/Tests/TestCasesRunner/SourceAndDestinationPair.cs new file mode 100644 index 0000000000..762887a137 --- /dev/null +++ b/external/linker/linker/Tests/TestCasesRunner/SourceAndDestinationPair.cs @@ -0,0 +1,9 @@ +using System; +using Mono.Linker.Tests.Extensions; + +namespace Mono.Linker.Tests.TestCasesRunner { + public class SourceAndDestinationPair { + public NPath Source; + public string DestinationFileName; + } +} diff --git a/external/linker/linker/Tests/TestCasesRunner/TestCaseCompiler.cs b/external/linker/linker/Tests/TestCasesRunner/TestCaseCompiler.cs index 4c403ccdbd..6184e3cd21 100644 --- a/external/linker/linker/Tests/TestCasesRunner/TestCaseCompiler.cs +++ b/external/linker/linker/Tests/TestCasesRunner/TestCaseCompiler.cs @@ -24,7 +24,7 @@ namespace Mono.Linker.Tests.TestCasesRunner { _metadataProvider = metadataProvider; } - public NPath CompileTestIn (NPath outputDirectory, string outputName, IEnumerable sourceFiles, IEnumerable references, IEnumerable defines) + public NPath CompileTestIn (NPath outputDirectory, string outputName, IEnumerable sourceFiles, IEnumerable references, IEnumerable defines, NPath[] resources) { var originalReferences = references.Select (r => r.ToNPath ()).ToArray (); var originalDefines = defines?.ToArray () ?? new string [0]; @@ -38,7 +38,8 @@ namespace Mono.Linker.Tests.TestCasesRunner { outputDirectory.Combine (outputName), sourceFiles.Select (s => s.ToNPath ()).ToArray (), allTestCaseReferences, - originalDefines); + originalDefines, + resources); var testAssembly = CompileAssembly (options); @@ -55,14 +56,15 @@ namespace Mono.Linker.Tests.TestCasesRunner { { } - protected virtual CompilerOptions CreateOptionsForTestCase (NPath outputPath, NPath[] sourceFiles, NPath[] references, string[] defines) + protected virtual CompilerOptions CreateOptionsForTestCase (NPath outputPath, NPath[] sourceFiles, NPath[] references, string[] defines, NPath[] resources) { return new CompilerOptions { OutputPath = outputPath, SourceFiles = sourceFiles, References = references, - Defines = defines.Concat (_metadataProvider.GetDefines ()).ToArray () + Defines = defines.Concat (_metadataProvider.GetDefines ()).ToArray (), + Resources = resources }; } @@ -177,6 +179,9 @@ namespace Mono.Linker.Tests.TestCasesRunner { compilerParameters.ReferencedAssemblies.AddRange (options.References.Select (r => r.ToString ()).ToArray ()); + if (options.Resources != null) + compilerParameters.EmbeddedResources.AddRange (options.Resources.Select (r => r.ToString ()).ToArray ()); + return compilerParameters; } } diff --git a/external/linker/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs b/external/linker/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs index fbd5f0fe3b..6380a47c94 100644 --- a/external/linker/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs +++ b/external/linker/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs @@ -52,6 +52,13 @@ namespace Mono.Linker.Tests.TestCasesRunner { } } + public virtual IEnumerable GetResources () + { + return _testCaseTypeDefinition.CustomAttributes + .Where (attr => attr.AttributeType.Name == nameof (SetupCompileResourceAttribute)) + .Select (GetSourceAndRelativeDestinationValue); + } + public virtual IEnumerable GetExtraLinkerSearchDirectories () { yield break; @@ -69,15 +76,11 @@ namespace Mono.Linker.Tests.TestCasesRunner { return false; } - public virtual IEnumerable AdditionalFilesToSandbox () + public virtual IEnumerable AdditionalFilesToSandbox () { - foreach (var attr in _testCaseTypeDefinition.CustomAttributes) { - if (attr.AttributeType.Name != nameof (SandboxDependencyAttribute)) - continue; - - var relativeDepPath = ((string) attr.ConstructorArguments.First ().Value).ToNPath (); - yield return _testCase.SourceFile.Parent.Combine (relativeDepPath); - } + return _testCaseTypeDefinition.CustomAttributes + .Where (attr => attr.AttributeType.Name == nameof (SandboxDependencyAttribute)) + .Select (GetSourceAndRelativeDestinationValue); } public virtual IEnumerable GetSetupCompileAssembliesBefore () @@ -101,6 +104,11 @@ namespace Mono.Linker.Tests.TestCasesRunner { .Select (attr => (string) attr.ConstructorArguments.First ().Value); } + public virtual string GetAssemblyName () + { + return GetOptionAttributeValue (nameof (SetupCompileAssemblyNameAttribute), "test.exe"); + } + T GetOptionAttributeValue (string attributeName, T defaultValue) { var attribute = _testCaseTypeDefinition.CustomAttributes.FirstOrDefault (attr => attr.AttributeType.Name == attributeName); @@ -110,6 +118,18 @@ namespace Mono.Linker.Tests.TestCasesRunner { return defaultValue; } + SourceAndDestinationPair GetSourceAndRelativeDestinationValue (CustomAttribute attribute) + { + var relativeSource = (string) attribute.ConstructorArguments.First ().Value; + var destinationFileName = (string) attribute.ConstructorArguments [1].Value; + var fullSource = _testCase.SourceFile.Parent.Combine (relativeSource); + return new SourceAndDestinationPair + { + Source = fullSource, + DestinationFileName = string.IsNullOrEmpty (destinationFileName) ? fullSource.FileName : destinationFileName + }; + } + private SetupCompileInfo CreateSetupCompileAssemblyInfo (CustomAttribute attribute) { var ctorArguments = attribute.ConstructorArguments; diff --git a/external/linker/linker/Tests/TestCasesRunner/TestCaseSandbox.cs b/external/linker/linker/Tests/TestCasesRunner/TestCaseSandbox.cs index 17f66dd0cb..9ef46540ba 100644 --- a/external/linker/linker/Tests/TestCasesRunner/TestCaseSandbox.cs +++ b/external/linker/linker/Tests/TestCasesRunner/TestCaseSandbox.cs @@ -36,6 +36,7 @@ namespace Mono.Linker.Tests.TestCasesRunner { InputDirectory = _directory.Combine ("input").EnsureDirectoryExists (); OutputDirectory = _directory.Combine ("output").EnsureDirectoryExists (); ExpectationsDirectory = _directory.Combine ("expectations").EnsureDirectoryExists (); + ResourcesDirectory = _directory.Combine ("resources").EnsureDirectoryExists (); } public NPath InputDirectory { get; } @@ -44,6 +45,8 @@ namespace Mono.Linker.Tests.TestCasesRunner { public NPath ExpectationsDirectory { get; } + public NPath ResourcesDirectory { get; } + public IEnumerable SourceFiles { get { return _directory.Files ("*.cs"); } } @@ -52,6 +55,8 @@ namespace Mono.Linker.Tests.TestCasesRunner { get { return InputDirectory.Files ("*.xml"); } } + public IEnumerable ResourceFiles => ResourcesDirectory.Files (); + public virtual void Populate (TestCaseMetadaProvider metadataProvider) { _testCase.SourceFile.Copy (_directory); @@ -62,7 +67,11 @@ namespace Mono.Linker.Tests.TestCasesRunner { CopyToInputAndExpectations (GetExpectationsAssemblyPath ()); foreach (var dep in metadataProvider.AdditionalFilesToSandbox ()) { - dep.FileMustExist ().Copy (_directory); + dep.Source.FileMustExist ().Copy (_directory.Combine (dep.DestinationFileName)); + } + + foreach (var res in metadataProvider.GetResources ()) { + res.Source.FileMustExist ().Copy (ResourcesDirectory.Combine (res.DestinationFileName)); } foreach (var compileRefInfo in metadataProvider.GetSetupCompileAssembliesBefore ()) diff --git a/external/linker/linker/Tests/TestCasesRunner/TestRunner.cs b/external/linker/linker/Tests/TestCasesRunner/TestRunner.cs index b9255435ac..c00618b459 100644 --- a/external/linker/linker/Tests/TestCasesRunner/TestRunner.cs +++ b/external/linker/linker/Tests/TestCasesRunner/TestRunner.cs @@ -23,7 +23,7 @@ namespace Mono.Linker.Tests.TestCasesRunner { var sandbox = Sandbox (testCase, metadataProvider); var compilationResult = Compile (sandbox, metadataProvider); -// PrepForLink (sandbox, compilationResult); + PrepForLink (sandbox, compilationResult); return Link (testCase, sandbox, compilationResult, metadataProvider); } } @@ -40,20 +40,21 @@ namespace Mono.Linker.Tests.TestCasesRunner { var compiler = _factory.CreateCompiler (sandbox, metadataProvider); var sourceFiles = sandbox.SourceFiles.Select(s => s.ToString()).ToArray(); + var assemblyName = metadataProvider.GetAssemblyName (); + var references = metadataProvider.GetReferencedAssemblies(sandbox.InputDirectory); - var inputAssemblyPath = compiler.CompileTestIn (sandbox.InputDirectory, "test.exe", sourceFiles, references, null); + var resources = sandbox.ResourceFiles.ToArray (); + var inputAssemblyPath = compiler.CompileTestIn (sandbox.InputDirectory, assemblyName, sourceFiles, references, null, resources); references = metadataProvider.GetReferencedAssemblies(sandbox.ExpectationsDirectory); - var expectationsAssemblyPath = compiler.CompileTestIn (sandbox.ExpectationsDirectory, "test.exe", sourceFiles, references, new [] { "INCLUDE_EXPECTATIONS" }); + var expectationsAssemblyPath = compiler.CompileTestIn (sandbox.ExpectationsDirectory, assemblyName, sourceFiles, references, new [] { "INCLUDE_EXPECTATIONS" }, resources); return new ManagedCompilationResult (inputAssemblyPath, expectationsAssemblyPath); } -/* - private void PrepForLink (TestCaseSandbox sandbox, ManagedCompilationResult compilationResult) + + protected virtual void PrepForLink (TestCaseSandbox sandbox, ManagedCompilationResult compilationResult) { - var entryPointLinkXml = sandbox.InputDirectory.Combine ("entrypoint.xml"); - LinkXmlHelpers.WriteXmlFileToPreserveEntryPoint (compilationResult.InputAssemblyPath, entryPointLinkXml); } -*/ + private LinkedTestCaseResult Link (TestCase testCase, TestCaseSandbox sandbox, ManagedCompilationResult compilationResult, TestCaseMetadaProvider metadataProvider) { var linker = _factory.CreateLinker (); diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs index f0345cbf88..e75ea945e1 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Json { @@ -152,7 +152,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { /// "version": 2, /// "targets": { /// ".NETFramework,Version=v4.5": { - /// "Newtonsoft.Json/8.0.3": { + /// "Newtonsoft.Json/9.0.1": { /// "type": "package", /// "compile": { /// "lib/net45/Newtonsoft.Json.dll": {} @@ -164,7 +164,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { /// } /// }, /// "libraries": { - /// "Newtonsoft.Json/8.0.3": { + /// "Newtonsoft.Json/9.0.1": { /// "sha512": "KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==", /// "type": " [rest of string was truncated]";. /// @@ -180,7 +180,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { /// "version": 2, /// "targets": { /// ".NETFramework,Version=v4.5": { - /// "Newtonsoft.Json/8.0.3": { + /// "Newtonsoft.Json/9.0.1": { /// "type": "package", /// "compile": { /// "lib/net45/Newtonsoft.Json.dll": {} @@ -204,6 +204,36 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { } } + /// + /// Looks up a localized string similar to { + /// "locked": false, + /// "version": 2, + /// "targets": { + /// ".NETFramework,Version=v4.5": { + /// "Newtonsoft.Json/9.0.1": { + /// "type": "package", + /// "compile": { + /// "lib/net45/Newtonsoft.Json.dll": {} + /// }, + /// "runtime": { + /// "lib/net45/Newtonsoft.Json.dll": {} + /// } + /// } + /// }, + /// ".NETFramework,Version=v4.6": { + /// "FluentAssertions/3.4.1": { + /// "frameworkAssemblies": [ + /// "System.Xml", + /// "System.Xml.Linq" + /// ], + /// [rest of string was truncated]";. + /// + internal static string MultipleProjectFileDependencyGroups_CaseMismatch { + get { + return ResourceManager.GetString("MultipleProjectFileDependencyGroups_CaseMismatch", resourceCulture); + } + } + /// /// Looks up a localized string similar to { /// "locked": false, diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx index a59102f3f4..993a1fef5b 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx @@ -148,4 +148,7 @@ ProjectDependency.assets.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + multipleprojectfiledependencygroups_casemismatch.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + \ No newline at end of file diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/LockFileWithWithSpecifiedPackageFolders.json b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/LockFileWithWithSpecifiedPackageFolders.json index 6df6a2a8b4..b529b16673 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/LockFileWithWithSpecifiedPackageFolders.json +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/LockFileWithWithSpecifiedPackageFolders.json @@ -3,7 +3,7 @@ "version": 2, "targets": { ".NETFramework,Version=v4.5": { - "Newtonsoft.Json/8.0.3": { + "Newtonsoft.Json/9.0.1": { "type": "package", "compile": { "lib/net45/Newtonsoft.Json.dll": {} @@ -15,10 +15,10 @@ } }, "libraries": { - "Newtonsoft.Json/8.0.3": { + "Newtonsoft.Json/9.0.1": { "sha512": "KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==", "type": "package", - "path": "newtonsoft.json/8.0.3", + "path": "newtonsoft.json/9.0.1", "files": [ "lib/net20/Newtonsoft.Json.dll", "lib/net20/Newtonsoft.Json.xml", @@ -32,7 +32,7 @@ "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml", "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.dll", "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.xml", - "newtonsoft.json.8.0.3.nupkg.sha512", + "newtonsoft.json.9.0.1.nupkg.sha512", "newtonsoft.json.nuspec", "tools/install.ps1" ] diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups.json b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups.json index aced1cec7f..a14ad6d5e1 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups.json +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups.json @@ -3,7 +3,7 @@ "version": 2, "targets": { ".NETFramework,Version=v4.5": { - "Newtonsoft.Json/8.0.3": { + "Newtonsoft.Json/9.0.1": { "type": "package", "compile": { "lib/net45/Newtonsoft.Json.dll": {} @@ -31,10 +31,10 @@ } }, "libraries": { - "Newtonsoft.Json/8.0.3": { + "Newtonsoft.Json/9.0.1": { "sha512": "KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==", "type": "package", - "path": "newtonsoft.json/8.0.3", + "path": "newtonsoft.json/9.0.1", "files": [ "lib/net20/Newtonsoft.Json.dll", "lib/net20/Newtonsoft.Json.xml", @@ -48,7 +48,7 @@ "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml", "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.dll", "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.xml", - "newtonsoft.json.8.0.3.nupkg.sha512", + "newtonsoft.json.9.0.1.nupkg.sha512", "newtonsoft.json.nuspec", "tools/install.ps1" ] diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups_CaseMismatch.json b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups_CaseMismatch.json new file mode 100644 index 0000000000..11c6892572 --- /dev/null +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups_CaseMismatch.json @@ -0,0 +1,150 @@ +{ + "locked": false, + "version": 2, + "targets": { + ".NETFramework,Version=v4.5": { + "Newtonsoft.Json/9.0.1": { + "type": "package", + "compile": { + "lib/net45/Newtonsoft.Json.dll": {} + }, + "runtime": { + "lib/net45/Newtonsoft.Json.dll": {} + } + } + }, + ".NETFramework,Version=v4.6": { + "FluentAssertions/3.4.1": { + "frameworkAssemblies": [ + "System.Xml", + "System.Xml.Linq" + ], + "compile": { + "lib/net45/FluentAssertions.Core.dll": {}, + "lib/net45/FluentAssertions.dll": {} + }, + "runtime": { + "lib/net45/FluentAssertions.Core.dll": {}, + "lib/net45/FluentAssertions.dll": {} + } + } + } + }, + "libraries": { + "Newtonsoft.Json/9.0.1": { + "sha512": "KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==", + "type": "package", + "path": "newtonsoft.json/9.0.1", + "files": [ + "lib/net20/Newtonsoft.Json.dll", + "lib/net20/Newtonsoft.Json.xml", + "lib/net35/Newtonsoft.Json.dll", + "lib/net35/Newtonsoft.Json.xml", + "lib/net40/Newtonsoft.Json.dll", + "lib/net40/Newtonsoft.Json.xml", + "lib/net45/Newtonsoft.Json.dll", + "lib/net45/Newtonsoft.Json.xml", + "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll", + "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml", + "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.dll", + "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.xml", + "newtonsoft.json.9.0.1.nupkg.sha512", + "newtonsoft.json.nuspec", + "tools/install.ps1" + ] + }, + "FluentAssertions/3.4.1": { + "sha512": "GTyLzP7d57D3HLVOSFrTSVwod3rZNQRMC2DR13u1hNNyhsskLrbI4SW5XXqyEv8WP7v8IqWx9hdlDiwLY0G8YA==", + "type": "Package", + "files": [ + "_rels/.rels", + "FluentAssertions.nuspec", + "lib/net40/FluentAssertions.Core.dll", + "lib/net40/FluentAssertions.Core.pdb", + "lib/net40/FluentAssertions.Core.xml", + "lib/net40/FluentAssertions.dll", + "lib/net40/FluentAssertions.pdb", + "lib/net40/FluentAssertions.xml", + "lib/net45/FluentAssertions.Core.dll", + "lib/net45/FluentAssertions.Core.pdb", + "lib/net45/FluentAssertions.Core.xml", + "lib/net45/FluentAssertions.dll", + "lib/net45/FluentAssertions.pdb", + "lib/net45/FluentAssertions.xml", + "lib/portable-monotouch+monoandroid+xamarin.ios/FluentAssertions.Core.dll", + "lib/portable-monotouch+monoandroid+xamarin.ios/FluentAssertions.Core.pdb", + "lib/portable-monotouch+monoandroid+xamarin.ios/FluentAssertions.Core.xml", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.Core.dll", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.Core.pdb", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.Core.xml", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.dll", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.pdb", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.XML", + "lib/portable-win81+wpa81/FluentAssertions.Core.dll", + "lib/portable-win81+wpa81/FluentAssertions.Core.pdb", + "lib/portable-win81+wpa81/FluentAssertions.Core.xml", + "lib/portable-win81+wpa81/FluentAssertions.dll", + "lib/portable-win81+wpa81/FluentAssertions.pdb", + "lib/portable-win81+wpa81/FluentAssertions.xml", + "lib/sl5/FluentAssertions.Core.dll", + "lib/sl5/FluentAssertions.Core.pdb", + "lib/sl5/FluentAssertions.Core.xml", + "lib/sl5/FluentAssertions.dll", + "lib/sl5/FluentAssertions.pdb", + "lib/sl5/FluentAssertions.xml", + "lib/sl5/Microsoft.CSharp.dll", + "lib/sl5/Microsoft.CSharp.xml", + "lib/sl5/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll", + "lib/sl5/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml", + "lib/sl5/System.Xml.Linq.dll", + "lib/sl5/System.Xml.Linq.xml", + "lib/sl5/de/Microsoft.CSharp.resources.dll", + "lib/sl5/de/System.Xml.Linq.resources.dll", + "lib/sl5/es/Microsoft.CSharp.resources.dll", + "lib/sl5/es/System.Xml.Linq.resources.dll", + "lib/sl5/fr/Microsoft.CSharp.resources.dll", + "lib/sl5/fr/System.Xml.Linq.resources.dll", + "lib/sl5/it/Microsoft.CSharp.resources.dll", + "lib/sl5/it/System.Xml.Linq.resources.dll", + "lib/sl5/ja/Microsoft.CSharp.resources.dll", + "lib/sl5/ja/System.Xml.Linq.resources.dll", + "lib/sl5/ko/Microsoft.CSharp.resources.dll", + "lib/sl5/ko/System.Xml.Linq.resources.dll", + "lib/sl5/ru/Microsoft.CSharp.resources.dll", + "lib/sl5/ru/System.Xml.Linq.resources.dll", + "lib/sl5/zh-Hans/Microsoft.CSharp.resources.dll", + "lib/sl5/zh-Hans/System.Xml.Linq.resources.dll", + "lib/sl5/zh-Hant/Microsoft.CSharp.resources.dll", + "lib/sl5/zh-Hant/System.Xml.Linq.resources.dll", + "lib/win8/FluentAssertions.Core.dll", + "lib/win8/FluentAssertions.Core.pdb", + "lib/win8/FluentAssertions.Core.xml", + "lib/win8/FluentAssertions.dll", + "lib/win8/FluentAssertions.pdb", + "lib/win8/FluentAssertions.XML", + "lib/wp8/FluentAssertions.Core.dll", + "lib/wp8/FluentAssertions.Core.pdb", + "lib/wp8/FluentAssertions.Core.xml", + "lib/wp8/FluentAssertions.dll", + "lib/wp8/FluentAssertions.pdb", + "lib/wp8/FluentAssertions.xml", + "package/services/metadata/core-properties/c21a09dd42de4a6295af89109b879195.psmdcp", + "[Content_Types].xml" + ] + } + }, + "projectFileDependencyGroups": { + "": [], + ".NETFramework,Version=v4.5": [ + "newtonsoft.json >= 8.0.1" + ], + ".NETFramework,Version=v4.6": [ + "fluentassertions >= 3.4.1" + ] + }, + "tools": {}, + "projectFileToolGroups": {}, + "packageFolders": { + "C:\\PackageFolder\\": {} + } +} \ No newline at end of file diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Microsoft.NuGet.Build.Tasks.Tests.csproj b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Microsoft.NuGet.Build.Tasks.Tests.csproj index ccf44639af..342af76599 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Microsoft.NuGet.Build.Tasks.Tests.csproj +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/Microsoft.NuGet.Build.Tasks.Tests.csproj @@ -34,8 +34,6 @@ 4 - - @@ -78,6 +76,7 @@ + diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/PackageFolderTests.cs b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/PackageFolderTests.cs index d8ef819bb9..90b6142125 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/PackageFolderTests.cs +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/PackageFolderTests.cs @@ -18,7 +18,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests runtimeIdentifier: null, createTemporaryFolderForPackages: false); - Assert.Equal(@"C:\PackageFolder\Newtonsoft.Json\8.0.3\lib\net45\Newtonsoft.Json.dll", result.References.Single().ItemSpec); + Assert.Equal(@"C:\PackageFolder\newtonsoft.json\9.0.1\lib\net45\Newtonsoft.Json.dll", result.References.Single().ItemSpec); } } } diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs index 994fdb4fed..3b690ab62c 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs @@ -414,6 +414,33 @@ namespace Microsoft.NuGet.Build.Tasks.Tests Assert.Contains("FluentAssertions", packageNames); } + // Regression test for https://devdiv.visualstudio.com/DevDiv/_workitems?id=500532&_a=edit + [Fact] + public static void MultipleProjectFileDependencyGroups_MismatchedCases() + { + var resultFor45 = NuGetTestHelpers.ResolvePackagesWithJsonFileContents( + Json.Json.MultipleProjectFileDependencyGroups_CaseMismatch, + targetMoniker: ".NETFramework,Version=v4.5", + runtimeIdentifier: "win", + allowFallbackOnTargetSelection: true); + + var packageNames = resultFor45.ReferencedPackages.Select(t => t.ItemSpec); + + Assert.Equal("Newtonsoft.Json", packageNames.Single(), ignoreCase: true); + + var resultFor46 = NuGetTestHelpers.ResolvePackagesWithJsonFileContents( + Json.Json.MultipleProjectFileDependencyGroups, + targetMoniker: ".NETFramework,Version=v4.6", + runtimeIdentifier: "win", + allowFallbackOnTargetSelection: true); + + AssertHelpers.AssertCountOf(1, resultFor46.ReferencedPackages); + + packageNames = resultFor46.ReferencedPackages.Select(t => t.ItemSpec); + + Assert.Equal("FluentAssertions", packageNames.Single(), ignoreCase: true); + } + [Fact] public static void ProjectsNotIncludedInReferences() { diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets index 3d99ea8517..71b454796e 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets @@ -14,10 +14,4 @@ Copyright (c) .NET Foundation. All rights reserved. $(MSBuildExtensionsPath)\Microsoft\NuGet\Microsoft.NuGet.targets - - - - $(MSBuildExtensionsPath)\NuGet.targets - - diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.Build.Tasks.csproj b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.Build.Tasks.csproj index 3d8611b3ea..2628d82bac 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.Build.Tasks.csproj +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.Build.Tasks.csproj @@ -34,8 +34,6 @@ 4 - - diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.targets b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.targets index 63446ae860..e0f7b8bbec 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.targets +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.targets @@ -70,6 +70,12 @@ Copyright (c) .NET Foundation. All rights reserved. true + + $(BaseNuGetRuntimeIdentifier) + win10 win @@ -225,6 +231,8 @@ Copyright (c) .NET Foundation. All rights reserved. + + @@ -256,6 +264,7 @@ Copyright (c) .NET Foundation. All rights reserved. --> .NETCore,Version=v5.0 + UAP,Version=v10.0.15138 .NETCore,Version=v5.0 <_ComputeNetCoreFrameworkInjectionParametersBeforeTargets Condition="'$(AppxPackage)' == 'true' and '$(TargetPlatformIdentifier)' == 'UAP'">BeforeGenerateProjectPriFile @@ -265,6 +274,8 @@ Copyright (c) .NET Foundation. All rights reserved. <_PackagingOutputsIncludesFramework Condition="'%(PackagingOutputs.FileName)%(PackagingOutputs.Extension)' == 'System.Runtime.dll'">true <_AppContainsManagedCodeForInjection Condition="'%(PackagingOutputs.Identity)' == '$(_TargetPlatformSdkDir)UnionMetadata\Windows.winmd'">true <_AppContainsManagedCodeForInjection Condition="'%(PackagingOutputs.Identity)' == '$(WindowsSDK_UnionMetadataPath)\Windows.winmd'">true + + <_AppContainsManagedCodeForInjection Condition="'%(PackagingOutputs.TargetPath)' == '$(WinMetadataDir)\Windows.winmd'">true @@ -286,7 +297,14 @@ Copyright (c) .NET Foundation. All rights reserved. + @(_NuGetInjectionSourceDirectories->'%(Identity)\RS2.project.lock.json') + @(_NuGetInjectionSourceDirectories->'%(Identity)\RS3.project.lock.json') @(_NuGetInjectionSourceDirectories->'%(Identity)\project.lock.json') + + + .NETCore,Version=v5.0 + @(_NuGetInjectionSourceDirectories->'%(Identity)\project.lock.json') + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\NuGet\Repository', 'NETCoreSDK', null, RegistryView.Registry32, RegistryView.Default)) diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs index beceac359d..97bddf3a04 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs @@ -892,7 +892,7 @@ namespace Microsoft.NuGet.Build.Tasks /// private static SortedSet GetAllPackageNames(JObject lockFile) { - var allPackageNames = new SortedSet(); + var allPackageNames = new SortedSet(StringComparer.OrdinalIgnoreCase); var libraries = (JObject)lockFile["libraries"]; foreach (var library in libraries) { diff --git a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/project.json b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/project.json index c992ffa0bf..133fa6aec1 100644 --- a/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/project.json +++ b/external/nuget-buildtasks/src/Microsoft.NuGet.Build.Tasks/project.json @@ -1,5 +1,12 @@ { - "dependencies": { "Newtonsoft.Json": "6.0.4" }, - "frameworks": { "net45": { } }, - "runtimes": { "win": { } } + "dependencies": { + "Microsoft.Build.Utilities.Core": "14.3.0", + "Newtonsoft.Json": "6.0.4" + }, + "frameworks": { + "net45": {} + }, + "runtimes": { + "win": {} + } } \ No newline at end of file diff --git a/mcs/build/common/Consts.cs b/mcs/build/common/Consts.cs index 6c9eee4f14..417dcfc694 100644 --- a/mcs/build/common/Consts.cs +++ b/mcs/build/common/Consts.cs @@ -34,7 +34,7 @@ static class Consts // Use these assembly version constants to make code more maintainable. // - public const string MonoVersion = "5.8.0.22"; + public const string MonoVersion = "5.8.0.88"; public const string MonoCompany = "Mono development team"; public const string MonoProduct = "Mono Common Language Infrastructure"; public const string MonoCopyright = "(c) Various Mono authors"; diff --git a/mcs/class/Mono.CSharp/Test/Evaluator/CompletionTest.cs b/mcs/class/Mono.CSharp/Test/Evaluator/CompletionTest.cs index 0a276d4d30..4c3a277491 100644 --- a/mcs/class/Mono.CSharp/Test/Evaluator/CompletionTest.cs +++ b/mcs/class/Mono.CSharp/Test/Evaluator/CompletionTest.cs @@ -26,6 +26,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !FULL_AOT_RUNTIME using System; using NUnit.Framework; using Mono.CSharp; @@ -75,4 +76,5 @@ namespace MonoTests.EvaluatorTest Assert.IsNull (res); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/mcs/class/Mono.CSharp/Test/Evaluator/EvaluatorTest.cs b/mcs/class/Mono.CSharp/Test/Evaluator/EvaluatorTest.cs index 71af4f4c07..8c4c5770b0 100644 --- a/mcs/class/Mono.CSharp/Test/Evaluator/EvaluatorTest.cs +++ b/mcs/class/Mono.CSharp/Test/Evaluator/EvaluatorTest.cs @@ -25,7 +25,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !FULL_AOT_RUNTIME using NUnit.Framework; using Mono.CSharp; @@ -41,4 +41,5 @@ namespace MonoTests.EvaluatorTest evaluator2.Run ("int i = 0;"); } } - } \ No newline at end of file + } + #endif \ No newline at end of file diff --git a/mcs/class/Mono.CSharp/Test/Evaluator/ExpressionsTest.cs b/mcs/class/Mono.CSharp/Test/Evaluator/ExpressionsTest.cs index 8c414dad79..054e164aee 100644 --- a/mcs/class/Mono.CSharp/Test/Evaluator/ExpressionsTest.cs +++ b/mcs/class/Mono.CSharp/Test/Evaluator/ExpressionsTest.cs @@ -25,7 +25,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !FULL_AOT_RUNTIME using System; using NUnit.Framework; using Mono.CSharp; @@ -203,3 +203,4 @@ namespace MonoTests.EvaluatorTest } } +#endif diff --git a/mcs/class/Mono.CSharp/Test/Evaluator/TypesTest.cs b/mcs/class/Mono.CSharp/Test/Evaluator/TypesTest.cs index 97f9e047e6..7c9ed99139 100644 --- a/mcs/class/Mono.CSharp/Test/Evaluator/TypesTest.cs +++ b/mcs/class/Mono.CSharp/Test/Evaluator/TypesTest.cs @@ -25,7 +25,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !FULL_AOT_RUNTIME using System; using NUnit.Framework; using Mono.CSharp; @@ -132,4 +132,5 @@ namespace MonoTests.EvaluatorTest Evaluator.Run ("public class TestClass { private TestEnum _te; public string Get() { return _te.ToString(); } } public enum TestEnum { First, Second }"); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/mcs/class/Mono.Data.Sqlite/Test/Bug27864.cs b/mcs/class/Mono.Data.Sqlite/Test/Bug27864.cs index b381e1fde7..eb72b75a4d 100644 --- a/mcs/class/Mono.Data.Sqlite/Test/Bug27864.cs +++ b/mcs/class/Mono.Data.Sqlite/Test/Bug27864.cs @@ -20,13 +20,24 @@ namespace MonoTests.Mono.Data.Sqlite { [TestFixture] public class SqliteiOS82BugTests { - readonly static string dbPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "adodemo.db3"); - readonly static string connectionString = "Data Source=" + dbPath; - static SqliteConnection cnn = new SqliteConnection (connectionString); + string dbPath; + string connectionString; + SqliteConnection cnn; [SetUp] public void Create() { + dbPath = Path.GetTempFileName (); + + // We want to start with a fresh db for each full run + // The database is created on the first open() + // but TempFile does create a file + if (File.Exists (dbPath)) + File.Delete (dbPath); + + connectionString = "Data Source=" + dbPath; + cnn = new SqliteConnection (connectionString); + try { if(File.Exists(dbPath)) { cnn.Dispose(); @@ -56,6 +67,13 @@ namespace MonoTests.Mono.Data.Sqlite { } } + [TearDown] + public void TearDown () + { + if (File.Exists (dbPath)) + File.Delete (dbPath); + } + // Ref: https://bugzilla.xamarin.com/show_bug.cgi?id=27864 // As of iOS 8.2 Apple updated Sqlite and broke queries that used to work pre iOS 8.2 like the select command in this test // The pruppose of this test is to know when apple fixes this. Expected test behaivour is as follows. diff --git a/mcs/class/Mono.Data.Sqlite/Test/SqliteCommandUnitTests.cs b/mcs/class/Mono.Data.Sqlite/Test/SqliteCommandUnitTests.cs index f10d6ec6fb..8d9e131d87 100644 --- a/mcs/class/Mono.Data.Sqlite/Test/SqliteCommandUnitTests.cs +++ b/mcs/class/Mono.Data.Sqlite/Test/SqliteCommandUnitTests.cs @@ -16,9 +16,9 @@ namespace MonoTests.Mono.Data.Sqlite [TestFixture] public class SqliteCommandUnitTests { - readonly static string _uri = Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SqliteTest.db"); - readonly static string _connectionString = "URI=file://" + _uri + ", version=3"; - static SqliteConnection _conn = new SqliteConnection (_connectionString); + string _uri; + string _connectionString; + SqliteConnection _conn; readonly static string stringvalue = "my keyboard is better than yours : äöüß"; public SqliteCommandUnitTests() @@ -28,6 +28,10 @@ namespace MonoTests.Mono.Data.Sqlite [SetUp] public void Create() { + _uri = Path.GetTempFileName (); + _connectionString = "URI=file://" + _uri + ", version=3"; + _conn = new SqliteConnection (_connectionString); + try { if(File.Exists(_uri)) @@ -65,6 +69,13 @@ namespace MonoTests.Mono.Data.Sqlite } } + [TearDown] + public void TearDown () + { + if (File.Exists (_uri)) + File.Delete (_uri); + } + [Test] public void Select() { @@ -195,4 +206,4 @@ namespace MonoTests.Mono.Data.Sqlite } } } -} \ No newline at end of file +} diff --git a/mcs/class/Mono.Data.Sqlite/Test/SqliteConnectionTest.cs b/mcs/class/Mono.Data.Sqlite/Test/SqliteConnectionTest.cs index 9afb83a2b3..7b1a12d0c8 100644 --- a/mcs/class/Mono.Data.Sqlite/Test/SqliteConnectionTest.cs +++ b/mcs/class/Mono.Data.Sqlite/Test/SqliteConnectionTest.cs @@ -37,13 +37,33 @@ using NUnit.Framework; namespace MonoTests.Mono.Data.Sqlite { - [TestFixture] - public class SqliteConnectionTest - { - readonly static string _uri = Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "test.db"); - readonly static string _connectionString = "URI=file://" + _uri + ", version=3"; - SqliteConnection _conn = new SqliteConnection (); + [TestFixture] + public class SqliteConnectionTest + { + string _dataFolder; + string _uri; + string _connectionString; + SqliteConnection _conn; + [SetUp] + public void SetUp () + { + _dataFolder = Path.GetTempFileName (); + if (File.Exists (_dataFolder)) + File.Delete (_dataFolder); + Directory.CreateDirectory (_dataFolder); + + _uri = Path.Combine (_dataFolder, "test.db"); + _connectionString = "URI=file://" + _uri + ", version=3"; + _conn = new SqliteConnection (); + } + + [TearDown] + public void TeatDown () + { + if (Directory.Exists (_dataFolder)) + Directory.Delete (_dataFolder, true); + } [Test] public void ReleaseDatabaseFileHandles () { @@ -64,49 +84,49 @@ namespace MonoTests.Mono.Data.Sqlite File.Delete (_uri); } - [Test] - [ExpectedException (typeof (ArgumentNullException))] - public void ConnectionStringTest_Null () - { - _conn.ConnectionString = null; - } + [Test] + [ExpectedException (typeof (ArgumentNullException))] + public void ConnectionStringTest_Null () + { + _conn.ConnectionString = null; + } - [Test] - [ExpectedException (typeof (InvalidOperationException))] - public void ConnectionStringTest_MustBeClosed () - { - _conn.ConnectionString = _connectionString; - try { - _conn.Open (); - _conn.ConnectionString = _connectionString; - } finally { - _conn.Close (); - } - } + [Test] + [ExpectedException (typeof (InvalidOperationException))] + public void ConnectionStringTest_MustBeClosed () + { + _conn.ConnectionString = _connectionString; + try { + _conn.Open (); + _conn.ConnectionString = _connectionString; + } finally { + _conn.Close (); + } + } - // behavior has changed, I guess - //[Test] - [Ignore ("opening a connection should not create db! though, leave for now")] - public void OpenTest () - { - try { - _conn.ConnectionString = _connectionString; - _conn.Open (); - Assert.AreEqual (ConnectionState.Open, _conn.State, "#1 not opened"); - _conn.Close (); + // behavior has changed, I guess + //[Test] + [Ignore ("opening a connection should not create db! though, leave for now")] + public void OpenTest () + { + try { + _conn.ConnectionString = _connectionString; + _conn.Open (); + Assert.AreEqual (ConnectionState.Open, _conn.State, "#1 not opened"); + _conn.Close (); - // negative test: try opening a non-existent file - _conn.ConnectionString = "URI=file://abcdefgh.db, version=3"; - try { - _conn.Open (); - Assert.Fail ("#1 should have failed on opening a non-existent db"); - } catch (ArgumentException e) {Console.WriteLine (e);} - - } finally { - if (_conn != null && _conn.State != ConnectionState.Closed) - _conn.Close (); - } - } + // negative test: try opening a non-existent file + _conn.ConnectionString = "URI=file://abcdefgh.db, version=3"; + try { + _conn.Open (); + Assert.Fail ("#1 should have failed on opening a non-existent db"); + } catch (ArgumentException e) {Console.WriteLine (e);} + + } finally { + if (_conn != null && _conn.State != ConnectionState.Closed) + _conn.Close (); + } + } - } + } } diff --git a/mcs/class/Mono.Data.Sqlite/Test/SqliteDataAdapterUnitTests.cs b/mcs/class/Mono.Data.Sqlite/Test/SqliteDataAdapterUnitTests.cs index efce04bdd9..7f5e3c1ca0 100644 --- a/mcs/class/Mono.Data.Sqlite/Test/SqliteDataAdapterUnitTests.cs +++ b/mcs/class/Mono.Data.Sqlite/Test/SqliteDataAdapterUnitTests.cs @@ -15,11 +15,26 @@ namespace MonoTests.Mono.Data.Sqlite [TestFixture] public class SqliteDataAdapterUnitTests { - readonly static string _uri = "SqliteTest.db"; - readonly static string _connectionString = "URI=file://" + _uri + ", version=3"; - static SqliteConnection _conn = new SqliteConnection (_connectionString); + string _uri; + string _connectionString; + SqliteConnection _conn; - static SqliteDataAdapter PrepareDataAdapter() + [SetUp] + public void SetUp () + { + _uri = Path.GetTempFileName (); + _connectionString = "URI=file://" + _uri + ", version=3"; + _conn = new SqliteConnection (_connectionString); + } + + [TearDown] + public void TearDown () + { + if (File.Exists (_uri)) + File.Delete (_uri); + } + + SqliteDataAdapter PrepareDataAdapter() { SqliteCommand select = new SqliteCommand("SELECT t, f, i, b FROM t1",_conn); SqliteCommand update = new SqliteCommand("UPDATE t1 SET t = :textP, f = :floatP, i = :integerP, n=:blobP WHERE t = :textP "); diff --git a/mcs/class/Mono.Data.Sqlite/Test/SqliteExceptionUnitTests.cs b/mcs/class/Mono.Data.Sqlite/Test/SqliteExceptionUnitTests.cs index 6a7fdbc487..b8f0ef0b11 100644 --- a/mcs/class/Mono.Data.Sqlite/Test/SqliteExceptionUnitTests.cs +++ b/mcs/class/Mono.Data.Sqlite/Test/SqliteExceptionUnitTests.cs @@ -15,12 +15,23 @@ namespace MonoTests.Mono.Data.Sqlite [TestFixture] public class SqliteExceptionUnitTests { - readonly static string _uri = "SqliteTest.db"; - readonly static string _connectionString = "URI=file://" + _uri + ", version=3"; - static SqliteConnection _conn = new SqliteConnection (_connectionString); + static string _uri; + static string _connectionString; + SqliteConnection _conn; - public SqliteExceptionUnitTests() + [SetUp] + public void SetUp () { + _uri = Path.GetTempFileName (); + _connectionString = "URI=file://" + _uri + ", version=3"; + _conn = new SqliteConnection (_connectionString); + } + + [TearDown] + public void TearDown () + { + if (File.Exists (_uri)) + File.Delete (_uri); } [Test] diff --git a/mcs/class/Mono.Data.Sqlite/Test/SqliteFunctionTests.cs b/mcs/class/Mono.Data.Sqlite/Test/SqliteFunctionTests.cs index 294a591a81..bfdfad543e 100644 --- a/mcs/class/Mono.Data.Sqlite/Test/SqliteFunctionTests.cs +++ b/mcs/class/Mono.Data.Sqlite/Test/SqliteFunctionTests.cs @@ -20,7 +20,20 @@ namespace MonoTests.Mono.Data.Sqlite [TestFixture] public class SqliteFunctionTest { - readonly static string uri = Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "test.db"); + string uri; + + [SetUp] + public void SetUp () + { + uri = Path.GetTempFileName (); + } + + [TearDown] + public void TearDown () + { + if (File.Exists (uri)) + File.Delete (uri); + } [Test] public void CollationTest() diff --git a/mcs/class/Mono.Data.Sqlite/Test/SqliteParameterUnitTests.cs b/mcs/class/Mono.Data.Sqlite/Test/SqliteParameterUnitTests.cs index b03b61a486..164be46898 100644 --- a/mcs/class/Mono.Data.Sqlite/Test/SqliteParameterUnitTests.cs +++ b/mcs/class/Mono.Data.Sqlite/Test/SqliteParameterUnitTests.cs @@ -15,14 +15,24 @@ namespace MonoTests.Mono.Data.Sqlite [TestFixture] public class SqliteParameterUnitTests { - readonly static string _uri = "SqliteTest.db"; - readonly static string _connectionString = "URI=file://" + _uri + ", version=3"; - static SqliteConnection _conn = new SqliteConnection (_connectionString); + string _uri; + string _connectionString; + SqliteConnection _conn; - public SqliteParameterUnitTests() + [SetUp] + public void SetUp () { + _uri = Path.GetTempFileName (); + _connectionString = "URI=file://" + _uri + ", version=3"; + _conn = new SqliteConnection (_connectionString); + } + + [TearDown] + public void TearDown () + { + if (File.Exists (_uri)) + File.Delete (_uri); } - [Test] [Category ("NotWorking")] // fails randomly :) diff --git a/mcs/class/Mono.Data.Sqlite/Test/SqliteTests.cs b/mcs/class/Mono.Data.Sqlite/Test/SqliteTests.cs index 969346d0fd..cdb7010b43 100644 --- a/mcs/class/Mono.Data.Sqlite/Test/SqliteTests.cs +++ b/mcs/class/Mono.Data.Sqlite/Test/SqliteTests.cs @@ -43,24 +43,16 @@ namespace MonoTests.Mono.Data.Sqlite [SetUp] public void Setup () { - var dataFolder = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "SqlTest"); - - _databasePath = Path.Combine (dataFolder, "database.db"); - - if (!Directory.Exists (dataFolder)) { - Directory.CreateDirectory (dataFolder); - } + _databasePath = Path.GetTempFileName (); File.Delete (_databasePath); } [TearDown] public void TearDown () { - try { + if (File.Exists (_databasePath)) File.Delete (_databasePath); - } catch { - } } [Test] diff --git a/mcs/class/Mono.Posix/Test/Mono.Unix.Native/SocketTest.cs b/mcs/class/Mono.Posix/Test/Mono.Unix.Native/SocketTest.cs index 31c4549dd6..1b2861d2c2 100644 --- a/mcs/class/Mono.Posix/Test/Mono.Unix.Native/SocketTest.cs +++ b/mcs/class/Mono.Posix/Test/Mono.Unix.Native/SocketTest.cs @@ -176,6 +176,9 @@ namespace MonoTests.Mono.Unix.Native } [Test] +#if MONODROID + [ExpectedException (typeof (ArgumentOutOfRangeException))] // IPPROTO_TCP not supported +#endif public void SockOptLinger () { WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_STREAM, UnixSocketProtocol.IPPROTO_TCP, (so1, so2) => { @@ -347,6 +350,9 @@ namespace MonoTests.Mono.Unix.Native } [Test] +#if MONODROID + [ExpectedException (typeof (ArgumentOutOfRangeException))] // IPPROTO_UDP not supported +#endif public void BindConnect () { WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_DGRAM, UnixSocketProtocol.IPPROTO_UDP, (so1, so2) => { @@ -516,6 +522,9 @@ namespace MonoTests.Mono.Unix.Native [Test] [Category ("NotOnMac")] +#if MONODROID + [ExpectedException (typeof (ArgumentOutOfRangeException))] // SOCK_NONBLOCK, SOCK_CLOEXEC not supported +#endif public void Accept4 () { WithSockets (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0, (so1, so2) => { @@ -553,6 +562,9 @@ namespace MonoTests.Mono.Unix.Native } [Test] +#if MONODROID + [ExpectedException (typeof (ArgumentOutOfRangeException))] // IPPROTO_UDP not supported +#endif public void SendToRecvFrom () { WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_DGRAM, UnixSocketProtocol.IPPROTO_UDP, (so1, so2) => { @@ -643,6 +655,9 @@ namespace MonoTests.Mono.Unix.Native } [Test] +#if MONODROID + [ExpectedException (typeof (ArgumentOutOfRangeException))] // IPPROTO_UDP not supported +#endif public unsafe void SendMsgRecvMsgAddress () { WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_DGRAM, UnixSocketProtocol.IPPROTO_UDP, (so1, so2) => { diff --git a/mcs/class/System.Core/Test/System.Security.Cryptography/AesManagedTest.cs b/mcs/class/System.Core/Test/System.Security.Cryptography/AesManagedTest.cs index 206655acc4..19e7047f58 100644 --- a/mcs/class/System.Core/Test/System.Security.Cryptography/AesManagedTest.cs +++ b/mcs/class/System.Core/Test/System.Security.Cryptography/AesManagedTest.cs @@ -37,7 +37,7 @@ namespace MonoTests.System.Security.Cryptography { public class AesManagedTest { [Test] -#if !MONOTOUCH +#if !MONOTOUCH && !XAMMAC [ExpectedException (typeof (CryptographicException))] #endif public void CFB_NotAllowed () @@ -61,7 +61,7 @@ namespace MonoTests.System.Security.Cryptography { } [Test] -#if !MONOTOUCH +#if !MONOTOUCH && !XAMMAC [ExpectedException (typeof (CryptographicException))] #endif public void OFB_NotAllowed () diff --git a/mcs/class/System.IO.Compression.FileSystem/Test/System.IO.Compression.FileSystem/ZipTest.cs b/mcs/class/System.IO.Compression.FileSystem/Test/System.IO.Compression.FileSystem/ZipTest.cs index 4321db8534..5b6f786ee3 100644 --- a/mcs/class/System.IO.Compression.FileSystem/Test/System.IO.Compression.FileSystem/ZipTest.cs +++ b/mcs/class/System.IO.Compression.FileSystem/Test/System.IO.Compression.FileSystem/ZipTest.cs @@ -36,22 +36,29 @@ namespace MonoTests.System.IO.Compression.FileSystem [TestFixture] public class ZipArchiveTests { + string tmpFile; + [SetUp] + public void SetUp () + { + tmpFile = Path.GetTempFileName (); + } + [TearDown] public void Dispose() { - File.Delete ("foo.zip"); + File.Delete (tmpFile); } [Test] public void ZipCreateFromDirectory() { - if (File.Exists ("foo.zip")) - File.Delete ("foo.zip"); + if (File.Exists (tmpFile)) + File.Delete (tmpFile); - ZipFile.CreateFromDirectory ("foo", "foo.zip"); - Assert.IsTrue(File.Exists("foo.zip")); + ZipFile.CreateFromDirectory ("foo", tmpFile); + Assert.IsTrue(File.Exists(tmpFile)); - using (var archive = new ZipArchive (File.Open ("foo.zip", FileMode.Open), + using (var archive = new ZipArchive (File.Open (tmpFile, FileMode.Open), ZipArchiveMode.Read)) { Assert.IsNotNull (archive.GetEntry ("foo.txt")); @@ -65,14 +72,14 @@ namespace MonoTests.System.IO.Compression.FileSystem [Test] public void ZipCreateFromDirectoryIncludeBase() { - if (File.Exists ("foo.zip")) - File.Delete ("foo.zip"); + if (File.Exists (tmpFile)) + File.Delete (tmpFile); - ZipFile.CreateFromDirectory ("foo", "foo.zip", CompressionLevel.Fastest, + ZipFile.CreateFromDirectory ("foo", tmpFile, CompressionLevel.Fastest, includeBaseDirectory: true); - Assert.IsTrue (File.Exists ("foo.zip")); + Assert.IsTrue (File.Exists (tmpFile)); - using (var archive = new ZipArchive (File.Open ("foo.zip", FileMode.Open), + using (var archive = new ZipArchive (File.Open (tmpFile, FileMode.Open), ZipArchiveMode.Read)) { Assert.IsNotNull (archive.GetEntry ("foo/foo.txt")); @@ -86,34 +93,35 @@ namespace MonoTests.System.IO.Compression.FileSystem [Test] public void ZipExtractToDirectory() { - if (Directory.Exists ("extract")) - Directory.Delete ("extract", true); + var extractDir = Path.Combine (Path.GetTempPath (), "extract"); + if (Directory.Exists (extractDir)) + Directory.Delete (extractDir, true); - if (File.Exists ("foo.zip")) - File.Delete ("foo.zip"); + if (File.Exists (tmpFile)) + File.Delete (tmpFile); - ZipFile.CreateFromDirectory ("foo", "foo.zip"); + ZipFile.CreateFromDirectory ("foo", tmpFile); - ZipFile.ExtractToDirectory ("foo.zip", "extract"); - Assert.IsTrue(Directory.Exists ("extract")); + ZipFile.ExtractToDirectory (tmpFile, extractDir); + Assert.IsTrue(Directory.Exists (extractDir)); - Assert.IsTrue (File.Exists ("extract/foo.txt")); - Assert.IsTrue (File.Exists ("extract/bar.txt")); - Assert.IsTrue (Directory.Exists ("extract/foobar")); - Assert.IsTrue (File.Exists ("extract/foobar/foo.txt")); - Assert.IsTrue (File.Exists ("extract/foobar/bar.txt")); + Assert.IsTrue (File.Exists (Path.Combine (extractDir, "foo.txt")), Path.Combine (extractDir, "foo.txt")); + Assert.IsTrue (File.Exists (Path.Combine (extractDir, "bar.txt")), Path.Combine (extractDir, "bar.txt")); + Assert.IsTrue (Directory.Exists (Path.Combine (extractDir, "foobar")), Path.Combine (extractDir, "foobar")); + Assert.IsTrue (File.Exists (Path.Combine (extractDir, "foobar", "foo.txt")), Path.Combine (extractDir, "foobar", "foo.txt")); + Assert.IsTrue (File.Exists (Path.Combine (extractDir, "foobar", "bar.txt")), Path.Combine (extractDir, "foobar", "bar.txt")); - Directory.Delete ("extract", true); + Directory.Delete (extractDir, true); } [Test] public void ZipCreateFromEntryChangeTimestamp() { - if (File.Exists ("foo.zip")) - File.Delete ("foo.zip"); + if (File.Exists (tmpFile)) + File.Delete (tmpFile); var file = "foo/foo.txt"; - using (var archive = new ZipArchive(File.Open("foo.zip", FileMode.Create), + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Create), ZipArchiveMode.Update)) { archive.CreateEntryFromFile(file, file); @@ -121,7 +129,7 @@ namespace MonoTests.System.IO.Compression.FileSystem var date = File.GetLastWriteTimeUtc(file); - using (var archive = new ZipArchive (File.Open ("foo.zip", FileMode.Open), + using (var archive = new ZipArchive (File.Open (tmpFile, FileMode.Open), ZipArchiveMode.Read)) { var entry = archive.GetEntry (file); diff --git a/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs b/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs index d02f8e8731..7df282b6bc 100644 --- a/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs +++ b/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs @@ -1,5 +1,4 @@ -// -// ZipTests.cs +// ZipTests.cs // // Author: // Joao Matos @@ -48,8 +47,9 @@ namespace MonoTests.System.IO.Compression [Test] public void ZipGetEntryReadMode() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entry = archive.GetEntry("foo.txt"); @@ -59,14 +59,15 @@ namespace MonoTests.System.IO.Compression Assert.IsNull(nullEntry); } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipGetEntryCreateMode() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Create)) { try { @@ -78,14 +79,15 @@ namespace MonoTests.System.IO.Compression Assert.Fail(); } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipGetEntryUpdateMode() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entry = archive.GetEntry("foo.txt"); @@ -95,14 +97,15 @@ namespace MonoTests.System.IO.Compression Assert.IsNull(nullEntry); } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipGetEntryOpen() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entry = archive.GetEntry("foo.txt"); @@ -111,15 +114,16 @@ namespace MonoTests.System.IO.Compression var foo = entry.Open(); } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipOpenAndReopenEntry() { + var tmpFile = Path.GetTempFileName (); try { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) { var entry = archive.GetEntry("foo.txt"); @@ -136,7 +140,7 @@ namespace MonoTests.System.IO.Compression Assert.Fail(); } } finally { - File.Delete ("test.zip"); + File.Delete (tmpFile); } } @@ -144,8 +148,9 @@ namespace MonoTests.System.IO.Compression [Test] public void ZipOpenCloseAndReopenEntry() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) { var entry = archive.GetEntry("foo.txt"); @@ -156,14 +161,15 @@ namespace MonoTests.System.IO.Compression stream = entry.Open(); } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipGetEntryDeleteReadMode() { - File.Copy("archive.zip", "delete.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) { var entry = archive.GetEntry("foo.txt"); @@ -172,21 +178,22 @@ namespace MonoTests.System.IO.Compression entry.Delete(); } - using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open), + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entry = archive.GetEntry("foo.txt"); Assert.IsNull(entry); } - File.Delete ("delete.zip"); + File.Delete (tmpFile); } [Test] public void ZipDeleteEntryCheckEntries() { - File.Copy("archive.zip", "delete.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) { var entry = archive.GetEntry("foo.txt"); @@ -197,14 +204,15 @@ namespace MonoTests.System.IO.Compression Assert.IsNull(archive.Entries.FirstOrDefault(e => e == entry)); } - File.Delete ("delete.zip"); + File.Delete (tmpFile); } [Test] public void ZipGetEntryDeleteUpdateMode() { - File.Copy("archive.zip", "delete.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) { var entry = archive.GetEntry("foo.txt"); @@ -213,20 +221,21 @@ namespace MonoTests.System.IO.Compression entry.Delete(); } - using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open), + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entry = archive.GetEntry("foo.txt"); Assert.IsNull(entry); } - File.Delete ("delete.zip"); + File.Delete (tmpFile); } [Test] public void ZipCreateArchive() { - using (var archive = new ZipArchive(File.Open("create.zip", FileMode.Create), + var tmpFile = Path.GetTempFileName (); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Create), ZipArchiveMode.Create)) { var dir = archive.CreateEntry("foobar/"); @@ -239,7 +248,7 @@ namespace MonoTests.System.IO.Compression } } - using (var archive = new ZipArchive(File.Open("create.zip", FileMode.Open), + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { Assert.IsNotNull(archive.GetEntry("foobar/")); @@ -253,22 +262,23 @@ namespace MonoTests.System.IO.Compression Assert.AreEqual("foo", text); } - File.Delete ("create.zip"); + File.Delete (tmpFile); } [Test] public void ZipEnumerateEntriesModifiedTime() { - File.Copy("archive.zip", "test.zip", overwrite: true); + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); var date = DateTimeOffset.Now; - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) { var entry = archive.GetEntry("foo.txt"); entry.LastWriteTime = date; } - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entry = archive.GetEntry("foo.txt"); @@ -278,25 +288,29 @@ namespace MonoTests.System.IO.Compression } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipEnumerateArchiveDefaultLastWriteTime() { - using (var archive = new ZipArchive(File.Open("test.nupkg", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("test.nupkg", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entry = archive.GetEntry("_rels/.rels"); Assert.AreEqual(new DateTime(624511296000000000).Ticks, entry.LastWriteTime.Ticks); Assert.IsNotNull(entry); } + File.Delete (tmpFile); } public void ZipGetArchiveEntryStreamLengthPosition(ZipArchiveMode mode) { - File.Copy("test.nupkg", "test2.nupkg", overwrite: true); - using (var archive = new ZipArchive(File.Open("test2.nupkg", FileMode.Open), mode)) + var tmpFile = Path.GetTempFileName (); + File.Copy("test.nupkg", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), mode)) { var entry = archive.GetEntry("_rels/.rels"); using (var stream = entry.Open()) @@ -316,7 +330,7 @@ namespace MonoTests.System.IO.Compression } } } - File.Delete ("test2.nupkg"); + File.Delete (tmpFile); } [Test] @@ -334,8 +348,9 @@ namespace MonoTests.System.IO.Compression [Test] public void ZipEnumerateEntriesReadMode() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entries = archive.Entries; @@ -348,14 +363,15 @@ namespace MonoTests.System.IO.Compression Assert.AreEqual("foobar/foo.txt", entries[4].FullName); } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipWriteEntriesUpdateMode() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) { var foo = archive.GetEntry("foo.txt"); @@ -366,7 +382,7 @@ namespace MonoTests.System.IO.Compression } } - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var foo = archive.GetEntry("foo.txt"); @@ -378,7 +394,7 @@ namespace MonoTests.System.IO.Compression } } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] @@ -418,8 +434,9 @@ namespace MonoTests.System.IO.Compression [Test] public void ZipWriteEntriesUpdateModeNonZeroPosition() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) { var foo = archive.GetEntry("foo.txt"); @@ -433,7 +450,7 @@ namespace MonoTests.System.IO.Compression } } - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entries = archive.Entries; @@ -446,14 +463,15 @@ namespace MonoTests.System.IO.Compression } } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipEnumerateEntriesUpdateMode() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Read)) { var entries = archive.Entries; @@ -466,14 +484,15 @@ namespace MonoTests.System.IO.Compression Assert.AreEqual("foobar/foo.txt", entries[4].FullName); } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipEnumerateEntriesCreateMode() { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.Copy("archive.zip", tmpFile, overwrite: true); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open), ZipArchiveMode.Create)) { try { @@ -485,18 +504,19 @@ namespace MonoTests.System.IO.Compression Assert.Fail(); } - File.Delete ("test.zip"); + File.Delete (tmpFile); } [Test] public void ZipUpdateEmptyArchive() { - File.WriteAllText("empty.zip", string.Empty); - using (var archive = new ZipArchive(File.Open("empty.zip", FileMode.Open), + var tmpFile = Path.GetTempFileName (); + File.WriteAllText(tmpFile, string.Empty); + using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open), ZipArchiveMode.Update)) { } - File.Delete ("empty.zip"); + File.Delete (tmpFile); } class MyFakeStream : FileStream @@ -517,21 +537,28 @@ namespace MonoTests.System.IO.Compression [Test] public void ZipReadNonSeekableStream() { - var stream = new MyFakeStream("test.nupkg", FileMode.Open); + var tmpFile = Path.GetTempFileName (); + File.Copy("test.nupkg", tmpFile, overwrite: true); + var stream = new MyFakeStream(tmpFile, FileMode.Open); using (var archive = new ZipArchive (stream, ZipArchiveMode.Read)) { } + File.Delete (tmpFile); } [Test] - public void ZipWriteNonSeekableStream() { - var stream = new MyFakeStream( "test.nupkg", FileMode.Open ); + public void ZipWriteNonSeekableStream() + { + var tmpFile = Path.GetTempFileName (); + File.Copy("test.nupkg", tmpFile, overwrite: true); + var stream = new MyFakeStream(tmpFile, FileMode.Open ); using ( var archive = new ZipArchive( stream, ZipArchiveMode.Create ) ) { var entry = archive.CreateEntry( "foo" ); using ( var es = entry.Open() ) { es.Write( new byte[] { 4, 2 }, 0, 2 ); } } + File.Delete (tmpFile); } } } diff --git a/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs b/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs index 8ea06b162b..7d154cd8fd 100644 --- a/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs +++ b/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs @@ -334,6 +334,20 @@ namespace System.Net.Http return response; } + static bool MethodHasBody (HttpMethod method) + { + switch (method.Method) { + case "HEAD": + case "GET": + case "MKCOL": + case "CONNECT": + case "TRACE": + return false; + default: + return true; + } + } + protected async internal override Task SendAsync (HttpRequestMessage request, CancellationToken cancellationToken) { if (disposed) @@ -378,7 +392,7 @@ namespace System.Net.Http using (var stream = await wrequest.GetRequestStreamAsync ().ConfigureAwait (false)) { await request.Content.CopyToAsync (stream).ConfigureAwait (false); } - } else if (HttpMethod.Post.Equals (request.Method) || HttpMethod.Put.Equals (request.Method) || HttpMethod.Delete.Equals (request.Method)) { + } else if (MethodHasBody (request.Method)) { // Explicitly set this to make sure we're sending a "Content-Length: 0" header. // This fixes the issue that's been reported on the forums: // http://forums.xamarin.com/discussion/17770/length-required-error-in-http-post-since-latest-release diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/CmsSignerTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/CmsSignerTest.cs index e2aa7f91f4..1efb80b5c8 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/CmsSignerTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/CmsSignerTest.cs @@ -26,7 +26,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -291,4 +291,4 @@ namespace MonoTests.System.Security.Cryptography.Pkcs { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/PkitsTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/PkitsTest.cs index 1722359b38..6847615257 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/PkitsTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/PkitsTest.cs @@ -27,7 +27,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -160,4 +160,4 @@ namespace MonoTests.System.Security.Cryptography.Pkcs { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/Pkits_4_01_SignatureVerification.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/Pkits_4_01_SignatureVerification.cs index 0bdc6d348a..67c7da6c92 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/Pkits_4_01_SignatureVerification.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/Pkits_4_01_SignatureVerification.cs @@ -26,7 +26,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -236,4 +236,4 @@ namespace MonoTests.System.Security.Cryptography.Pkcs { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignedCmsTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignedCmsTest.cs index d8f1b12fad..c479201040 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignedCmsTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignedCmsTest.cs @@ -26,6 +26,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !MOBILE using NUnit.Framework; @@ -452,4 +453,4 @@ namespace MonoTests.System.Security.Cryptography.Pkcs { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignerInfoCollectionTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignerInfoCollectionTest.cs index 59941a1a75..22089974c6 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignerInfoCollectionTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignerInfoCollectionTest.cs @@ -25,7 +25,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -134,4 +134,4 @@ namespace MonoTests.System.Security.Cryptography.Pkcs { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignerInfoTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignerInfoTest.cs index 50e6376ac1..8c842d6ed0 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignerInfoTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignerInfoTest.cs @@ -26,7 +26,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -102,4 +102,5 @@ namespace MonoTests.System.Security.Cryptography.Pkcs { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SubjectIdentifierTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SubjectIdentifierTest.cs index 1418e8cc46..df5d30f5c1 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SubjectIdentifierTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SubjectIdentifierTest.cs @@ -26,7 +26,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -85,4 +85,4 @@ namespace MonoTests.System.Security.Cryptography.Pkcs { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.X509Certificates/X509Certificate2UICas.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.X509Certificates/X509Certificate2UICas.cs index 192ade125c..b6d50bac35 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.X509Certificates/X509Certificate2UICas.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.X509Certificates/X509Certificate2UICas.cs @@ -25,6 +25,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !MOBILE using NUnit.Framework; @@ -203,4 +204,4 @@ namespace MonoCasTests.System.Security.Cryptography.X509Certificates { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.X509Certificates/X509Certificate2UITest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.X509Certificates/X509Certificate2UITest.cs index 4d97499fb1..67bfa6e891 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.X509Certificates/X509Certificate2UITest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.X509Certificates/X509Certificate2UITest.cs @@ -25,7 +25,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -128,4 +128,4 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs index 7f7bd03a97..192c0881f3 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs @@ -6,6 +6,7 @@ // // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -76,3 +77,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif \ No newline at end of file diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs index e1bd2cebbd..ff715a2cc2 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs @@ -8,6 +8,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // (C) 2004 Novell Inc. // +#if !MOBILE using System; using System.Security.Cryptography; @@ -190,3 +191,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataReferenceTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataReferenceTest.cs index ff8ffb6689..f16fc17dc5 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataReferenceTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataReferenceTest.cs @@ -27,6 +27,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !MOBILE using System; using System.Security.Cryptography; @@ -51,4 +52,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/EncryptedXmlTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/EncryptedXmlTest.cs index 6949154ec0..7ff9beef39 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/EncryptedXmlTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/EncryptedXmlTest.cs @@ -6,7 +6,7 @@ // // Copyright (C) 2006 Novell, Inc (http://www.novell.com) // - +#if !MOBILE using System; using System.Collections; @@ -295,3 +295,4 @@ namespace MonoTests.System.Security.Cryptography.Xml } } } +#endif \ No newline at end of file diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs index 1c6bf09108..1a6448a04b 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs @@ -6,6 +6,7 @@ // // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -73,3 +74,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif \ No newline at end of file diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs index f0886c90d5..9643e062c4 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs @@ -6,6 +6,7 @@ // // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -66,3 +67,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs index 554c0a7f81..6226486f2f 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs @@ -7,6 +7,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // Copyright (C) 2005 Novell, Inc (http://www.novell.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -82,3 +83,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif \ No newline at end of file diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs index 9ea85fec06..e082a50667 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs @@ -7,6 +7,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -192,3 +193,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoX509DataTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoX509DataTest.cs index 58cdf2d830..73c6d01ed1 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoX509DataTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoX509DataTest.cs @@ -7,6 +7,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // Copyright (C) 2005 Novell, Inc (http://www.novell.com) // +#if !MOBILE using System; using System.IO; @@ -339,3 +340,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs index 4a8cdf8e13..e58892f46b 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs @@ -6,6 +6,7 @@ // // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -72,3 +73,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs index 06dfb70c42..2dab097c63 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs @@ -7,6 +7,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // (C) 2004 Novell (http://www.novell.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -235,3 +236,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs index 021caf05a9..6abf3dbe9b 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs @@ -7,6 +7,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -80,3 +81,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs index d96e26fd0b..604735dad7 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs @@ -7,6 +7,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // Copyright (C) 2005, 2009 Novell, Inc (http://www.novell.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -212,3 +213,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs index 0a06e23aa7..b5baf86ebd 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs @@ -7,6 +7,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // Copyright (C) 2004-2005, 2008 Novell, Inc (http://www.novell.com) // +#if !MOBILE using System; using System.Globalization; @@ -1769,4 +1770,5 @@ namespace MonoTests.System.Security.Cryptography.Xml { Assert.That (signatureMethodElement.Attributes["Algorithm"].Value, Is.EqualTo (algorithmName)); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs index 5f9684470e..aa8740a6c5 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs @@ -6,6 +6,7 @@ // // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // +#if !MOBILE using System; using System.Security.Cryptography; @@ -65,3 +66,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif \ No newline at end of file diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformTest.cs index ab9d2bb2e3..4039011575 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformTest.cs @@ -25,6 +25,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !MOBILE using NUnit.Framework; @@ -82,3 +83,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDecryptionTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDecryptionTransformTest.cs index a2a2c841eb..5de4d9fff1 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDecryptionTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDecryptionTransformTest.cs @@ -25,7 +25,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -68,4 +68,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs index e1a847ae54..9dbb9057ad 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs @@ -7,6 +7,7 @@ // (C) 2002 Motus Technologies Inc. (http://www.motus.com) // (C) 2004 Novell (http://www.novell.com) // +#if !MOBILE using System; using System.IO; @@ -179,3 +180,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs index a21c496300..6e04748f90 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs @@ -9,6 +9,7 @@ // (C) 2003 Aleksey Sanin (aleksey@aleksey.com) // (C) 2004 Novell (http://www.novell.com) // +#if !MOBILE using System; using System.IO; @@ -530,3 +531,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif \ No newline at end of file diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs index a3608afc00..2eea71d0ce 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs @@ -8,6 +8,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com) // +#if !MOBILE using System; using System.IO; @@ -407,3 +408,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { ""; } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransformTest.cs index 15cfee93d9..8f88ef8a44 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransformTest.cs @@ -6,6 +6,7 @@ // // (C) 2004 Novell Inc. // +#if !MOBILE using System; using System.IO; @@ -143,3 +144,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NTransformTest.cs index d14b5ee280..69e38cf817 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NTransformTest.cs @@ -18,6 +18,7 @@ // This file is simply replaced C14N->ExcC14N, and then replaced expected // output XML. So, they are *not* from c14n specification. // +#if !MOBILE using System; @@ -594,4 +595,5 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransformTest.cs index 9562da1864..ed5a460ab0 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransformTest.cs @@ -13,7 +13,7 @@ // (C) 2004 Novell (http://www.novell.com) // (C) 2008 Gert Driesen // - +#if !MOBILE using System; using System.IO; @@ -138,4 +138,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs index 56e87d6cdb..269ca1ca2b 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs @@ -7,7 +7,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com) // - +#if !MOBILE using System; using System.IO; using System.Security.Cryptography; @@ -291,3 +291,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs index 03b4f215b8..8201049cd4 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs @@ -8,6 +8,7 @@ // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // (C) 2004 Novell (http://www.novell.com) // +#if !MOBILE using System; using System.Collections; @@ -286,3 +287,5 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } +#endif + diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlLicenseTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlLicenseTransformTest.cs index ab05a297dc..7211c38d08 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlLicenseTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlLicenseTransformTest.cs @@ -12,7 +12,7 @@ // (C) 2004 Novell (http://www.novell.com) // (C) 2008 Gert Driesen // - +#if !MOBILE using System; using System.IO; @@ -88,4 +88,4 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedDataCas.cs b/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedDataCas.cs index bc2e6aeb40..b7777c39d6 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedDataCas.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedDataCas.cs @@ -26,7 +26,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -169,4 +169,4 @@ namespace MonoCasTests.System.Security.Cryptography { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedDataTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedDataTest.cs index 4848f68621..b97c23ef69 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedDataTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedDataTest.cs @@ -67,6 +67,7 @@ namespace MonoTests.System.Security.Cryptography { ProtectUnprotect (notMuchEntropy, DataProtectionScope.LocalMachine); } +#if !MOBILE // System.PlatformNotSupportedException: Operation is not supported on this platform. [Test] // https://bugzilla.xamarin.com/show_bug.cgi?id=38933 public void ProtectCurrentUserMultiThread () { @@ -91,6 +92,7 @@ namespace MonoTests.System.Security.Cryptography { foreach (var t in tasks) t.Start (); Task.WaitAll (tasks.ToArray ()); } +#endif [Test] public void DataProtectionScope_All () diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedMemoryCas.cs b/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedMemoryCas.cs index 2d98ae52cb..d81ae91a00 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedMemoryCas.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedMemoryCas.cs @@ -26,7 +26,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +#if !MOBILE using NUnit.Framework; @@ -165,4 +165,4 @@ namespace MonoCasTests.System.Security.Cryptography { } } } - +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedMemoryTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedMemoryTest.cs index dab36660d2..7cd2030bf4 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedMemoryTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography/ProtectedMemoryTest.cs @@ -7,7 +7,7 @@ // (C) 2003 Motus Technologies Inc. (http://www.motus.com) // Copyright (C) 2005 Novell, Inc (http://www.novell.com) // - +#if !MOBILE using NUnit.Framework; @@ -140,4 +140,4 @@ namespace MonoTests.System.Security.Cryptography { } } } - +#endif diff --git a/mcs/class/System.ServiceModel.Web/Test/System.ServiceModel.Web/WebInvokeAttributeTest.cs b/mcs/class/System.ServiceModel.Web/Test/System.ServiceModel.Web/WebInvokeAttributeTest.cs index 2858239af9..6dc547281f 100644 --- a/mcs/class/System.ServiceModel.Web/Test/System.ServiceModel.Web/WebInvokeAttributeTest.cs +++ b/mcs/class/System.ServiceModel.Web/Test/System.ServiceModel.Web/WebInvokeAttributeTest.cs @@ -57,10 +57,15 @@ namespace MonoTests.System.ServiceModel.Description } [Test] - [ExpectedException (typeof (InvalidOperationException))] public void RejectTwoParametersWhenNotWrapped () { - new WebChannelFactory (new WebHttpBinding (), new Uri ("http://localhost:37564")).CreateChannel (); + var factory = new WebChannelFactory (new WebHttpBinding (), new Uri ("http://localhost:37564")); + +#if MOBILE + factory.Endpoint.Behaviors.Add (new WebHttpBehavior ()); +#endif + + Assert.Throws (() => factory.CreateChannel ()); } [ServiceContract] diff --git a/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs b/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs index 8ed25908b0..3406cae2c0 100644 --- a/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs +++ b/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs @@ -227,7 +227,7 @@ namespace Mono.Net.Security if (Interlocked.Exchange (ref WriteRequested, 0) != 0) { // Flush the write queue. Debug ("ProcessOperation - flushing write queue"); - await Parent.InnerWrite (RunSynchronously, cancellationToken); + await Parent.InnerWrite (RunSynchronously, cancellationToken).ConfigureAwait (false); } Debug ("ProcessOperation done: {0} -> {1}", status, newStatus); diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs index b038095093..35b7f3fac6 100644 --- a/mcs/class/System/System.Diagnostics/Process.cs +++ b/mcs/class/System/System.Diagnostics/Process.cs @@ -72,6 +72,8 @@ namespace System.Diagnostics string process_name; + static ProcessModule current_main_module; + /* Private constructor called from other methods */ private Process (SafeProcessHandle handle, int id) { SetProcessHandle (handle); @@ -98,7 +100,14 @@ namespace System.Diagnostics [MonitoringDescription ("The main module of the process.")] public ProcessModule MainModule { get { - return(this.Modules[0]); + /* Optimize Process.GetCurrentProcess ().MainModule */ + if (processId == NativeMethods.GetCurrentProcessId ()) { + if (current_main_module == null) + current_main_module = this.Modules [0]; + return current_main_module; + } else { + return this.Modules [0]; + } } } diff --git a/mcs/class/System/System.IO.Compression/DeflateStream.cs b/mcs/class/System/System.IO.Compression/DeflateStream.cs index 8249d786c2..3b772a19af 100644 --- a/mcs/class/System/System.IO.Compression/DeflateStream.cs +++ b/mcs/class/System/System.IO.Compression/DeflateStream.cs @@ -322,7 +322,7 @@ namespace System.IO.Compression UnmanagedReadOrWrite feeder; // This will be passed to unmanaged code and used there Stream base_stream; - IntPtr z_stream; + SafeDeflateStreamHandle z_stream; GCHandle data; bool disposed; byte [] io_buffer; @@ -337,7 +337,7 @@ namespace System.IO.Compression dsn.data = GCHandle.Alloc (dsn); dsn.feeder = mode == CompressionMode.Compress ? new UnmanagedReadOrWrite (UnmanagedWrite) : new UnmanagedReadOrWrite (UnmanagedRead); dsn.z_stream = CreateZStream (mode, gzip, dsn.feeder, GCHandle.ToIntPtr (dsn.data)); - if (dsn.z_stream == IntPtr.Zero) { + if (dsn.z_stream.IsInvalid) { dsn.Dispose (true); return null; } @@ -359,10 +359,7 @@ namespace System.IO.Compression io_buffer = null; - IntPtr zz = z_stream; - z_stream = IntPtr.Zero; - if (zz != IntPtr.Zero) - CloseZStream (zz); // This will Flush() the remaining output if any + z_stream.Dispose(); } if (data.IsAllocated) { @@ -488,21 +485,21 @@ namespace System.IO.Compression #if !ORBIS [DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)] - static extern IntPtr CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data); + static extern SafeDeflateStreamHandle CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data); [DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)] static extern int CloseZStream (IntPtr stream); [DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)] - static extern int Flush (IntPtr stream); + static extern int Flush (SafeDeflateStreamHandle stream); [DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)] - static extern int ReadZStream (IntPtr stream, IntPtr buffer, int length); + static extern int ReadZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length); [DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)] - static extern int WriteZStream (IntPtr stream, IntPtr buffer, int length); + static extern int WriteZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length); #else - static IntPtr CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data) + static SafeDeflateStreamHandle CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data) { throw new PlatformNotSupportedException (); } @@ -512,22 +509,39 @@ namespace System.IO.Compression throw new PlatformNotSupportedException (); } - static int Flush (IntPtr stream) + static int Flush (SafeDeflateStreamHandle stream) { throw new PlatformNotSupportedException (); } - static int ReadZStream (IntPtr stream, IntPtr buffer, int length) + static int ReadZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length) { throw new PlatformNotSupportedException (); } - static int WriteZStream (IntPtr stream, IntPtr buffer, int length) + static int WriteZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length) { throw new PlatformNotSupportedException (); } #endif + sealed class SafeDeflateStreamHandle : SafeHandle + { + public override bool IsInvalid + { + get { return handle == IntPtr.Zero; } + } + + private SafeDeflateStreamHandle() : base(IntPtr.Zero, true) + { + } + + override protected bool ReleaseHandle() + { + DeflateStreamNative.CloseZStream(handle); + return true; + } + } } } diff --git a/mcs/class/System/System_test.dll.sources b/mcs/class/System/System_test.dll.sources index 2435169907..6cd61c0847 100644 --- a/mcs/class/System/System_test.dll.sources +++ b/mcs/class/System/System_test.dll.sources @@ -278,6 +278,7 @@ System.Net.Security/SslStreamTest.cs System.Runtime.Versioning/FrameworkNameTest.cs System.Security.AccessControl/SemaphoreSecurityTest.cs System.Security.Cryptography/AsnEncodedDataTest.cs +System.Security.Cryptography/CryptoConfigTest.cs System.Security.Cryptography/OidCollectionTest.cs System.Security.Cryptography/OidEnumeratorTest.cs System.Security.Cryptography/OidTest.cs diff --git a/mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs b/mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs index 84f7572a9d..1c348dc488 100644 --- a/mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs +++ b/mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs @@ -26,7 +26,7 @@ namespace MonoTests.System.ComponentModel SynchronizationContext sc1 = new SynchronizationContext (); SynchronizationContext sc2 = new SynchronizationContext (); -#if MONOTOUCH || XAMMAC +#if MONOTOUCH Assert.IsNotNull (SynchronizationContext.Current, "A1"); #else Assert.IsNull (SynchronizationContext.Current, "A1"); diff --git a/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs b/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs index cf366aca2f..576ba329d4 100644 --- a/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs +++ b/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs @@ -170,6 +170,9 @@ namespace MonoTests.System.Net [Test] #if FEATURE_NO_BSD_SOCKETS [ExpectedException (typeof (PlatformNotSupportedException))] +#endif +#if MONOTOUCH + [Ignore ("Randomly produces ObjectDisposedExceptions, in particular on device. See bug #39780.")] #endif public void HttpBasicAuthScheme () { @@ -290,6 +293,9 @@ namespace MonoTests.System.Net [Test] #if FEATURE_NO_BSD_SOCKETS [ExpectedException (typeof (PlatformNotSupportedException))] +#endif +#if MONOTOUCH + [Ignore ("On device sometimes hangs in the call to listener.GetContext (). See bug #60542.")] #endif public void HttpRequestIgnoreBadCookies () { diff --git a/mcs/class/System/Test/System.Security.Cryptography/CryptoConfigTest.cs b/mcs/class/System/Test/System.Security.Cryptography/CryptoConfigTest.cs new file mode 100644 index 0000000000..460802f938 --- /dev/null +++ b/mcs/class/System/Test/System.Security.Cryptography/CryptoConfigTest.cs @@ -0,0 +1,54 @@ +// +// CryptoConfig.cs - NUnit tests for CryptoConfig +// +// Author: +// Chris Hamons +// +// Copyright (c) 2017 Xamarin, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + + +using NUnit.Framework; + +using System; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; + +namespace MonoTests.System.Security.Cryptography +{ + + [TestFixture] + public class CryptoConfigTest + { + [Test] + [TestCase ("http://www.w3.org/2000/09/xmldsig#dsa-sha1")] + [TestCase ("http://www.w3.org/2000/09/xmldsig#rsa-sha1")] + [TestCase ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")] + [TestCase ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384")] + [TestCase ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512")] + public void CryptoConfig_NonNullDigest (string name) + { + SignatureDescription signatureDescription = CryptoConfig.CreateFromName (name) as SignatureDescription; + Assert.NotNull (signatureDescription.CreateDigest ()); + } + } +} + diff --git a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml index c5028d4742..68786da22a 100644 --- a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml +++ b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml @@ -745,6 +745,11 @@ + + + + + diff --git a/mcs/class/corlib/LinkerDescriptor/mscorlib_test.xml b/mcs/class/corlib/LinkerDescriptor/mscorlib_test.xml new file mode 100644 index 0000000000..6ecd1be005 --- /dev/null +++ b/mcs/class/corlib/LinkerDescriptor/mscorlib_test.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/mcs/class/corlib/Makefile b/mcs/class/corlib/Makefile index 131443e8c2..94baf24e48 100644 --- a/mcs/class/corlib/Makefile +++ b/mcs/class/corlib/Makefile @@ -101,7 +101,7 @@ endif # System.IO/DirectoryInfoTest.cs needs Mono.Posix TEST_MCS_FLAGS += -debug -nowarn:168,219,618,672 -unsafe \ - -define:MONO_DATACONVERTER_STATIC_METHODS $(TEST_RESX_RESOURCES:%=-resource:%) + -define:MONO_DATACONVERTER_STATIC_METHODS $(TEST_RESX_RESOURCES:%=-resource:%) -resource:LinkerDescriptor/mscorlib_test.xml,$(test_lib:.dll=.xml) CC_PROFILE := $(filter monotouch% xammac, $(PROFILE)) @@ -137,7 +137,8 @@ EXTRA_DISTFILES = \ Test/resources/Fergie.GED \ Test/resources/culture-*.cs \ $(RESOURCE_FILES) \ - $(TEST_RESOURCES:.resources=.resx) + $(TEST_RESOURCES:.resources=.resx) \ + LinkerDescriptor/mscorlib_test.xml TEST_RESX_RESOURCES = \ Test/resources/Resources.resources diff --git a/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs b/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs index 4f20771c40..bd9af4717b 100644 --- a/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs +++ b/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs @@ -416,7 +416,7 @@ public partial class CryptoConfig { unresolved_algorithms.Add (nameECDsa_2, defaultECDsa); unresolved_algorithms.Add (nameECDsa_3, defaultECDsa); -#if MONODROID +#if MONODROID || XAMARIN_MODERN algorithms.Add (nameSHA1Cng, defaultSHA1); algorithms.Add (nameSHA256Cng, defaultSHA256); algorithms.Add (nameSHA256Provider, defaultSHA256); diff --git a/mcs/class/corlib/Test/System.IO/FileTest.cs b/mcs/class/corlib/Test/System.IO/FileTest.cs index 7e01ce544d..e9300c82c7 100644 --- a/mcs/class/corlib/Test/System.IO/FileTest.cs +++ b/mcs/class/corlib/Test/System.IO/FileTest.cs @@ -25,13 +25,16 @@ namespace MonoTests.System.IO public class FileTest { CultureInfo old_culture; - static string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests"); + string tmpFolder; [SetUp] public void SetUp () { - DeleteDirectory (TempFolder); - Directory.CreateDirectory (TempFolder); + tmpFolder = Path.GetTempFileName (); + if (File.Exists (tmpFolder)) + File.Delete (tmpFolder); + DeleteDirectory (tmpFolder); + Directory.CreateDirectory (tmpFolder); old_culture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false); } @@ -39,7 +42,7 @@ namespace MonoTests.System.IO [TearDown] public void TearDown () { - DeleteDirectory (TempFolder); + DeleteDirectory (tmpFolder); Thread.CurrentThread.CurrentCulture = old_culture; } @@ -65,7 +68,7 @@ namespace MonoTests.System.IO public void TestExists () { FileStream s = null; - string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; + string path = tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; try { Assert.IsFalse (File.Exists (null), "#1"); Assert.IsFalse (File.Exists (string.Empty), "#2"); @@ -74,7 +77,7 @@ namespace MonoTests.System.IO s = File.Create (path); s.Close (); Assert.IsTrue (File.Exists (path), "#4"); - Assert.IsFalse (File.Exists (TempFolder + Path.DirectorySeparatorChar + "doesnotexist"), "#5"); + Assert.IsFalse (File.Exists (tmpFolder + Path.DirectorySeparatorChar + "doesnotexist"), "#5"); } finally { if (s != null) s.Close (); @@ -112,7 +115,7 @@ namespace MonoTests.System.IO [Test] public void Create_Path_Directory () { - string path = Path.Combine (TempFolder, "foo"); + string path = Path.Combine (tmpFolder, "foo"); Directory.CreateDirectory (path); try { File.Create (path); @@ -146,7 +149,7 @@ namespace MonoTests.System.IO [Test] public void Create_Path_ReadOnly () { - string path = Path.Combine (TempFolder, "foo"); + string path = Path.Combine (tmpFolder, "foo"); File.Create (path).Close (); File.SetAttributes (path, FileAttributes.ReadOnly); try { @@ -182,7 +185,7 @@ namespace MonoTests.System.IO public void Create_Directory_DoesNotExist () { FileStream stream = null; - string path = TempFolder + Path.DirectorySeparatorChar + "directory_does_not_exist" + Path.DirectorySeparatorChar + "foo"; + string path = tmpFolder + Path.DirectorySeparatorChar + "directory_does_not_exist" + Path.DirectorySeparatorChar + "foo"; try { stream = File.Create (path); @@ -207,7 +210,7 @@ namespace MonoTests.System.IO string path = null; /* positive test: create resources/foo */ - path = TempFolder + Path.DirectorySeparatorChar + "foo"; + path = tmpFolder + Path.DirectorySeparatorChar + "foo"; try { stream = File.Create (path); @@ -222,7 +225,7 @@ namespace MonoTests.System.IO stream = null; /* positive test: repeat test above again to test for overwriting file */ - path = TempFolder + Path.DirectorySeparatorChar + "foo"; + path = tmpFolder + Path.DirectorySeparatorChar + "foo"; try { stream = File.Create (path); Assert.IsTrue (File.Exists (path), "#2"); @@ -339,8 +342,8 @@ namespace MonoTests.System.IO [Test] public void Copy_DestFileName_AlreadyExists () { - string source = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; - string dest = TempFolder + Path.DirectorySeparatorChar + "bar"; + string source = tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; + string dest = tmpFolder + Path.DirectorySeparatorChar + "bar"; DeleteFile (source); DeleteFile (dest); try { @@ -365,7 +368,7 @@ namespace MonoTests.System.IO [Test] public void Copy_SourceFileName_DestFileName_Same () { - string source = TempFolder + Path.DirectorySeparatorChar + "SameFile.txt"; + string source = tmpFolder + Path.DirectorySeparatorChar + "SameFile.txt"; DeleteFile (source); try { // new empty file @@ -386,8 +389,8 @@ namespace MonoTests.System.IO [Test] public void Copy () { - string path1 = TempFolder + Path.DirectorySeparatorChar + "bar"; - string path2 = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; + string path1 = tmpFolder + Path.DirectorySeparatorChar + "bar"; + string path2 = tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; /* positive test: copy resources/AFile.txt to resources/bar */ try { DeleteFile (path1); @@ -455,7 +458,7 @@ namespace MonoTests.System.IO [Test] public void Delete_Directory_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "directory_does_not_exist" + Path.DirectorySeparatorChar + "foo"; + string path = tmpFolder + Path.DirectorySeparatorChar + "directory_does_not_exist" + Path.DirectorySeparatorChar + "foo"; if (Directory.Exists (path)) Directory.Delete (path, true); @@ -474,7 +477,7 @@ namespace MonoTests.System.IO [Test] public void Delete () { - string foopath = TempFolder + Path.DirectorySeparatorChar + "foo"; + string foopath = tmpFolder + Path.DirectorySeparatorChar + "foo"; DeleteFile (foopath); try { File.Create (foopath).Close (); @@ -490,7 +493,7 @@ namespace MonoTests.System.IO [Category ("NotWorking")] public void Delete_FileLock () { - string path = TempFolder + Path.DirectorySeparatorChar + "DeleteOpenStreamException"; + string path = tmpFolder + Path.DirectorySeparatorChar + "DeleteOpenStreamException"; DeleteFile (path); FileStream stream = null; try { @@ -520,7 +523,7 @@ namespace MonoTests.System.IO if (RunningOnUnix) Assert.Ignore ("ReadOnly files can be deleted on unix since fdef50957f508627928c7876a905d5584da45748."); - string path = TempFolder + Path.DirectorySeparatorChar + "DeleteReadOnly"; + string path = tmpFolder + Path.DirectorySeparatorChar + "DeleteReadOnly"; DeleteFile (path); try { File.Create (path).Close (); @@ -546,7 +549,7 @@ namespace MonoTests.System.IO FileAttributes attrs; - string path = Path.Combine (TempFolder, "GetAttributes.tmp"); + string path = Path.Combine (tmpFolder, "GetAttributes.tmp"); File.Create (path).Close (); attrs = File.GetAttributes (path); @@ -565,7 +568,7 @@ namespace MonoTests.System.IO if (RunningOnUnix) Assert.Ignore ("bug #325181: FileAttributes.Archive has no effect on Unix."); - string path = Path.Combine (TempFolder, "GetAttributes.tmp"); + string path = Path.Combine (tmpFolder, "GetAttributes.tmp"); File.Create (path).Close (); FileAttributes attrs = File.GetAttributes (path); @@ -581,7 +584,7 @@ namespace MonoTests.System.IO [Test] public void GetAttributes_Default_Directory () { - FileAttributes attrs = File.GetAttributes (TempFolder); + FileAttributes attrs = File.GetAttributes (tmpFolder); Assert.IsFalse ((attrs & FileAttributes.Archive) != 0, "#1"); Assert.IsTrue ((attrs & FileAttributes.Directory) != 0, "#2"); @@ -594,16 +597,16 @@ namespace MonoTests.System.IO [Test] public void GetAttributes_Directory () { - FileAttributes attrs = File.GetAttributes (TempFolder); + FileAttributes attrs = File.GetAttributes (tmpFolder); Assert.IsTrue ((attrs & FileAttributes.Directory) != 0, "#1"); attrs &= ~FileAttributes.Directory; - File.SetAttributes (TempFolder, attrs); + File.SetAttributes (tmpFolder, attrs); Assert.IsFalse ((attrs & FileAttributes.Directory) != 0, "#2"); - string path = Path.Combine (TempFolder, "GetAttributes.tmp"); + string path = Path.Combine (tmpFolder, "GetAttributes.tmp"); File.Create (path).Close (); attrs = File.GetAttributes (path); @@ -618,7 +621,7 @@ namespace MonoTests.System.IO { FileAttributes attrs; - string path = Path.Combine (TempFolder, "GetAttributes.tmp"); + string path = Path.Combine (tmpFolder, "GetAttributes.tmp"); File.Create (path).Close (); attrs = File.GetAttributes (path); @@ -643,7 +646,7 @@ namespace MonoTests.System.IO FileAttributes attrs; - string path = Path.Combine (TempFolder, "GetAttributes.tmp"); + string path = Path.Combine (tmpFolder, "GetAttributes.tmp"); File.Create (path).Close (); attrs = File.GetAttributes (path); @@ -659,7 +662,7 @@ namespace MonoTests.System.IO [Test] public void GetAttributes_Path_DoesNotExist () { - string path = Path.Combine (TempFolder, "GetAttributes.tmp"); + string path = Path.Combine (tmpFolder, "GetAttributes.tmp"); try { File.GetAttributes (path); Assert.Fail ("#1"); @@ -791,7 +794,7 @@ namespace MonoTests.System.IO [Test] public void Move_SourceFileName_DoesNotExist () { - string file = TempFolder + Path.DirectorySeparatorChar + "doesnotexist"; + string file = tmpFolder + Path.DirectorySeparatorChar + "doesnotexist"; DeleteFile (file); try { File.Move (file, "b"); @@ -807,8 +810,8 @@ namespace MonoTests.System.IO [Test] public void Move_DestFileName_DirectoryDoesNotExist () { - string sourceFile = TempFolder + Path.DirectorySeparatorChar + "foo"; - string destFile = Path.Combine (Path.Combine (TempFolder, "doesnotexist"), "b"); + string sourceFile = tmpFolder + Path.DirectorySeparatorChar + "foo"; + string destFile = Path.Combine (Path.Combine (tmpFolder, "doesnotexist"), "b"); DeleteFile (sourceFile); try { File.Create (sourceFile).Close (); @@ -830,13 +833,13 @@ namespace MonoTests.System.IO [Test] public void Move_DestFileName_AlreadyExists () { - string sourceFile = TempFolder + Path.DirectorySeparatorChar + "foo"; + string sourceFile = tmpFolder + Path.DirectorySeparatorChar + "foo"; string destFile; // move to same directory File.Create (sourceFile).Close (); try { - File.Move (sourceFile, TempFolder); + File.Move (sourceFile, tmpFolder); Assert.Fail ("#A1"); } catch (IOException ex) { // Cannot create a file when that file already exists @@ -844,14 +847,14 @@ namespace MonoTests.System.IO Assert.IsNull (ex.InnerException, "#A3"); Assert.IsNotNull (ex.Message, "#A4"); Assert.IsFalse (ex.Message.IndexOf (sourceFile) != -1, "#A5"); - Assert.IsFalse (ex.Message.IndexOf (TempFolder) != -1, "#A6"); + Assert.IsFalse (ex.Message.IndexOf (tmpFolder) != -1, "#A6"); } finally { DeleteFile (sourceFile); } // move to exist file File.Create (sourceFile).Close (); - destFile = TempFolder + Path.DirectorySeparatorChar + "bar"; + destFile = tmpFolder + Path.DirectorySeparatorChar + "bar"; File.Create (destFile).Close (); try { File.Move (sourceFile, destFile); @@ -870,7 +873,7 @@ namespace MonoTests.System.IO // move to existing directory File.Create (sourceFile).Close (); - destFile = TempFolder + Path.DirectorySeparatorChar + "bar"; + destFile = tmpFolder + Path.DirectorySeparatorChar + "bar"; Directory.CreateDirectory (destFile); try { File.Move (sourceFile, destFile); @@ -891,8 +894,8 @@ namespace MonoTests.System.IO [Test] public void Move () { - string bar = TempFolder + Path.DirectorySeparatorChar + "bar"; - string baz = TempFolder + Path.DirectorySeparatorChar + "baz"; + string bar = tmpFolder + Path.DirectorySeparatorChar + "bar"; + string baz = tmpFolder + Path.DirectorySeparatorChar + "baz"; if (!File.Exists (bar)) { FileStream f = File.Create(bar); f.Close(); @@ -904,8 +907,8 @@ namespace MonoTests.System.IO Assert.IsTrue (File.Exists (baz), "#3"); // Test moving of directories - string dir = Path.Combine (TempFolder, "dir"); - string dir2 = Path.Combine (TempFolder, "dir2"); + string dir = Path.Combine (tmpFolder, "dir"); + string dir2 = Path.Combine (tmpFolder, "dir2"); string dir_foo = Path.Combine (dir, "foo"); string dir2_foo = Path.Combine (dir2, "foo"); @@ -965,7 +968,7 @@ namespace MonoTests.System.IO string path = null; FileStream stream = null; - path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; + path = tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; try { if (!File.Exists (path)) stream = File.Create (path); @@ -1009,7 +1012,7 @@ namespace MonoTests.System.IO stream = null; /* Exception tests */ - path = TempFolder + Path.DirectorySeparatorChar + "filedoesnotexist"; + path = tmpFolder + Path.DirectorySeparatorChar + "filedoesnotexist"; try { stream = File.Open (path, FileMode.Open); Assert.Fail ("#D1"); @@ -1028,10 +1031,10 @@ namespace MonoTests.System.IO [Test] public void Open_CreateNewMode_ReadAccess () { - string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; + string path = tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; FileStream stream = null; try { - stream = File.Open (TempFolder + Path.DirectorySeparatorChar + "AFile.txt", FileMode.CreateNew, FileAccess.Read); + stream = File.Open (tmpFolder + Path.DirectorySeparatorChar + "AFile.txt", FileMode.CreateNew, FileAccess.Read); Assert.Fail ("#1"); } catch (ArgumentException ex) { // Combining FileMode: CreateNew with FileAccess: Read is invalid @@ -1049,7 +1052,7 @@ namespace MonoTests.System.IO [Test] public void Open_AppendMode_ReadAccess () { - string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; + string path = tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; FileStream s = null; if (!File.Exists (path)) File.Create (path).Close (); @@ -1072,7 +1075,7 @@ namespace MonoTests.System.IO [Test] public void OpenRead () { - string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; + string path = tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; if (!File.Exists (path)) File.Create (path).Close (); FileStream stream = null; @@ -1092,7 +1095,7 @@ namespace MonoTests.System.IO [Test] public void OpenWrite () { - string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; + string path = tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; if (!File.Exists (path)) File.Create (path).Close (); FileStream stream = null; @@ -1113,7 +1116,7 @@ namespace MonoTests.System.IO [Test] public void TestGetCreationTime () { - string path = TempFolder + Path.DirectorySeparatorChar + "baz"; + string path = tmpFolder + Path.DirectorySeparatorChar + "baz"; DeleteFile (path); try { @@ -1170,7 +1173,7 @@ namespace MonoTests.System.IO [Test] public void LastAccessTime () { - string path = TempFolder + Path.DirectorySeparatorChar + "lastAccessTime"; + string path = tmpFolder + Path.DirectorySeparatorChar + "lastAccessTime"; if (File.Exists (path)) File.Delete (path); FileStream stream = null; @@ -1217,7 +1220,7 @@ namespace MonoTests.System.IO [Test] public void LastWriteTime () { - string path = TempFolder + Path.DirectorySeparatorChar + "lastWriteTime"; + string path = tmpFolder + Path.DirectorySeparatorChar + "lastWriteTime"; if (File.Exists (path)) File.Delete (path); FileStream stream = null; @@ -1293,7 +1296,7 @@ namespace MonoTests.System.IO [Test] public void GetCreationTime_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "GetCreationTimeException3"; + string path = tmpFolder + Path.DirectorySeparatorChar + "GetCreationTimeException3"; DeleteFile (path); DateTime time = File.GetCreationTime (path); @@ -1368,7 +1371,7 @@ namespace MonoTests.System.IO [Test] public void GetCreationTimeUtc_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "GetCreationTimeUtcException3"; + string path = tmpFolder + Path.DirectorySeparatorChar + "GetCreationTimeUtcException3"; DeleteFile (path); DateTime time = File.GetCreationTimeUtc (path); @@ -1442,7 +1445,7 @@ namespace MonoTests.System.IO [Test] public void GetLastAccessTime_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeException3"; + string path = tmpFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeException3"; DeleteFile (path); DateTime time = File.GetLastAccessTime (path); @@ -1517,7 +1520,7 @@ namespace MonoTests.System.IO [Test] public void GetLastAccessTimeUtc_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3"; + string path = tmpFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3"; DeleteFile (path); DateTime time = File.GetLastAccessTimeUtc (path); @@ -1591,7 +1594,7 @@ namespace MonoTests.System.IO [Test] public void GetLastWriteTime_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3"; + string path = tmpFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3"; DeleteFile (path); DateTime time = File.GetLastWriteTime (path); @@ -1666,7 +1669,7 @@ namespace MonoTests.System.IO [Test] public void GetLastWriteTimeUtc_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "GetLastWriteTimeUtcException3"; + string path = tmpFolder + Path.DirectorySeparatorChar + "GetLastWriteTimeUtcException3"; DeleteFile (path); DateTime time = File.GetLastWriteTimeUtc (path); @@ -1711,7 +1714,7 @@ namespace MonoTests.System.IO [Test] public void FileStreamClose () { - string path = TempFolder + Path.DirectorySeparatorChar + "FileStreamClose"; + string path = tmpFolder + Path.DirectorySeparatorChar + "FileStreamClose"; FileStream stream = null; try { stream = File.Create (path); @@ -1792,7 +1795,7 @@ namespace MonoTests.System.IO [Test] public void SetCreationTime_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeFileNotFoundException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "SetCreationTimeFileNotFoundException1"; DeleteFile (path); try { @@ -1810,7 +1813,7 @@ namespace MonoTests.System.IO // [ExpectedException(typeof (ArgumentOutOfRangeException))] // public void SetCreationTimeArgumentOutOfRangeException1 () // { -// string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeArgumentOutOfRangeException1"; +// string path = tmpFolder + Path.DirectorySeparatorChar + "SetCreationTimeArgumentOutOfRangeException1"; // FileStream stream = null; // DeleteFile (path); // try { @@ -1827,7 +1830,7 @@ namespace MonoTests.System.IO [Test] public void SetCreationTime_FileLock () { - string path = TempFolder + Path.DirectorySeparatorChar + "CreationTimeIOException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "CreationTimeIOException1"; DeleteFile (path); FileStream stream = null; try { @@ -1916,7 +1919,7 @@ namespace MonoTests.System.IO [Test] public void SetCreationTimeUtc_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcFileNotFoundException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcFileNotFoundException1"; DeleteFile (path); try { @@ -1934,7 +1937,7 @@ namespace MonoTests.System.IO // [ExpectedException(typeof (ArgumentOutOfRangeException))] // public void SetCreationTimeUtcArgumentOutOfRangeException1 () // { -// string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcArgumentOutOfRangeException1"; +// string path = tmpFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcArgumentOutOfRangeException1"; // DeleteFile (path); // FileStream stream = null; // try { @@ -1951,7 +1954,7 @@ namespace MonoTests.System.IO [Test] public void SetCreationTimeUtc_FileLock () { - string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcIOException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcIOException1"; DeleteFile (path); FileStream stream = null; try { @@ -2042,7 +2045,7 @@ namespace MonoTests.System.IO [Test] public void SetLastAccessTime_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeFileNotFoundException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeFileNotFoundException1"; DeleteFile (path); try { @@ -2060,7 +2063,7 @@ namespace MonoTests.System.IO // [ExpectedException(typeof (ArgumentOutOfRangeException))] // public void SetLastAccessTimeArgumentOutOfRangeException1 () // { -// string path = TempFolder + Path.DirectorySeparatorChar + "SetLastTimeArgumentOutOfRangeException1"; +// string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastTimeArgumentOutOfRangeException1"; // DeleteFile (path); // FileStream stream = null; // try { @@ -2077,7 +2080,7 @@ namespace MonoTests.System.IO [Test] public void SetLastAccessTime_FileLock () { - string path = TempFolder + Path.DirectorySeparatorChar + "LastAccessIOException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "LastAccessIOException1"; DeleteFile (path); FileStream stream = null; try { @@ -2166,7 +2169,7 @@ namespace MonoTests.System.IO [Test] public void SetLastAccessTimeUtc_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcFileNotFoundException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcFileNotFoundException1"; DeleteFile (path); try { @@ -2184,7 +2187,7 @@ namespace MonoTests.System.IO // [ExpectedException(typeof (ArgumentOutOfRangeException))] // public void SetLastAccessTimeUtcArgumentOutOfRangeException1 () // { -// string path = TempFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcArgumentOutOfRangeException1"; +// string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcArgumentOutOfRangeException1"; // DeleteFile (path); // FileStream stream = null; // try { @@ -2201,7 +2204,7 @@ namespace MonoTests.System.IO [Test] public void SetLastAccessTimeUtc_FileLock () { - string path = TempFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcIOException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcIOException1"; DeleteFile (path); FileStream stream = null; try { @@ -2292,7 +2295,7 @@ namespace MonoTests.System.IO [Test] public void SetLastWriteTime_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeFileNotFoundException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeFileNotFoundException1"; DeleteFile (path); try { @@ -2310,7 +2313,7 @@ namespace MonoTests.System.IO // [ExpectedException(typeof (ArgumentOutOfRangeException))] // public void SetLastWriteTimeArgumentOutOfRangeException1 () // { -// string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeArgumentOutOfRangeException1"; +// string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeArgumentOutOfRangeException1"; // DeleteFile (path); // FileStream stream = null; // try { @@ -2327,7 +2330,7 @@ namespace MonoTests.System.IO [Test] public void SetLastWriteTime_FileLock () { - string path = TempFolder + Path.DirectorySeparatorChar + "LastWriteTimeIOException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "LastWriteTimeIOException1"; DeleteFile (path); FileStream stream = null; try { @@ -2416,7 +2419,7 @@ namespace MonoTests.System.IO [Test] public void SetLastWriteTimeUtc_Path_DoesNotExist () { - string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcFileNotFoundException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcFileNotFoundException1"; DeleteFile (path); try { @@ -2434,7 +2437,7 @@ namespace MonoTests.System.IO // [ExpectedException(typeof (ArgumentOutOfRangeException))] // public void SetLastWriteTimeUtcArgumentOutOfRangeException1 () // { -// string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcArgumentOutOfRangeException1"; +// string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcArgumentOutOfRangeException1"; // DeleteFile (path); // FileStream stream = null; // try { @@ -2451,7 +2454,7 @@ namespace MonoTests.System.IO [Test] public void SetLastWriteTimeUtc_FileLock () { - string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcIOException1"; + string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcIOException1"; DeleteFile (path); FileStream stream = null; try { @@ -2580,7 +2583,7 @@ namespace MonoTests.System.IO [Test] public void ReplaceTest () { - string tmp = Path.Combine (TempFolder, "ReplaceTest"); + string tmp = Path.Combine (tmpFolder, "ReplaceTest"); Directory.CreateDirectory (tmp); string origFile = Path.Combine (tmp, "origFile"); string replaceFile = Path.Combine (tmp, "replaceFile"); @@ -2694,6 +2697,9 @@ namespace MonoTests.System.IO public static extern int symlink (string oldpath, string newpath); [Test] +#if __TVOS__ + [Ignore ("See bug #59239")] +#endif public void SymLinkLoop () { if (!RunningOnUnix) diff --git a/mcs/class/corlib/Test/System.IO/StreamReaderTest.cs b/mcs/class/corlib/Test/System.IO/StreamReaderTest.cs index eb29cfa9e4..f916c57a6a 100644 --- a/mcs/class/corlib/Test/System.IO/StreamReaderTest.cs +++ b/mcs/class/corlib/Test/System.IO/StreamReaderTest.cs @@ -18,15 +18,20 @@ namespace MonoTests.System.IO [TestFixture] public class StreamReaderTest { - static string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests"); - private string _codeFileName = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; + private string _tmpFolder; + private string _codeFileName; private const string TestString = "Hello World!"; [SetUp] public void SetUp () { - if (!Directory.Exists (TempFolder)) - Directory.CreateDirectory (TempFolder); + _tmpFolder = Path.GetTempFileName (); + if (File.Exists (_tmpFolder)) + File.Delete (_tmpFolder); + _codeFileName = _tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; + + if (!Directory.Exists (_tmpFolder)) + Directory.CreateDirectory (_tmpFolder); if (!File.Exists (_codeFileName)) File.Create (_codeFileName).Close (); @@ -35,8 +40,8 @@ public class StreamReaderTest [TearDown] public void TearDown () { - if (Directory.Exists (TempFolder)) - Directory.Delete (TempFolder, true); + if (Directory.Exists (_tmpFolder)) + Directory.Delete (_tmpFolder, true); } @@ -245,7 +250,7 @@ public class StreamReaderTest { bool errorThrown = false; try { - new StreamReader(TempFolder + "/nonexistentfile", false); + new StreamReader(_tmpFolder + "/nonexistentfile", false); } catch (FileNotFoundException) { errorThrown = true; } catch (Exception e) { @@ -256,7 +261,7 @@ public class StreamReaderTest { bool errorThrown = false; try { - new StreamReader(TempFolder + "/nonexistentdir/file", false); + new StreamReader(_tmpFolder + "/nonexistentdir/file", false); } catch (DirectoryNotFoundException) { errorThrown = true; } catch (Exception e) { @@ -310,7 +315,7 @@ public class StreamReaderTest { bool errorThrown = false; try { - new StreamReader(TempFolder + "/nonexistentfile", true); + new StreamReader(_tmpFolder + "/nonexistentfile", true); } catch (FileNotFoundException) { errorThrown = true; } catch (Exception e) { @@ -321,7 +326,7 @@ public class StreamReaderTest { bool errorThrown = false; try { - new StreamReader(TempFolder + "/nonexistentdir/file", true); + new StreamReader(_tmpFolder + "/nonexistentdir/file", true); } catch (DirectoryNotFoundException) { errorThrown = true; } catch (Exception e) { diff --git a/mcs/class/corlib/Test/System.IO/StreamWriterTest.cs b/mcs/class/corlib/Test/System.IO/StreamWriterTest.cs index a0afe23178..9e47fd6921 100644 --- a/mcs/class/corlib/Test/System.IO/StreamWriterTest.cs +++ b/mcs/class/corlib/Test/System.IO/StreamWriterTest.cs @@ -95,16 +95,23 @@ namespace MonoTests.System.IO } } - static string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests"); - private string _codeFileName = TempFolder + Path.DirectorySeparatorChar + "AFile.txt"; - private string _thisCodeFileName = TempFolder + Path.DirectorySeparatorChar + "StreamWriterTest.temp"; + private string _tmpFolder; + private string _codeFileName; + private string _thisCodeFileName; [SetUp] public void SetUp () { - if (Directory.Exists (TempFolder)) - Directory.Delete (TempFolder, true); - Directory.CreateDirectory (TempFolder); + _tmpFolder = Path.GetTempFileName (); + if (File.Exists (_tmpFolder)) + File.Delete (_tmpFolder); + + _codeFileName = _tmpFolder + Path.DirectorySeparatorChar + "AFile.txt"; + _thisCodeFileName = _tmpFolder + Path.DirectorySeparatorChar + "StreamWriterTest.temp"; + + if (Directory.Exists (_tmpFolder)) + Directory.Delete (_tmpFolder, true); + Directory.CreateDirectory (_tmpFolder); if (!File.Exists (_thisCodeFileName)) File.Create (_thisCodeFileName).Close (); @@ -113,8 +120,8 @@ namespace MonoTests.System.IO [TearDown] public void TearDown () { - if (Directory.Exists (TempFolder)) - Directory.Delete (TempFolder, true); + if (Directory.Exists (_tmpFolder)) + Directory.Delete (_tmpFolder, true); } [Test] // .ctor (Stream) @@ -182,7 +189,7 @@ namespace MonoTests.System.IO [Test] // .ctor (String) public void Constructor2_Path_DirectoryNotFound () { - Directory.Delete (TempFolder, true); + Directory.Delete (_tmpFolder, true); try { new StreamWriter (_codeFileName); @@ -192,7 +199,7 @@ namespace MonoTests.System.IO Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#2"); Assert.IsNull (ex.InnerException, "#3"); Assert.IsNotNull (ex.Message, "#4"); - Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#5"); + Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#5"); } } @@ -328,7 +335,7 @@ namespace MonoTests.System.IO [Test] // .ctor (String, Boolean) public void Constructor4_Path_DirectoryNotFound () { - Directory.Delete (TempFolder, true); + Directory.Delete (_tmpFolder, true); try { new StreamWriter (_codeFileName, false); @@ -338,7 +345,7 @@ namespace MonoTests.System.IO Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#A2"); Assert.IsNull (ex.InnerException, "#A3"); Assert.IsNotNull (ex.Message, "#A4"); - Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#A5"); + Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#A5"); } try { @@ -349,7 +356,7 @@ namespace MonoTests.System.IO Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#B2"); Assert.IsNull (ex.InnerException, "#B3"); Assert.IsNotNull (ex.Message, "#B4"); - Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#B5"); + Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#B5"); } } @@ -579,7 +586,7 @@ namespace MonoTests.System.IO [Test] // .ctor (String, Boolean, Encoding) public void Constructor6_Path_DirectoryNotFound () { - Directory.Delete (TempFolder, true); + Directory.Delete (_tmpFolder, true); try { new StreamWriter (_codeFileName, false, Encoding.UTF8); @@ -589,7 +596,7 @@ namespace MonoTests.System.IO Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#A2"); Assert.IsNull (ex.InnerException, "#A3"); Assert.IsNotNull (ex.Message, "#A4"); - Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#A5"); + Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#A5"); } try { @@ -600,7 +607,7 @@ namespace MonoTests.System.IO Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#B2"); Assert.IsNull (ex.InnerException, "#B3"); Assert.IsNotNull (ex.Message, "#B4"); - Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#B5"); + Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#B5"); } } @@ -759,7 +766,7 @@ namespace MonoTests.System.IO [Test] // .ctor (String, Boolean, Encoding, Int32) public void Constructor7_Path_DirectoryNotFound () { - Directory.Delete (TempFolder, true); + Directory.Delete (_tmpFolder, true); try { new StreamWriter (_codeFileName, false, Encoding.UTF8, 10); @@ -769,7 +776,7 @@ namespace MonoTests.System.IO Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#A2"); Assert.IsNull (ex.InnerException, "#A3"); Assert.IsNotNull (ex.Message, "#A4"); - Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#A5"); + Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#A5"); } try { @@ -780,7 +787,7 @@ namespace MonoTests.System.IO Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#B2"); Assert.IsNull (ex.InnerException, "#B3"); Assert.IsNotNull (ex.Message, "#B4"); - Assert.IsTrue (ex.Message.IndexOf (TempFolder) != -1, "#B5"); + Assert.IsTrue (ex.Message.IndexOf (_tmpFolder) != -1, "#B5"); } } diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/ModuleBuilderTest.cs b/mcs/class/corlib/Test/System.Reflection.Emit/ModuleBuilderTest.cs index 3bf8fe8246..e2574908f4 100644 --- a/mcs/class/corlib/Test/System.Reflection.Emit/ModuleBuilderTest.cs +++ b/mcs/class/corlib/Test/System.Reflection.Emit/ModuleBuilderTest.cs @@ -298,6 +298,59 @@ namespace MonoTests.System.Reflection.Emit // (they do not provide an implementation of ToString). } + [Test] + public void GetArrayMethodMultipleCallsTest () + { + AssemblyBuilder ab = genAssembly (); + ModuleBuilder modb = ab.DefineDynamicModule ("foo.dll", "foo.dll"); + + TypeBuilder tb = modb.DefineType ("TestType"); + var int2D = typeof (int[,]); + var mb = tb.DefineMethod ("TestMeth", MethodAttributes.Static | MethodAttributes.Public, + typeof(int), new Type[] { int2D }); + var ilg = mb.GetILGenerator (); + + // static int TestMeth(int[,] a) + // { + // int x; + // x = a.Get(0,0); + // return a.Get(0,1) + x; + // } + // + + var x = ilg.DeclareLocal (typeof (int)); + + ilg.Emit (OpCodes.Ldarg_0); + ilg.Emit (OpCodes.Ldc_I4_0); + ilg.Emit (OpCodes.Ldc_I4_0); + var arrmi = modb.GetArrayMethod (int2D, "Get", + CallingConventions.Standard | CallingConventions.HasThis, + typeof(int), + new Type[] { typeof(int), typeof(int) }); + ilg.Emit (OpCodes.Call, arrmi); + ilg.Emit (OpCodes.Stloc, x); + var arrmi2 = modb.GetArrayMethod (int2D, "Get", + CallingConventions.Standard | CallingConventions.HasThis, + typeof(int), + new Type[] { typeof(int), typeof(int) }); + ilg.Emit (OpCodes.Ldarg_0); + ilg.Emit (OpCodes.Ldc_I4_0); + ilg.Emit (OpCodes.Ldc_I4_1); + ilg.Emit (OpCodes.Call, arrmi2); + ilg.Emit (OpCodes.Ldloc, x); + ilg.Emit (OpCodes.Add); + ilg.Emit (OpCodes.Ret); + Assert.AreNotSame (arrmi, arrmi2); // fresh MonoArrayMethods each time + + var t = tb.CreateType (); + Assert.IsNotNull (t); + var a = new int[,] { { 5, 7 }, { 11, 19 } }; + var mi = t.GetMethod ("TestMeth"); + Assert.IsNotNull (t); + var o = mi.Invoke (null, new object[] { a }); + Assert.AreEqual (12, (int)o); + } + private static void AssertArrayEqualsSorted (Array o1, Array o2) { Array s1 = (Array) o1.Clone (); diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyAlgorithmIdAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyAlgorithmIdAttributeTest.cs index 2c3ca308fa..5250a24648 100644 --- a/mcs/class/corlib/Test/System.Reflection/AssemblyAlgorithmIdAttributeTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyAlgorithmIdAttributeTest.cs @@ -5,8 +5,6 @@ // (C) 2004 Ximian, Inc. http://www.ximian.com // -#if !MONOTOUCH && !FULL_AOT_RUNTIME - using System; using System.Threading; using System.Reflection; @@ -22,6 +20,7 @@ namespace MonoTests.System.Reflection { [TestFixture] public class AssemblyAlgorithmIdAttributeTest { +#if !MOBILE private AssemblyBuilder dynAssembly; AssemblyName dynAsmName = new AssemblyName (); AssemblyAlgorithmIdAttribute attr; @@ -84,7 +83,14 @@ namespace MonoTests.System.Reflection { attr.Match (new AssemblyAlgorithmIdAttribute (AssemblyHashAlgorithm.SHA1)), false, "#1"); } +#endif + + [Test] + public void CtorTest () + { + var a = new AssemblyAlgorithmIdAttribute (AssemblyHashAlgorithm.SHA256); + Assert.AreEqual ((uint)AssemblyHashAlgorithm.SHA256, a.AlgorithmId); + } } } -#endif diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyCompanyAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyCompanyAttributeTest.cs new file mode 100644 index 0000000000..1515d0b7a3 --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyCompanyAttributeTest.cs @@ -0,0 +1,112 @@ +// +// AssemblyCompanyAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyCompanyAttributeTest. + /// + [TestFixture] + public class AssemblyCompanyAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyCompanyAttribute attr; + + public AssemblyCompanyAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyCompanyAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { "Xamarin" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyCompanyAttribute; + } + + [Test] + public void CompanyTest () + { + Assert.AreEqual ( + attr.Company, + "Xamarin", "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyCompanyAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyCompanyAttribute ("Microsoft")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyCompanyAttribute ("some text"); + Assert.AreEqual ("some text", a.Company); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyConfigurationAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyConfigurationAttributeTest.cs index 93637fd19f..e062ff8568 100644 --- a/mcs/class/corlib/Test/System.Reflection/AssemblyConfigurationAttributeTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyConfigurationAttributeTest.cs @@ -5,8 +5,6 @@ // (C) 2004 Ximian, Inc. http://www.ximian.com // -#if !MOBILE - using System; using System.Threading; using System.Reflection; @@ -21,6 +19,7 @@ namespace MonoTests.System.Reflection { [TestFixture] public class AssemblyConfigurationAttributeTest { +#if !MOBILE private AssemblyBuilder dynAssembly; AssemblyName dynAsmName = new AssemblyName (); AssemblyConfigurationAttribute attr; @@ -80,7 +79,14 @@ namespace MonoTests.System.Reflection { attr.Match (new AssemblyConfigurationAttribute ("abcd")), false, "#1"); } +#endif + + [Test] + public void CtorTest () + { + var a = new AssemblyConfigurationAttribute ("abcd"); + Assert.AreEqual ("abcd", a.Configuration); + } } } -#endif diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyCopyrightAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyCopyrightAttributeTest.cs index fd7579fc48..40dd06f345 100644 --- a/mcs/class/corlib/Test/System.Reflection/AssemblyCopyrightAttributeTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyCopyrightAttributeTest.cs @@ -5,7 +5,6 @@ // (C) 2004 Ximian, Inc. http://www.ximian.com // -#if !MOBILE using System; using System.Threading; using System.Reflection; @@ -20,6 +19,7 @@ namespace MonoTests.System.Reflection { [TestFixture] public class AssemblyCopyrightAttributeTest { +#if !MOBILE private AssemblyBuilder dynAssembly; AssemblyName dynAsmName = new AssemblyName (); AssemblyCopyrightAttribute attr; @@ -79,7 +79,14 @@ namespace MonoTests.System.Reflection { attr.Match (new AssemblyCopyrightAttribute ("imian")), false, "#1"); } +#endif + + [Test] + public void CtorTest () + { + var a = new AssemblyCopyrightAttribute ("abcd"); + Assert.AreEqual ("abcd", a.Copyright); + } } } -#endif diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyCultureAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyCultureAttributeTest.cs index 5e5692c38e..c9bc3994b7 100644 --- a/mcs/class/corlib/Test/System.Reflection/AssemblyCultureAttributeTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyCultureAttributeTest.cs @@ -5,8 +5,6 @@ // (C) 2004 Ximian, Inc. http://www.ximian.com // -#if !MOBILE - using System; using System.Threading; using System.Reflection; @@ -21,6 +19,7 @@ namespace MonoTests.System.Reflection { [TestFixture] public class AssemblyCultureAttributeTest { +#if !MOBILE private AssemblyBuilder dynAssembly; AssemblyName dynAsmName = new AssemblyName (); AssemblyCultureAttribute attr; @@ -80,7 +79,14 @@ namespace MonoTests.System.Reflection { attr.Match (new AssemblyCultureAttribute ("Spanish")), false, "#1"); } +#endif + + [Test] + public void CtorTest () + { + var a = new AssemblyCultureAttribute ("en"); + Assert.AreEqual ("en", a.Culture); + } } } -#endif diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyDefaultAliasAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyDefaultAliasAttributeTest.cs new file mode 100644 index 0000000000..9ffc92ea68 --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyDefaultAliasAttributeTest.cs @@ -0,0 +1,112 @@ +// +// AssemblyDefaultAliasAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyDefaultAliasAttributeTest. + /// + [TestFixture] + public class AssemblyDefaultAliasAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyDefaultAliasAttribute attr; + + public AssemblyDefaultAliasAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyDefaultAliasAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { "corlib" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyDefaultAliasAttribute; + } + + [Test] + public void DefaultAliasTest () + { + Assert.AreEqual ( + attr.DefaultAlias, + "corlib", "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyDefaultAliasAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyDefaultAliasAttribute ("System")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyDefaultAliasAttribute ("some text"); + Assert.AreEqual ("some text", a.DefaultAlias); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyDelaySignAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyDelaySignAttributeTest.cs index 1a0d93f636..c903c20057 100644 --- a/mcs/class/corlib/Test/System.Reflection/AssemblyDelaySignAttributeTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyDelaySignAttributeTest.cs @@ -5,7 +5,6 @@ // (C) 2004 Ximian, Inc. http://www.ximian.com // -#if !MOBILE using System; using System.Threading; using System.Reflection; @@ -20,6 +19,7 @@ namespace MonoTests.System.Reflection { [TestFixture] public class AssemblyDelaySignAttributeTest { +#if !MOBILE private AssemblyBuilder dynAssembly; AssemblyName dynAsmName = new AssemblyName (); AssemblyDelaySignAttribute attr; @@ -78,7 +78,14 @@ namespace MonoTests.System.Reflection { attr.Match (new AssemblyDelaySignAttribute (true)), false, "#1"); } +#endif + + [Test] + public void CtorTest () + { + var a = new AssemblyDelaySignAttribute (true); + Assert.AreEqual (true, a.DelaySign); + } } } -#endif diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyDescriptionAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyDescriptionAttributeTest.cs index c64d3195e8..18c7c19077 100644 --- a/mcs/class/corlib/Test/System.Reflection/AssemblyDescriptionAttributeTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyDescriptionAttributeTest.cs @@ -5,7 +5,6 @@ // (C) 2004 Ximian, Inc. http://www.ximian.com // -#if !MOBILE using System; using System.Threading; using System.Reflection; @@ -20,6 +19,7 @@ namespace MonoTests.System.Reflection { [TestFixture] public class AssemblyDescriptionAttributeTest { +#if !MOBILE private AssemblyBuilder dynAssembly; AssemblyName dynAsmName = new AssemblyName (); AssemblyDescriptionAttribute attr; @@ -79,7 +79,13 @@ namespace MonoTests.System.Reflection { attr.Match (new AssemblyDescriptionAttribute ("Descrptn")), false, "#1"); } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyDescriptionAttribute ("some text"); + Assert.AreEqual ("some text", a.Description); + } } } -#endif diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyFileVersionAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyFileVersionAttributeTest.cs index e81b587ac5..91dccdce55 100644 --- a/mcs/class/corlib/Test/System.Reflection/AssemblyFileVersionAttributeTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyFileVersionAttributeTest.cs @@ -5,8 +5,6 @@ // (C) 2004 Ximian, Inc. http://www.ximian.com // -#if !MOBILE - using System; using System.Threading; using System.Reflection; @@ -21,6 +19,7 @@ namespace MonoTests.System.Reflection { [TestFixture] public class AssemblyFileVersionAttributeTest { +#if !MOBILE private AssemblyBuilder dynAssembly; AssemblyName dynAsmName = new AssemblyName (); AssemblyFileVersionAttribute attr; @@ -87,7 +86,13 @@ namespace MonoTests.System.Reflection { attr.Match (new AssemblyFileVersionAttribute ("Descrptn")), false, "#1"); } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyFileVersionAttribute ("1.2.3.4"); + Assert.AreEqual ("1.2.3.4", a.Version); + } } } -#endif diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyFlagsAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyFlagsAttributeTest.cs new file mode 100644 index 0000000000..291adf9b38 --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyFlagsAttributeTest.cs @@ -0,0 +1,118 @@ +// +// AssemblyFlagsAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyFlagsAttributeTest. + /// + [TestFixture] + public class AssemblyFlagsAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyFlagsAttribute attr; + + public AssemblyFlagsAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyFlagsAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (AssemblyNameFlags) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { AssemblyNameFlags.PublicKey | AssemblyNameFlags.Retargetable }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyFlagsAttribute; + } + + [Test] + public void AssemblyFlagsTest () + { + Assert.AreEqual ( + attr.AssemblyFlags, + (int)(AssemblyNameFlags.PublicKey | AssemblyNameFlags.Retargetable), "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyFlagsAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyFlagsAttribute (AssemblyNameFlags.None)), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyFlagsAttribute (AssemblyNameFlags.PublicKey); + Assert.AreEqual ((int)AssemblyNameFlags.PublicKey, a.AssemblyFlags); + + a = new AssemblyFlagsAttribute ((int)AssemblyNameFlags.PublicKey); + Assert.AreEqual ((int)AssemblyNameFlags.PublicKey, a.AssemblyFlags); + + a = new AssemblyFlagsAttribute ((uint)AssemblyNameFlags.PublicKey); + Assert.AreEqual ((uint)AssemblyNameFlags.PublicKey, a.Flags); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyInformationalVersionAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyInformationalVersionAttributeTest.cs index ac16035c58..2c84a27c52 100644 --- a/mcs/class/corlib/Test/System.Reflection/AssemblyInformationalVersionAttributeTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyInformationalVersionAttributeTest.cs @@ -4,7 +4,6 @@ // // (C) 2004 Ximian, Inc. http://www.ximian.com // -#if !MOBILE using System; using System.Threading; @@ -20,6 +19,7 @@ namespace MonoTests.System.Reflection { [TestFixture] public class AssemblyInformationalVersionAttributeTest { +#if !MOBILE private AssemblyBuilder dynAssembly; AssemblyName dynAsmName = new AssemblyName (); AssemblyInformationalVersionAttribute attr; @@ -79,7 +79,12 @@ namespace MonoTests.System.Reflection { attr.Match (new AssemblyInformationalVersionAttribute ("Descrptn")), false, "#1"); } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyInformationalVersionAttribute ("1.2.3.4"); + Assert.AreEqual ("1.2.3.4", a.InformationalVersion); + } } } - -#endif \ No newline at end of file diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyKeyFileAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyKeyFileAttributeTest.cs new file mode 100644 index 0000000000..ee24f79bbf --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyKeyFileAttributeTest.cs @@ -0,0 +1,112 @@ +// +// AssemblyKeyFileAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyKeyFileAttributeTest. + /// + [TestFixture] + public class AssemblyKeyFileAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyKeyFileAttribute attr; + + public AssemblyKeyFileAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyKeyFileAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { "test.snk" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyKeyFileAttribute; + } + + [Test] + public void KeyFileTest () + { + Assert.AreEqual ( + attr.KeyFile, + "test.snk", "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyKeyFileAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyKeyFileAttribute ("other.snk")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyKeyFileAttribute ("some text"); + Assert.AreEqual ("some text", a.KeyFile); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyKeyNameAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyKeyNameAttributeTest.cs new file mode 100644 index 0000000000..8fa18e2790 --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyKeyNameAttributeTest.cs @@ -0,0 +1,112 @@ +// +// AssemblyKeyNameAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyKeyNameAttributeTest. + /// + [TestFixture] + public class AssemblyKeyNameAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyKeyNameAttribute attr; + + public AssemblyKeyNameAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyKeyNameAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { "MyKey" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyKeyNameAttribute; + } + + [Test] + public void KeyNameTest () + { + Assert.AreEqual ( + attr.KeyName, + "MyKey", "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyKeyNameAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyKeyNameAttribute ("OtherKey")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyKeyNameAttribute ("some text"); + Assert.AreEqual ("some text", a.KeyName); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyMetadataAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyMetadataAttributeTest.cs new file mode 100644 index 0000000000..7a29b46fb5 --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyMetadataAttributeTest.cs @@ -0,0 +1,116 @@ +// +// AssemblyMetadataAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyMetadataAttributeTest. + /// + [TestFixture] + public class AssemblyMetadataAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyMetadataAttribute attr; + + public AssemblyMetadataAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyMetadataAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string), typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [2] { "MyKey", "MyValue" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyMetadataAttribute; + } + + [Test] + public void MetadataTest () + { + Assert.AreEqual ( + attr.Key, + "MyKey", "#1"); + Assert.AreEqual ( + attr.Value, + "MyValue", "#2"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyMetadataAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyMetadataAttribute ("OtherKey", "OtherValue")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyMetadataAttribute ("some text", "some other text"); + Assert.AreEqual ("some text", a.Key); + Assert.AreEqual ("some other text", a.Value); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyProductAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyProductAttributeTest.cs new file mode 100644 index 0000000000..13757a1d99 --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyProductAttributeTest.cs @@ -0,0 +1,112 @@ +// +// AssemblyProductAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyProductAttributeTest. + /// + [TestFixture] + public class AssemblyProductAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyProductAttribute attr; + + public AssemblyProductAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyProductAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { "Mono" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyProductAttribute; + } + + [Test] + public void ProductTest () + { + Assert.AreEqual ( + attr.Product, + "Mono", "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyProductAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyProductAttribute ("Java")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyProductAttribute ("some text"); + Assert.AreEqual ("some text", a.Product); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblySignatureKeyAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblySignatureKeyAttributeTest.cs new file mode 100644 index 0000000000..f5fe969134 --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblySignatureKeyAttributeTest.cs @@ -0,0 +1,116 @@ +// +// AssemblySignatureKeyAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblySignatureKeyAttributeTest. + /// + [TestFixture] + public class AssemblySignatureKeyAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblySignatureKeyAttribute attr; + + public AssemblySignatureKeyAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblySignatureKeyAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string), typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [2] { "PublicKey", "CounterSignature" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblySignatureKeyAttribute; + } + + [Test] + public void SignatureKeyTest () + { + Assert.AreEqual ( + attr.PublicKey, + "PublicKey", "#1"); + Assert.AreEqual ( + attr.Countersignature, + "CounterSignature", "#2"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblySignatureKeyAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblySignatureKeyAttribute ("OtherPublicKey", "OtherCounterSignature")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblySignatureKeyAttribute ("some text", "some other text"); + Assert.AreEqual ("some text", a.PublicKey); + Assert.AreEqual ("some other text", a.Countersignature); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyTitleAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyTitleAttributeTest.cs new file mode 100644 index 0000000000..a18c43f5ca --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyTitleAttributeTest.cs @@ -0,0 +1,112 @@ +// +// AssemblyTitleAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyTitleAttributeTest. + /// + [TestFixture] + public class AssemblyTitleAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyTitleAttribute attr; + + public AssemblyTitleAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyTitleAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { "The Assembly" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyTitleAttribute; + } + + [Test] + public void TitleTest () + { + Assert.AreEqual ( + attr.Title, + "The Assembly", "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyTitleAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyTitleAttribute ("Not The Assembly")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyTitleAttribute ("some text"); + Assert.AreEqual ("some text", a.Title); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyTrademarkAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyTrademarkAttributeTest.cs new file mode 100644 index 0000000000..0b82bf8fe9 --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyTrademarkAttributeTest.cs @@ -0,0 +1,112 @@ +// +// AssemblyTrademarkAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyTrademarkAttributeTest. + /// + [TestFixture] + public class AssemblyTrademarkAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyTrademarkAttribute attr; + + public AssemblyTrademarkAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyTrademarkAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { "(c) Xamarin" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyTrademarkAttribute; + } + + [Test] + public void TrademarkTest () + { + Assert.AreEqual ( + attr.Trademark, + "(c) Xamarin", "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyTrademarkAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyTrademarkAttribute ("(c) Microsoft")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyTrademarkAttribute ("some text"); + Assert.AreEqual ("some text", a.Trademark); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/AssemblyVersionAttributeTest.cs b/mcs/class/corlib/Test/System.Reflection/AssemblyVersionAttributeTest.cs new file mode 100644 index 0000000000..72701abe53 --- /dev/null +++ b/mcs/class/corlib/Test/System.Reflection/AssemblyVersionAttributeTest.cs @@ -0,0 +1,112 @@ +// +// AssemblyVersionAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System.Reflection { + + /// + /// Summary description for AssemblyVersionAttributeTest. + /// + [TestFixture] + public class AssemblyVersionAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AssemblyVersionAttribute attr; + + public AssemblyVersionAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AssemblyVersionAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { "1.2.3.4" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AssemblyVersionAttribute; + } + + [Test] + public void VersionTest () + { + Assert.AreEqual ( + attr.Version, + "1.2.3.4", "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AssemblyVersionAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AssemblyVersionAttribute ("2.0.0.0")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AssemblyVersionAttribute ("some text"); + Assert.AreEqual ("some text", a.Version); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs b/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs index e3ed495888..2a73eecbac 100644 --- a/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs +++ b/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs @@ -1362,6 +1362,63 @@ namespace MonoTests.System.Reflection Assert.AreEqual ("B", fields.str); } + [Test] + public void GetValueContextBoundObject () + { + var instance = new CBOTest (); + + var field1 = typeof (CBOTest).GetField ("d1"); + var d1 = field1.GetValue (instance); + Assert.AreEqual ((double)d1, 14.0, "d1"); + + var field2 = typeof (CBOTest).GetField ("d2"); + var d2 = field2.GetValue (instance); + Assert.AreEqual ((double)d2, -20, "d2"); + + var field3 = typeof (CBOTest).GetField ("s1"); + var s1 = field3.GetValue (instance); + Assert.AreEqual (s1, "abcd", "s1"); + + var field4 = typeof (CBOTest).GetField ("s2"); + var s2 = field4.GetValue (instance); + Assert.AreEqual (s2, "hijkl", "s2"); + } + + [Test] + public void SetValueContextBoundObject () + { + var instance = new CBOTest (); + + var field1 = typeof (CBOTest).GetField ("d1"); + field1.SetValue (instance, 90.3); + var d1 = field1.GetValue (instance); + Assert.AreEqual ((double)d1, 90.3, "d1"); + + var field2 = typeof (CBOTest).GetField ("d2"); + field2.SetValue (instance, 1); + var d2 = field2.GetValue (instance); + Assert.AreEqual ((double)d2, 1, "d2"); + + var field3 = typeof (CBOTest).GetField ("s1"); + field3.SetValue (instance, "//////"); + var s1 = field3.GetValue (instance); + Assert.AreEqual (s1, "//////", "s1"); + + var field4 = typeof (CBOTest).GetField ("s2"); + field4.SetValue (instance, "This is a string"); + var s2 = field4.GetValue (instance); + Assert.AreEqual (s2, "This is a string", "s2"); + + } + + class CBOTest : ContextBoundObject { + public double d1 = 14.0; + public double d2 = -20.0; + public string s1 = "abcd"; + public string s2 = "hijkl"; + } + + public IntEnum PPP; public class Foo diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/MethodImplAttributeTest.cs b/mcs/class/corlib/Test/System.Runtime.CompilerServices/MethodImplAttributeTest.cs new file mode 100644 index 0000000000..ff0ce7c9c2 --- /dev/null +++ b/mcs/class/corlib/Test/System.Runtime.CompilerServices/MethodImplAttributeTest.cs @@ -0,0 +1,127 @@ +// +// MethodImplAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.CompilerServices; +using NUnit.Framework; + +namespace MonoTests.System.Runtime.CompilerServices { + + /// + /// Summary description for MethodImplAttributeTest. + /// + [TestFixture] + public class MethodImplAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + MethodImplAttribute attr; + + public MethodImplAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (MethodImplAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (MethodImplOptions) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { MethodImplOptions.InternalCall }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as MethodImplAttribute; + } + + [Test] + public void MethodImplTest () + { + Assert.AreEqual ( + attr.Value, + MethodImplOptions.InternalCall, "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (MethodImplAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new MethodImplAttribute (MethodImplOptions.NoInlining)), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new MethodImplAttribute (MethodImplOptions.InternalCall); + Assert.AreEqual (MethodImplOptions.InternalCall, a.Value); + + a = new MethodImplAttribute ((short)1); + Assert.AreEqual ((MethodImplOptions)1, a.Value); + + a = new MethodImplAttribute (); + Assert.AreEqual ((MethodImplOptions)0, a.Value); + } + + [Test] + public void FieldsTest () + { + var a = new MethodImplAttribute (MethodImplOptions.NoInlining); + + Assert.AreEqual (MethodCodeType.IL, a.MethodCodeType); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/TypeForwardedFromAttributeTest.cs b/mcs/class/corlib/Test/System.Runtime.CompilerServices/TypeForwardedFromAttributeTest.cs new file mode 100644 index 0000000000..d11fa7138a --- /dev/null +++ b/mcs/class/corlib/Test/System.Runtime.CompilerServices/TypeForwardedFromAttributeTest.cs @@ -0,0 +1,50 @@ +// +// TypeForwardedFromAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.CompilerServices; +using NUnit.Framework; + +namespace MonoTests.System.Runtime.CompilerServices { + + public class TypeForwardedFromAttributeTest + { + [Test] + public void CtorTest () + { + var a = new TypeForwardedFromAttribute ("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a"); + Assert.AreEqual ("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a", a.AssemblyFullName); + + Assert.Throws ( () => new TypeForwardedFromAttribute (null) ); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/TypeForwardedToAttributeTest.cs b/mcs/class/corlib/Test/System.Runtime.CompilerServices/TypeForwardedToAttributeTest.cs new file mode 100644 index 0000000000..65548e6523 --- /dev/null +++ b/mcs/class/corlib/Test/System.Runtime.CompilerServices/TypeForwardedToAttributeTest.cs @@ -0,0 +1,51 @@ +// +// TypeForwardedToAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.CompilerServices; +using NUnit.Framework; + +namespace MonoTests.System.Runtime.CompilerServices { + + public class TypeForwardedToAttributeTest + { + [Test] + public void CtorTest () + { + var a = new TypeForwardedToAttribute (typeof(Math)); + Assert.AreEqual (typeof(Math), a.Destination); + + a = new TypeForwardedToAttribute (null); + Assert.AreEqual (null, a.Destination); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Runtime.InteropServices/DllImportAttributeTest.cs b/mcs/class/corlib/Test/System.Runtime.InteropServices/DllImportAttributeTest.cs new file mode 100644 index 0000000000..b4e6a759ed --- /dev/null +++ b/mcs/class/corlib/Test/System.Runtime.InteropServices/DllImportAttributeTest.cs @@ -0,0 +1,128 @@ +// +// DllImportAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.InteropServices; +using NUnit.Framework; + +namespace MonoTests.System.Runtime.InteropServices { + + /// + /// Summary description for DllImportAttributeTest. + /// + [TestFixture] + public class DllImportAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + DllImportAttribute attr; + + public DllImportAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (DllImportAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (string) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { "libc.dylib" }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as DllImportAttribute; + } + + [Test] + public void DllImportTest () + { + Assert.AreEqual ( + attr.Value, + "libc.dylib", "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (DllImportAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new DllImportAttribute ("libcups.dylib")), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new DllImportAttribute ("some text"); + Assert.AreEqual ("some text", a.Value); + } + + [Test] + public void FieldsTest () + { + var a = new DllImportAttribute ("libc.dylib"); + + Assert.Null (a.EntryPoint); + Assert.AreEqual ((CharSet)0, a.CharSet); + Assert.False (a.SetLastError); + Assert.False (a.ExactSpelling); + Assert.AreEqual ((CallingConvention)0, a.CallingConvention); + Assert.False (a.BestFitMapping); + Assert.False (a.PreserveSig); + Assert.False (a.ThrowOnUnmappableChar); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Runtime.InteropServices/MarshalAsAttributeTest.cs b/mcs/class/corlib/Test/System.Runtime.InteropServices/MarshalAsAttributeTest.cs new file mode 100644 index 0000000000..b67c00a7d5 --- /dev/null +++ b/mcs/class/corlib/Test/System.Runtime.InteropServices/MarshalAsAttributeTest.cs @@ -0,0 +1,132 @@ +// +// MarshalAsAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.InteropServices; +using NUnit.Framework; + +namespace MonoTests.System.Runtime.InteropServices { + + /// + /// Summary description for MarshalAsAttributeTest. + /// + [TestFixture] + public class MarshalAsAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + MarshalAsAttribute attr; + + public MarshalAsAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (MarshalAsAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (UnmanagedType) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { UnmanagedType.LPWStr }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as MarshalAsAttribute; + } + + [Test] + public void MarshalAsTest () + { + Assert.AreEqual ( + attr.Value, + UnmanagedType.LPWStr, "#1"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (MarshalAsAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new MarshalAsAttribute (UnmanagedType.Bool)), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new MarshalAsAttribute (UnmanagedType.Bool); + Assert.AreEqual (UnmanagedType.Bool, a.Value); + + a = new MarshalAsAttribute ((short)UnmanagedType.Bool); + Assert.AreEqual (UnmanagedType.Bool, a.Value); + } + + [Test] + public void FieldsTest () + { + var a = new MarshalAsAttribute (UnmanagedType.Bool); + + Assert.Null (a.MarshalCookie); + Assert.Null (a.MarshalType); + Assert.Null (a.MarshalTypeRef); + Assert.Null (a.SafeArrayUserDefinedSubType); + Assert.AreEqual ((UnmanagedType)0, a.ArraySubType); + Assert.AreEqual (VarEnum.VT_EMPTY, a.SafeArraySubType); + Assert.AreEqual (0, a.SizeConst); + Assert.AreEqual (0, a.IidParameterIndex); + Assert.AreEqual (0, a.SizeParamIndex); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Runtime.InteropServices/StructLayoutAttributeTest.cs b/mcs/class/corlib/Test/System.Runtime.InteropServices/StructLayoutAttributeTest.cs new file mode 100644 index 0000000000..642778de29 --- /dev/null +++ b/mcs/class/corlib/Test/System.Runtime.InteropServices/StructLayoutAttributeTest.cs @@ -0,0 +1,62 @@ +// +// StructLayoutAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.InteropServices; +using NUnit.Framework; + +namespace MonoTests.System.Runtime.InteropServices { + + [TestFixture] + public class StructLayoutAttributeTest + { + [Test] + public void CtorTest () + { + var a = new StructLayoutAttribute (LayoutKind.Explicit); + Assert.AreEqual (LayoutKind.Explicit, a.Value); + + a = new StructLayoutAttribute (LayoutKind.Auto); + Assert.AreEqual (LayoutKind.Auto, a.Value); + } + + [Test] + public void FieldsTest () + { + var a = new StructLayoutAttribute (LayoutKind.Explicit); + + Assert.AreEqual ((CharSet)0, a.CharSet); + Assert.AreEqual (0, a.Pack); + Assert.AreEqual (0, a.Size); + } + } +} + diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/SignatureDescriptionTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/SignatureDescriptionTest.cs index 46fbe94a6d..82e664df94 100644 --- a/mcs/class/corlib/Test/System.Security.Cryptography/SignatureDescriptionTest.cs +++ b/mcs/class/corlib/Test/System.Security.Cryptography/SignatureDescriptionTest.cs @@ -310,7 +310,7 @@ public class SignatureDescriptionTest { public void RSASignatureDescription () { // TODO: this would be cleaner with NUnit TestCase'es but they're NUnit 2.5+ :( -#if FULL_AOT_RUNTIME || MONOTOUCH || MONODROID +#if FULL_AOT_RUNTIME || MONOTOUCH || MONODROID || XAMMAC || XAMMAC_4_5 RSASignatureDescriptionCore ("http://www.w3.org/2000/09/xmldsig#rsa-sha1", "System.Security.Cryptography.SHA1Cng", "System.Security.Cryptography.SHA1CryptoServiceProvider"); RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", "System.Security.Cryptography.SHA256Cng", "System.Security.Cryptography.SHA256Managed"); RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", "System.Security.Cryptography.SHA384Cng", "System.Security.Cryptography.SHA384Managed"); diff --git a/mcs/class/corlib/Test/System/AttributeUsageAttributeTest.cs b/mcs/class/corlib/Test/System/AttributeUsageAttributeTest.cs new file mode 100644 index 0000000000..050505d20d --- /dev/null +++ b/mcs/class/corlib/Test/System/AttributeUsageAttributeTest.cs @@ -0,0 +1,131 @@ +// +// AttributeUsageAttributeTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; +using NUnit.Framework; + +namespace MonoTests.System { + + /// + /// Summary description for AttributeUsageAttributeTest. + /// + [TestFixture] + public class AttributeUsageAttributeTest + { +#if !MOBILE + private AssemblyBuilder dynAssembly; + AssemblyName dynAsmName = new AssemblyName (); + AttributeUsageAttribute attr; + + public AttributeUsageAttributeTest () + { + //create a dynamic assembly with the required attribute + //and check for the validity + + dynAsmName.Name = "TestAssembly"; + + dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( + dynAsmName,AssemblyBuilderAccess.Run + ); + + // Set the required Attribute of the assembly. + Type attribute = typeof (AttributeUsageAttribute); + ConstructorInfo ctrInfo = attribute.GetConstructor ( + new Type [] { typeof (AttributeTargets) } + ); + CustomAttributeBuilder attrBuilder = + new CustomAttributeBuilder (ctrInfo, new object [1] { AttributeTargets.Assembly }); + dynAssembly.SetCustomAttribute (attrBuilder); + object [] attributes = dynAssembly.GetCustomAttributes (true); + attr = attributes [0] as AttributeUsageAttribute; + } + + [Test] + public void AttributeUsageTest () + { + Assert.AreEqual ( + attr.ValidOn, + AttributeTargets.Assembly, "#1"); + Assert.AreEqual ( + attr.AllowMultiple, + false, "#2"); + Assert.AreEqual ( + attr.Inherited, + true, "#3"); + } + + [Test] + public void TypeIdTest () + { + Assert.AreEqual ( + attr.TypeId, + typeof (AttributeUsageAttribute), "#1" + ); + } + + [Test] + public void MatchTestForTrue () + { + Assert.AreEqual ( + attr.Match (attr), + true, "#1"); + } + + [Test] + public void MatchTestForFalse () + { + Assert.AreEqual ( + attr.Match (new AttributeUsageAttribute (AttributeTargets.Method)), + false, "#1"); + } +#endif + [Test] + public void CtorTest () + { + var a = new AttributeUsageAttribute (AttributeTargets.Method); + Assert.AreEqual (AttributeTargets.Method, a.ValidOn); + Assert.False (a.AllowMultiple); + Assert.True (a.Inherited); + } + + [Test] + public void PropertyTest () + { + var a = new AttributeUsageAttribute (AttributeTargets.Method | AttributeTargets.Class); + a.AllowMultiple = true; + a.Inherited = false; + Assert.AreEqual (AttributeTargets.Method | AttributeTargets.Class, a.ValidOn); + Assert.True (a.AllowMultiple); + Assert.False (a.Inherited); + } + } +} + diff --git a/mcs/class/corlib/Test/System/ConsoleKeyInfoTest.cs b/mcs/class/corlib/Test/System/ConsoleKeyInfoTest.cs new file mode 100644 index 0000000000..6811c95399 --- /dev/null +++ b/mcs/class/corlib/Test/System/ConsoleKeyInfoTest.cs @@ -0,0 +1,65 @@ +// +// ConsoleKeyInfoTest.cs +// +// Authors: +// Alexander Köplinger (alkpli@microsoft.com) +// +// (c) 2017 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using NUnit.Framework; +using System; +using System.IO; +using System.Text; + +namespace MonoTests.System +{ + [TestFixture] + public class ConsoleKeyInfoTest + { + [Test] + public void CtorTest() + { + var cki = new ConsoleKeyInfo ('A', ConsoleKey.A, true, false, true); + + Assert.AreEqual ('A', cki.KeyChar, "#1"); + Assert.AreEqual (ConsoleKey.A, cki.Key, "#2"); + Assert.AreEqual ((ConsoleModifiers.Shift | ConsoleModifiers.Control) , cki.Modifiers, "#3"); + } + + [Test] + public void EqualTest() + { + var ckiA = new ConsoleKeyInfo ('a', ConsoleKey.A, false, false, false); + var ckiB = new ConsoleKeyInfo ('b', ConsoleKey.B, false, false, false); + var ckiA2 = new ConsoleKeyInfo ('a', ConsoleKey.A, false, false, false); + + Assert.IsFalse (ckiA == ckiB, "#1"); + Assert.IsTrue (ckiA != ckiB, "#2"); + Assert.IsFalse (ckiA.Equals (ckiB), "#3"); + + Assert.IsTrue (ckiA == ckiA2, "#4"); + Assert.IsFalse (ckiA != ckiA2, "#5"); + Assert.IsTrue (ckiA.Equals (ckiA2), "#6"); + } + } +} diff --git a/mcs/class/corlib/Test/System/TimeZoneTest.cs b/mcs/class/corlib/Test/System/TimeZoneTest.cs index 0b9897a32e..ef17224201 100644 --- a/mcs/class/corlib/Test/System/TimeZoneTest.cs +++ b/mcs/class/corlib/Test/System/TimeZoneTest.cs @@ -346,7 +346,7 @@ public class TimeZoneTest { var standardOffset = tz.GetUtcOffset(daylightChanges.Start.AddMinutes(-1)); var dstOffset = tz.GetUtcOffset(daylightChanges.Start.AddMinutes(61)); - Assert.AreEqual(standardOffset, tz.GetUtcOffset (dst_end)); +// Assert.AreEqual(standardOffset, tz.GetUtcOffset (dst_end)); Assert.AreEqual(dstOffset, tz.GetUtcOffset (dst_end.Add (daylightChanges.Delta.Negate ().Add (TimeSpan.FromSeconds(1))))); Assert.AreEqual(dstOffset, tz.GetUtcOffset (dst_end.Add(daylightChanges.Delta.Negate ()))); Assert.AreEqual(dstOffset, tz.GetUtcOffset (dst_end.Add(daylightChanges.Delta.Negate ().Add (TimeSpan.FromSeconds(-1))))); diff --git a/mcs/class/corlib/corlib_test.dll.sources b/mcs/class/corlib/corlib_test.dll.sources index fa80393883..8bb9c8a409 100644 --- a/mcs/class/corlib/corlib_test.dll.sources +++ b/mcs/class/corlib/corlib_test.dll.sources @@ -13,6 +13,7 @@ System/ArrayTest.cs System/ArraySortArgChecks.cs System/ArraySegmentTest.cs System/AttributeTest.cs +System/AttributeUsageAttributeTest.cs System/BadImageFormatExceptionTest.cs System/BitConverterTest.cs System/BooleanTest.cs @@ -54,6 +55,7 @@ System.Collections.ObjectModel/CollectionTest.cs System.Collections.ObjectModel/KeyedCollectionTest.cs System.Collections.ObjectModel/ReadOnlyCollectionTest.cs System/ConsoleTest.cs +System/ConsoleKeyInfoTest.cs System/ConvertTest.cs System/DateTimeOffsetTest.cs System/DateTimeOffsetTestCoreFx.cs @@ -131,12 +133,23 @@ System/ObjectTest.cs System/RandomTest.cs System.Reflection/AssemblyAlgorithmIdAttributeTest.cs System.Reflection/AssemblyConfigurationAttributeTest.cs +System.Reflection/AssemblyCompanyAttributeTest.cs System.Reflection/AssemblyCopyrightAttributeTest.cs System.Reflection/AssemblyCultureAttributeTest.cs +System.Reflection/AssemblyDefaultAliasAttributeTest.cs System.Reflection/AssemblyDelaySignAttributeTest.cs System.Reflection/AssemblyDescriptionAttributeTest.cs System.Reflection/AssemblyFileVersionAttributeTest.cs +System.Reflection/AssemblyFlagsAttributeTest.cs System.Reflection/AssemblyInformationalVersionAttributeTest.cs +System.Reflection/AssemblyKeyFileAttributeTest.cs +System.Reflection/AssemblyKeyNameAttributeTest.cs +System.Reflection/AssemblyMetadataAttributeTest.cs +System.Reflection/AssemblyProductAttributeTest.cs +System.Reflection/AssemblySignatureKeyAttributeTest.cs +System.Reflection/AssemblyTitleAttributeTest.cs +System.Reflection/AssemblyTrademarkAttributeTest.cs +System.Reflection/AssemblyVersionAttributeTest.cs System.Reflection/AssemblyNameTest.cs System.Reflection/AssemblyTest.cs System.Reflection/BinderTests.cs @@ -185,19 +198,25 @@ System.Resources/ResourceSetTest.cs System.Resources/ResourceWriterTest.cs System.Runtime.CompilerServices/ConditionalWeakTableTest.cs System.Runtime.CompilerServices/InternalsVisibleToAttributeTest.cs +System.Runtime.CompilerServices/MethodImplAttributeTest.cs System.Runtime.CompilerServices/RuntimeHelpersTest.cs System.Runtime.CompilerServices/RuntimeWrappedExceptionTest.cs System.Runtime.CompilerServices/AsyncTaskMethodBuilderTest.cs System.Runtime.CompilerServices/AsyncVoidMethodBuilderTest.cs System.Runtime.CompilerServices/TaskAwaiterTest.cs System.Runtime.CompilerServices/TaskAwaiterTest_T.cs +System.Runtime.CompilerServices/TypeForwardedFromAttributeTest.cs +System.Runtime.CompilerServices/TypeForwardedToAttributeTest.cs System.Runtime.CompilerServices/YieldAwaitableTest.cs System.Runtime.ExceptionServices/ExceptionDispatchInfoTest.cs +System.Runtime.InteropServices/DllImportAttributeTest.cs System.Runtime.InteropServices/ExternalExceptionTest.cs System.Runtime.InteropServices/GCHandleTest.cs +System.Runtime.InteropServices/MarshalAsAttributeTest.cs System.Runtime.InteropServices/MarshalTest.cs System.Runtime.InteropServices/RuntimeEnvironmentTest.cs System.Runtime.InteropServices/SafeHandleTest.cs +System.Runtime.InteropServices/StructLayoutAttributeTest.cs System.Runtime.Remoting/ContextTest.cs System.Runtime.Remoting/SoapServicesTest.cs System.Runtime.Remoting/SynchronizationAttributeTest.cs diff --git a/mcs/class/lib/monolite-darwin/1050800000/Mono.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-darwin/1050800000/Mono.Security.dll.REMOVED.git-id index 348ff41de1..6fe5171a65 100644 --- a/mcs/class/lib/monolite-darwin/1050800000/Mono.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-darwin/1050800000/Mono.Security.dll.REMOVED.git-id @@ -1 +1 @@ -2f28943fa84feba0ab41293218a859f392cbc2ab \ No newline at end of file +c460af5e308e5dcd4ce52fe1f96343a85c8e8ed4 \ No newline at end of file diff --git a/mcs/class/lib/monolite-darwin/1050800000/System.Configuration.dll.REMOVED.git-id b/mcs/class/lib/monolite-darwin/1050800000/System.Configuration.dll.REMOVED.git-id index d4085ec9dc..d802e39f88 100644 --- a/mcs/class/lib/monolite-darwin/1050800000/System.Configuration.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-darwin/1050800000/System.Configuration.dll.REMOVED.git-id @@ -1 +1 @@ -522bc15c74250c49d059268171516ece66952603 \ No newline at end of file +ad4bf3fe7092b8a49e8a4b5272e6bd2e1a3e754d \ No newline at end of file diff --git a/mcs/class/lib/monolite-darwin/1050800000/System.Numerics.dll.REMOVED.git-id b/mcs/class/lib/monolite-darwin/1050800000/System.Numerics.dll.REMOVED.git-id index be6d3bd397..aef9b8923f 100644 --- a/mcs/class/lib/monolite-darwin/1050800000/System.Numerics.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-darwin/1050800000/System.Numerics.dll.REMOVED.git-id @@ -1 +1 @@ -0f297a8a6aa955270647898697c643971fab8440 \ No newline at end of file +22ebdf4fb26c210ef61597b5c98e36ee6738c566 \ No newline at end of file diff --git a/mcs/class/lib/monolite-darwin/1050800000/System.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-darwin/1050800000/System.Security.dll.REMOVED.git-id index 3ec808a836..3e95f50b4c 100644 --- a/mcs/class/lib/monolite-darwin/1050800000/System.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-darwin/1050800000/System.Security.dll.REMOVED.git-id @@ -1 +1 @@ -40ae9ead5b53c9453e7cb79edbb17921c40f4338 \ No newline at end of file +b61e7c78b678a0e29b371066324c40cc54d8290a \ No newline at end of file diff --git a/mcs/class/lib/monolite-darwin/1050800000/System.Xml.dll.REMOVED.git-id b/mcs/class/lib/monolite-darwin/1050800000/System.Xml.dll.REMOVED.git-id index 2146192101..233f9c433c 100644 --- a/mcs/class/lib/monolite-darwin/1050800000/System.Xml.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-darwin/1050800000/System.Xml.dll.REMOVED.git-id @@ -1 +1 @@ -68f6025e9ad825698888c0f7ac790764a0e95fd0 \ No newline at end of file +f8c250e2523d70ab4cc7212751f123f38f6222f0 \ No newline at end of file diff --git a/mcs/class/lib/monolite-darwin/1050800000/System.dll.REMOVED.git-id b/mcs/class/lib/monolite-darwin/1050800000/System.dll.REMOVED.git-id index 5f1889c6a8..c7ea97985a 100644 --- a/mcs/class/lib/monolite-darwin/1050800000/System.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-darwin/1050800000/System.dll.REMOVED.git-id @@ -1 +1 @@ -0043e206dd4c4dff5483325570a2cd63a9d1ea2e \ No newline at end of file +3674314ec608873638973618f84c0c09564439ef \ No newline at end of file diff --git a/mcs/class/lib/monolite-darwin/1050800000/mcs.exe.REMOVED.git-id b/mcs/class/lib/monolite-darwin/1050800000/mcs.exe.REMOVED.git-id index 4f726f3c5e..12ece4711c 100644 --- a/mcs/class/lib/monolite-darwin/1050800000/mcs.exe.REMOVED.git-id +++ b/mcs/class/lib/monolite-darwin/1050800000/mcs.exe.REMOVED.git-id @@ -1 +1 @@ -459f73c17780865cdc43ebccb8bea2439dca46f7 \ No newline at end of file +3c229dd1cd687ae6aaaf02c99caf42f48272d2e0 \ No newline at end of file diff --git a/mcs/class/lib/monolite-darwin/1050800000/mscorlib.dll.REMOVED.git-id b/mcs/class/lib/monolite-darwin/1050800000/mscorlib.dll.REMOVED.git-id index 105cc2383b..17e2b38e61 100644 --- a/mcs/class/lib/monolite-darwin/1050800000/mscorlib.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-darwin/1050800000/mscorlib.dll.REMOVED.git-id @@ -1 +1 @@ -82b0b276128e20aff7675c4da13e7c715d8726c6 \ No newline at end of file +d1b3960c2e53dd40209ef617d0359bd6facb3459 \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/1050800000/Mono.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/1050800000/Mono.Security.dll.REMOVED.git-id index d76639494b..51eaa3e5a4 100644 --- a/mcs/class/lib/monolite-linux/1050800000/Mono.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/1050800000/Mono.Security.dll.REMOVED.git-id @@ -1 +1 @@ -393dcd63d15abc118b077c8528bfc887b58e14ea \ No newline at end of file +1e337c3129e2f8920ae3074e27e4cad8dfa80f4d \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/1050800000/System.Configuration.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/1050800000/System.Configuration.dll.REMOVED.git-id index 88b776c272..1ee936f677 100644 --- a/mcs/class/lib/monolite-linux/1050800000/System.Configuration.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/1050800000/System.Configuration.dll.REMOVED.git-id @@ -1 +1 @@ -318ba916d7b14196d59712bb9cc1da209fe0ffa2 \ No newline at end of file +5cd79b8575f26f15deeeaaf7847dde1920ccff81 \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/1050800000/System.Numerics.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/1050800000/System.Numerics.dll.REMOVED.git-id index e0bee28a30..2e907bc359 100644 --- a/mcs/class/lib/monolite-linux/1050800000/System.Numerics.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/1050800000/System.Numerics.dll.REMOVED.git-id @@ -1 +1 @@ -f9814faa926ab70a436f40cebab8a657f424f0dc \ No newline at end of file +bdb13b5a912c910e389cf8a71503467473bf862f \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/1050800000/System.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/1050800000/System.Security.dll.REMOVED.git-id index 88933342a2..f61b57d383 100644 --- a/mcs/class/lib/monolite-linux/1050800000/System.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/1050800000/System.Security.dll.REMOVED.git-id @@ -1 +1 @@ -7f937d46b957aa75624b3f0e46e00ee91639d8da \ No newline at end of file +8d2205d67d86470adbe0102be00e862070d907fc \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/1050800000/System.Xml.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/1050800000/System.Xml.dll.REMOVED.git-id index 465b7fd26d..69733bd6f5 100644 --- a/mcs/class/lib/monolite-linux/1050800000/System.Xml.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/1050800000/System.Xml.dll.REMOVED.git-id @@ -1 +1 @@ -157dd6ce1f43cc6342f2b75b9db22820b8d25971 \ No newline at end of file +f12c42672958d7d4aec3ad6c7039f5690b3aaa9a \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/1050800000/System.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/1050800000/System.dll.REMOVED.git-id index c851b7d3f0..e8096584ac 100644 --- a/mcs/class/lib/monolite-linux/1050800000/System.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/1050800000/System.dll.REMOVED.git-id @@ -1 +1 @@ -04a12df41c5ea29256c9b923a19377c16d83c2c8 \ No newline at end of file +0584e6f11a61379d04a37167d0cad693af971a1b \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/1050800000/mscorlib.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/1050800000/mscorlib.dll.REMOVED.git-id index a18bc055f8..521a914e7e 100644 --- a/mcs/class/lib/monolite-linux/1050800000/mscorlib.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/1050800000/mscorlib.dll.REMOVED.git-id @@ -1 +1 @@ -70c9f416b124869968736fa95a3bed2bb16ebb05 \ No newline at end of file +a5322f57a2f00e7de78ef60d35784b0d7edfe0e6 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/1050800000/Mono.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/1050800000/Mono.Security.dll.REMOVED.git-id index dcf26006e8..6df49ab1bb 100644 --- a/mcs/class/lib/monolite-win32/1050800000/Mono.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/1050800000/Mono.Security.dll.REMOVED.git-id @@ -1 +1 @@ -c373538d136fa2ac33a6cb0905eaa7c18e2cefc9 \ No newline at end of file +fb51678822ba19283fa5d4fe415aa99a924724a3 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/1050800000/System.Configuration.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/1050800000/System.Configuration.dll.REMOVED.git-id index e48b5f5773..a891426f46 100644 --- a/mcs/class/lib/monolite-win32/1050800000/System.Configuration.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/1050800000/System.Configuration.dll.REMOVED.git-id @@ -1 +1 @@ -123ee852e1d6862493d117f2b29f402e7945ec4e \ No newline at end of file +b9468862e00b5ce32a69725e11976e6bcb1bec36 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/1050800000/System.Numerics.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/1050800000/System.Numerics.dll.REMOVED.git-id index b88c285772..602307b4b3 100644 --- a/mcs/class/lib/monolite-win32/1050800000/System.Numerics.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/1050800000/System.Numerics.dll.REMOVED.git-id @@ -1 +1 @@ -d5d1083f7091e4e47f2c8f29183cb26f6062a7fd \ No newline at end of file +798e96081eac184a05402f0359ea68c921c752ec \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/1050800000/System.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/1050800000/System.Security.dll.REMOVED.git-id index ca32b04679..242c160a35 100644 --- a/mcs/class/lib/monolite-win32/1050800000/System.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/1050800000/System.Security.dll.REMOVED.git-id @@ -1 +1 @@ -68d4272764ceaebbe9db8539cf4b559f087950e7 \ No newline at end of file +60227503e13c4a7575b30e0fe10cc0d769b42876 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/1050800000/System.Xml.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/1050800000/System.Xml.dll.REMOVED.git-id index a6d1c6397c..e438a68357 100644 --- a/mcs/class/lib/monolite-win32/1050800000/System.Xml.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/1050800000/System.Xml.dll.REMOVED.git-id @@ -1 +1 @@ -3e17250dd69fee04902f0f7c4acbc737b25a9ad4 \ No newline at end of file +6e6368f45a69b8f488106fa01ffde9cd8db25369 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/1050800000/System.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/1050800000/System.dll.REMOVED.git-id index 28a6b3b4ca..b1cdb1f4d2 100644 --- a/mcs/class/lib/monolite-win32/1050800000/System.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/1050800000/System.dll.REMOVED.git-id @@ -1 +1 @@ -74629777c168636daaf1d763c2c19c47d7e50267 \ No newline at end of file +8263e4b9b49459605da0d90c211cbd347e8a704e \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/1050800000/mcs.exe.REMOVED.git-id b/mcs/class/lib/monolite-win32/1050800000/mcs.exe.REMOVED.git-id index 73d600cc4e..ba3d825ce0 100644 --- a/mcs/class/lib/monolite-win32/1050800000/mcs.exe.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/1050800000/mcs.exe.REMOVED.git-id @@ -1 +1 @@ -f8b90529dd288331ba4e5114fbd7b73b57adfb78 \ No newline at end of file +dc9865b21a260efca86f1c6fdefcfb697d05f93b \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/1050800000/mscorlib.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/1050800000/mscorlib.dll.REMOVED.git-id index 1f002b8cb5..4ee768cdc3 100644 --- a/mcs/class/lib/monolite-win32/1050800000/mscorlib.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/1050800000/mscorlib.dll.REMOVED.git-id @@ -1 +1 @@ -b680b136217a1741ebc44f91637031adbecb24d0 \ No newline at end of file +8ad7c260dca99201c101cfbbf2cdf206e2f453c5 \ No newline at end of file diff --git a/mcs/packages/Makefile b/mcs/packages/Makefile index c5db5962ea..696039fc38 100644 --- a/mcs/packages/Makefile +++ b/mcs/packages/Makefile @@ -25,19 +25,6 @@ ROSLYN_FILES_TO_COPY_FOR_MSBUILD = \ $(ROSLYN_CSC_DIR)/Microsoft.CSharp.Core.targets \ $(ROSLYN_CSC_DIR)/Microsoft.VisualBasic.Core.targets -ROSLYN_FILES_TO_LINK_FOR_MSBUILD = \ - csi.exe \ - csi.exe.config \ - csi.rsp \ - Microsoft.CodeAnalysis.dll \ - Microsoft.CodeAnalysis.CSharp.dll \ - Microsoft.CodeAnalysis.CSharp.Scripting.dll \ - Microsoft.CodeAnalysis.Scripting.dll \ - System.Collections.Immutable.dll \ - System.Reflection.Metadata.dll \ - VBCSCompiler.exe \ - VBCSCompiler.exe.config - DISTFILES = $(ROSLYN_FILES_FOR_MONO) $(ROSLYN_FILES_TO_COPY_FOR_MSBUILD) csi-test.csx ifeq ($(PROFILE), $(DEFAULT_PROFILE)) @@ -51,7 +38,7 @@ install-local: $(MKINSTALLDIRS) $(MSBUILD_ROSLYN_DIR) $(INSTALL_LIB) $(ROSLYN_FILES_TO_COPY_FOR_MSBUILD) $(MSBUILD_ROSLYN_DIR) - (cd $(MSBUILD_ROSLYN_DIR); for asm in $(ROSLYN_FILES_TO_LINK_FOR_MSBUILD); do ln -fs ../../../../$(FRAMEWORK_VERSION)/$$asm . ; done) + (cd $(MSBUILD_ROSLYN_DIR); for asm in $(ROSLYN_FILES_FOR_MONO); do ln -fs ../../../../$(FRAMEWORK_VERSION)/$$(basename $$asm) . ; done) run-test-local: test-csi diff --git a/mcs/tools/linker/Makefile b/mcs/tools/linker/Makefile index 6823765ffd..b1bfdd1856 100644 --- a/mcs/tools/linker/Makefile +++ b/mcs/tools/linker/Makefile @@ -7,7 +7,8 @@ PROGRAM = monolinker.exe LIB_REFS = System System.Core System.Xml Mono.Cecil TEST_CASES = \ - mscorlib/test-array.cs + mscorlib/test-array.cs \ + mscorlib/test-remoting.cs ifndef AOT_FRIENDLY_PROFILE TEST_CASES += \ diff --git a/mcs/tools/xbuild/Makefile b/mcs/tools/xbuild/Makefile index 20268929bf..78c426686f 100644 --- a/mcs/tools/xbuild/Makefile +++ b/mcs/tools/xbuild/Makefile @@ -25,6 +25,7 @@ PCL5_FX_DIR=$(mono_libdir)/mono/xbuild-frameworks/.NETPortable/v5.0 VS_TARGETS_DIR = $(mono_libdir)/mono/xbuild/Microsoft/VisualStudio PORTABLE_TARGETS_DIR = $(mono_libdir)/mono/xbuild/Microsoft/Portable NUGET_BUILDTASKS_TARGETS_DIR = $(mono_libdir)/mono/xbuild/Microsoft/NuGet +MSBUILD_EXTENSIONS_15_DIR=$(mono_libdir)/mono/xbuild/15.0 ifeq (14.0, $(XBUILD_VERSION)) install-extras: install-versioned-files install-global-files @@ -101,8 +102,12 @@ NUGET_BUILDTASKS_REPO_DIR=$(topdir)/../external/nuget-buildtasks install-nuget-targets: $(MKINSTALLDIRS) $(DESTDIR)$(NUGET_BUILDTASKS_TARGETS_DIR) + $(MKINSTALLDIRS) $(DESTDIR)$(MSBUILD_EXTENSIONS_15_DIR)/Imports/Microsoft.Common.props/ImportBefore + $(MKINSTALLDIRS) $(DESTDIR)$(MSBUILD_EXTENSIONS_15_DIR)/Microsoft.Common.targets/ImportAfter $(INSTALL_DATA) $(NUGET_BUILDTASKS_REPO_DIR)/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.targets $(DESTDIR)$(NUGET_BUILDTASKS_TARGETS_DIR) $(INSTALL_DATA) $(NUGET_BUILDTASKS_REPO_DIR)/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.props $(DESTDIR)$(NUGET_BUILDTASKS_TARGETS_DIR) + $(INSTALL_DATA) $(NUGET_BUILDTASKS_REPO_DIR)/src/Microsoft.NuGet.Build.Tasks/ImportBeforeAfter/Microsoft.NuGet.ImportBefore.props $(DESTDIR)$(MSBUILD_EXTENSIONS_15_DIR)/Imports/Microsoft.Common.props/ImportBefore + $(INSTALL_DATA) $(NUGET_BUILDTASKS_REPO_DIR)/src/Microsoft.NuGet.Build.Tasks/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets $(DESTDIR)$(MSBUILD_EXTENSIONS_15_DIR)/Microsoft.Common.targets/ImportAfter install-nuget-imports: ifeq (14.0, $(XBUILD_VERSION)) diff --git a/mono/metadata/class.c.REMOVED.git-id b/mono/metadata/class.c.REMOVED.git-id index b6b472dc79..73487046ce 100644 --- a/mono/metadata/class.c.REMOVED.git-id +++ b/mono/metadata/class.c.REMOVED.git-id @@ -1 +1 @@ -da8fc30585b67fb1fa23f44a182cb0ae2ea3ce3f \ No newline at end of file +044af0800fba95ddf296c18babf16299cff2b6be \ No newline at end of file diff --git a/mono/metadata/icall.c.REMOVED.git-id b/mono/metadata/icall.c.REMOVED.git-id index d348baa4ec..1f90e11c69 100644 --- a/mono/metadata/icall.c.REMOVED.git-id +++ b/mono/metadata/icall.c.REMOVED.git-id @@ -1 +1 @@ -912a86e4cb88bee93004d3796075f462ae3f3d2e \ No newline at end of file +3198e4fbc46804c871794fa1bc64a82aac2bfeed \ No newline at end of file diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c index a5ef34da2d..4bec14b2c1 100644 --- a/mono/metadata/loader.c +++ b/mono/metadata/loader.c @@ -1826,63 +1826,92 @@ mono_get_method_checked (MonoImage *image, guint32 token, MonoClass *klass, Mono return result; } -static MonoMethod * +static MonoMethod* get_method_constrained (MonoImage *image, MonoMethod *method, MonoClass *constrained_class, MonoGenericContext *context, MonoError *error) { - MonoMethod *result; - MonoClass *ic = NULL; - MonoGenericContext *method_context = NULL; - MonoMethodSignature *sig, *original_sig; + MonoClass *base_class = method->klass; error_init (error); - mono_class_init (constrained_class); - original_sig = sig = mono_method_signature_checked (method, error); - if (sig == NULL) { + if (!mono_class_is_assignable_from (base_class, constrained_class)) { + char *base_class_name = mono_type_get_full_name (base_class); + char *constrained_class_name = mono_type_get_full_name (constrained_class); + mono_error_set_invalid_operation (error, "constrained call: %s is not assignable from %s", base_class_name, constrained_class_name); + g_free (base_class_name); + g_free (constrained_class_name); return NULL; } - if (method->is_inflated && sig->generic_param_count) { - MonoMethodInflated *imethod = (MonoMethodInflated *) method; - sig = mono_method_signature_checked (imethod->declaring, error); /*We assume that if the inflated method signature is valid, the declaring method is too*/ - if (!sig) - return NULL; - method_context = mono_method_get_context (method); + /* If the constraining class is actually an interface, we don't learn + * anything new by constraining. + */ + if (MONO_CLASS_IS_INTERFACE (constrained_class)) + return method; - original_sig = sig; - /* - * We must inflate the signature with the class instantiation to work on - * cases where a class inherit from a generic type and the override replaces - * any type argument which a concrete type. See #325283. + mono_class_setup_vtable (base_class); + if (mono_class_has_failure (base_class)) { + mono_error_set_for_class_failure (error, base_class); + return NULL; + } + + MonoGenericContext inflated_method_ctx = { .class_inst = NULL, .method_inst = NULL }; + gboolean inflated_generic_method = FALSE; + if (method->is_inflated) { + MonoGenericContext *method_ctx = mono_method_get_context (method); + /* If method is an instantiation of a generic method definition, ie + * class H { void M (...) { ... } } + * and method is H.M + * we will get at the end a refined HSubclass<...>.M and we will need to re-instantiate it with D. + * to get HSubclass<...>.M + * */ - if (method_context->class_inst) { - MonoGenericContext ctx; - ctx.method_inst = NULL; - ctx.class_inst = method_context->class_inst; - /*Fixme, property propagate this error*/ - sig = inflate_generic_signature_checked (method->klass->image, sig, &ctx, error); - if (!sig) - return NULL; + if (method_ctx->method_inst != NULL) { + inflated_generic_method = TRUE; + inflated_method_ctx.method_inst = method_ctx->method_inst; } } + int vtable_slot = 0; + if (!MONO_CLASS_IS_INTERFACE (base_class)) { + /*if the base class isn't an interface and the method isn't + * virtual, there's nothing to do, we're already on the method + * we want to call. */ + if ((method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0) + return method; + /* if this isn't an interface method, get the vtable slot and + * find the corresponding method in the constrained class, + * which is a subclass of the base class. */ + vtable_slot = mono_method_get_vtable_index (method); - if ((constrained_class != method->klass) && (MONO_CLASS_IS_INTERFACE (method->klass))) - ic = method->klass; - - result = find_method (constrained_class, ic, method->name, sig, constrained_class, error); - if (sig != original_sig) - mono_metadata_free_inflated_signature (sig); - - if (!result) - return NULL; - - if (method_context) { - result = mono_class_inflate_generic_method_checked (result, method_context, error); - if (!result) + mono_class_setup_vtable (constrained_class); + if (mono_class_has_failure (constrained_class)) { + mono_error_set_for_class_failure (error, constrained_class); return NULL; + } + } else { + mono_class_setup_vtable (constrained_class); + if (mono_class_has_failure (constrained_class)) { + mono_error_set_for_class_failure (error, constrained_class); + return NULL; + } + + /* Get the slot of the method in the interface. Then get the + * interface base in constrained_class */ + int itf_slot = mono_method_get_vtable_index (method); + g_assert (itf_slot >= 0); + gboolean variant = FALSE; + int itf_base = mono_class_interface_offset_with_variance (constrained_class, base_class, &variant); + vtable_slot = itf_slot + itf_base; } + g_assert (vtable_slot >= 0); - return result; + MonoMethod *res = mono_class_get_vtable_entry (constrained_class, vtable_slot); + g_assert (res != NULL); + if (inflated_generic_method) { + g_assert (res->is_generic); + res = mono_class_inflate_generic_method_checked (res, &inflated_method_ctx, error); + return_val_if_nok (error, NULL); + } + return res; } MonoMethod * diff --git a/mono/metadata/locales.c b/mono/metadata/locales.c index b0e6135f49..cd7ef43236 100644 --- a/mono/metadata/locales.c +++ b/mono/metadata/locales.c @@ -448,7 +448,8 @@ region_info_entry_from_lcid (int lcid) static gchar* get_darwin_locale (void) { - static gchar *darwin_locale = NULL; + static gchar *cached_locale = NULL; + gchar *darwin_locale = NULL; CFLocaleRef locale = NULL; CFStringRef locale_language = NULL; CFStringRef locale_country = NULL; @@ -459,8 +460,8 @@ get_darwin_locale (void) CFIndex len; int i; - if (darwin_locale != NULL) - return g_strdup (darwin_locale); + if (cached_locale != NULL) + return g_strdup (cached_locale); locale = CFLocaleCopyCurrent (); @@ -502,7 +503,7 @@ get_darwin_locale (void) if (!CFStringGetCString (locale_cfstr, darwin_locale, len, kCFStringEncodingMacRoman)) { g_free (darwin_locale); CFRelease (locale); - darwin_locale = NULL; + cached_locale = NULL; return NULL; } @@ -515,7 +516,9 @@ get_darwin_locale (void) CFRelease (locale); } - return g_strdup (darwin_locale); + mono_memory_barrier (); + cached_locale = darwin_locale; + return g_strdup (cached_locale); } #endif diff --git a/mono/metadata/object-offsets.h b/mono/metadata/object-offsets.h index 8968bf737f..88d086e12b 100644 --- a/mono/metadata/object-offsets.h +++ b/mono/metadata/object-offsets.h @@ -226,6 +226,8 @@ DECL_OFFSET(MonoLMF, iregs) DECL_OFFSET(MonoLMF, fregs) DECL_OFFSET(DynCallArgs, fpregs) DECL_OFFSET(DynCallArgs, has_fpregs) +DECL_OFFSET(DynCallArgs, regs) +DECL_OFFSET(DynCallArgs, n_stackargs) DECL_OFFSET(SeqPointInfo, ss_tramp_addr) #elif defined(TARGET_ARM64) DECL_OFFSET(MonoLMF, pc) diff --git a/mono/metadata/sre.c.REMOVED.git-id b/mono/metadata/sre.c.REMOVED.git-id index 15fb06a71a..8468b4ea06 100644 --- a/mono/metadata/sre.c.REMOVED.git-id +++ b/mono/metadata/sre.c.REMOVED.git-id @@ -1 +1 @@ -f17ea1dd2ddeef2a4efd39fc1c66c149958f01a4 \ No newline at end of file +92cef23ceca074320e4bbe96223ad509c990dc37 \ No newline at end of file diff --git a/mono/mini/aot-compiler.c.REMOVED.git-id b/mono/mini/aot-compiler.c.REMOVED.git-id index 2c4cc525ed..b12fa05f83 100644 --- a/mono/mini/aot-compiler.c.REMOVED.git-id +++ b/mono/mini/aot-compiler.c.REMOVED.git-id @@ -1 +1 @@ -6b91543a56b6bbfd9e7f6a4c32f6bdb29911f289 \ No newline at end of file +6a32c135e9212ab9d7a66157990c5e67740fe8be \ No newline at end of file diff --git a/mono/mini/gshared.cs b/mono/mini/gshared.cs index 75ea14aad6..089c583cbf 100644 --- a/mono/mini/gshared.cs +++ b/mono/mini/gshared.cs @@ -2017,6 +2017,23 @@ public class Tests return 2; return 0; } + + interface IFace59956 { + int foo (); + } + + class Impl59956 : IFace59956 { + public int foo () { + var builder = new SparseArrayBuilder(true); + + return builder.Markers._count; + } + } + + public static int test_1_59956_regress () { + IFace59956 iface = new Impl59956 (); + return iface.foo (); + } } // #13191 @@ -2034,6 +2051,35 @@ public class MobileServiceCollection } } +// #59956 +internal struct Marker +{ + public Marker(int count, int index) { + } +} + +public struct ArrayBuilder +{ + private T[] _array; + public int _count; + + public ArrayBuilder(int capacity) { + _array = new T[capacity]; + _count = 1; + } +} + +internal struct SparseArrayBuilder +{ + private ArrayBuilder _markers; + + public SparseArrayBuilder(bool initialize) : this () { + _markers = new ArrayBuilder (10); + } + + public ArrayBuilder Markers => _markers; +} + #if !__MOBILE__ public class GSharedTests : Tests { } diff --git a/mono/mini/iltests.il b/mono/mini/iltests.il index 30419d9178..8dfda57c03 100644 --- a/mono/mini/iltests.il +++ b/mono/mini/iltests.il @@ -6,6 +6,13 @@ .assembly extern TestDriver {} .assembly extern mscorlib {} + .class private sequential ansi sealed beforefieldinit FLSharedKeys + extends [mscorlib]System.ValueType + { + .pack 0 + .size 1 + } + .class public auto ansi sealed beforefieldinit Tests { .method static public int32 Main(string[] args) il managed { @@ -3091,4 +3098,26 @@ L_3: IL_000c: ret } + .field public static class FLSharedKeys* keys + + .method public hidebysig static int32 test_0_regress_60634 () cil managed + { + .maxstack 8 + ldsflda class FLSharedKeys* Tests::keys + initobj class FLSharedKeys* + ldc.i4.0 + ret + } + + .method public hidebysig static int32 test_104_conv_u_and_string() cil managed + { + .maxstack 8 + ldstr "hello" + conv.u + call int32 [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::get_OffsetToStringData() + add + ldind.u2 + ret + } + } diff --git a/mono/mini/interp/interp.c.REMOVED.git-id b/mono/mini/interp/interp.c.REMOVED.git-id index 674b3502a1..31a246e7a3 100644 --- a/mono/mini/interp/interp.c.REMOVED.git-id +++ b/mono/mini/interp/interp.c.REMOVED.git-id @@ -1 +1 @@ -412145683039727b6c053676cf346110372960a3 \ No newline at end of file +c821b7ac59ac6773746b6d5a79da93c03e0543cf \ No newline at end of file diff --git a/mono/mini/interp/transform.c.REMOVED.git-id b/mono/mini/interp/transform.c.REMOVED.git-id index f2b0a77e6a..9cc02dcc3a 100644 --- a/mono/mini/interp/transform.c.REMOVED.git-id +++ b/mono/mini/interp/transform.c.REMOVED.git-id @@ -1 +1 @@ -1868eb62c1024e74b43f95dd60d3930562ba25b5 \ No newline at end of file +0bdb158053412048eeb49db2387fdf86f22fbfb1 \ No newline at end of file diff --git a/mono/mini/method-to-ir.c.REMOVED.git-id b/mono/mini/method-to-ir.c.REMOVED.git-id index 534cdec88a..86d83651b3 100644 --- a/mono/mini/method-to-ir.c.REMOVED.git-id +++ b/mono/mini/method-to-ir.c.REMOVED.git-id @@ -1 +1 @@ -ce326f3c2d3443d3461073d826215663523955e4 \ No newline at end of file +54e8c3580bf1ac6270c750908ad59a82b1165102 \ No newline at end of file diff --git a/mono/mini/mini-arm.c.REMOVED.git-id b/mono/mini/mini-arm.c.REMOVED.git-id index bb096b3e92..cc44d2dbde 100644 --- a/mono/mini/mini-arm.c.REMOVED.git-id +++ b/mono/mini/mini-arm.c.REMOVED.git-id @@ -1 +1 @@ -44626141830fe9f5ff2c42f28ae54de1c668f0ee \ No newline at end of file +1d2863ddde4cd9118013e3daf333c8934ccbb9c5 \ No newline at end of file diff --git a/mono/mini/mini-arm.h b/mono/mini/mini-arm.h index 633c16f306..58bfe7f0eb 100644 --- a/mono/mini/mini-arm.h +++ b/mono/mini/mini-arm.h @@ -234,14 +234,15 @@ typedef struct { #define PARAM_REGS 4 #define FP_PARAM_REGS 8 -#define DYN_CALL_STACK_ARGS 10 typedef struct { - mgreg_t regs [PARAM_REGS + FP_PARAM_REGS]; double fpregs [FP_PARAM_REGS]; mgreg_t res, res2; guint8 *ret; guint32 has_fpregs; + guint32 n_stackargs; + /* This should come last as the structure is dynamically extended */ + mgreg_t regs [PARAM_REGS]; } DynCallArgs; void arm_patch (guchar *code, const guchar *target); @@ -327,7 +328,7 @@ typedef struct MonoCompileArch { #define MONO_ARCH_GSHARED_SUPPORTED 1 #define MONO_ARCH_DYN_CALL_SUPPORTED 1 -#define MONO_ARCH_DYN_CALL_PARAM_AREA (DYN_CALL_STACK_ARGS * sizeof (mgreg_t)) +#define MONO_ARCH_DYN_CALL_PARAM_AREA 0 #if !(defined(TARGET_ANDROID) && defined(MONO_CROSS_COMPILE)) #define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1 diff --git a/mono/mini/mini-llvm.c.REMOVED.git-id b/mono/mini/mini-llvm.c.REMOVED.git-id index fc6e751b57..6f2d3fcb28 100644 --- a/mono/mini/mini-llvm.c.REMOVED.git-id +++ b/mono/mini/mini-llvm.c.REMOVED.git-id @@ -1 +1 @@ -0b996be7f1838ee8a684725105b03d1d60afe7b5 \ No newline at end of file +fa45fc39012f130b416a9e0a82e5caa1f8ac24a2 \ No newline at end of file diff --git a/mono/mini/objects.cs b/mono/mini/objects.cs index ef796986cd..97ca3c1801 100644 --- a/mono/mini/objects.cs +++ b/mono/mini/objects.cs @@ -1362,6 +1362,7 @@ ncells ) { return 1.4e-45f; } + [Category ("!BITCODE")] // bug #59953 public static int test_0_float_return_spill () { // The return value of return_float () is spilled because of the // boxing call diff --git a/mono/mini/simd-intrinsics.c b/mono/mini/simd-intrinsics.c index d55055f9f4..92d7a4eb56 100644 --- a/mono/mini/simd-intrinsics.c +++ b/mono/mini/simd-intrinsics.c @@ -852,7 +852,6 @@ load_simd_vreg_class (MonoCompile *cfg, MonoClass *klass, MonoInst *src, gboolea return src->sreg1; } else if (src->opcode == OP_LDADDR) { int res = ((MonoInst*)src->inst_p0)->dreg; - NULLIFY_INS (src); return res; } else if (spec [MONO_INST_DEST] == 'x') { return src->dreg; diff --git a/mono/mini/version.h b/mono/mini/version.h index a2e2785fb3..34b80f9a3a 100644 --- a/mono/mini/version.h +++ b/mono/mini/version.h @@ -1 +1 @@ -#define FULL_VERSION "explicit/7e85cfa" +#define FULL_VERSION "explicit/ddeba6e" diff --git a/mono/profiler/log-args.c b/mono/profiler/log-args.c index 3cfadd1e51..bd1e558a60 100644 --- a/mono/profiler/log-args.c +++ b/mono/profiler/log-args.c @@ -10,6 +10,7 @@ typedef struct { const char *event_name; const int mask; + const int compat_mask; } NameAndMask; static NameAndMask event_list[] = { @@ -24,7 +25,8 @@ static NameAndMask event_list[] = { { "counter", PROFLOG_COUNTER_EVENTS }, { "jit", PROFLOG_JIT_EVENTS }, - { "alloc", PROFLOG_ALLOC_ALIAS }, + { "counters", PROFLOG_COUNTER_EVENTS }, + { "alloc", PROFLOG_ALLOC_ALIAS, PROFLOG_ALLOC_ALIAS | PROFLOG_GC_ROOT_EVENTS }, { "legacy", PROFLOG_LEGACY_ALIAS }, }; @@ -52,11 +54,25 @@ match_option (const char *arg, const char *opt_name, const char **rval) } } +static gboolean compat_args_parsing; + static void parse_arg (const char *arg, ProfilerConfig *config) { const char *val; + static gboolean first_processed; + + if (!first_processed) { + first_processed = TRUE; + if (match_option (arg, "nodefaults", NULL)) { + //enables new style of default events, IE, nothing. + } else { + config->enable_mask = PROFLOG_EXCEPTION_EVENTS | PROFLOG_COUNTER_EVENTS; + compat_args_parsing = TRUE; + } + } + if (match_option (arg, "help", NULL)) { usage (); } else if (match_option (arg, "report", NULL)) { @@ -65,8 +81,11 @@ parse_arg (const char *arg, ProfilerConfig *config) config->do_debug = TRUE; } else if (match_option (arg, "heapshot", &val)) { set_hsmode (config, val); - if (config->hs_mode != MONO_PROFILER_HEAPSHOT_NONE) + if (config->hs_mode != MONO_PROFILER_HEAPSHOT_NONE) { config->enable_mask |= PROFLOG_HEAPSHOT_ALIAS; + if (compat_args_parsing) + config->enable_mask |= PROFLOG_GC_MOVE_EVENTS; + } } else if (match_option (arg, "heapshot-on-shutdown", NULL)) { config->hs_on_shutdown = TRUE; config->enable_mask |= PROFLOG_HEAPSHOT_ALIAS; @@ -74,12 +93,15 @@ parse_arg (const char *arg, ProfilerConfig *config) set_sample_freq (config, val); config->sampling_mode = MONO_PROFILER_SAMPLE_MODE_PROCESS; config->enable_mask |= PROFLOG_SAMPLE_EVENTS; - } else if (match_option (arg, "sample-real", &val)) { + } else if (match_option (arg, "sample-real", &val) || (compat_args_parsing && match_option (arg, "sampling-real", &val))) { set_sample_freq (config, val); config->sampling_mode = MONO_PROFILER_SAMPLE_MODE_REAL; config->enable_mask |= PROFLOG_SAMPLE_EVENTS; } else if (match_option (arg, "calls", NULL)) { config->enter_leave = TRUE; + } else if (match_option (arg, "nocalls", NULL)) { + if (!compat_args_parsing) + mono_profiler_printf_err ("Could not parse argument: %s", arg); } else if (match_option (arg, "coverage", NULL)) { g_warning ("the log profiler support for code coverage is obsolete, use the \"coverage\" profiler"); config->collect_coverage = TRUE; @@ -112,11 +134,14 @@ parse_arg (const char *arg, ProfilerConfig *config) int i; for (i = 0; i < G_N_ELEMENTS (event_list); ++i){ + int mask = event_list [i].mask; + if (compat_args_parsing && event_list [i].compat_mask) + mask = event_list [i].compat_mask; if (!strcmp (arg, event_list [i].event_name)) { - config->enable_mask |= event_list [i].mask; + config->enable_mask |= mask; break; } else if (!strncmp (arg, "no", 2) && !strcmp (arg + 2, event_list [i].event_name)) { - config->disable_mask |= event_list [i].mask; + config->disable_mask |= mask; break; } } @@ -234,19 +259,35 @@ set_hsmode (ProfilerConfig *config, const char* val) static void set_sample_freq (ProfilerConfig *config, const char *val) { + int freq; + if (!val) return; - char *end; + const char *p = val; - int freq = strtoul (val, &end, 10); + // Is it only the frequency (new option style)? + if (isdigit (*p)) + goto parse; - if (val == end) { - usage (); - return; + // Skip the sample type for backwards compatibility. + while (isalpha (*p)) + p++; + + // Skip the forward slash only if we got a sample type. + if (p != val && *p == '/') { + p++; + + char *end; + +parse: + freq = strtoul (p, &end, 10); + + if (p == end) + usage (); + else + config->sample_freq = freq; } - - config->sample_freq = freq; } static void @@ -262,6 +303,7 @@ usage (void) for (int i = 0; i < G_N_ELEMENTS (event_list); i++) mono_profiler_printf ("\t %s", event_list [i].event_name); + mono_profiler_printf ("\tnodefaults disable legacy rules for enabling extra events"); mono_profiler_printf ("\t[no]alloc enable/disable recording allocation info"); mono_profiler_printf ("\t[no]legacy enable/disable pre Mono 5.6 default profiler events"); mono_profiler_printf ("\tsample[-real][=FREQ] enable/disable statistical sampling of threads"); @@ -272,6 +314,7 @@ usage (void) mono_profiler_printf ("\theapshot-on-shutdown do a heapshot on runtime shutdown"); mono_profiler_printf ("\t this option is independent of the above option"); mono_profiler_printf ("\tcalls enable recording enter/leave method events (very heavy)"); + mono_profiler_printf ("\tnocalls compat switch with previous versions of the profiler, does nothing"); mono_profiler_printf ("\tcoverage enable collection of code coverage data"); mono_profiler_printf ("\tcovfilter=ASSEMBLY add ASSEMBLY to the code coverage filters"); mono_profiler_printf ("\t prefix a + to include the assembly or a - to exclude it"); diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am index 77f06635dd..90eff77326 100755 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@ -219,6 +219,7 @@ TESTS_CS_SRC= \ iface3.cs \ iface4.cs \ iface-large.cs \ + iface-contravariant1.cs \ virtual-method.cs \ intptrcast.cs \ indexer.cs \ diff --git a/mono/tests/Makefile.in.REMOVED.git-id b/mono/tests/Makefile.in.REMOVED.git-id index 0cf7369d18..44bb03943d 100644 --- a/mono/tests/Makefile.in.REMOVED.git-id +++ b/mono/tests/Makefile.in.REMOVED.git-id @@ -1 +1 @@ -f3dc03a8591049e750a5338ea1fa64bcfbfd596e \ No newline at end of file +f0eb94c705ca503be0b3c1061a43fb3b5375f86d \ No newline at end of file diff --git a/mono/tests/iface-contravariant1.cs b/mono/tests/iface-contravariant1.cs new file mode 100644 index 0000000000..58570ec5dd --- /dev/null +++ b/mono/tests/iface-contravariant1.cs @@ -0,0 +1,60 @@ +using System; + +/* Test of constrained.callvirt resolution for contravariant interfaces */ + + +public interface I +{ + string F (T t); +} + +public class C : I +{ + public string F (object t) + { + return t.GetType().Name; + } +} + +/* U should be instantiated by a valuetype because we don't want the generic + * sharing codepath */ +public class G + where TI : I +{ + public G(TI i) + { + _i = i; + } + + public string Do (T t) + { + // we want to get this in IL: + // + // constrained. !1 + // callvirt I`1::F(!0) + // + return _i.F (t); + } + + private readonly TI _i; +} + +public class Driver +{ + public static int Main () + { + var c = new C(); + // instantiate with: T=string because we want to be + // contravariant with object; U=int because we need a valuetype + // to not end up in the generic sharing codepath. + var h = new G(c); + var s = h.Do ("abc"); + var expected = typeof(string).Name; + if (s == expected) + return 0; + else { + Console.Error.WriteLine ("Got '{0}', expected '{1}'", s, expected); + return 1; + } + } +} diff --git a/po/mcs/de.gmo b/po/mcs/de.gmo index 16e8ec20bb87498f1ca6395d0af6c38d70069d18..43ab216f74aa2e7128141837d0505ea31fa7543d 100644 GIT binary patch delta 23 ecmbQIHBW29BQ7pOT_XzxLklYt^UZI#jJN\n" "Language-Team: LANGUAGE \n" diff --git a/po/mcs/pt_BR.gmo b/po/mcs/pt_BR.gmo index eb8d65cfddfcb4521c195cb3810ba7f46050494c..c3dc71ed6d733d7a07c437c4ae27b30ea8b79a22 100644 GIT binary patch delta 25 hcmcb=i{<_